Skip to content

Display image dimensions and aspect ratio in status bar#2013

Open
j03l wants to merge 2 commits intoPintaProject:masterfrom
j03l:feature/statusbar-image-dimensions
Open

Display image dimensions and aspect ratio in status bar#2013
j03l wants to merge 2 commits intoPintaProject:masterfrom
j03l:feature/statusbar-image-dimensions

Conversation

@j03l
Copy link

@j03l j03l commented Feb 27, 2026

Add a new status bar widget showing image dimensions and simplified aspect ratio (e.g. "800 × 600 · 4:3"). The label updates on resize, rotate, undo/redo, and document switching.

The selection size widget previously showed the canvas dimensions (e.g., "800, 600") even when no selection was active. This was because ResetSelectionPaths() in Document.cs creates an invisible selection rectangle covering the full canvas, and the status bar handler read its bounds without checking Selection.Visible.

Before my changes, this was arguably useful, it was the only place showing the canvas dimensions. But now that I've added a dedicated image dimensions widget ("800 × 600 · 4:3"), showing the same numbers in the selection widget is redundant and misleading. It looks like there's an active selection when there isn't one. So I hide the selection widget entirely until the user actually makes a selection.

image

Ref: #1994

Add a new status bar widget showing image dimensions and simplified
aspect ratio (e.g. "800 × 600 · 4:3"). The label updates on resize,
rotate, undo/redo, and document switching.

Also hide the selection size widget when no selection is active,
instead of showing the full canvas dimensions.

Ref: PintaProject#1994
@cameronwhite
Copy link
Member

Thanks for working on this!

I'll look through the code more closely later but gave it a quick try
Trying it out on macOS I had some layout issues (attached video)

  • There is a lot of extra space to the right
  • After making a selection the palette ends up being cut off. This probably depends on the window size and how much space is available
statusbar.mp4

@j03l
Copy link
Author

j03l commented Feb 28, 2026

Thanks for working on this!

I'll look through the code more closely later but gave it a quick try Trying it out on macOS I had some layout issues (attached video)

  • There is a lot of extra space to the right
  • After making a selection the palette ends up being cut off. This probably depends on the window size and how much space is available

statusbar.mp4

Interesting! The palette being cut off is actually in the live version of Pinta. I'll have a play around.

image

…dows

- Render the color palette as a Gtk.Overlay child on top of the info
  widgets (selection, cursor, image size, zoom) so it overlaps instead
  of being compressed when the window is too narrow.
- Pass through clicks on empty palette areas to info widgets underneath.
- Use view-fullscreen-symbolic icon for image dimensions widget.
- Reduce WidthChars from 24 to 16 with dynamic growth to minimize gap.

Avoided using vertical containers (Box or Grid) inside the horizontal
status bar, as the alternating-orientation nesting triggers the GTK
box layout measurement warning from PintaProject#1356. Even a multi-line label
with a newline causes the same issue since Pango's height-for-width
measurement creates the same non-monotonic dependency. All status bar
children remain flat/horizontal to prevent this.
@j03l
Copy link
Author

j03l commented Mar 5, 2026

Added an overlay approach for the status bar so the color palette renders on top of the info widgets when the window is narrow, rather than being squished.

One thing worth noting: I originally wanted to stack the cursor position and image dimensions vertically (two lines) to save horizontal space, but any vertical container (Gtk.Box, Gtk.Grid, or even a single Gtk.Label with \n) inside the horizontal status bar triggers the GTK box layout measurement warning from #1356. The root cause is alternating-orientation nesting (vertical inside horizontal inside vertical shell_layout), GTK's two-phase opposite-axis measurement in gtk_box_layout_compute_opposite_size_for_size() can produce min > natural width, which is harmless but noisy. There's no upstream fix planned; GTK just clamps and warns.

So the info widgets stay flat/horizontal to avoid this. The image dimensions label uses WidthChars = 16 with dynamic growth for large images to keep the gap to the zoom widget tight without clipping.

);
// Use an overlay so the palette renders on top of the info widgets
// when the window is too narrow, instead of being squished.
var overlay = Gtk.Overlay.New ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if instead the palette should have a scrollbar for the palette colours if there isn't enough space? The overlay can do some weird things like the screenshot below when you really reduce the window size :)

Image

return $"{w / gcd}:{h / gcd}";
}

private static int GCD (int a, int b)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remembered we have some existing code that could be used for this:

public static TInt EuclidGCD<TInt> (TInt a, TInt b) where TInt : IBinaryInteger<TInt>

var selection_size = Gtk.Label.New ("");
selection_size.Xalign = 0.0f;
selection_size.Halign = Gtk.Align.Start;
selection_size.WidthChars = 11;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the original comments about left aligned with enough space to display coordinates up to tens of thousands (e.g. 10000, 10000) to explain the magic numbers like having WidthChars = 11, or perhaps we could also define a constant to use for these?

selection_size.SetVisible (false);
return;
}
var bounds = workspaceManager.ActiveDocument.Selection.GetBounds ();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't something you changed, but looking more closely it'd be safer to do GetBounds().ToInt() here since this is a RectangleD, to avoid any chance of having the status bar show non-integer values to the user

var image_size = Gtk.Label.New ("");
image_size.Xalign = 0.0f;
image_size.Halign = Gtk.Align.Start;
image_size.WidthChars = 16;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the selection size and mouse position, we pre-allocate enough space so that the status bar layout doesn't shift around as you move the mouse.
The image size doesn't change as often, so maybe try removing the logic for setting WidthChars here (and below when the size changes)? That would minimize the extra padding and free up more space in the status bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants