Skip to content

Commit

Permalink
Add a sidebar toggle to WinForms/Gtk
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Aug 19, 2024
1 parent 6bc1945 commit e8e9309
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion NAPS2.Lib.Mac/EtoForms/Mac/MacIconProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MacIconProvider : IIconProvider
{ "text_align_justify_small", "text.justify" },
{ "large_tiles_small", "square.grid.2x2" },
{ "exclamation_small", "exclamationmark.triangle" },
{ "sidebar", "sidebar.left" },
{ "application_side_list", "sidebar.left" },
// TODO: Consider these
// { "ask", "questionmark" },
// { "network_ip", "wifi.router" },
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib.Mac/EtoForms/Ui/MacDesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,5 @@ private void ThumbnailController_ThumbnailSizeChanged(object? o, EventArgs event
_zoomSlider!.DoubleValue = ThumbnailSizes.SizeToCurve(_thumbnailController.VisibleSize);
}

protected override LayoutElement GetZoomButtons() => C.Spacer();
protected override LayoutElement GetControlButtons() => C.Spacer();
}
11 changes: 7 additions & 4 deletions NAPS2.Lib.WinForms/EtoForms/Ui/WinFormsDesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected override void OnShown(EventArgs e)
base.OnShown(e);
}

protected override LayoutElement GetZoomButtons()
protected override LayoutElement GetControlButtons()
{
// Disabled buttons don't prevent click events from being sent to the listview below the button, so without this
// "mouse catcher" control you could e.g. spam click zoom out until it's maxed and then accidentally keep
Expand All @@ -100,9 +100,12 @@ protected override LayoutElement GetZoomButtons()
Size = new Size(45, 23),
FlatStyle = WF.FlatStyle.Flat
};
return L.Overlay(
L.Row(mouseCatcher.ToEto().AlignTrailing()),
base.GetZoomButtons()
return L.Row(
GetSidebarButton(),
L.Overlay(
L.Row(mouseCatcher.ToEto().AlignTrailing()),
GetZoomButtons()
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public override void UpdateRtl(Window window)

public override void ConfigureZoomButton(Button button)
{
button.Size = new Size(23, 23);
button.Size = new Size(25, 25);
var wfButton = (WF.Button) button.ToNative();
wfButton.AccessibleName = button.Text;
wfButton.Text = "";
Expand Down
2 changes: 1 addition & 1 deletion NAPS2.Lib/EtoForms/Ui/DesktopCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public DesktopCommands(DesktopController desktopController, DesktopScanControlle
ToggleSidebar = new ActionCommand(() => _desktopFormProvider.DesktopForm.ToggleSidebar())
{
Text = UiStrings.ToggleSidebar,
Image = iconProvider.GetIcon("sidebar")
Image = iconProvider.GetIcon("application_side_list")
};
}

Expand Down
18 changes: 14 additions & 4 deletions NAPS2.Lib/EtoForms/Ui/DesktopForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ protected override void BuildLayout()
LayoutController,
_sidebar.CreateView(this),
L.Overlay(
GetMainContent(),
_listView.Control,
L.Column(
C.Filler(),
L.Row(
GetZoomButtons(),
GetControlButtons(),
C.Filler(),
_notificationArea.Content)
).Padding(10)
Expand Down Expand Up @@ -432,9 +432,19 @@ protected SubMenuItem CreateSubMenu(Command menuCommand, MenuProvider menuProvid
return menuItem;
}

protected virtual LayoutElement GetMainContent() => _listView.Control;
protected virtual LayoutElement GetControlButtons()
{
return L.Row(GetSidebarButton(), GetZoomButtons());
}

protected LayoutElement GetSidebarButton()
{
var toggleSidebar = C.ImageButton(Commands.ToggleSidebar);
EtoPlatform.Current.ConfigureZoomButton(toggleSidebar);
return toggleSidebar.AlignTrailing();
}

protected virtual LayoutElement GetZoomButtons()
protected LayoutElement GetZoomButtons()
{
var zoomIn = C.ImageButton(Commands.ZoomIn);
EtoPlatform.Current.ConfigureZoomButton(zoomIn);
Expand Down
10 changes: 10 additions & 0 deletions NAPS2.Lib/Icons.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions NAPS2.Lib/Icons.resx
Original file line number Diff line number Diff line change
Expand Up @@ -469,4 +469,7 @@
<data name="shape_align_right" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Icons\shape_align_right.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="application_side_list" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Icons\application_side_list.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
Binary file added NAPS2.Lib/Icons/application_side_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e8e9309

Please sign in to comment.