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.

Shelf: hide the Vertex / Texture paint target without a texture (contextual controls rule)

islandmed9af43637520a
diff --git a/docs/ui-design.md b/docs/ui-design.md
index 17174d69..eb8fa735 100644
--- a/docs/ui-design.md
+++ b/docs/ui-design.md
@@ -182,6 +182,7 @@ Row 1:
- `[Sculpt | Paint]` (`paintMode_`)
- `[Zadd | Zsub]` (`invertToggle_`)
- `[Rgb]` (`paintRgb_`)
+- `[Vertex | Texture]` paint target (`act:draw.paint_vertex`, `act:draw.paint_texture`; contextual: only when the SubTool has a texture)
- `Draw Size 60` slider (w 180; `radiusPx_`, `S`)
- `Strength 0.50` slider (w 180; `strength_`, `I`)
@@ -192,6 +193,11 @@ Row 2:
- `[Pressure>Str] [Pressure>Size]`
- right-aligned `5.1k / 10.2k` (ActivePoints / TotalPoints analogue: visible vs total tris)
+**Contextual controls.** A shelf button that only applies in some situations (the Vertex / Texture paint target
+needs a texture, Splats needs a capture) is *hidden* while it doesn't apply, rather than shown greyed out, so the
+shelves don't fill with dead buttons. Customize mode shows them all so they can be moved or removed. Palette
+entries stay visible and disabled (with the reason in Ctrl help), because palettes are where users look things up.
+
Sliders use the ZBrush style: the label sits inside the frame (`SliderFloat("##size", ..., "Draw Size %.0f")`), and the grab is a thin accent bar.
### 3.4 Left shelf (w 88)
diff --git a/src/app/App.h b/src/app/App.h
index 9e9316d6..7c33c476 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -552,6 +552,7 @@ private:
void drawPaletteBar(const ShellGeometry& g);
void drawShelf(int shelf, const CanvasRect& rect);
void drawShelfItem(int shelf, int index, const std::string& item, bool vertical);
+ bool shelfItemShown(const std::string& item) const;
void drawTray(bool right, const CanvasRect& rect);
void drawDivider(bool right, const CanvasRect& rect);
void drawPaletteDropdown();
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index 722d7ec6..33d98ecc 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -13,6 +13,7 @@
#include "app/Ui.h"
#include "core/Matcap.h"
#include "core/Polypaint.h"
+#include "core/Texture.h"
#include <IconsLucide.h>
#include <imgui_internal.h>
@@ -1078,15 +1079,16 @@ void App::drawShelf(int shelf, const CanvasRect& r) {
}
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(4.0f * s, 4.0f * s));
bool lineStart = true;
+ int prevShown = -1; // the last item drawn on this line (contextual items may be skipped)
for (int i = 0; i < int(list.size()); ++i) {
const std::string& item = list[size_t(i)];
if (item == "row") {
lineStart = true;
continue;
}
- if (item == "view.splats" && doc_.splats.empty()) continue; // only when there's a capture
- if (!vertical && !lineStart) {
- const std::string& prev = list[size_t(i - 1)];
+ if (!shelfItemShown(item)) continue;
+ if (!vertical && !lineStart && prevShown >= 0) {
+ const std::string& prev = list[size_t(prevShown)];
ImGui::SameLine(0.0f, prev == "sep" || item == "sep" ? 0.0f : segmentPair(prev, item) ? 1.0f * s : 4.0f * s);
}
if (!vertical && item == "widget.points") { // right-aligned readout
@@ -1094,6 +1096,7 @@ void App::drawShelf(int shelf, const CanvasRect& r) {
ImGui::SameLine(std::max(ImGui::GetCursorPosX(), ImGui::GetWindowContentRegionMax().x - w));
}
lineStart = false;
+ prevShown = i;
drawShelfItem(shelf, i, item, vertical);
rects.push_back(ImRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax()));
indices.push_back(i);
@@ -1154,6 +1157,15 @@ void App::drawShelf(int shelf, const CanvasRect& r) {
ImGui::End();
}
+// Contextual shelf items (docs/ui-design.md, "Contextual controls"): shown only when they apply, and always in
+// Customize mode so they can still be moved or removed.
+bool App::shelfItemShown(const std::string& item) const {
+ if (layout_.customize) return true;
+ if (item == "view.splats") return !doc_.splats.empty(); // only when there's a capture
+ if (item == "draw.paint_vertex" || item == "draw.paint_texture") return hasTexture(doc_.mesh); // paint target
+ return true;
+}
+
void App::drawShelfItem(int shelf, int index, const std::string& item, bool vertical) {
const float s = uiScale_;
const float winW = ImGui::GetWindowWidth();
@@ -1177,7 +1189,10 @@ void App::drawShelfItem(int shelf, int index, const std::string& item, bool vert
}
} else if (item == "widget.draw_size" || item == "widget.strength") {
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8.0f * s, (rowH - ImGui::GetFontSize()) * 0.5f));
- ImGui::SetNextItemWidth(180.0f * s);
+ // 180 px each, narrower when the row is full (e.g. with the contextual Vertex / Texture buttons at 1600 px).
+ const float avail = ImGui::GetContentRegionAvail().x - (item == "widget.draw_size" ? 4.0f * s : 0.0f);
+ ImGui::SetNextItemWidth(vertical ? 180.0f * s
+ : std::clamp(item == "widget.draw_size" ? avail * 0.5f : avail, 120.0f * s, 180.0f * s));
if (item == "widget.draw_size") {
ui::SliderInside("##drawsize", &radiusPx_, 2.0f, 800.0f, "Draw Size %.0f", ImGuiSliderFlags_Logarithmic);
ui::HelpText("Draw Size", "S", "Brush radius in screen pixels. [ and ] change it by 10%; Ctrl+click to type.", "Draw");
diff --git a/tests/ui/contextual_shelf.sfui b/tests/ui/contextual_shelf.sfui
new file mode 100644
index 00000000..40c33ea9
--- /dev/null
+++ b/tests/ui/contextual_shelf.sfui
@@ -0,0 +1,25 @@
+# Contextual shelf buttons (docs/ui-design.md, "Contextual controls"): the top shelf's Vertex / Texture paint
+# target only shows when the SubTool has a texture to paint into, instead of sitting there greyed out.
+run new_sphere subdivisions=3
+expect_value texture_size == 0
+expect "Rgb##draw.rgb"
+expect_not "Vertex##draw.paint_vertex"
+expect_not "Texture##draw.paint_texture"
+shot no-texture
+
+# Give it UVs and a texture: the paint target appears, set to Texture.
+run uv_auto
+run texture_create size=1024
+expect_value texture_size == 1024
+expect "Vertex##draw.paint_vertex"
+expect "Texture##draw.paint_texture"
+expect_value paint_texture == 1
+click "Vertex##draw.paint_vertex"
+expect_value paint_texture == 0
+shot with-texture
+
+# Undo back past the texture: the buttons go again.
+key ctrl+z
+key ctrl+z
+expect_value texture_size == 0
+expect_not "Vertex##draw.paint_vertex"