imgui-knobs
imgui-knobs copied to clipboard
Added setters to specify start and end angles of knobs
Added setters (and related context) to specify start and end angles of knobs (the original interface is still usable)
Example usage:
ImGui::Begin("AngleRangeKnob"); static int value1 = 0; if (ImGuiKnobs::KnobInt("OriginalMin", &value1, 0, 7, 1, "%d", ImGuiKnobVariant_Stepped, 0.0f, 0, 8)) { } ImGui::SameLine(); static int value2 = 7; if (ImGuiKnobs::KnobInt("OriginalMax", &value2, 0, 7, 1, "%d", ImGuiKnobVariant_Stepped, 0.0f, 0, 8)) { }
ImGuiKnobs::SetStartAndEndAngle(0.0f, 0.5f); if (ImGuiKnobs::KnobInt("RangedMin", &value1, 0, 7, 1, "%d", ImGuiKnobVariant_Stepped, 0.0f, 0, 8)) { } ImGui::SameLine(); ImGuiKnobs::SetStartAndEndAngleDeg(0.0f, 90.0f); if (ImGuiKnobs::KnobInt("RangedMax", &value2, 0, 7, 1, "%d", ImGuiKnobVariant_Stepped, 0.0f, 0, 8)) { } ImGui::End();
Hi and thank you for the PR!
I like the idea of making the start/end angles configurable, but I'm not sure if using a separate SetStartAndEndAngle function is desirable, because no other settings are handled that way. It also introduces the knobs context which is a nice addition, but I think it's overkill just for the angles. If anything I would consider moving more of the settings into the context. Also, do you know if using a static is the way ImGui and other libraries implement a context?
Hi,
I think it is really important to keep the existing interface as it is, it is clear and easy to use (and of course to not break the programs which are using it). However we could be a little bit more verbose by using the context during the creation of the next switch... (parameters always have higher priority) In this way it would not be necessary to remember to the order of the arguments, we could use "setters" instead...(yes, I know that nowadays the IDE could help us but I think we should write our source text in a way which is understandable without IDE support also e.g. by reading the related code part on github...) this is why I could suggest the following concept / approach (of course we could use carefully more language features as well to be more compact, if this is a goal...):
it is a .diff ... concept.txt
Hi @GyorgyRotter, I decided to just add another two arguments to the knob functions. While not ideal I think the added context and extra setter functions are too much for now. Maybe later we can work out a better way to manage arguments/customization in general.
Thank you very much for taking the time to create the PR!