-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Editor: add gutter to preview and update inline colors in the script and shader editors #76171
base: master
Are you sure you want to change the base?
Editor: add gutter to preview and update inline colors in the script and shader editors #76171
Conversation
73fe19a
to
334e5c2
Compare
Fixed clang-format check failing, add missing new line to SVG file. |
334e5c2
to
952d027
Compare
Fixed clang-format check failing, remove reference syntax |
952d027
to
6c5d136
Compare
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.
This is a great feature, looking forward to it! :D
Though the color constructor parsing/rewriting seems a bit hacky to me:
- it assumes
CodeEdit
is only ever used for GDScript (it's not). I assume you want this feature to be supported by anyone using this UI element, not just the editor. Otherwise, look at modifyingScriptTextEditor
. - any changes to
Color
constructors / static methods would need to be reflected here as well. This increases the cost of maintenance.
Some ideas I've come up with to solve these issues, but feel free to think of your own:
Could the color parsing maybe be changed to work similarly to the "Evaluate Selection" feature, by parsing the Color\(.+?\)
expression, and using the resulting variant as input for the color picker? I don't actually know if the Expression
class is capable of this, but I'd assume it would work, since it's a built-in variant type - needs testing.
Possibly allow overriding this logic for different languages, by adding a virtual method, something like func _parse_color_editor_value(line: String) -> Color | null
.
And as for storing the result, it might be enough to have a virtual method like func _save_color_editor_value(color: Color) -> String
which by default would be implemented using a single constructor of Color (for example, have it always use the hexadecimal syntax).
Or if you want to go crazy, couple this with a "preferred color format" editor setting where you can choose RGBA, leave out the alpha component if it's 100% opaque, etc.
But I don't see a need to keep the color syntax the same from what it initially was - VSCode for example does not do it like this.
Could you update the PR description with photos or videos of using it so we can take a quick cursory look? I have some concerns regarding the implementation, mainly that having a whole gutter for this means a significant loss of horizontal space in the script editor. The info editor could be used for this, but then I feel like we'd also need some infrastructure around deciding what to show on that gutter and what to hide... |
Here three screenshots with different positioning of the picker: |
Not a fan of adding it to the gutter, I was thinking we'd add support for a "drawing API" of some form to |
You used formatting incorrectly. Only classes can be linked to with just |
I did mention such possibility in the GIP, which brings another question. However there is no such "drawing API" to my knowledge. It would need another GIP / PR to discuss about the use-cases of such feature (at least this one but I can think of another). I think more work and experience with the engine would be required as it gets closer to the engine's core.
My first intent was to just target the editor. But as I was searching, it was not clear to me what was what in the engine. Thank you for explaining this, I'll refactor and move rules to
In deed, I though about this and the maintenance cost it induces. I think such changes is unlikely as it would also require Godot's projects to be refactored to support a new syntax (big downside). Nonetheless, I didn't know the engine enough to provide a better approach.
Oh, great! I'll check this and test it, thank you for the feature's name.
I guess this would also apply while using
I beg to differ on this, as I proposed in GIP. It's a bit like
Thinking about it, I like your idea, it should be a good compromise. It would enforce the proposed rule above for all users of a Godot project. I'll investigate this as I work on Many thanks! |
6c5d136
to
96d8730
Compare
Improved documentation: format with special tag |
@RedMser , I tried with the |
That's a shame.
I'm not in a position to be able to decide or judge these things. But my recommendation would be, if you want this merged, to start out simple and have the chance to extend it later. So maybe parsing just Color constructors via Expression is already enough for the MVP, and finding a nice solution to parse the static methods and named color properties could follow later. Same goes for the saving logic, which could start out by just using what the "Evaluate Selection" function uses internally to convert the result back into a String. Maybe other more experienced contributors could chime in here and provide their thoughts. |
96d8730
to
ccacd14
Compare
Moreover, I figured there is an "issue" when parsing other syntaxes like
|
ccacd14
to
c64f72e
Compare
Video of this current commit here, steps:
|
c64f72e
to
1b8a46f
Compare
@RedMser |
See #28607 Code editors already duplicate lots of code, so it's fine until they are refactored. |
1b8a46f
to
b8c320a
Compare
|
b8c320a
to
bf934b1
Compare
8d91ebd
to
2596e7c
Compare
…and shader editors.
2596e7c
to
3b87a8a
Compare
This is an implementation of this GIP #6653.
Color
constructors and static methods.ColorPicker
when clicking on color preview's gutter. Set picker's position around color preview's gutter such as editor's content can still be visualized (may need Right-To-Left support in the future).text_editor/appearance/gutters/show_color_previews
.doc/classes
.Implementation is essentially
private
. Therefore only setter / getter to draw gutter are bound withClassDB
.Not compatible with
v3.x
. I'd be willing to create another PR to supportv3.x
if this one were accepted.Edit:
Production edit: Closes godotengine/godot-proposals#6653