-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
Style: Slight vertical gradient in background for all controls #1223
Comments
Nothing is purely optional! The code has a cost even if you don't use it + maintainance cost + raising expectations of styling is a never-ending path. It's not too hard to implement but it would incur a small overhead (and may be tricky to remove it even when gradients are disabled?). Basically the simplest would be to post-op rewrite the colors after drawing shapes. It'd be less intrusive, perhaps a little slower when gradient are involved, because we'd write over vertices twice, but probably worthy overall. And we hard-code it for single-axis (Y) it'd be less computation. Pseudo-code to express what I was thinking for this:
Biggest overhead is in plumbing it all and finding way for it to not cost much when disabled. (Bonus opinion: Personally I find those gradients rather ugly but apparently I am a minority with this opinion!) |
I think making the style system more complex to tweak and to dynamically change is also quite a problem. Suddenly you can't use Idea for a solution: Perhaps gradient and hovered/active variations should be expressed by the user as delta in RGB or HSV space, and imgui would compute then automatically as you edit the style via PushStyleColor() or at the beginning of the frame. This is also relate to your PR #511 which I refused for similar reason or paying hard-to-remove pollution for a short term solution. Expressing variants as delta would be helpful there (HSV delta would be costly to naively recompute in case the user is abusing of PushStyleColor.?) I would like to revamp the color storage so we can stop manipulating the ImVec4 and multiplying by Alpha everytime a color is used as well. So perhaps there would be user-side Colors[] array with fancy high-level concept such as BaseColor+HoveredDeltaHSV+ActiveDeltaHSV+GradientDeltaHSV? and imgui packs and maintain of all of that into ImU32. This is also in line with what I initially wanted to do for v1.50 in #707 and moved to probably v1.51. It would make a nice release of combining this (more styling options, less overhead) + rounding render optimization + merging color picker? |
Color customisation is the only reel enhancement ImGui needs in terms of styling (that's my opinion, obviously). We may want to decompose ImGuiCol_ in 2 things : the color-target and the widget component. If I take the current enum values, I would do something like this to identify which color target the bitfield is referring to:
and for the widget component:
(I may have forgotten some values..) So, instead of calling today:
you would call:
and you may even set multiple colors with a single call:
About my PR #511, it wouldn't require any new enum values to be supported:
Obviously, not all the combination of (WidgetComponent) x (ColorTarget) would be supported at the beginning, and some of them wouldn't make any sense. Coming back to the original topic, adding a new color customisation becomes easier in terms of user interface without breaking previous compatibility.
Maybe you have something completely different in mind. Or maybe I don't see hidden complexity of ImGui coloring. |
Interesting ideas, thanks for writing that up. Making the two sections of flags a sequential list of integers (not individual flags), would allow more data to be packed and be somehow more simple to parse/look at/use at runtime to index tables. Widgets needs to lookup their raw color they need with minimum operation, so ideally a linear enum exists somewhere which they can access (the drawback is to lose the ability to set multiple color together.) On #511 there is still a misconception because you called your enum TextHovered/TextActive but the name is really wrong. The correct name would be along the lines of Text-over-Header, Text-over-Header-Active. See @petrihakkinen spot-on comment and screenshots in #511 which is a generalization of your idea:
Except Petri implies 1 text color for all 3 bg variations, and Pacome explicitly wants different text color for bg variations. So possibly For button the list would be:
Which is quite a lot. Also consider if you want gradients ButtonBg is x2 in theory that's 12 values. If we have a system where "NULL/default" can be encoded we can establish simple obvious rules such as "ButtonTextHovered and ButtonTextActive defaults to ButtonText", "ButtonText" default to "Text", "BgBottom" default to "Bg" etc. Dropping single enum and introducing flags as Pacome suggested would make this natural to comprehend and easy to implement (it's obviously out of question to have a 100+ list raw enum). Using HSV-delta would be very useful to manage those inherited defaults, and the UI can still allow you to edit an absolute RGB value if you need such. I'll try to prototype something to clarify this. |
You're right : by generalising the color of text, then |
Pasting some discussions about colors from Anton M
TL;DR; I think HSV-delta are probably fine as long as the Style Editing UI is nice enough (e.g. Edit as absolute RGB and HSV, store as HSV-delta). |
Nice, do you think making those prototype widgets available (as a gist maybe)? |
I love the outline of texts |
Do you expect to release it in a existing branch ? Thx |
They are merely experiments at this point (all the branches are in a private repo we give access to supporters for toying and feedback). Currently the gradient shading and shadows add too much overhead so i’d like us to fix a few things before releasing eg even a gist, and move toward making some variations of the shadow primitives available in master. |
IMHO, the overhead of vertical gradients shouldn't be significant : even if it multiples by 4 or 5 the number of triangles (due to new vertices) to draw a background, it remains negligable in comparison with round borders or text rendering, right ? For my understanding, by shadows you means the outline of text is rendered using "shadows" and not FreeType's outline feature ? Which means it would be compatible with stb_truetype, being a very good news ! |
Gradient don’t add vertices at this point there are a simple post-process on existing vertices, it is fast but could be done faster if we build things in one pass.
Yes the outline are done manually, not ideal but flexible. There are also (subtle) shadows under many widgets which was i was referring too initially.
|
These are good news, really ! |
Hi @ocornut , That experiments looks really good. Have you published any experimental branch yet? |
Hello,
I am playing with Blender app these days. The look-n-feel is great, the rest is discutable.
Everything in Blender could be done with stock ImGui, except one missing background customisation : a vertical gradient.
Please look at the screenshot :
As you can see, all controls support a light vertical gradient in the background, giving a sense of perspective.
It could be implemented in ImGui by setting 2 (or 3, 4) colors for the Background which would be interpolated. I guess the 2-color version would even be trivial to implement now :)
This feature is purely optional, but having that possibility would allow to enhance the styling of ImGui. And I would be pleased to reproduce the Blender style configuration with ImGui !
Best regards
The text was updated successfully, but these errors were encountered: