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.

Empty shelves hide outside Customize Shelves; the canvas takes their room (#139)

islandmed74fb20b1d842
diff --git a/changes/feat-hide-empty-shelves.md b/changes/feat-hide-empty-shelves.md
new file mode 100644
index 00000000..c07735d5
--- /dev/null
+++ b/changes/feat-hide-empty-shelves.md
@@ -0,0 +1,11 @@
+---
+whats_new: **Empty shelves hide**: a shelf you empty is hidden outside **Customize Shelves** and the canvas takes its
+ room; it comes back while customizing so you can drop buttons onto it again.
+changed: An empty shelf is hidden when **Customize Shelves** is off, and the canvas takes its space; it returns
+ while customizing so items can be dropped back onto it. Saved layouts with empty shelves load as before (#139,
+ thanks ebarranco).
+testers:
+ - Any OS: Edit > Preferences > Config > Customize Shelves; right-click each right-shelf button > Remove from shelf;
+ turn Customize Shelves off: the right shelf is gone and the canvas reaches the tray. Turn it on again: the empty
+ shelf is back, outlined; Ctrl+Alt+drag a button onto it.
+---
diff --git a/docs/guide/interface.md b/docs/guide/interface.md
index c70f0781..33d16629 100644
--- a/docs/guide/interface.md
+++ b/docs/guide/interface.md
@@ -472,6 +472,9 @@ you keep them with **Save Layout**.
Right-clicking a shelf item and choosing **Remove from shelf** works without Customize mode.
+A shelf you empty is hidden when Customize Shelves is off, and the canvas takes its room. Turn Customize Shelves
+back on and the empty shelf returns, outlined, so you can drag buttons onto it again.
+
### Assign shortcuts
- Hold <kbd>Ctrl</kbd>+<kbd>Alt</kbd> and **click** any button (with Customize off), then press the key you
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index 1851a0c6..b749a733 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -972,10 +972,9 @@ void App::drawShell() {
else drawTitleStrip(shell_);
if (layout_.paletteBarVisible && !sculptForgeLayout()) drawPaletteBar(shell_);
if (shell_.shelves) {
- drawShelf(kShelfTop, shell_.topShelf);
- drawShelf(kShelfLeft, shell_.leftShelf);
- drawShelf(kShelfRight, shell_.rightShelf);
- drawShelf(kShelfBottom, shell_.bottomShelf);
+ const CanvasRect* shelves[] = {&shell_.topShelf, &shell_.leftShelf, &shell_.rightShelf, &shell_.bottomShelf};
+ for (int k : {kShelfTop, kShelfLeft, kShelfRight, kShelfBottom})
+ if (shelves[k]->w > 0.0f && shelves[k]->h > 0.0f) drawShelf(k, *shelves[k]); // empty: hidden (#139)
if (shell_.leftTray.w > 0.0f) drawTray(false, shell_.leftTray);
if (shell_.rightTray.w > 0.0f) drawTray(true, shell_.rightTray);
drawDivider(false, shell_.leftDivider);
diff --git a/src/app/ShellGeometry.cpp b/src/app/ShellGeometry.cpp
index 53f9aa46..a3e24f78 100644
--- a/src/app/ShellGeometry.cpp
+++ b/src/app/ShellGeometry.cpp
@@ -123,16 +123,18 @@ ShellGeometry computeShell(const UiLayout& l, float W, float H, float s, float t
}
const float span = std::max(0.0f, right - left);
- const float topH = g.shelves ? (m.topShelfH + m.grow) * s : 0.0f;
- const float bottomH = g.shelves ? (bottomShelfSize(l.shelfTiles).shelfH + m.grow) * s : 0.0f;
+ // An empty shelf takes no room outside Customize Shelves (#139).
+ auto shown = [&](const std::vector<std::string>& items) { return g.shelves && (l.customize || !shelfEmpty(items)); };
+ const float topH = shown(l.topShelf) ? (m.topShelfH + m.grow) * s : 0.0f;
+ const float bottomH = shown(l.bottomShelf) ? (bottomShelfSize(l.shelfTiles).shelfH + m.grow) * s : 0.0f;
g.topShelf = {left, top, span, topH};
g.bottomShelf = {left, H - bottomH, span, bottomH};
const float consoleH = l.consoleOpen ? std::clamp(l.consoleHeight, kConsoleMinH, kConsoleMaxH) * s : 0.0f;
g.console = {left, g.bottomShelf.y - consoleH, span, consoleH};
const float y0 = top + topH, y1 = std::max(y0, g.console.y);
- const float leftW = g.shelves ? ((g.narrow ? kLeftShelfNarrowW : kLeftShelfW) + m.grow) * s : 0.0f;
- const float rightW = g.shelves ? (kRightShelfW + m.grow) * s : 0.0f;
+ const float leftW = shown(l.leftShelf) ? ((g.narrow ? kLeftShelfNarrowW : kLeftShelfW) + m.grow) * s : 0.0f;
+ const float rightW = shown(l.rightShelf) ? (kRightShelfW + m.grow) * s : 0.0f;
g.leftShelf = {left, y0, leftW, y1 - y0};
g.rightShelf = {right - rightW, y0, rightW, y1 - y0};
g.canvas = {left + leftW, y0, std::max(1.0f, span - leftW - rightW), std::max(1.0f, y1 - y0)};
diff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cpp
index 61a2fa3a..6d61b13c 100644
--- a/src/app/UiLayout.cpp
+++ b/src/app/UiLayout.cpp
@@ -99,6 +99,10 @@ Json toJson(const UiLayout& l) {
return j;
}
+bool shelfEmpty(const std::vector<std::string>& items) {
+ return std::all_of(items.begin(), items.end(), [](const std::string& id) { return id == "sep" || id == "row"; });
+}
+
bool fromJson(const Json& j, UiLayout& l, std::string& error, int shellLayout) {
if (!j.isObject()) {
error = "The UI configuration is not a JSON object";
diff --git a/src/app/UiLayout.h b/src/app/UiLayout.h
index 0be1e09f..55a82683 100644
--- a/src/app/UiLayout.h
+++ b/src/app/UiLayout.h
@@ -39,6 +39,10 @@ struct UiLayout {
bool customize = false; // runtime only, never stored
};
+// A shelf with nothing on it but separators and line breaks: hidden outside Customize Shelves, so the canvas takes
+// its space, and back while customizing so items can be dropped onto it again (#139).
+bool shelfEmpty(const std::vector<std::string>& items);
+
UiLayout standardLayout(); // the built-in default
UiLayout standardLayout(int shellLayout); // 0 the Classic layout (the same), 1 the SculptForge layout
Json toJson(const UiLayout& layout);
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index cbbead39..1675205d 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -826,6 +826,13 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "shelves_visible") return app_.layout_.shelvesVisible ? 1.0 : 0.0;
if (name == "right_tray_open") return app_.layout_.rightTrayOpen ? 1.0 : 0.0;
if (name == "left_tray_open") return app_.layout_.leftTrayOpen ? 1.0 : 0.0;
+ if (name == "canvas_width") return double(app_.shell_.canvas.w / std::max(app_.uiScale_, 0.01f)); // logical px
+ // A shelf drawn (not hidden for being empty outside Customize Shelves, #139): 0 top, 1 left, 2 right, 3 bottom.
+ if (name.rfind("shelf_shown_", 0) == 0) {
+ const CanvasRect* r[] = {&app_.shell_.topShelf, &app_.shell_.leftShelf, &app_.shell_.rightShelf, &app_.shell_.bottomShelf};
+ const int k = std::atoi(name.c_str() + 12);
+ return k >= 0 && k < 4 && r[k]->w > 0.0f && r[k]->h > 0.0f ? 1.0 : 0.0;
+ }
if (name == "right_tray_shown") return app_.shell_.rightTray.w > 0.0f ? 1.0 : 0.0; // drawn, not just set open (#107)
if (name == "shell_narrow") return app_.shell_.narrow ? 1.0 : 0.0;
if (name == "offscreen_items") { // items drawn past the window's edge last frame (#105); names them in the log
diff --git a/tests/test_shell_layout.cpp b/tests/test_shell_layout.cpp
index 3be27998..9244cefd 100644
--- a/tests/test_shell_layout.cpp
+++ b/tests/test_shell_layout.cpp
@@ -56,6 +56,29 @@ TEST(shell_bottom_shelf_tile_sizes) {
CHECK(fromJson(toJson(l), back, err) && back.shelfTiles == 2);
}
+TEST(shell_empty_shelves_hide_outside_customize) { // #139
+ UiLayout l = standardLayout();
+ l.rightShelf = {"sep"}; // separators alone count as empty
+ l.leftShelf.clear();
+ ShellGeometry g = computeShell(l, 1600, 960, 1.0f);
+ CHECK(near(g.rightShelf.w, 0) && near(g.leftShelf.w, 0));
+ CHECK(rectIs(g.canvas, 8, 110, 1284, 772)); // the canvas takes both shelves' room
+ l.customize = true; // back while customizing, to drop items onto
+ g = computeShell(l, 1600, 960, 1.0f);
+ CHECK(rectIs(g.rightShelf, 1240, 110, 52, 772));
+ CHECK(rectIs(g.canvas, 96, 110, 1144, 772));
+ l.customize = false;
+ l.topShelf = {"row"};
+ l.bottomShelf.clear();
+ g = computeShell(l, 1600, 960, 1.0f);
+ CHECK(near(g.topShelf.h, 0) && near(g.bottomShelf.h, 0));
+ CHECK(rectIs(g.canvas, 8, 46, 1284, 914));
+ UiLayout back; // a saved layout with empty shelves loads with them empty
+ std::string err;
+ CHECK(fromJson(toJson(l), back, err) && back.leftShelf.empty() && back.bottomShelf.empty());
+ CHECK(computeShell(l, 1600, 960, 1.0f, 0.0f, sculptForgeMetrics(8.0f)).canvas.w > 1200.0f); // tiles
+}
+
TEST(shell_standard_layout_1920x1080) {
const ShellGeometry g = computeShell(standardLayout(), 1920, 1080, 1.0f);
CHECK(rectIs(g.canvas, 96, 110, 1444, 892)); // §2.3: the extra width goes to the canvas
diff --git a/tests/ui/data/prefs/ui_empty_shelves.json b/tests/ui/data/prefs/ui_empty_shelves.json
new file mode 100644
index 00000000..3b2c3738
--- /dev/null
+++ b/tests/ui/data/prefs/ui_empty_shelves.json
@@ -0,0 +1,10 @@
+{
+ "version": 1,
+ "layout": {
+ "version": 4,
+ "leftShelf": [],
+ "rightShelf": ["view.wire", "sep"]
+ },
+ "shortcuts": {},
+ "prefs": {}
+}
diff --git a/tests/ui/empty_shelves.sfui b/tests/ui/empty_shelves.sfui
new file mode 100644
index 00000000..b9d993ac
--- /dev/null
+++ b/tests/ui/empty_shelves.sfui
@@ -0,0 +1,44 @@
+# Empty shelves (#139): a shelf with nothing on it is hidden outside Customize Shelves and the canvas takes its room;
+# while customizing it is back, so buttons can be dropped onto it again. A saved layout with an empty shelf loads.
+run new_sphere
+restart data/prefs/ui_empty_shelves.json
+wait 0.2
+expect_value customize == 0
+expect_value shelf_shown_1 == 0 # the saved empty left shelf: hidden
+expect_value shelf_shown_2 == 1 # the right shelf: Wire and a separator
+expect "Wire##view.wire"
+remember canvas_width before
+shot loaded
+
+# Customize: the empty left shelf comes back (the canvas gives it room); empty the right shelf too.
+key f3
+type "##Command palette" "customize shelves"
+key enter
+expect_value customize == 1
+expect_value shelf_shown_1 == 1
+expect_value canvas_width < $before
+right_click "Wire##view.wire"
+click "Remove from shelf"
+expect_not "Wire##view.wire"
+expect_value shelf_shown_2 == 1 # still there while customizing (only a separator left)
+shot customizing
+
+# Customize off: both empty shelves go and the canvas is wider than with the right shelf.
+key f3
+type "##Command palette" "customize shelves"
+key enter
+expect_value customize == 0
+expect_value shelf_shown_1 == 0
+expect_value shelf_shown_2 == 0
+expect_value shelf_shown_0 == 1
+expect_value shelf_shown_3 == 1
+expect_value canvas_width > $before+40
+shot hidden
+
+# Back into Customize: the shelves return, ready for a drop.
+key f3
+type "##Command palette" "customize shelves"
+key enter
+expect_value shelf_shown_1 == 1
+expect_value shelf_shown_2 == 1
+expect_value canvas_width < $before