-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul the Gradient Editor #70760
Overhaul the Gradient Editor #70760
Conversation
I would prefer a more laid back milestone because this isn't a bugfix, I made a separate PR with just the bugfixes. I could use some time to improve this PR. |
9cdfe5a
to
e0fcbd3
Compare
504c78e
to
03dcc8a
Compare
Maybe the Snap field should let you set the number of intervals instead of the distance between them? |
7966269
to
3472df3
Compare
48679f6
to
f3891f2
Compare
ac140e4
to
eb25b21
Compare
Oops. Edit: I can't fix this, sorry. I'll start a new PR. And I believe I've worked out how to rebase for real this time, so this won't happen again >_< Here's the new PR: #71746 |
temp note: There's a few bugs I found while testing this again, will fix soon
draw_rect()
was fixed upSee also #70548, where I isolated the bugfixes in this PR so it can more easily get merged into 4.0
I just wanted to implement snapping in the Gradient Editor. But when I pulled on that thread, the whole ball of yarn unraveled.
Refactoring
Previously, we had two sets of files (
gradient_editor
andgradient_editor_plugin
).gradient_editor
had the GradientEditor class. This was for the colorful rectangle that lets you edit a gradient, having all the logic around GUI input on it and also the color selector.gradient_editor_plugin
had the EditorInspectorPluginGradient class, which included the GradientEditor and a small button for reversing the gradient. It also had the GradientReverseButton class, because... yeah, needed a hack just to add that button. This wasn't scalable.I renamed GradientEditor to GradientEditorRect. The stuff inside EditorInspectorPluginGradient are essentially moved to the new GradientEditor, which includes a GradientEditorRect and regular buttons. These were all moved to one file.
Snap Button
It looks like this:
The spin slider and the vertical lines are only shown when snap is toggled.
I removed
Ctrl+Drag
(which snaps by 0.1) andCtrl+Shift+Drag
(which snaps by 0.025) as the snap button makes these tricks completely obsolete.Shift+Drag
still works and is quite useful to get two points near each other when snapping. I gave it a smaller threshold by default for this reason.Improved Undo/Redo system
The undo/redo system wasn't functional. The single manager in
_ramp_changed()
left thousands of vague "Gradient Changed" messages in the output and would usually only lead you one step back before breaking, and that step back would usually not be where you wanted to get.I didn't want to leave this system even more broken than before, so I modernized it. Now it has more descriptive messages and is more predictable.
Testing/Review on this would be appreciated because it might corrupt gradients if not done right!
Misc enhancements
gradient.h
(ponit -> point 🎠)Bugfixes
The bugfixes are in the aforementioned PR, so I'll remove this section if it gets merged.