Mac: Toolbar fixes for macOS 10.15

This commit is contained in:
Ben Olden-Cooligan 2022-12-20 00:04:12 -08:00
parent 8d30d9e2f4
commit d8f52871bf
8 changed files with 48 additions and 13 deletions

View File

@ -10,8 +10,8 @@ public class MacIconProvider : IIconProvider
{ "control_play_blue", "play" },
{ "blueprints", "list.bullet" },
{ "folder_picture", "folder" },
{ "save", "square.and.arrow.down" },
{ "viewfinder", "viewfinder" },
{ "diskette", "square.and.arrow.down" },
{ "zoom", "viewfinder" },
{ "arrow_rotate_anticlockwise", "arrow.counterclockwise" },
{ "arrow_rotate_anticlockwise_small", "arrow.counterclockwise" },
{ "arrow_rotate_clockwise_small", "arrow.clockwise" },
@ -44,7 +44,12 @@ public class MacIconProvider : IIconProvider
public Image? GetIcon(string name)
{
// TODO: Fix names (like "save") that have no non-mac image and will break on macOS 10.15
if (!OperatingSystem.IsMacOSVersionAtLeast(11) && name == "arrow_rotate_anticlockwise")
{
// TODO: Verify this fixes the rotate menu on macOS 10.15
// TODO: Also maybe map other icons to 16x16 versions (e.g. control_play_blue) for better rendering
return _defaultIconProvider.GetIcon("arrow_rotate_anticlockwise_small");
}
if (OperatingSystem.IsMacOSVersionAtLeast(11) && IconMap.ContainsKey(name))
{
var symbol = NSImage.GetSystemSymbol(IconMap[name], null);

View File

@ -19,7 +19,8 @@ public static class MacToolbarItems
Image = command.Image?.ToNS(),
Title = title ?? "",
Label = command.ToolBarText ?? "",
ToolTip = tooltip ?? command.ToolBarText ?? "",
// TODO: Verify this fixes label display on macOS 10.15
ToolTip = OperatingSystem.IsMacOSVersionAtLeast(11) ? tooltip ?? command.ToolBarText ?? "" : "",
Bordered = true,
Autovalidates = false
}.WithAction(command.Execute);

View File

@ -135,18 +135,21 @@ public class MacDesktopForm : DesktopForm
toolbar.Delegate = new MacToolbarDelegate(CreateMacToolbarItems());
toolbar.AllowsUserCustomization = true;
// toolbar.AutosavesConfiguration = true;
toolbar.DisplayMode = NSToolbarDisplayMode.Icon;
// TODO: Get rid of the borders/excessive padding on macOS 13
var window = this.ToNative();
window.Toolbar = toolbar;
if (OperatingSystem.IsMacOSVersionAtLeast(11))
{
toolbar.DisplayMode = NSToolbarDisplayMode.Icon;
window.ToolbarStyle = NSWindowToolbarStyle.Unified;
window.StyleMask |= NSWindowStyle.FullSizeContentView;
window.StyleMask |= NSWindowStyle.UnifiedTitleAndToolbar;
}
// TODO: Do we want full size content?
window.StyleMask |= NSWindowStyle.FullSizeContentView;
window.StyleMask |= NSWindowStyle.UnifiedTitleAndToolbar;
else
{
toolbar.DisplayMode = NSToolbarDisplayMode.IconAndLabel;
}
window.Toolbar = toolbar;
}
private List<NSToolbarItem> CreateMacToolbarItems()

View File

@ -64,13 +64,13 @@ public class DesktopCommands
SaveAll = new ActionCommand(_imageListActions.SaveAllAsPdfOrImages)
{
Text = UiStrings.SaveAll,
Image = iconProvider.GetIcon("save"),
Image = iconProvider.GetIcon("diskette"),
Shortcut = Application.Instance.CommonModifier | Keys.S
};
SaveSelected = new ActionCommand(_imageListActions.SaveSelectedAsPdfOrImages)
{
Text = UiStrings.SaveSelected,
Image = iconProvider.GetIcon("save"),
Image = iconProvider.GetIcon("diskette"),
Shortcut = Application.Instance.CommonModifier | Keys.Shift | Keys.S
};
SavePdf = new ActionCommand(desktopController.SavePdf)
@ -143,7 +143,7 @@ public class DesktopCommands
ViewImage = new ActionCommand(desktopSubFormController.ShowViewerForm)
{
Text = UiStrings.View,
Image = iconProvider.GetIcon("viewfinder")
Image = iconProvider.GetIcon("zoom")
};
Crop = new ActionCommand(desktopSubFormController.ShowCropForm)
{

View File

@ -429,6 +429,16 @@ namespace NAPS2 {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] diskette {
get {
object obj = ResourceManager.GetObject("diskette", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
@ -879,6 +889,16 @@ namespace NAPS2 {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] zoom {
get {
object obj = ResourceManager.GetObject("zoom", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>

View File

@ -373,4 +373,10 @@
<data name="exclamation" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Icons\exclamation.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="diskette" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Icons\diskette.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Icons\zoom.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
NAPS2.Lib/Icons/zoom.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB