@@ -51,14 +51,7 @@ float MeshCraftApplication::drawToolbar(float menuBarH, int screenW)
5151 UI::Toolbar::drawDisplayToggles (gizmoLocalSpace_, showEdgeOverlay_,
5252 showWireframeMode_, showBoundingBox_);
5353
54- // Snap-to-grid toggle button (left-click toggles, right-click configures)
55- { bool was = snapEnabled_;
56- if (was) ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 .20f , 0 .45f , 0 .20f , 1 .f ));
57- if (ImGui::Button (" Snap" , ImVec2 (44 , 30 ))) snapEnabled_ = !snapEnabled_;
58- if (was) ImGui::PopStyleColor (); }
59- if (ImGui::IsItemHovered ())
60- ImGui::SetTooltip (" Snap to grid Move: %.2g u Rotate: %.0f° Scale: %.2g\n Right-click to configure" ,
61- snapTranslate_, snapRotate_, snapScale_);
54+ UI::Toolbar::drawSnapToggle (snapEnabled_, snapTranslate_, snapRotate_, snapScale_);
6255 if (ImGui::BeginPopupContextItem (" ##snapcfg" )) {
6356 ImGui::TextDisabled (" Snap Intervals" );
6457 ImGui::Separator ();
@@ -255,4 +248,14 @@ void Toolbar::drawSurfaceSnap(bool& enabled) {
255248 ImGui::SameLine ();
256249}
257250
251+ void Toolbar::drawSnapToggle (bool & enabled, float translate, float rotate, float scale) {
252+ const bool wasEnabled = enabled;
253+ if (wasEnabled) ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 .20f , 0 .45f , 0 .20f , 1 .f ));
254+ if (ImGui::Button (" Snap" , ImVec2 (44 , 30 ))) enabled = !enabled;
255+ if (wasEnabled) ImGui::PopStyleColor ();
256+ if (ImGui::IsItemHovered ())
257+ ImGui::SetTooltip (" Snap to grid Move: %.2g u Rotate: %.0f° Scale: %.2g\n Right-click to configure" ,
258+ translate, rotate, scale);
259+ }
260+
258261} // namespace MeshCraft::Application::UI
0 commit comments