Skip to content

Numeric spin in angle picker now wraps around#1440

Merged
cameronwhite merged 6 commits into
PintaProject:masterfrom
Lehonti:improvement1
May 14, 2025
Merged

Numeric spin in angle picker now wraps around#1440
cameronwhite merged 6 commits into
PintaProject:masterfrom
Lehonti:improvement1

Conversation

@Lehonti

@Lehonti Lehonti commented May 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #1142

The only catch that I see is that the range includes 360 itself. It's annoying but not a huge problem, because the Value exposed by the widget is always a valid angle.

I think (but I'm not sure) that the value of 360 could be excluded through coercion by creating the Gtk.SpinButton with a Gtk.Adjustment and playing a bit with its OnValueChanged signal.

@cameronwhite

Copy link
Copy Markdown
Member

The interesting thing I noticed is that this happens only in one direction: pressing the + button I got 357, 358, 359, 0, 1, ..., but then with the - button I got 2, 1, 0, 360, 359 which is annoying since you have to press twice when you're at 0

I think this is from interactions between the wrapping in DegreesAngle, and how the widget compares angle values from the picker widget against the spin button's value

@cameronwhite

Copy link
Copy Markdown
Member

The way I originally interpreted the bug report was that the user wanted to be able to directly enter in a value like -15, rather than just using the +/- buttons, so another alternative to try would be making the spin button have a range of -360 to 360, without this wrap flag. That actually seems to work quite well from a quick test I did

@Lehonti

Lehonti commented May 11, 2025

Copy link
Copy Markdown
Contributor Author

I haven't had the time to look at this in detail yet, but I see why you interpreted the message that way.

What you suggested (expanding the range to -360) clearly would get the job done. I will give it some thought over the next day or two.

@Lehonti

Lehonti commented May 13, 2025

Copy link
Copy Markdown
Contributor Author

You are right @cameronwhite, setting the lower bound to -360 works pretty well and (at least from my testing) when navigating with the buttons to -1, it becomes 359. I haven't had the time to see exactly why that happens, but it works for most practical purposes (almost nobody is going to go all the way to the bounds using the up/down buttons).

There might be some cleaner or more 'canonical' way to do it but I don't think we should spend too long on this right now.

@cameronwhite

Copy link
Copy Markdown
Member

Thanks, yeah the behaviour seems good to me.
I think the wrapping from -1 to 359 comes from the DegreesAngle class. It's a bit weird how it ends up causing the spinner value to update (I think from the angle widget updating to the clamped value, and then updating the spinner again), but it all works well in the end.

@cameronwhite cameronwhite merged commit a577c98 into PintaProject:master May 14, 2025
@Lehonti Lehonti deleted the improvement1 branch May 14, 2025 08:21
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.

Add Negative Rotation on Rotate / Zoom layer

2 participants