@@ -52,7 +52,7 @@ float MeshCraftApplication::drawToolbar(float menuBarH, int screenW)
5252 showWireframeMode_, showBoundingBox_);
5353
5454 UI::Toolbar::drawSnapToggle (snapEnabled_, snapTranslate_, snapRotate_, snapScale_);
55- if ( ImGui::BeginPopupContextItem ( " ##snapcfg " )) {
55+ UI::Toolbar::drawSnapSettings ([ this ] {
5656 ImGui::TextDisabled (" Snap Intervals" );
5757 ImGui::Separator ();
5858 // Move presets
@@ -103,8 +103,7 @@ float MeshCraftApplication::drawToolbar(float menuBarH, int screenW)
103103 ImGui::NewLine ();
104104 ImGui::SetNextItemWidth (120 );
105105 ImGui::DragFloat (" ##ss" , &snapScale_, 0 .01f , 0 .01f , 10 .0f , " %.3g" , ImGuiSliderFlags_AlwaysClamp);
106- ImGui::EndPopup ();
107- }
106+ });
108107 ImGui::SameLine ();
109108
110109 UI::Toolbar::drawSurfaceSnap (surfaceSnapEnabled_);
@@ -214,6 +213,12 @@ void Toolbar::drawSnapToggle(bool& enabled, float translate, float rotate, float
214213 translate, rotate, scale);
215214}
216215
216+ void Toolbar::drawSnapSettings (const std::function<void ()>& drawContents) {
217+ if (!ImGui::BeginPopupContextItem (" ##snapcfg" )) return ;
218+ drawContents ();
219+ ImGui::EndPopup ();
220+ }
221+
217222void Toolbar::drawProportionalEdit (bool & enabled, float & radius) {
218223 const bool wasEnabled = enabled;
219224 if (wasEnabled) ImGui::PushStyleColor (ImGuiCol_Button, ImVec4 (0 .45f , 0 .20f , 0 .45f , 1 .f ));
0 commit comments