Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Title strip: minimise and close buttons at the far right

islandmed8b30f4ce4fbd
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index fb7f1c08..29e226ae 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -624,7 +624,9 @@ void App::drawTitleStrip(const ShellGeometry& g) {
auto buttonW = [&](const char* label) { return ImGui::CalcTextSize(label, nullptr, true).x + st.FramePadding.x * 2.0f; };
const bool quickSave = actions_.find("file.quicksave") != nullptr;
const float searchW = 150.0f * s;
- float rightW = searchW + buttonW(ICON_LC_MENU " Menus") + 3.0f * (buttonH + 2.0f * s) + 18.0f * s;
+ const float windowButtonW = buttonH + 6.0f * s; // minimise and close, at the far right like ZBrush's
+ float rightW = searchW + buttonW(ICON_LC_MENU " Menus") + 3.0f * (buttonH + 2.0f * s) + 18.0f * s +
+ 10.0f * s + 2.0f * windowButtonW + 2.0f * s;
if (quickSave) rightW += buttonW("QuickSave") + 8.0f * s;
const float rightX = g.title.w - 8.0f * s - rightW;
@@ -705,6 +707,29 @@ void App::drawTitleStrip(const ShellGeometry& g) {
}
ui::HelpText("Search", "F3", "Find any command, brush or material by name and run it.", "Title");
}
+ // Window controls: minimise, and close (asks to save changes first).
+ ImGui::SameLine(0.0f, 10.0f * s);
+ for (int k = 0; k < 2; ++k) {
+ const bool close = k == 1;
+ const ImVec2 p = ImGui::GetCursorScreenPos();
+ const bool clicked = ImGui::InvisibleButton(close ? "Close##window" : "Minimize##window", ImVec2(windowButtonW, buttonH));
+ const bool hovered = ImGui::IsItemHovered();
+ if (hovered)
+ dl->AddRectFilled(p, ImVec2(p.x + windowButtonW, p.y + buttonH),
+ theme::u32(close ? theme::danger : theme::frameHover), 3.0f * s);
+ const char* glyph = close ? ICON_LC_X : ICON_LC_MINUS;
+ const ImVec2 gs = ImGui::CalcTextSize(glyph);
+ dl->AddText(ImVec2(p.x + (windowButtonW - gs.x) * 0.5f, p.y + (buttonH - ImGui::GetFontSize()) * 0.5f),
+ theme::u32(hovered && close ? theme::text : theme::textDim), glyph);
+ if (close) {
+ if (clicked) requestQuit();
+ ui::HelpAction(*this, "file.quit");
+ } else {
+ if (clicked) SDL_MinimizeWindow(window_);
+ ui::HelpText("Minimize", nullptr, "Minimize the SculptForge window.", "Title");
+ }
+ if (!close) ImGui::SameLine(0.0f, 2.0f * s);
+ }
ImGui::PopStyleVar(2);
ImGui::End();
}
diff --git a/tests/ui/shell_layout.sfui b/tests/ui/shell_layout.sfui
index 94f23128..399b8afc 100644
--- a/tests/ui/shell_layout.sfui
+++ b/tests/ui/shell_layout.sfui
@@ -105,3 +105,7 @@ shot preset-wide
click "1##ui.preset.1"
expect "SubTools/Append"
expect_not "Stroke/DragRect"
+
+# Window controls: minimise and close sit at the far right of the title strip.
+expect "Minimize##window"
+expect "Close##window"