imgui-knobs icon indicating copy to clipboard operation
imgui-knobs copied to clipboard

Custom colors for primary, secondary and track colors

Open Simon-L opened this issue 2 years ago • 2 comments

Having the feature to select custom colors for each parts of the knobs could bring a lot of styling capabilities to this excellent library!

There are functions defined for this here: https://github.com/altschuler/imgui-knobs/blob/main/imgui-knobs.cpp#L203-L224

One workaround is to wrap the Knob() call in Push/PopStyleColor() for each colors used (namely ImGuiCol_ButtonActive and ImGuiCol_ButtonHovered for primary and ImGuiCol_Framebg for Track) except ImGuiCol_Framebg will likely also affect the input box background and all 6 colors can not be overriden as they are not unique so it doesn't give full customisation.

@altschuler Do you have an idea/suggestion for that? I know you're not the author of the original code from which this is ported but have you an idea of why these colors were picked up as base for the knobs initially?

I'd have to look at the style editor again but if there are enough unique colors sharing the same default (in dark and light theme) then they could be used instead as base/hovered/active triple and allow each to be overriden as explained above. Hope that makes sense.

Another solution is adding yet another 2/3 optional arguments to Knob()

PS: https://github.com/Simon-L/minisilver/blob/dev/src/imgui-knobs-svg.h for my usecase I wanted fancier knobs so I went ahead and added SVG background and front element!

Simon-L avatar Mar 30 '23 21:03 Simon-L

Those SVG knobs are beautiful! 🤩

Regarding the color customization, I think a way to "hook into" the GetPrimaryColorSet and GetSecondaryColorSet would be ideal. Somehow pushing some color data onto the stack and then reading that in the two color functions (if set, otherwise use the current config). So that is exactly the same way as Push/Pop style colors, but customized for knobs.

I'm not sure what the best way to store the stacked data is, but should be relatively easy to see how ImGui does it internally.

altschuler avatar Apr 19 '23 20:04 altschuler

I'd really like to see both the SVG and Push/Pop style for colors. If I'm doing anything with DISTRHO DPF where the knobs are most needed I'm likely to want to use my own SVG. PNG or sprite. SVG seems like the cleanest option.

frink avatar May 30 '23 19:05 frink

I've changed the track color to use ImGuiCol_Button, that seems like a reasonable default and it makes the input field separately stylable with ImGuiCol_FrameBg/ImGuiCol_Text etc.

altschuler avatar Aug 30 '24 20:08 altschuler