Skip to content

Conversation

@Lehonti
Copy link
Contributor

@Lehonti Lehonti commented Sep 5, 2025

Addresses #1094

For multiple selections I'd like to highlight the different bounds separately, but I think this will do for now.

pinta_rule_highlighting.mp4

if (selection_start < selection_end) {

// Convert selection coordinates to ruler widget coordinates
double p1 = (selection_start - Lower) * (settings.EffectiveSize.Width / (Upper - Lower));
Copy link
Member

Choose a reason for hiding this comment

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

Maybe there should be a helper function for this conversion, since it also happens for the marker position?

double p1 = (selection_start - Lower) * (settings.EffectiveSize.Width / (Upper - Lower));
double p2 = (selection_end - Lower) * (settings.EffectiveSize.Width / (Upper - Lower));

cr.SetSourceRgba (0.5, 0.7, 1.0, 0.5); // Semi-transparent blue
Copy link
Member

Choose a reason for hiding this comment

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

How does it look with the same color that's used for selections on the canvas?

Gdk.RGBA fillColor = new () { Red = 0.7f, Green = 0.8f, Blue = 0.9f, Alpha = 0.2f };

@cameronwhite
Copy link
Member

Looks good overall!

I did notice an off by one error that's easier to see when you're zoomed in on a really small image
It's probably because RectangleI.Right is the x coordinate of the last pixel that's in the rectangle , so computing Width as Right - Left is off by one

Screenshot 2025-09-04 at 11 20 00 PM

@Lehonti
Copy link
Contributor Author

Lehonti commented Sep 5, 2025

You are right @cameronwhite, although the selection bounds are a RectangleD. For clarity I changed it the ends of the selection to bounds.Left + bounds.Width and bounds.Top + bounds.Height and made them nullable (to indicate the absence/presence of a selection).

As for the selection color, I think the one I chose is more similar to Paint.NET's. Not that Pinta has to copy its features, but it's worth noting for context.

The color you suggested is on commit bccde34 and it looks like this:

Pinta_5k3ds041x6.mp4

On a different, but related note, looking through the code, I found that the ToInt method in RectangleD is like this:

public readonly record struct RectangleD (
	double X,
	double Y,
	double Width,
	double Height)
{
	// ...
	
	public readonly RectangleI ToInt ()
		=> new (
			(int) Math.Floor (X),
			(int) Math.Floor (Y),
			(int) Math.Ceiling (Width),
			(int) Math.Ceiling (Height));
	
	// ...
}

I think this could be unclear or misleading. Maybe we should add an enum-typed parameter that specifies exactly how it should be rounded?

@cameronwhite
Copy link
Member

Thanks! The original color looks better, but maybe we can make it a more subtle (e.g. a bit more transparent perhaps?)
Right now I think it stands out a bit too much versus the selected widgets in the panels , for example

We could actually use https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/method.StyleManager.get_accent_color_rgba.html to get the exact same color, but I'm not sure if we want that since the accent color can vary based on system settings (https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/css-variables.html#accent-colors), and I think this should stay blue to match the selection. Using the same blue color could be worth trying though

Screenshot 2025-09-08 at 10 56 29 PM Screenshot 2025-09-08 at 10 56 40 PM Screenshot 2025-09-08 at 10 57 16 PM Screenshot 2025-09-08 at 10 57 30 PM

@Lehonti
Copy link
Contributor Author

Lehonti commented Sep 9, 2025

@cameronwhite now the color is more similar to Adwaita's accent color. I normalized the channels to a range of 0-1, rounded it to two decimal places, and set an alpha of 0.25.

image image

@cameronwhite
Copy link
Member

Thanks! That colour looks good to me 👍

@cameronwhite cameronwhite merged commit 4a5b05b into PintaProject:master Sep 10, 2025
7 checks passed
@Lehonti Lehonti deleted the feature/ruler_selection_highlighting branch September 10, 2025 05:01
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