mirror of
https://github.com/cyanfish/naps2.git
synced 2024-09-11 15:26:55 +03:00
Mac: Toolbar fixes for macOS 10.15
This commit is contained in:
parent
8d30d9e2f4
commit
d8f52871bf
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
{
|
||||
|
20
NAPS2.Lib/Icons.Designer.cs
generated
20
NAPS2.Lib/Icons.Designer.cs
generated
@ -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>
|
||||
|
@ -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>
|
BIN
NAPS2.Lib/Icons/diskette.png
Normal file
BIN
NAPS2.Lib/Icons/diskette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
NAPS2.Lib/Icons/zoom.png
Normal file
BIN
NAPS2.Lib/Icons/zoom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue
Block a user