CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.22k stars 907 forks source link

Add style/color override options for #147 #251

Closed aaronkirkham closed 2 years ago

aaronkirkham commented 2 years ago

Initial work on adding style/color override options for the gizmos. This is a PR for https://github.com/CedricGuillemet/ImGuizmo/issues/147.

I've tried to keep the API as close to ImGui's style API as possible, there's no support for push/popping styles/colors as I personally didn't find any need for it in my own project. You setup the style once just like you would with ImGui themes.

Not only does this support changing colors but I've also exposed a few float values to control thicknesses of the lines in some gizmos.

I haven't provided any demos but can if needed, basic setup looks something like this (taken from my own project running this PR)

ImGuizmo::Style* style  = &ImGuizmo::GetStyle(); // get a pointer to the global style context
ImVec4*          colors = style->Colors;         // get access to the colors array

after we have those pointers, we can edit the style of the gizmos:

// make the translation lines smaller, but have a bigger arrow head
style->TranslationLineThickness = 2.0f;
style->TranslationLineArrowSize = 10.0f;

// lighter r/g/b colours
colors[ImGuizmo::DIRECTION_X] = ImVec4(0.858f, 0.243f, 0.113f, 0.929f);
colors[ImGuizmo::DIRECTION_Y] = ImVec4(0.603f, 0.952f, 0.282f, 0.929f);
colors[ImGuizmo::DIRECTION_Z] = ImVec4(0.227f, 0.478f, 0.972f, 0.929f);

Feedback is welcome, if you have any issues with the API or the naming of things, I'm happy to edit.

Thanks.

CedricGuillemet commented 2 years ago

There is a conflict

aaronkirkham commented 2 years ago

Will re-create the PR with conflicts resolved!