diff options
author | thsparks <thsparks@microsoft.com> | 2022-03-08 03:31:23 +0300 |
---|---|---|
committer | thsparks <thsparks@microsoft.com> | 2022-03-08 03:31:23 +0300 |
commit | 22dae9aa1930771c675a66e0ba661eed3b8a3df1 (patch) | |
tree | 169a7e494ae1f070beff315c09021f01e5e82418 | |
parent | 84aa093427daec3be603a4431766ec42d3d8eebe (diff) | |
parent | 67538aec107829384f0d13e64bb669574ba14bb5 (diff) |
Merge with main
69 files changed, 468 insertions, 363 deletions
diff --git a/.build/automation/stages/merge-translations-update.yml b/.build/automation/stages/merge-translations-update.yml index e70f091..ebcae9b 100644 --- a/.build/automation/stages/merge-translations-update.yml +++ b/.build/automation/stages/merge-translations-update.yml @@ -8,7 +8,7 @@ stages: - job : validate_merge displayName: 'Validate and Merge Translations' pool: - name: VSEng-ReleasePool + name: $(HostedWinVS2019) variables: pull_request_number: $(System.PullRequest.PullRequestNumber) workspace: diff --git a/.build/automation/stages/validate.yml b/.build/automation/stages/validate.yml index 590824b..d59b470 100644 --- a/.build/automation/stages/validate.yml +++ b/.build/automation/stages/validate.yml @@ -12,6 +12,13 @@ stages: clean: true persistCredentials: true + - task: provisionator@2 + displayName: Provision Dependencies + inputs: + github_token: $(GitHub.Token) + provisioning_script: $(System.DefaultWorkingDirectory)/bot-provisioning/dependencies.csx + provisioning_extra_args: -vv DEVDIV_PKGS_NUGET_TOKEN=$(DevDiv.NuGet.Token) SECTOOLS_PKGS_NUGET_TOKEN=$(SecTools.NuGet.Token) + - task: MSBuild@1 displayName: Build inputs: @@ -44,12 +51,6 @@ stages: - task: NuGetAuthenticate@0 - - task: CmdLine@1 - displayName: 'Set Token' - inputs: - filename: echo - arguments: '##vso[task.setvariable variable=GITHUB_TOKEN]$(GitHub.Token)' - - task: provisionator@2 displayName: Provision Dependencies inputs: @@ -75,5 +76,5 @@ stages: displayName: 'Publish Test Results' inputs: testResultsFormat: NUnit - testResultsFiles: '**/TestResult.xml' + testResultsFiles: '**/*.Tests.xml' condition: succeededOrFailed() diff --git a/.config/LocProject.json b/.config/LocProject.json index 90f9cbe..d534e7b 100644 --- a/.config/LocProject.json +++ b/.config/LocProject.json @@ -4,10 +4,10 @@ "LanguageSet": "VS_Main_Languages", "LocItems": [ { - "SourceFile": "Xamarin.PropertyEditing\\Resources\\Resources.resx", - "LclFile": "loc\\{Lang}\\Xamarin.PropertyEditing\\Resources\\Resources.resx.lcl", + "SourceFile": "Xamarin.PropertyEditing\\Properties\\Resources.resx", + "LclFile": "loc\\{Lang}\\Xamarin.PropertyEditing\\Properties\\Resources.resx.lcl", "CopyOption": "LangIDOnName", - "OutputPath": "\\Xamarin.PropertyEditing\\Resources\\Resources" + "OutputPath": "Xamarin.PropertyEditing\\Properties" } ], "LssFiles": [], diff --git a/Directory.Build.props b/Directory.Build.props index 4ec85ea..91eb5fc 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,13 +1,19 @@ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <!-- Enable MicroBuild signing on all projects, if the build is running in a pipeline where MicroBuild has been setup. --> - <ItemGroup> - <PackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core"> - <Version>1.0.0</Version> - </PackageReference> - </ItemGroup> - <ItemGroup> - <FilesToSign Include="$(OutDir)\$(AssemblyName).dll"> - <Authenticode>Microsoft400</Authenticode> - </FilesToSign> - </ItemGroup> + <PropertyGroup> + <IsMac>$([MSBuild]::IsOSPlatform('OSX'))</IsMac> + <IsWindows>$([MSBuild]::IsOSPlatform('Windows'))</IsWindows> + <IsLinux>$([MSBuild]::IsOSPlatform('Linux'))</IsLinux> + </PropertyGroup> + + <!-- Enable MicroBuild signing on all projects, if the build is running in a pipeline where MicroBuild has been setup. --> + <ItemGroup> + <PackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core"> + <Version>1.0.0</Version> + </PackageReference> + </ItemGroup> + <ItemGroup> + <FilesToSign Include="$(OutDir)\$(AssemblyName).dll"> + <Authenticode>Microsoft400</Authenticode> + </FilesToSign> + </ItemGroup> </Project> diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Info.plist b/Xamarin.PropertyEditing.Mac.Standalone/Info.plist index a9d6ddb..3f7108c 100644 --- a/Xamarin.PropertyEditing.Mac.Standalone/Info.plist +++ b/Xamarin.PropertyEditing.Mac.Standalone/Info.plist @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> @@ -11,7 +11,7 @@ <key>CFBundleVersion</key> <string>1</string> <key>LSMinimumSystemVersion</key> - <string>10.11</string> + <string>10.14</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleInfoDictionaryVersion</key> @@ -28,6 +28,5 @@ <string>Main</string> <key>XSAppIconAssets</key> <string>Assets.xcassets/AppIcon.appiconset</string> - </dict> </plist> diff --git a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitButton.cs b/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitButton.cs index 81e9957..89c9948 100644 --- a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitButton.cs +++ b/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitButton.cs @@ -1,5 +1,6 @@ using System; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Tests.MockControls; namespace Xamarin.PropertyEditing.Mac.Standalone @@ -8,7 +9,7 @@ namespace Xamarin.PropertyEditing.Mac.Standalone public class MockedAppKitButton : MockedControlButton<MockNSButton> { // Called when created from unmanaged code - public MockedAppKitButton (IntPtr handle) : base (new MockNSButton (), handle) + public MockedAppKitButton (NativeHandle handle) : base (new MockNSButton (), handle) { } diff --git a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.cs b/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.cs deleted file mode 100644 index ad2e4d0..0000000 --- a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using Foundation; -using AppKit; -using Xamarin.PropertyEditing.Tests.MockControls; - -namespace Xamarin.PropertyEditing.Mac.Standalone -{ - public abstract class MockedAppKitControlButton<T> : AppKit.NSButtonCell where T : MockControl - { - protected MockedAppKitControlButton (T mockedControl, IntPtr handle) : base (handle) - { - MockedControl = mockedControl; - Initialize (); - } - - protected MockedAppKitControlButton (T mockedControl, NSCoder coder) : base (coder) - { - Initialize (); - MockedControl = mockedControl; - } - - // Shared initialization code - void Initialize () - { - } - - public T MockedControl { get; } - } - - public partial class MockedAppKitButton : MockedAppKitControlButton<MockNSButton> - { - // Called when created from unmanaged code - public MockedAppKitButton (IntPtr handle) : base (new MockNSButton (), handle) - { - } - - // Called when created directly from a XIB file - [Export ("initWithCoder:")] - public MockedAppKitButton (NSCoder coder) : base (new MockNSButton (), coder) - { - } - } -} diff --git a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.designer.cs b/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.designer.cs deleted file mode 100644 index c81fc16..0000000 --- a/Xamarin.PropertyEditing.Mac.Standalone/MockedAppKitControlButton.designer.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Xamarin.PropertyEditing.Mac.Standalone -{ - - // Should subclass AppKit.NSView - [Foundation.Register ("MockedAppKitButton")] - public partial class MockedAppKitButton - { - } -} diff --git a/Xamarin.PropertyEditing.Mac.Standalone/MockedSampleControlButton.cs b/Xamarin.PropertyEditing.Mac.Standalone/MockedSampleControlButton.cs index 8a441a7..fc1edd2 100644 --- a/Xamarin.PropertyEditing.Mac.Standalone/MockedSampleControlButton.cs +++ b/Xamarin.PropertyEditing.Mac.Standalone/MockedSampleControlButton.cs @@ -1,5 +1,6 @@ using System; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Tests.MockControls; namespace Xamarin.PropertyEditing.Mac.Standalone @@ -8,7 +9,7 @@ namespace Xamarin.PropertyEditing.Mac.Standalone public class MockedSampleControlButton : MockedControlButton<MockSampleControl> { // Called when created from unmanaged code - public MockedSampleControlButton (IntPtr handle) : base (new MockSampleControl (), handle) + public MockedSampleControlButton (NativeHandle handle) : base (new MockSampleControl (), handle) { } diff --git a/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs b/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs index 535dffe..bf91b8f 100644 --- a/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs +++ b/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using AppKit; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.Tests; @@ -10,7 +11,7 @@ namespace Xamarin.PropertyEditing.Mac.Standalone { public partial class ViewController : NSViewController { - public ViewController (IntPtr handle) : base (handle) + public ViewController (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj b/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj index a92df9b..b8f1d55 100644 --- a/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj +++ b/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj @@ -1,134 +1,21 @@ <?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{8319A66C-72AE-4C40-B737-97279D4AB899}</ProjectGuid>
- <ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <TargetFramework>net6.0-macos</TargetFramework>
<OutputType>Exe</OutputType>
- <RootNamespace>Xamarin.PropertyEditing.Mac.Standalone</RootNamespace>
- <AssemblyName>Xamarin.PropertyEditing.Mac.Standalone</AssemblyName>
- <MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
- <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
- <TargetFrameworkProfile />
- <XamarinMacAnalyzerMinimumOSVersion>10.12</XamarinMacAnalyzerMinimumOSVersion>
+ <SupportedOSPlatformVersion>10.14</SupportedOSPlatformVersion>
</PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug</OutputPath>
- <DefineConstants>DEBUG;</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <EnableCodeSigning>false</EnableCodeSigning>
- <CodeSigningKey>Mac Developer</CodeSigningKey>
- <CreatePackage>false</CreatePackage>
- <EnablePackageSigning>false</EnablePackageSigning>
- <IncludeMonoRuntime>false</IncludeMonoRuntime>
- <UseSGen>true</UseSGen>
- <UseRefCounting>true</UseRefCounting>
- <Profiling>false</Profiling>
- <HttpClientHandler></HttpClientHandler>
- <LinkMode></LinkMode>
- <XamMacArch></XamMacArch>
- <XamarinInspectorDisabled>True</XamarinInspectorDisabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release</OutputPath>
- <DefineConstants></DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- <EnableCodeSigning>false</EnableCodeSigning>
- <CreatePackage>true</CreatePackage>
- <EnablePackageSigning>false</EnablePackageSigning>
- <IncludeMonoRuntime>true</IncludeMonoRuntime>
- <UseSGen>true</UseSGen>
- <UseRefCounting>true</UseRefCounting>
- <LinkMode>None</LinkMode>
- <HttpClientHandler></HttpClientHandler>
- <XamMacArch></XamMacArch>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="Xamarin.Mac" />
- </ItemGroup>
- <ItemGroup>
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128%402x.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16%402x.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256%402x.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32%402x.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512.png" />
- <ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512%402x.png" />
- <ImageAsset Include="Assets.xcassets\Contents.json" />
- <ImageAsset Include="Assets.xcassets\Checkerboard0.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\Checkerboard1.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\ForegroundColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\PadBackgroundColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\PopoverContentBackground.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\ValueBlockBackgroundColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\DescriptionLabelColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\TabBorderColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\PanelTabBackground.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\FrameBoxBorderColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\FrameBoxBackgroundColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\FrameBoxButtonBorderColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\FrameBoxButtonBackgroundColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\ListHeaderSeparatorColor.colorset\Contents.json" />
- <ImageAsset Include="Assets.xcassets\ControlBackground.colorset\Contents.json" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Resources\" />
- </ItemGroup>
- <ItemGroup>
- <None Include="Info.plist" />
- <None Include="Entitlements.plist" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Main.cs" />
- <Compile Include="AppDelegate.cs" />
- <Compile Include="ViewController.cs" />
- <Compile Include="ViewController.designer.cs">
- <DependentUpon>ViewController.cs</DependentUpon>
- </Compile>
- <Compile Include="MockedControlButton.cs" />
- <Compile Include="MockedAppKitButton.cs" />
- <Compile Include="IMockedControl.cs" />
- <Compile Include="MockedSampleControlButton.cs" />
- </ItemGroup>
- <ItemGroup>
- <InterfaceDefinition Include="Main.storyboard" />
- </ItemGroup>
+
<ItemGroup>
- <ProjectReference Include="..\Xamarin.PropertyEditing.Mac\Xamarin.PropertyEditing.Mac.csproj">
- <Project>{E8F4F0EB-C2B1-4116-8459-E076E0E0E485}</Project>
- <Name>Xamarin.PropertyEditing.Mac</Name>
- </ProjectReference>
- <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
- <Project>{A0B6FE73-D046-4E1C-BA9D-F20683889C5A}</Project>
- <Name>Xamarin.PropertyEditing</Name>
- </ProjectReference>
- <ProjectReference Include="..\Xamarin.PropertyEditing.Tests\Xamarin.PropertyEditing.Tests.csproj">
- <Project>{84101D04-9CE4-4CE7-916E-21F86EE96898}</Project>
- <Name>Xamarin.PropertyEditing.Tests</Name>
- </ProjectReference>
+ <ProjectReference Include="..\Xamarin.PropertyEditing.Mac\Xamarin.PropertyEditing.Mac.csproj" />
+ <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj" />
+ <ProjectReference Include="..\Xamarin.PropertyEditing.Tests\Xamarin.PropertyEditing.Tests.csproj" />
</ItemGroup>
- <Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
+
<Target Name="AfterBuild">
<ItemGroup>
<PropertyEditingResourceBundlePath Include="$(OutputPath)\PropertyEditingResource.bundle\**\*" />
</ItemGroup>
- <Copy
- SourceFiles="@(PropertyEditingResourceBundlePath)"
- DestinationFiles="@(PropertyEditingResourceBundlePath->'$(OutputPath)\$(AssemblyName).app\Contents\MonoBundle\PropertyEditingResource.bundle\%(RecursiveDir)%(Filename)%(Extension)')"
- SkipUnchangedFiles="true" />
+ <Copy SourceFiles="@(PropertyEditingResourceBundlePath)" DestinationFiles="@(PropertyEditingResourceBundlePath->'$(OutputPath)\$(AssemblyName).app\Contents\MonoBundle\PropertyEditingResource.bundle\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>
</Project>
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs index 923281e..f7f0d39 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePathEditorControl.cs @@ -23,11 +23,35 @@ namespace Xamarin.PropertyEditing.Mac private readonly NSObject[] objects;
public override NSObject[] AccessibilityChildren { get => this.objects; }
+ private readonly DelegatedRowTextFieldDelegate textNextResponderDelegate; + + class BasePathEditorDelegate : DelegatedRowTextFieldDelegate + { + WeakReference<BasePathEditorControl<T>> weakView; + + public BasePathEditorDelegate (BasePathEditorControl<T> basePathEditorControl) + { + weakView = new WeakReference<BasePathEditorControl<T>>(basePathEditorControl); + } + + public override void Changed (NSNotification notification) + { + if (this.weakView.TryGetTarget(out BasePathEditorControl<T> t)) { + t.StoreCurrentValue (); + } + } + } + protected BasePathEditorControl (IHostResourceProvider hostResource)
: base (hostResource)
{
this.currentTextField = new TextFieldSmallButtonContainer ();
- this.currentTextField.Changed += CurrentTextField_Changed; + + this.textNextResponderDelegate = new BasePathEditorDelegate (this) + { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; + this.currentTextField.Delegate = this.textNextResponderDelegate; AddSubview (this.currentTextField); #region Reveal handler
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs index e60f5f4..7193566 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs @@ -28,6 +28,7 @@ namespace Xamarin.PropertyEditing.Mac BackgroundColor = NSColor.Clear, Value = 0.0f }; + XEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.FirstView); XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField { @@ -39,6 +40,7 @@ namespace Xamarin.PropertyEditing.Mac BackgroundColor = NSColor.Clear, Value = 0.0f }; + YEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.LastView); YEditor.ValueChanged += OnInputUpdated; AddSubview (XLabel); diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs index 005ef89..68406a1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs @@ -33,6 +33,7 @@ namespace Xamarin.PropertyEditing.Mac BackgroundColor = NSColor.Clear, Value = 0.0f }; + XEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.FirstView); XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField { @@ -63,6 +64,7 @@ namespace Xamarin.PropertyEditing.Mac BackgroundColor = NSColor.Clear, Value = 0.0f }; + HeightEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.LastView); HeightEditor.ValueChanged += OnInputUpdated; AddSubview (XLabel); diff --git a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BaseSelectorOutlineView.cs b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BaseSelectorOutlineView.cs index e18c197..b26b06f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BaseSelectorOutlineView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BaseSelectorOutlineView.cs @@ -1,6 +1,7 @@ using System; using AppKit; using Foundation; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -12,7 +13,7 @@ namespace Xamarin.PropertyEditing.Mac } // Called when created from unmanaged code - public BaseSelectorOutlineView (IntPtr handle) : base (handle) + public BaseSelectorOutlineView (NativeHandle handle) : base (handle) { Initialize (); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BindingEditorWindow.cs b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BindingEditorWindow.cs index 3413bb9..734a0f8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BindingEditorWindow.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/BindingEditorWindow.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using AppKit; using CoreGraphics; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Common; using Xamarin.PropertyEditing.ViewModels; diff --git a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/HeaderView.cs b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/HeaderView.cs index 833a76b..7e9a5c6 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/HeaderView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BindingEditor/HeaderView.cs @@ -2,6 +2,7 @@ using System; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { diff --git a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs index d9541a6..b6c1ca5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs @@ -11,7 +11,10 @@ namespace Xamarin.PropertyEditing.Mac public BooleanEditorControl (IHostResourceProvider hostResource)
: base (hostResource) { - BooleanEditor = new FocusableBooleanButton (); + BooleanEditor = new FocusableBooleanButton () + { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; BooleanEditor.Title = string.Empty; // update the value on 'enter' diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index cb8bc44..799a91d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -56,6 +56,7 @@ namespace Xamarin.PropertyEditing.Mac ControlSize = NSControlSize.Small, Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), TranslatesAutoresizingMaskIntoConstraints = false, + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) }; this.popupButtonList = new NSMenu (); @@ -129,7 +130,7 @@ namespace Xamarin.PropertyEditing.Mac { base.AppearanceChanged (); - this.popover.SetAppearance (HostResources.GetVibrantAppearance (EffectiveAppearance)); + this.popover.Appearance = HostResources.GetVibrantAppearance (EffectiveAppearance); this.popover.ContentViewController.View.Appearance = EffectiveAppearance; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/CharEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CharEditorControl.cs index f68457d..e1eb1b6 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CharEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CharEditorControl.cs @@ -13,7 +13,11 @@ namespace Xamarin.PropertyEditing.Mac protected override EntryPropertyEditorDelegate<char> CreateDelegate (PropertyViewModel<char> viewModel) { - return new CharDelegate (viewModel); + var charDelegate = new CharDelegate (viewModel) + { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; + return charDelegate; } protected override void UpdateAccessibilityValues () diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs index 51a0f8a..6bb5105 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionEditorControl.cs @@ -299,12 +299,13 @@ namespace Xamarin.PropertyEditing.Mac public override bool WriteRows (NSTableView tableView, NSIndexSet rowIndexes, NSPasteboard pboard) { var item = new NSPasteboardItem (); - item.SetDataForType (NSKeyedArchiver.ArchivedDataWithRootObject (rowIndexes), DataTypeName); + item.SetDataForType (NSKeyedArchiver.GetArchivedData (rowIndexes), DataTypeName); pboard.WriteObjects (new[] { item }); return true; } - public override NSDragOperation ValidateDrop (NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) + [Export ("tableView:validateDrop:proposedRow:proposedDropOperation:")] + public NSDragOperation ValidateDrop (NSTableView tableView, INSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { if (info.DraggingPasteboard.GetDataForType (DataTypeName) != null) return NSDragOperation.Move; @@ -312,7 +313,8 @@ namespace Xamarin.PropertyEditing.Mac return NSDragOperation.None; } - public override bool AcceptDrop (NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) + [Export ("tableView:acceptDrop:row:dropOperation:")] + public bool AcceptDrop (NSTableView tableView, INSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation) { NSData data = info.DraggingPasteboard.GetDataForType (DataTypeName); NSIndexSet indexes = NSKeyedUnarchiver.UnarchiveObject (data) as NSIndexSet; diff --git a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs index 00608b1..0bdcabb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CollectionInlineEditorControl.cs @@ -24,6 +24,7 @@ namespace Xamarin.PropertyEditing.Mac Title = Properties.Resources.CollectionEditButton, BezelStyle = NSBezelStyle.Rounded, AccessibilityEnabled = true, + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView), AccessibilityHelp = Properties.Resources.AccessibilityCollectionHelp }; diff --git a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs index 5122f24..c2ce8a5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs @@ -83,8 +83,21 @@ namespace Xamarin.PropertyEditing.Mac } // Set our tabable order - this.firstKeyView = this.combinableList.KeyAt (0); - this.lastKeyView = this.combinableList.KeyAt (this.combinableList.Count - 1); + var firstButton = (FocusableBooleanButton) this.combinableList.KeyAt (0); + this.firstKeyView = firstButton; + + var lastButton = (FocusableBooleanButton)this.combinableList.KeyAt (this.combinableList.Count - 1); + this.lastKeyView = lastButton; + + if (combinableList.Count > 0) + { + if (firstButton == lastButton) { + firstButton.ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView); + } else { + firstButton.ProxyResponder = new ProxyResponder (this, ProxyRowType.FirstView); + lastButton.ProxyResponder = new ProxyResponder (this, ProxyRowType.LastView); + } + } SetEnabled (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs index bb1fafd..f516c13 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs @@ -21,7 +21,7 @@ namespace Xamarin.PropertyEditing.Mac Delegate = new PopoverFocusRestoreDelegate (); CloseOnEnter = true; - this.SetAppearance (this.hostResources.GetVibrantAppearance (effectiveAppearance)); + Appearance = this.hostResources.GetVibrantAppearance (effectiveAppearance); } public override void KeyUp (NSEvent theEvent) diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index e4bea5e..b5c27b4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -68,7 +68,7 @@ namespace Xamarin.PropertyEditing.Mac protected void AppearanceChanged() { - this.SetAppearance (HostResources.GetVibrantAppearance (EffectiveAppearance)); + Appearance = HostResources.GetVibrantAppearance (EffectiveAppearance); this.viewTitle.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index 47caf85..d958e58 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -4,6 +4,7 @@ using System.Linq; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs index 6657ba1..68f3cfc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs @@ -2,6 +2,7 @@ using System; using CoreAnimation; using CoreGraphics; using Foundation; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -16,7 +17,7 @@ namespace Xamarin.PropertyEditing.Mac return null; } - public ColorEditorLayer (IntPtr handle) : base (handle) + public ColorEditorLayer (NativeHandle handle) : base (handle) { } @@ -31,7 +32,7 @@ namespace Xamarin.PropertyEditing.Mac { } - public UnanimatedGradientLayer (IntPtr handle) : base (handle) + public UnanimatedGradientLayer (NativeHandle handle) : base (handle) { } @@ -47,7 +48,7 @@ namespace Xamarin.PropertyEditing.Mac { } - public UnanimatedLayer (IntPtr handle) : base (handle) + public UnanimatedLayer (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs index 21f4753..bef2ff2 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs @@ -3,6 +3,7 @@ using System.ComponentModel; using AppKit; using CoreGraphics; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac @@ -25,7 +26,7 @@ namespace Xamarin.PropertyEditing.Mac Adaptor = new NotifyingViewAdaptor<TViewModel> (this); } - public NotifyingView (IntPtr handle) : base (handle) + public NotifyingView (NativeHandle handle) : base (handle) { } @@ -60,7 +61,7 @@ namespace Xamarin.PropertyEditing.Mac { protected const float Padding = 3; - public ColorEditorView (IntPtr handle) : base (handle) + public ColorEditorView (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs index 9fce3f7..ac76c0d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs @@ -84,8 +84,11 @@ namespace Xamarin.PropertyEditing.Mac public NSImage RenderPreview () { var scale = this.ContentsScale; - nint h = (nint)(this.Bounds.Height * scale); - nint w = (nint)(this.Bounds.Width * scale); + // The double cast below is needed for now, while Width/Height/scale are of type ObjCRuntime.nfloat + // in order for the floating point to integral conversion to work properly. Later when ObjCRuntime.nfloat + // is replaced with System.Runtime.InteropServices.NFloat that won't be needed (but can't hurt). + nint h = (nint)(double)(this.Bounds.Height * scale); + nint w = (nint)(double)(this.Bounds.Width * scale); nint bytesPerRow = w * 4; if (h <= 0 || w <= 0) diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs index fe9200d..4eb0799 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs @@ -2,6 +2,7 @@ using System; using System.Linq; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac @@ -12,7 +13,7 @@ namespace Xamarin.PropertyEditing.Mac { } - public CommonGradientBrushLayer (IntPtr handle) : base (handle) + public CommonGradientBrushLayer (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs index 988c9cd..cf87d01 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs @@ -2,6 +2,7 @@ using System; using AppKit; using CoreGraphics; using CoreImage; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs index 7a6aedd..d836877 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs @@ -14,14 +14,14 @@ namespace Xamarin.PropertyEditing.Mac BorderWidth = 0; BoxType = NSBoxType.NSBoxCustom; TranslatesAutoresizingMaskIntoConstraints = false; - + this.WantsLayer = true; this.fillColor = fillName; if (fillName == null) - FillColor = NSColor.Clear; + this.Layer.BackgroundColor = NSColor.Clear.CGColor; this.borderColor = borderName; if (borderName == null) - BorderColor = NSColor.Clear; + this.Layer.BorderColor = NSColor.Clear.CGColor; HostResourceProvider = hostResources; } @@ -43,7 +43,7 @@ namespace Xamarin.PropertyEditing.Mac { this.fillColor = value; if (value == null) - FillColor = NSColor.Clear; + this.Layer.BackgroundColor = NSColor.Clear.CGColor; AppearanceChanged (); } @@ -56,7 +56,7 @@ namespace Xamarin.PropertyEditing.Mac { this.borderColor = value; if (value == null) - BorderColor = NSColor.Clear; + this.Layer.BorderColor = NSColor.Clear.CGColor; AppearanceChanged (); } @@ -78,16 +78,14 @@ namespace Xamarin.PropertyEditing.Mac NSColor color = this.hostResources.GetNamedColor (this.fillColor); if (color == null) return; - - FillColor = color; + this.Layer.BackgroundColor = color.CGColor; } if (this.borderColor != null) { NSColor color = this.hostResources.GetNamedColor (this.borderColor); if (color == null) return; - - BorderColor = color; + this.Layer.BorderColor = color.CGColor; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs index f8ed20d..8548985 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableBooleanButton.cs @@ -3,7 +3,7 @@ using AppKit; namespace Xamarin.PropertyEditing.Mac { - internal class FocusableBooleanButton : NSButton + internal class FocusableBooleanButton : ProxyResponderButton { public override bool CanBecomeKeyView { get { return Enabled; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs index 9e3366d..9d7476d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableButton.cs @@ -3,7 +3,7 @@ using AppKit; namespace Xamarin.PropertyEditing.Mac { - internal class FocusableButton : NSButton + internal class FocusableButton : ProxyResponderButton { public override bool CanBecomeKeyView { get { return Enabled; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs index 577ce4b..b1f5eaa 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusableComboBox.cs @@ -5,6 +5,25 @@ namespace Xamarin.PropertyEditing.Mac { internal class FocusableComboBox : NSComboBox { + public ProxyResponder ProxyResponder { get; set; } + + public override void KeyDown (NSEvent theEvent) + { + switch (theEvent.KeyCode) { + case (int)NSKey.Tab: + if (ProxyResponder != null) { + if (theEvent.ModifierFlags.HasFlag(NSEventModifierMask.ShiftKeyMask)) { + ProxyResponder.PreviousResponder (); + } else { + ProxyResponder.NextResponder (); + } + return; + } + break; + } + base.KeyDown (theEvent); + } + public override bool BecomeFirstResponder () { var willBecomeFirstResponder = base.BecomeFirstResponder (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs index 988dc2b..7d1bc6c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/FocusablePopupButton.cs @@ -8,11 +8,30 @@ namespace Xamarin.PropertyEditing.Mac { public override bool CanBecomeKeyView { get { return Enabled; } } + public ProxyResponder ProxyResponder { get; set; } + public FocusablePopUpButton () { Cell.LineBreakMode = NSLineBreakMode.TruncatingMiddle; } + public override void KeyDown (NSEvent theEvent) + { + switch (theEvent.KeyCode) { + case (int)NSKey.Tab: + if (ProxyResponder != null) { + if (theEvent.ModifierFlags.HasFlag(NSEventModifierMask.ShiftKeyMask)) { + ProxyResponder.PreviousResponder (); + } else { + ProxyResponder.NextResponder (); + } + return; + } + break; + } + base.KeyDown (theEvent); + } + public override bool BecomeFirstResponder () { var willBecomeFirstResponder = base.BecomeFirstResponder (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs index e56786b..9f90d61 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs @@ -2,6 +2,7 @@ using System; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -22,7 +23,7 @@ namespace Xamarin.PropertyEditing.Mac lastClip.AddSublayer (last); } - public HistoryLayer (IntPtr handle) : base (handle) + public HistoryLayer (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs index c67b138..1fba98a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs @@ -2,6 +2,7 @@ using System; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac @@ -23,7 +24,7 @@ namespace Xamarin.PropertyEditing.Mac Initialize (); } - public HueLayer (IntPtr handle) : base (handle) + public HueLayer (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs index 45a93b3..7e15a44 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs @@ -6,6 +6,7 @@ using AppKit; using CoreAnimation; using CoreGraphics; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index 831dfff..9da66b9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -3,6 +3,7 @@ using System; using AppKit; using CoreGraphics; using Foundation; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -171,6 +172,12 @@ namespace Xamarin.PropertyEditing.Mac set { this.numericEditor.AccessibilityTitle = value; } } + public ProxyResponder ProxyResponder + { + get => this.numericEditor.ProxyResponder; + set => this.numericEditor.ProxyResponder = value; + } + public virtual void Reset () { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs index 4c215b7..9e00331 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericTextField.cs @@ -51,6 +51,19 @@ namespace Xamarin.PropertyEditing.Mac Delegate = keyUpDownDelegate; } + public ProxyResponder ProxyResponder + { + get { + return Delegate is KeyUpDownDelegate viewDownDelegate ? viewDownDelegate.ProxyResponder : null; + } + set + { + if (Delegate is KeyUpDownDelegate keydown) { + keydown.ProxyResponder = value; + } + } + } + public override CGSize IntrinsicContentSize => new CGSize(30, 20); public override bool ShouldBeginEditing (NSText textObject) @@ -156,28 +169,35 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class KeyUpDownDelegate : NSTextFieldDelegate + internal class KeyUpDownDelegate : DelegatedRowTextFieldDelegate { public event EventHandler<bool> KeyArrowUp; public event EventHandler<bool> KeyArrowDown; public override bool DoCommandBySelector (NSControl control, NSTextView textView, Selector commandSelector) { + //if parent already handles command we break the event chain + var parentHandlesCommand = base.DoCommandBySelector (control, textView, commandSelector); + if (parentHandlesCommand) + { + return false; + } + switch (commandSelector.Name) { - case "moveUp:": - OnKeyArrowUp (); - break; - case "moveDown:": - OnKeyArrowDown (); - break; - case "moveUpAndModifySelection:": - OnKeyArrowUp (true); - break; - case "moveDownAndModifySelection:": - OnKeyArrowDown (true); - break; - default: - return false; + case "moveUp:": + OnKeyArrowUp (); + break; + case "moveDown:": + OnKeyArrowDown (); + break; + case "moveUpAndModifySelection:": + OnKeyArrowUp (true); + break; + case "moveDownAndModifySelection:": + OnKeyArrowDown (true); + break; + default: + return false; } return true; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ProxyResponderButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ProxyResponderButton.cs new file mode 100644 index 0000000..a37479f --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ProxyResponderButton.cs @@ -0,0 +1,26 @@ +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class ProxyResponderButton : NSButton + { + public ProxyResponder ProxyResponder { get; set; } + + public override void KeyDown (NSEvent theEvent) + { + switch (theEvent.KeyCode) { + case (int)NSKey.Tab: + if (ProxyResponder != null) { + if (theEvent.ModifierFlags.HasFlag(NSEventModifierMask.ShiftKeyMask)) { + ProxyResponder.PreviousResponder (); + } else { + ProxyResponder.NextResponder (); + } + return; + } + break; + } + base.KeyDown (theEvent); + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineView.cs index 7437ae2..63df3d5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineView.cs @@ -2,6 +2,7 @@ using AppKit; using CoreGraphics; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac @@ -18,7 +19,7 @@ namespace Xamarin.PropertyEditing.Mac } // Called when created from unmanaged code - public ResourceOutlineView (IntPtr handle) : base (handle) + public ResourceOutlineView (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs index 045116e..166f1f4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs @@ -2,6 +2,7 @@ using System; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -31,7 +32,7 @@ namespace Xamarin.PropertyEditing.Mac }); } - public ShadeLayer (IntPtr handle) : base (handle) + public ShadeLayer (NativeHandle handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs index 40304bc..80ee61a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs @@ -5,6 +5,7 @@ using System.Linq; using AppKit; using CoreAnimation; using CoreGraphics; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/TextFieldSmallButtonContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/TextFieldSmallButtonContainer.cs index 0dbeb28..99e35e2 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/TextFieldSmallButtonContainer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/TextFieldSmallButtonContainer.cs @@ -6,7 +6,7 @@ using Foundation; namespace Xamarin.PropertyEditing.Mac { - internal class SmallButton : NSButton + internal class SmallButton : ProxyResponderButton { private NSView previousKeyView; public override NSView PreviousKeyView => this.previousKeyView ?? base.PreviousKeyView; diff --git a/Xamarin.PropertyEditing.Mac/Controls/EntryPropertyEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/EntryPropertyEditor.cs index f1d92ac..d6d7e1d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/EntryPropertyEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/EntryPropertyEditor.cs @@ -2,9 +2,35 @@ using System; using AppKit; using Foundation; using Xamarin.PropertyEditing.ViewModels; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { + class DelegatedRowTextFieldDelegate : NSTextFieldDelegate + { + public ProxyResponder ProxyResponder { get; set; } + + public override bool DoCommandBySelector (NSControl control, NSTextView textView, Selector commandSelector) + { + if (ProxyResponder != null) + { + switch (commandSelector.Name) { + case "insertTab:": + if (ProxyResponder.NextResponder ()) { + return true; + } + break; + case "insertBacktab:": + if (ProxyResponder.PreviousResponder ()) { + return true; + } + break; + } + } + return false; + } + } + internal abstract class EntryPropertyEditor<T> : PropertyEditorControl<PropertyViewModel<T>> { @@ -19,6 +45,11 @@ namespace Xamarin.PropertyEditing.Mac }; AddSubview (Entry); + Entry.Delegate = new DelegatedRowTextFieldDelegate () + { + ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView) + }; + RightEdgeConstraint = NSLayoutConstraint.Create (Entry, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0); AddConstraints (new[] { NSLayoutConstraint.Create (Entry, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0), @@ -61,7 +92,11 @@ namespace Xamarin.PropertyEditing.Mac protected virtual EntryPropertyEditorDelegate<T> CreateDelegate (PropertyViewModel<T> viewModel) { - return new EntryPropertyEditorDelegate<T> (viewModel); + var propertyEditorDelegate = new EntryPropertyEditorDelegate<T> (viewModel) + { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; + return propertyEditorDelegate; } protected virtual string GetValue (T value) @@ -71,7 +106,7 @@ namespace Xamarin.PropertyEditing.Mac } internal class EntryPropertyEditorDelegate<T> - : NSTextFieldDelegate + : DelegatedRowTextFieldDelegate { public EntryPropertyEditorDelegate (PropertyViewModel<T> viewModel) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs index e56debf..3a00b28 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs @@ -16,7 +16,10 @@ namespace Xamarin.PropertyEditing.Mac { base.TranslatesAutoresizingMaskIntoConstraints = false; - NumericEditor = new NumericSpinEditor<T> (hostResources); + NumericEditor = new NumericSpinEditor<T> (hostResources) + { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; NumericEditor.ValueChanged += OnValueChanged; var t = typeof (T); @@ -129,6 +132,9 @@ namespace Xamarin.PropertyEditing.Mac TranslatesAutoresizingMaskIntoConstraints = false, }; + this.NumericEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.FirstView); + this.inputModePopup.ProxyResponder = new ProxyResponder (this, ProxyRowType.LastView); + this.inputModePopup.Activated += (o, e) => { var popupButton = o as NSPopUpButton; ViewModel.InputMode = this.viewModelInputModes.FirstOrDefault (im => im.Identifier == popupButton.Title); @@ -163,7 +169,7 @@ namespace Xamarin.PropertyEditing.Mac private Type underlyingType; - internal NSPopUpButton inputModePopup; + internal FocusablePopUpButton inputModePopup; private IReadOnlyList<InputMode> viewModelInputModes; private readonly NSLayoutConstraint editorRightConstraint; diff --git a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs index f402bf7..77f6edb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs @@ -74,8 +74,8 @@ namespace Xamarin.PropertyEditing.Mac } } - private NSComboBox comboBox; - private NSPopUpButton popupButton; + private FocusableComboBox comboBox; + private FocusablePopUpButton popupButton; private NSMenu popupButtonList; private NSView firstKeyView; @@ -113,8 +113,9 @@ namespace Xamarin.PropertyEditing.Mac Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), TranslatesAutoresizingMaskIntoConstraints = false, StringValue = String.Empty, + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) }; - + this.popupButton.ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView); this.popupButtonList = new NSMenu (); this.popupButton.Menu = this.popupButtonList; this.popupButton.Activated += PopupButton_Activated; @@ -155,12 +156,13 @@ namespace Xamarin.PropertyEditing.Mac LineBreakMode = NSLineBreakMode.TruncatingTail, UsesSingleLineMode = true, }, + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView), ControlSize = NSControlSize.Small, Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), TranslatesAutoresizingMaskIntoConstraints = false, StringValue = String.Empty, }; - + this.comboBox.ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView); this.comboBox.SelectionChanged += ComboBox_SelectionChanged; AddSubview (this.comboBox); diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs index 73a7f5b..8deacbb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyContainer.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using AppKit; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index e2d5eb9..0f2cec0 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -64,43 +64,9 @@ namespace Xamarin.PropertyEditing.Mac NSView INativeContainer.NativeView => this; - [Export ("_primitiveSetDefaultNextKeyView:")] - public void SetDefaultNextKeyView (NSView child) - { - if (child == FirstKeyView || child == LastKeyView) { - UpdateKeyViews (); - } - } public virtual bool NeedsPropertyButton => true; - public void UpdateKeyViews () - { - if (TableView != null) { - nint row = TableView.RowForView (this); - if (row <= 0) - return; - - NSView view; - PropertyEditorControl ctrl = null; - do { - row--; - view = TableView.GetView (0, row, makeIfNecessary: false); - if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer - ctrl = pec; - } else { - ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; - } - } while (row > 0 && ctrl == null); - - if (ctrl != null) { - ctrl.LastKeyView.NextKeyView = FirstKeyView; - ctrl.UpdateKeyViews (); - } else if (row == 0 && view is PanelHeaderEditorControl header) { - header.SetNextKeyView (FirstKeyView); - } - } - } /// <remarks>You should treat the implementation of this as static.</remarks> public virtual nint GetHeight (EditorViewModel vm) @@ -146,6 +112,42 @@ namespace Xamarin.PropertyEditing.Mac AppearanceChanged (); } + + public void OnNextResponderRequested (bool reverse) + { + if (TableView != null) { + var modifier = reverse ? -1 : 1; + + nint row = TableView.RowForView (this) + modifier; + + NSView view; + PropertyEditorControl ctrl = null; + + var rowCount = TableView.RowCount; + for (; reverse ? row > 0 : row < rowCount; row += modifier) { + + view = TableView.GetView (0, row, makeIfNecessary: false); + if (view is PropertyEditorControl pec) { // This is to include the CategoryContainer + ctrl = pec; + } else { + ctrl = (view as EditorContainer)?.EditorView?.NativeView as PropertyEditorControl; + } + + if (ctrl?.viewModel != null && !ctrl.viewModel.IsInputEnabled) { + ctrl = null; + } + + if (ctrl != null) { + var targetView = reverse ? ctrl.LastKeyView : ctrl.FirstKeyView; + Window?.MakeFirstResponder (targetView); + return; + } else if (row == 0 && view is PanelHeaderEditorControl header) { + Window?.MakeFirstResponder (header); + return; + } + } + } + } } internal abstract class PropertyEditorControl<TViewModel> diff --git a/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs new file mode 100644 index 0000000..406bde4 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/ProxyRowResponder.cs @@ -0,0 +1,48 @@ +using System; + +namespace Xamarin.PropertyEditing.Mac +{ + internal enum ProxyRowType + { + SingleView, + FirstView, + LastView + } + + internal class ProxyResponder + { + protected WeakReference<PropertyEditorControl> editorControl; + + readonly ProxyRowType rowType; + + public ProxyResponder (PropertyEditorControl editorControl, ProxyRowType rowType) + { + this.rowType = rowType; + this.editorControl = new WeakReference<PropertyEditorControl> (editorControl); + } + + public bool NextResponder() + { + if (this.editorControl.TryGetTarget (out var editor)) + { + if (this.rowType == ProxyRowType.LastView || this.rowType == ProxyRowType.SingleView) { + editor.OnNextResponderRequested (false); + return true; + } + } + return false; + } + + public bool PreviousResponder () + { + if (this.editorControl.TryGetTarget (out var editor)) + { + if (this.rowType == ProxyRowType.FirstView || this.rowType == ProxyRowType.SingleView) { + editor.OnNextResponderRequested (true); + return true; + } + } + return false; + } + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs index 7591c2b..a5c8fdc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs @@ -16,6 +16,7 @@ namespace Xamarin.PropertyEditing.Mac base.TranslatesAutoresizingMaskIntoConstraints = false; this.ratioEditor = new RatioEditor<T> (hostResources); + this.ratioEditor.ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView); this.ratioEditor.SetFormatter (null); // update the value on keypress diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs index c05abc9..ad8738c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using AppKit; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; diff --git a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs index e10ec78..01a4af4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs @@ -45,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), TranslatesAutoresizingMaskIntoConstraints = false }; - + this.inputModePopup.ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView); this.inputModePopup.Activated += (o, e) => { var popupButton = o as NSPopUpButton; ViewModel.InputMode = this.viewModelInputModes.FirstOrDefault (im => im.Identifier == popupButton.Title); @@ -104,7 +104,7 @@ namespace Xamarin.PropertyEditing.Mac private NSView lastKeyView; private NSLayoutConstraint editorInputModeConstraint; - private NSPopUpButton inputModePopup; + private FocusablePopUpButton inputModePopup; private IReadOnlyList<InputMode> viewModelInputModes; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/TimeSpanEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/TimeSpanEditorControl.cs index 222af81..d6c6361 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/TimeSpanEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/TimeSpanEditorControl.cs @@ -13,7 +13,9 @@ namespace Xamarin.PropertyEditing.Mac protected override EntryPropertyEditorDelegate<TimeSpan> CreateDelegate (PropertyViewModel<TimeSpan> viewModel) { - return new TimeSpanDelegate (viewModel); + return new TimeSpanDelegate (viewModel) { + ProxyResponder = new ProxyResponder (this, ProxyRowType.SingleView) + }; } protected override void UpdateAccessibilityValues () diff --git a/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs index 9ee86d1..0baee02 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/TypeEditorControl.cs @@ -22,7 +22,9 @@ namespace Xamarin.PropertyEditing.Mac this.selectType = new FocusableButton { BezelStyle = NSBezelStyle.Rounded, Title = Properties.Resources.Select, + ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView) }; + this.selectType.Activated += OnSelectPressed; AddSubview (this.selectType); @@ -89,7 +91,7 @@ namespace Xamarin.PropertyEditing.Mac } private readonly UnfocusableTextField typeLabel; - private readonly NSButton selectType; + private readonly FocusableButton selectType; private void OnTypeRequested (object sender, TypeRequestedEventArgs e) { diff --git a/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs index 4d42f06..42720a8 100644 --- a/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs +++ b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs @@ -2,6 +2,7 @@ using System; using System.IO; using AppKit; using Foundation; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { @@ -39,7 +40,8 @@ namespace Xamarin.PropertyEditing.Mac public virtual NSImage GetNamedImage (string name) { - if ((CurrentAppearance ?? NSAppearance.CurrentAppearance).Name.ToLower ().Contains ("dark")) { + NSAppearance currentAppearance = CurrentAppearance ?? NSAppearance.CurrentAppearance; + if (currentAppearance != null && currentAppearance.Name.ToLower ().Contains ("dark")) { bool sel = name.EndsWith ("~sel"); if (sel) name = name.Substring (0, name.Length - 4); diff --git a/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs b/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs index 3fb3619..8fd8188 100644 --- a/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs +++ b/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs @@ -1,5 +1,6 @@ using System; using AppKit; +using ObjCRuntime; namespace Xamarin.PropertyEditing.Mac { diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs index ad62967..fc2d975 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using CoreGraphics; using Foundation; using AppKit; +using ObjCRuntime; using Xamarin.PropertyEditing.ViewModels; @@ -26,7 +27,7 @@ namespace Xamarin.PropertyEditing.Mac } // Called when created from unmanaged code - public PropertyEditorPanel (IntPtr handle) : base (handle) + public PropertyEditorPanel (NativeHandle handle) : base (handle) { this.hostResources = new HostResourceProvider (); Initialize (); diff --git a/Xamarin.PropertyEditing.Mac/PropertyList.cs b/Xamarin.PropertyEditing.Mac/PropertyList.cs index 8e242a1..027b21f 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyList.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyList.cs @@ -129,7 +129,9 @@ namespace Xamarin.PropertyEditing.Mac SelectRow (0, false); this.tabbedIn = true; var row = GetRowView ((nint)SelectedRows.FirstIndex, false); - return Window.MakeFirstResponder (row.NextValidKeyView); + if (row != null) { + return Window.MakeFirstResponder (row.NextValidKeyView); + } } } this.tabbedIn = false; diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index 9410bc5..fa71c50 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading; using AppKit; using Foundation; +using ObjCRuntime; using Xamarin.PropertyEditing.ViewModels; @@ -211,7 +212,11 @@ namespace Xamarin.PropertyEditing.Mac this.registrations[cellIdentifier] = registration; } - return registration.GetHeight (vm); + // The double cast below is needed for now, while the return value is type ObjCRuntime.nfloat + // in order for the integral to floating point conversion to work properly. Later when ObjCRuntime.nfloat + // is replaced with System.Runtime.InteropServices.NFloat that won't be needed (but can't hurt). + nfloat rowHeight = (nfloat)(double)registration.GetHeight (vm); + return rowHeight; } private class EditorRegistration diff --git a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj index eee6cb9..42c433b 100644 --- a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj +++ b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj @@ -1,21 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> - <TargetFramework>net472</TargetFramework> - <XamarinMacAnalyzerMinimumOSVersion>10.12</XamarinMacAnalyzerMinimumOSVersion> + <TargetFramework>net6.0-macos</TargetFramework> + <SupportedOSPlatformVersion>10.14</SupportedOSPlatformVersion> </PropertyGroup> <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Drawing" /> - <Reference Include="Xamarin.Mac"> - <HintPath Condition="Exists('/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/x86_64/full/Xamarin.Mac.dll')">/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/x86_64/full/Xamarin.Mac.dll</HintPath> - <HintPath Condition="Exists('/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/64bits/full/Xamarin.Mac.dll')">/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/64bits/full/Xamarin.Mac.dll</HintPath> - </Reference> - </ItemGroup> - - <ItemGroup> <ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj" /> </ItemGroup> diff --git a/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj b/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj index ef2a41d..ddc768d 100644 --- a/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj +++ b/Xamarin.PropertyEditing.Tests/Xamarin.PropertyEditing.Tests.csproj @@ -1,28 +1,18 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project Sdk="Microsoft.NET.Sdk"> - <PropertyGroup> + <PropertyGroup Condition=" $(IsMac)" > + <TargetFramework>net6.0</TargetFramework> + </PropertyGroup> + <PropertyGroup Condition=" $(IsWindows)" > <TargetFramework>net472</TargetFramework> - <RestorePackagesPath>$(MSBuildThisFileDirectory)packages\</RestorePackagesPath> </PropertyGroup> <ItemGroup> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Net.Http" /> - <Reference Include="System.Xml" /> - </ItemGroup> - - <ItemGroup> <PackageReference Include="Moq" Version="4.10.1" /> <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.2" /> - <PackageReference Include="NUnit" Version="3.11.0" /> - <PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" /> - <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" /> + <PackageReference Include="NUnit" Version="3.13.2" /> + <PackageReference Include="NUnit3TestAdapter" Version="4.2.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" /> </ItemGroup> <ItemGroup> diff --git a/Xamarin.PropertyEditing.sln b/Xamarin.PropertyEditing.sln index 9404a75..297c815 100644 --- a/Xamarin.PropertyEditing.sln +++ b/Xamarin.PropertyEditing.sln @@ -7,14 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Windows", "Xamarin.PropertyEditing.Windows\Xamarin.PropertyEditing.Windows.csproj", "{60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Tests", "Xamarin.PropertyEditing.Tests\Xamarin.PropertyEditing.Tests.csproj", "{84101D04-9CE4-4CE7-916E-21F86EE96898}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Windows.Standalone", "Xamarin.PropertyEditing.Windows.Standalone\Xamarin.PropertyEditing.Windows.Standalone.csproj", "{070E46F6-916C-4987-8F90-C0CEF1572FFE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Mac.Standalone", "Xamarin.PropertyEditing.Mac.Standalone\Xamarin.PropertyEditing.Mac.Standalone.csproj", "{8319A66C-72AE-4C40-B737-97279D4AB899}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Mac", "Xamarin.PropertyEditing.Mac\Xamarin.PropertyEditing.Mac.csproj", "{E8F4F0EB-C2B1-4116-8459-E076E0E0E485}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Tests", "Xamarin.PropertyEditing.Tests\Xamarin.PropertyEditing.Tests.csproj", "{BA78BFE9-B51A-476D-B949-BD764CB55807}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.PropertyEditing.Mac.Standalone", "Xamarin.PropertyEditing.Mac.Standalone\Xamarin.PropertyEditing.Mac.Standalone.csproj", "{A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -37,32 +37,32 @@ Global {60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}.Release|Any CPU.Build.0 = Release|Any CPU {60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {60AF04BE-1B6B-411B-BCBA-C95EAFBD7AC0}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.Debug|Any CPU.Build.0 = Debug|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.Release|Any CPU.ActiveCfg = Release|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.Release|Any CPU.Build.0 = Release|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.DebugMac|Any CPU.Build.0 = Debug|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU - {84101D04-9CE4-4CE7-916E-21F86EE96898}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.Debug|Any CPU.Build.0 = Debug|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.Release|Any CPU.ActiveCfg = Release|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.Release|Any CPU.Build.0 = Release|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {070E46F6-916C-4987-8F90-C0CEF1572FFE}.ReleaseMac|Any CPU.ActiveCfg = Debug|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.DebugMac|Any CPU.Build.0 = Debug|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU - {8319A66C-72AE-4C40-B737-97279D4AB899}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.Release|Any CPU.ActiveCfg = Release|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.DebugMac|Any CPU.Build.0 = Debug|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU {E8F4F0EB-C2B1-4116-8459-E076E0E0E485}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.Release|Any CPU.Build.0 = Release|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {BA78BFE9-B51A-476D-B949-BD764CB55807}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.DebugMac|Any CPU.ActiveCfg = Debug|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.DebugMac|Any CPU.Build.0 = Debug|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.ReleaseMac|Any CPU.ActiveCfg = Release|Any CPU + {A8ADFD5D-26CE-446B-AACA-99F6CA26FE45}.ReleaseMac|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/azure-pipelines.yaml b/azure-pipelines.yaml index a14e617..0a713e9 100644 --- a/azure-pipelines.yaml +++ b/azure-pipelines.yaml @@ -25,6 +25,6 @@ stages: - template: .build/automation/stages/validate.yml - template: .build/automation/stages/security_compliance.yml # The following Stages are dependent on the OneLocBuild task which is not available in the Xamarin Public AzDevops instance -# - template: .build/automation/stages/localization-handoff.yml # Process outgoing strings [Localization Handoff] -# - template: .build/automation/stages/localization-handback.yml # Process incoming translations and Create PR to main [Localization Handback] -# - template: .build/automation/stages/merge-translations-update.yml # Validating incoming translations strings and merge PR [Localization Handback] + - template: .build/automation/stages/localization-handoff.yml # Process outgoing strings [Localization Handoff] + - template: .build/automation/stages/localization-handback.yml # Process incoming translations and Create PR to main [Localization Handback] + - template: .build/automation/stages/merge-translations-update.yml # Validating incoming translations strings and merge PR [Localization Handback] diff --git a/bot-provisioning/dependencies.csx b/bot-provisioning/dependencies.csx index b082be1..33f1054 100644 --- a/bot-provisioning/dependencies.csx +++ b/bot-provisioning/dependencies.csx @@ -2,6 +2,16 @@ using static Xamarin.Provisioning.ProvisioningScript; -Item ("https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2020-02/77/e9d3af508e46454389cb29836d19616eae1615c0/MonoFramework-MDK-6.12.0.74.macos10.xamarin.universal.pkg"); -Item ("https://download.visualstudio.microsoft.com/download/pr/951ce94d-144e-4a6e-9c1b-31066ce2044c/6c24acc6dfa374bb5f311c46e0dddc03/xamarin.mac-7.11.2.4.pkg"); -Xcode ("12.4.0").XcodeSelect(); +if (IsMac) { + DotNetCoreSdk ("../global.json", installDirectory: Env("DOTNET_ROOT")) + .Workload( + "microsoft.net.sdk.macos", + "12.1.301-preview.13.7", + "https://aka.ms/dotnet6/nuget/index.json", + "https://api.nuget.org/v3/index.json"); + + Xcode ("13.2.1").XcodeSelect (); +} +else if (IsWindows) { + DotNetCoreSdk ("../global.json"); +} @@ -27,16 +27,13 @@ <CommonBuildProperties>$(CommonBuildProperties);Configuration=$(Configuration)</CommonBuildProperties> + <TestProjectDirectory>Xamarin.PropertyEditing.Tests\</TestProjectDirectory> <TestAssemblyBaseDirectory>Xamarin.PropertyEditing.Tests\bin\</TestAssemblyBaseDirectory> <TestAssemblyName>Xamarin.PropertyEditing.Tests.dll</TestAssemblyName> - <Out Condition="'$(Out)' == ''">out</Out> + <Out Condition="'$(Out)' == ''">$(MSBuildThisFileDirectory)out</Out> </PropertyGroup> - <ItemGroup> - <NunitConsoleRunner Include="**/nunit3-console.exe" /> - </ItemGroup> - <!-- List the sln files we need to build --> <ItemGroup> <SolutionFiles Include="$(MSBuildThisFileDirectory)Xamarin.PropertyEditing.sln" /> @@ -62,7 +59,7 @@ <TestAssembly Include="$(TestAssemblyBaseDirectory)**\$(TestAssemblyName)" /> </ItemGroup> <MakeDir Directories="$(Out)" /> - <Exec Command="$(Mono64) @(NunitConsoleRunner) @(TestAssembly) -result=$(Out)\TestResult.xml" /> + <Exec Command="dotnet test $(TestProjectDirectory)Xamarin.PropertyEditing.Tests.csproj -- NUnit.TestOutputXml='$(Out)'" /> </Target> <Target Name="TestMac" Condition=" '$(IsMac)' "> diff --git a/global.json b/global.json new file mode 100644 index 0000000..a2ce2ee --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "6.0.200" + } +} |