-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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 #71915
Overhaul the Gradient Editor #71915
Conversation
16d93fd
to
1517aac
Compare
47142af
to
277d414
Compare
Tested the editor and functionally it's good, although it would be nice if snapping was remembered. Right now it resets even if you just fold the gradient. You could use project metadata for that, or a static member. |
Not sure right now how I could save snapping, especially since it seems mostly useful on a per-gradient basis... GradientTexture2D's snapping could also use the solution to this. |
4378e2a
to
f7e52e1
Compare
0136b43
to
09773de
Compare
Reversing broke again if you spam-click the button. Help |
@MewPurPur How does it break? Have you considered adding a guard to the method, so it doesn't run again until it finishes the previous call? Also, you haven't addressed some of the comments that you have marked as resolved. Is that intentional? |
No, not intentional, sorry, I reset my fix-up thinking that was what introduced the glitch.
Idek how to put guards in Undo Redo, but I'll try more things in a little. |
For UndoRedo you can use the merge events feature, then multiple subsequent actions should be treated as one operation. But I meant adding guards to the method that handles the click itself, before the UndoRedo gets called. |
09773de
to
f7b80ed
Compare
Okay, now all the resolved things are fixed, sorry for the blunder. The reverse bug isn't fixed though, and it's easier to trigger than I thought. You don't have to spam-click, I had it happen after spacing out my clicks for about a second. (though it never happens if you hold off for longer than a second) |
Then you definitely need some guards that would make the |
f7b80ed
to
7b0f5be
Compare
I found more things about the
|
7b0f5be
to
5e4769a
Compare
W. T. F. now I'm occasionally getting the gradient corrupted with handles becoming colors that didn't even exist on the gradient. EDIT: I removed the crash dump, it was unrelated and I've fixed it. But the thing with the colors is real. |
@MewPurPur If the issue is within the gradient itself, and not within this editor plugin, then we can go ahead with this PR (and make sure the issue is reported, so it can be looked into). Can it be reproduced without your PR? With the editor UI, or, say, by calling the reverse function from a script in a loop? |
I don't think it's within Gradient. I'm perplexed. |
5e4769a
to
0030dd2
Compare
Still no idea what it is, but I can only reproduce with one inconspicuous gradient. Reversing it in any context corrupts it, not just the gradient editor.
So no, doesn't seem like a bug with my PR after all. Very strange though. |
0030dd2
to
7b86969
Compare
In spite of this, I actually can't reproduce the bug with this gradient outside of this PR. Send help |
I can't reproduce your bug even when holding down Undo/Redo shortcut (so things change very rapidly back and forth). There is a tiny bit of lag when the editor refreshes if you have packed arrays unfolded. But it doesn't corrupt the gradient in any way. I say we merge it and maybe somebody will be able to reproduce your heisenbug. |
Me neither. Hopefully it's just some sort of artifact from this PR being up since pre-4.0 times, that won't happen in real projects. By now this is easily the weirdest bug I've ever had. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally (rebased on top of master
2048fe5), it works as expected.
Thanks MewPurPur for this big improvement, and thanks to all reviewers too :) |
Closes godotengine/godot-proposals#6555
(I murdered this PR twice with bad rebasing, sorry about that :/ replaces #71746)
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 GradientEdit, whereas the whole thing with the buttons is now a GradientEditor. These were all moved to one file like other editor plugins.
Snap Button
Looks like this:
The slider and the vertical lines are only shown when snap is toggled.
I removed
Ctrl+Shift+Drag
(which snaps with 40 partitions) as the snap button makes this quite obsolete.Ctrl+Drag
still works though, but it applies the snap count of the gradient.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. This can also be combined withCtrl
.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. Code was simplified a lot too, removing some unused or unnecessary things.
Testing/Review on this would be appreciated because it might corrupt gradients if not done right!
Misc enhancements
gradient.h
(ponit -> point 🎠)