Skip to content

Commit

Permalink
A few windowing / layout improvements towards fixing toolbars in full…
Browse files Browse the repository at this point in the history
…screen

- When a header bar is being used, also use AdwApplicationWindow which is better integrated with the libadwaita styling. We don't use this on macOS (which has a global menubar) since this removes the normal titlebar from the window when no headerbar is used
- Simplify the layout code a bit and eliminiate the unnecessary 'menu_layout' member
- Use Adw.ToolbarView for the main layout, which allows more control over the header bar when fullscreen (https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/migrating-to-breakpoints.html#fullscreen-header-bar)

Bug: #2047094
  • Loading branch information
cameronwhite committed Dec 25, 2023
1 parent 9f22a9b commit a3ab26d
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions Pinta/WindowShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,30 @@ namespace Pinta;

public sealed class WindowShell
{
private readonly ApplicationWindow app_window;
private readonly Gtk.ApplicationWindow app_window;
private readonly Adw.HeaderBar? header_bar;
private readonly Box shell_layout;
private readonly Box menu_layout;
private Box? workspace_layout;
private Box? main_toolbar;

public WindowShell (Application app, string name, string title, int width, int height, bool maximize)
{
app_window = Gtk.ApplicationWindow.New (app);
var app_layout = Adw.ToolbarView.New ();

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'.

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 42 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.New()' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

// On macOS the global menubar is used, but otherwise use a header bar.
// We also use a regular Gtk window on macOS to have a traditional titlebar with the standard close / minimize buttons.
bool use_header_bar = PintaCore.System.OperatingSystem != OS.Mac;
if (use_header_bar) {
var adwWindow = Adw.ApplicationWindow.New (app);
adwWindow.SetContent (app_layout);
app_window = adwWindow;

header_bar = Adw.HeaderBar.New ();
app_layout.AddTopBar (header_bar);

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'.

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 53 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.AddTopBar(Widget)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
} else {
app_window = Gtk.ApplicationWindow.New (app);
app_window.SetChild (app_layout);
}

app_window.Name = name;
app_window.Title = title;
Expand All @@ -51,30 +65,21 @@ public WindowShell (Application app, string name, string title, int width, int h
if (maximize)
app_window.Maximize ();

// On macOS the global menubar is used, but otherwise use a header bar.
if (PintaCore.System.OperatingSystem != OS.Mac) {
header_bar = Adw.HeaderBar.New ();
app_window.SetTitlebar (header_bar);
}

shell_layout = Box.New (Orientation.Vertical, 0);
menu_layout = Box.New (Orientation.Vertical, 0);

shell_layout.Prepend (menu_layout);
app_layout.SetContent (shell_layout);

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-macos

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (7.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-windows

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'.

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

Check warning on line 69 in Pinta/WindowShell.cs

View workflow job for this annotation

GitHub Actions / build-ubuntu (8.0.x)

This call site is reachable on all platforms. 'ToolbarView.SetContent(Widget?)' is unsupported on: 'macOS/OSX'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)

app_window.SetChild (shell_layout);
app_window.Present ();
}

public ApplicationWindow Window => app_window;
public Gtk.ApplicationWindow Window => app_window;
public Adw.HeaderBar? HeaderBar => header_bar;

public Box CreateToolBar (string name)
{
main_toolbar = GtkExtensions.CreateToolBar ();
main_toolbar.Name = name;

menu_layout.Append (main_toolbar);
shell_layout.Append (main_toolbar);
main_toolbar.Show ();

return main_toolbar;
Expand Down

0 comments on commit a3ab26d

Please sign in to comment.