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.

UI polish for 0.10.9: brush previews, Library paths and close, shelf outline, x glyphs, macOS restore, notices

islandmedc73669c85311
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5607791..d3626811 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,24 @@ All notable changes to SculptForge are listed here. The format follows
## [Unreleased]
+### Fixed
+- Brush shelf previews: Tendril and Elastic Tendril pull a long horn out past the ball (Tendril's preview re-aimed
+ every dab at the ball and dropped the dabs past its edge; scripted Tendril strokes now drag in the view plane as
+ the viewport does), and Layer and Nudge draw clean shapes instead of a pinched plateau and a torn ridge. Previews
+ are re-rendered once (thumbnail version 4). A new test sculpts every built-in brush's preview and checks its shape.
+- Library > Projects listed each project twice on Windows: recent files and the User folder spelled the same path
+ with different slashes (#90). Paths are now compared normalised, and without case on Windows.
+- The Library's close button stays on screen on small displays (1280x720), and Esc closes the Library (#80).
+- The right shelf's region outline is no longer drawn under its buttons, and the "x" buttons (Library, console,
+ window, palettes) are centred (#98).
+- The "Strokes start off the model" chip over the 3D view no longer stays there for good: it shows for a few seconds
+ after the setting changes, and its x hides it until Preferences > Interface > Reset hidden notices (Discord).
+- macOS: a window closed in full screen reopens maximised instead of full screen, so the traffic lights and menu
+ bar stay reachable (#85, again after #41).
+
+### Added
+- Preferences > Interface > Show hints and notices (on by default) and Reset hidden notices.
+
## [0.10.8] - 2026-11-02
### Fixed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd947ce2..6a6f5774 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -282,6 +282,7 @@ if(SCULPTFORGE_BUILD_APP)
src/app/Console.cpp
src/app/Config.cpp
src/app/LightBox.cpp
+ src/app/BrushPreview.cpp
src/app/Thumbnails.cpp
src/app/Pickers.cpp
src/app/UserGuide.cpp
@@ -518,7 +519,7 @@ endif()
if(SCULPTFORGE_BUILD_TESTS)
# tests/test_main.cpp plus every tests/test_*.cpp (add a file to add tests; see tests/TestHarness.h).
file(GLOB SCULPTFORGE_TEST_SOURCES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_*.cpp)
- add_executable(sculptforge_tests ${SCULPTFORGE_TEST_SOURCES} src/cli/McpServer.cpp src/app/AssetLibrary.cpp
+ add_executable(sculptforge_tests ${SCULPTFORGE_TEST_SOURCES} src/cli/McpServer.cpp src/app/AssetLibrary.cpp src/app/BrushPreview.cpp
src/app/UiLayout.cpp src/app/ShellGeometry.cpp src/app/LookSchemes.cpp src/app/I18n.cpp src/app/I18nSpanish.cpp src/render/Camera.cpp
src/render/Clusters.cpp src/render/Ghost.cpp)
target_include_directories(sculptforge_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
@@ -644,6 +645,10 @@ if(SCULPTFORGE_BUILD_TESTS)
add_test(NAME ui_size_popup_scaled COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/size_popup.sfui
--size 2400x1350 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/size_popup_scaled)
set_tests_properties(ui_size_popup_scaled PROPERTIES LABELS ui TIMEOUT 300)
+ # The Library on a 1280x720 screen (#80): its close button stays on screen.
+ add_test(NAME ui_library_small_screen_720 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/library_small_screen.sfui
+ --size 1280x720 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/library_small_screen_720)
+ set_tests_properties(ui_library_small_screen_720 PROPERTIES LABELS ui TIMEOUT 300)
add_test(NAME ui_user_guide_1080 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/user_guide.sfui
--size 1920x1080 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/user_guide_1080)
set_tests_properties(ui_user_guide_1080 PROPERTIES LABELS ui TIMEOUT 300)
diff --git a/docs/guide/interface.md b/docs/guide/interface.md
index b2d5d8e9..92e0dd67 100644
--- a/docs/guide/interface.md
+++ b/docs/guide/interface.md
@@ -312,6 +312,8 @@ Working with the strip:
- Choose **1** to **4** rows of thumbnails.
- **Open folder...** adds a folder of your own to the root of every tab.
- On the Snapshots tab, **Save now** takes a snapshot.
+- The **x** at the right end of the header, or <kbd>Esc</kbd>, closes the Library (while you type in Filter,
+ <kbd>Esc</kbd> first leaves the field). The **x** stays on screen on small displays such as 1280x720.
- Right-click a tile for **Open**, **Append as Part**, the image actions, **Show in file manager** and
**Refresh thumbnail**.
@@ -524,10 +526,19 @@ choice for the next session, and each project keeps the background it was saved
![The Preferences palette with the Config and Interface sub-palettes](images/preferences.jpg)
+### Hints and notices
+
+A setting that changes how strokes start, such as **Start strokes off the model** (Preferences > Input), shows a
+small chip over the top of the 3D view for a few seconds when you turn it on. Click the chip (its **x**) to stop
+showing it for good. **Preferences > Interface > Show hints and notices** (on by default) turns every such notice
+off; **Reset hidden notices** shows the ones you hid again. Both are remembered without Store Config.
+
### Fullscreen, the palette bar and the camera notch
- <kbd>F11</kbd> (or **Render > Fullscreen**) fills the screen with SculptForge; press it again to go back to
- a window. `sculptforge --fullscreen` starts that way.
+ a window. `sculptforge --fullscreen` starts that way. SculptForge reopens the way you left it; on macOS a window
+ closed in full screen reopens maximised instead, so the menu bar and the window buttons stay reachable (press
+ <kbd>F11</kbd> or the green button to go full screen again).
- **Menus** in the title strip hides the palette bar; click it again to bring it back.
- <kbd>Tab</kbd> hides the shelves and trays.
- On MacBooks with a camera notch, SculptForge keeps the interface below the notch when it fills the screen
diff --git a/docs/guide/navigation.md b/docs/guide/navigation.md
index 2e6fc9f1..4de383be 100644
--- a/docs/guide/navigation.md
+++ b/docs/guide/navigation.md
@@ -62,7 +62,7 @@ they go the ZBrush way: drag up to zoom out, down to zoom in.
Quick Menu. With it on, <kbd>Space</kbd> no longer opens the Quick Menu (a right click still does), and a space typed in
a text field is never taken.
-**Start strokes off the model** is off by default. With it on (a label at the top of the canvas says so), a
+**Start strokes off the model** is off by default. With it on (a label at the top of the canvas says so for a few seconds; see [Hints and notices](interface.md#hints-and-notices)), a
left-drag on the background no longer rotates: it waits, and the brush starts where the cursor first reaches the
model, so strokes that begin at the silhouette never turn the view by accident. <kbd>Ctrl</kbd> (mask) and
<kbd>Shift</kbd> (smooth) strokes start the same way, and a <kbd>Ctrl</kbd>+click on the background still inverts
diff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.md
index d8920df6..8f2f2f26 100644
--- a/docs/guide/whats-new.md
+++ b/docs/guide/whats-new.md
@@ -5,6 +5,18 @@ chapter opens by itself the first time you start a new version; you can always f
**Help > What's New**. Every detail is in the
[changelog](https://github.com/islandmed/SculptForge/blob/main/CHANGELOG.md).
+## Version 0.10.9
+
+- **Brush previews fixed**: the shelf shows Tendril and Elastic Tendril as long horns pulled out past the ball, as
+ they behave in the viewport, and Layer and Nudge with clean shapes; previews are rebuilt once after updating.
+- **Library**: projects no longer show twice on Windows (#90); the close button stays on small screens and
+ <kbd>Esc</kbd> closes the Library (#80).
+- **Cleaner outlines**: the right shelf's outline draws correctly and the **x** buttons are centred (#98).
+- **Quieter notices**: **Strokes start off the model** shows its chip for a few seconds when you turn it on, then
+ it goes; click the chip's **x** to never see it again. **Preferences > Interface > Show hints and notices** turns
+ them all off, and **Reset hidden notices** brings them back.
+- **macOS**: a window closed in full screen reopens maximised, with the window buttons reachable (#85).
+
## Version 0.10.8
- **Tablets in mouse mode work again**: on some Windows tablets with **Mouse mode** on (Preferences > Tablet) the
diff --git a/src/app/App.cpp b/src/app/App.cpp
index 08c6194c..df0f5234 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -134,15 +134,11 @@ bool App::init(const AppOptions& options) {
}
if (rememberWindow_) { // #35: where and how big it was last time
if (saved.placed) SDL_SetWindowPosition(window_, saved.x, saved.y);
-#if defined(__APPLE__)
- // #41: full screen on macOS is its own Space, entered from a window already on screen and key; entered
- // here, before the first frame, the menu bar and traffic lights couldn't be revealed. The loop enters it
- // after the first swap instead.
- if (saved.fullscreen) fullscreenAfterFirstFrame_ = true;
-#else
- if (saved.fullscreen) SDL_SetWindowFullscreen(window_, true);
-#endif
- else if (saved.maximized) SDL_MaximizeWindow(window_);
+ if (restoresFullscreen(saved.fullscreen)) SDL_SetWindowFullscreen(window_, true);
+ // #41, #85: on macOS full screen is a Space of its own; entered at start-up (before the first frame, or right
+ // after it) the menu bar and traffic lights couldn't be revealed. A window that was full screen comes back
+ // filling the screen as a maximised window instead (the green button, or F11, takes it full screen again).
+ else if (saved.maximized || saved.fullscreen) SDL_MaximizeWindow(window_);
}
{
Image icon;
@@ -1072,11 +1068,6 @@ int App::run() {
hardwareProfileFrameEnd();
if (proof_) proofBeforeSwap(fbW, fbH); // Help > Benchmark: timing, video capture, the scripted pointer
SDL_GL_SwapWindow(window_);
- if (fullscreenAfterFirstFrame_) { // (#41, macOS: the window is shown now; raise it, then full screen)
- fullscreenAfterFirstFrame_ = false;
- SDL_RaiseWindow(window_);
- SDL_SetWindowFullscreen(window_, true);
- }
mark();
if (phases == 7 && phase[6] - phase[0] > frameLogMs)
SDL_Log("frame %.1f ms: events %.1f, dabs %.1f, UI %.1f, ghost + sync %.1f, draw %.1f, UI draw + swap %.1f",
diff --git a/src/app/App.h b/src/app/App.h
index 34fbdfa2..63459457 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -158,6 +158,24 @@ private:
void airStrokeTo(float x, float y);
void airStrokeRelease();
void drawAirStrokeIndicator();
+ // Notices (Preferences > Interface > Show hints and notices): a mode chip shows for a few seconds when its
+ // setting changes, never for good; its x (a click on it) hides it until Reset hidden notices.
+public:
+ bool noticeShown(const std::string& id) const; // notices are on and `id` isn't hidden
+ void hideNotice(const std::string& id);
+ void resetHiddenNotices();
+ void setShowNotices(bool on);
+private:
+ struct ModeChip {
+ bool seen = false, last = false; // the setting's value last frame (none before the first)
+ double until = 0.0; // seconds (ImGui::GetTime): shown until then
+ };
+ static constexpr double kModeChipSeconds = 4.0;
+ // A chip over the top of the 3D view while `on` changed less than kModeChipSeconds ago; `id` names it for
+ // hideNotice. Returns whether it is shown this frame (UI tests read it).
+ bool drawModeChip(const char* id, bool on, const char* text, ModeChip& chip, float y);
+ ModeChip airStrokeChip_;
+ bool airStrokeChipShown_ = false;
bool airMask_ = false; // the waiting stroke masks (Ctrl held at the press)
bool airMoved_ = false; // it moved past the click slop (a Ctrl+click still inverts the mask)
float airX_ = 0.0f, airY_ = 0.0f; // where it was pressed
@@ -1342,7 +1360,6 @@ private:
static WindowState loadWindowState();
void saveWindowState() const;
bool rememberWindow_ = false;
- bool fullscreenAfterFirstFrame_ = false; // macOS: the saved full screen, entered once the window is on screen (#41)
void drawAxisGizmo();
std::array<AxisGizmoEnd, 6> axisGizmoLayout() const; // the gizmo's ends on screen now (AxisGizmo.h)
bool axisGizmoMouseDown(float x, float y); // a click on an end: that side view (#43)
diff --git a/src/app/AssetLibrary.cpp b/src/app/AssetLibrary.cpp
index 75eba2df..7006dfdd 100644
--- a/src/app/AssetLibrary.cpp
+++ b/src/app/AssetLibrary.cpp
@@ -111,6 +111,26 @@ bool isImageFile(const std::string& path) {
bool isBrushFile(const std::string& path) { return lowerExt(path) == ".sfbrush"; }
bool isProjectFile(const std::string& path) { return lowerExt(path) == ".sfproj"; }
+std::string pathKey(const std::string& path, bool windowsRules) {
+ std::string s = path;
+ if (windowsRules) std::replace(s.begin(), s.end(), '\\', '/');
+ const std::u8string g = fsPath(s).lexically_normal().generic_u8string();
+ s.assign(g.begin(), g.end());
+ if (windowsRules) {
+ std::replace(s.begin(), s.end(), '\\', '/');
+ for (char& c : s) c = char(std::tolower(static_cast<unsigned char>(c)));
+ }
+ std::string out; // doubled separators once, no trailing one (but keep a root "/")
+ for (char c : s)
+ if (c != '/' || out.empty() || out.back() != '/') out += c;
+ while (out.size() > 1 && out.back() == '/') out.pop_back();
+ return out;
+}
+
+bool samePath(const std::string& a, const std::string& b, bool windowsRules) {
+ return a == b || pathKey(a, windowsRules) == pathKey(b, windowsRules);
+}
+
AssetKind fileKindForTab(LibraryTab tab, const std::string& path) {
switch (tab) {
case LibraryTab::Project:
diff --git a/src/app/AssetLibrary.h b/src/app/AssetLibrary.h
index ee2e014a..eba21d52 100644
--- a/src/app/AssetLibrary.h
+++ b/src/app/AssetLibrary.h
@@ -79,6 +79,16 @@ bool ensureUserLibrary(const std::string& root, std::string& error);
// newest first. Hidden files (".x") are skipped. Never throws.
std::vector<AssetEntry> listFolder(const std::string& dir, const std::function<AssetKind(const std::string&)>& accept,
bool newestFirst = false);
+// Whether two paths name the same file (#90: the User folder is joined with "/", recent files are native "\\" on
+// Windows): "." and ".." resolved, doubled and trailing separators dropped; with Windows rules (the default there)
+// "\\" equals "/" and letters compare case-insensitively. Lexical only (no disk access): the Library calls it every frame.
+#if defined(_WIN32)
+constexpr bool kWindowsPaths = true;
+#else
+constexpr bool kWindowsPaths = false;
+#endif
+std::string pathKey(const std::string& path, bool windowsRules = kWindowsPaths);
+bool samePath(const std::string& a, const std::string& b, bool windowsRules = kWindowsPaths);
// Seconds since the epoch of the last change of `path` (0 if missing).
int64_t modifiedTime(const std::string& path);
@@ -113,7 +123,7 @@ private:
// --- Thumbnail cache keys (spec: fnv1a64(kind|absPath|size|mtime|version)) ---
-constexpr int kThumbnailVersion = 3; // bump when thumbnails are rendered differently
+constexpr int kThumbnailVersion = 4; // bump when thumbnails are rendered differently
uint64_t fnv1a64(std::string_view data, uint64_t seed = 0xcbf29ce484222325ull);
std::string hex64(uint64_t v); // 16 lower-case hex digits
// Key of a file's thumbnail: changes when the file is rewritten (size or time) or the renderer changes.
diff --git a/src/app/BrushPreview.cpp b/src/app/BrushPreview.cpp
new file mode 100644
index 00000000..c4d82f8f
--- /dev/null
+++ b/src/app/BrushPreview.cpp
@@ -0,0 +1,213 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "app/BrushPreview.h"
+
+#include "app/AssetLibrary.h"
+#include "core/Document.h"
+#include "core/PathStroke.h"
+#include "core/Primitives.h"
+#include "core/Sculpt.h"
+
+#include <algorithm>
+#include <cmath>
+
+namespace sf {
+
+std::unique_ptr<Mesh> sceneMesh(Document& doc) {
+ auto out = std::make_unique<Mesh>();
+ bool colors = false;
+ for (int i = 0; i < doc.subtoolCount(); ++i)
+ colors |= doc.subtools[size_t(i)].visible &&
+ doc.subtoolMesh(i).colors.size() == doc.subtoolMesh(i).positions.size() &&
+ !doc.subtoolMesh(i).colors.empty();
+ for (int i = 0; i < doc.subtoolCount(); ++i) {
+ if (!doc.subtools[size_t(i)].visible) continue;
+ const Mesh& m = doc.subtoolMesh(i);
+ const uint32_t base = uint32_t(out->positions.size());
+ out->positions.insert(out->positions.end(), m.positions.begin(), m.positions.end());
+ if (colors) {
+ if (m.colors.size() == m.positions.size())
+ out->colors.insert(out->colors.end(), m.colors.begin(), m.colors.end());
+ else
+ out->colors.insert(out->colors.end(), m.positions.size(), glm::vec3(1.0f));
+ }
+ const bool hidden = m.hidden.size() == m.triangles.size();
+ for (size_t t = 0; t < m.triangles.size(); ++t)
+ if (!hidden || !m.hidden[t]) out->triangles.push_back(m.triangles[t] + glm::uvec3(base));
+ }
+ if (out->triangles.empty()) return nullptr;
+ out->rebuildTopology();
+ out->recomputeAllNormals();
+ return out;
+}
+
+
+namespace {
+
+// An S across the front of the ball, as stroke points in front of it (strokes look along -z).
+std::vector<glm::vec3> frontCurve(float width = 1.0f) {
+ std::vector<glm::vec3> pts;
+ for (int i = 0; i <= 8; ++i) {
+ const float u = float(i) / 8.0f;
+ pts.emplace_back((-0.56f + 1.12f * u) * width, 0.24f * std::sin(u * 6.2831853f), 2.0f);
+ }
+ return pts;
+}
+std::vector<glm::vec3> line(glm::vec3 a, glm::vec3 b) { return {a, b}; }
+// Points on a circle of radius `r` around (cx, cy) on the front of the ball, from angle a0 to a1 (radians).
+std::vector<glm::vec3> arc(float cx, float cy, float r, float a0, float a1, int n = 24) {
+ std::vector<glm::vec3> pts;
+ for (int i = 0; i <= n; ++i) {
+ const float a = a0 + (a1 - a0) * float(i) / float(n);
+ pts.emplace_back(cx + r * std::cos(a), cy + r * std::sin(a), 2.0f);
+ }
+ return pts;
+}
+
+void stroke(Document& d, const BrushRecipe* recipe, BrushType type, std::vector<glm::vec3> pts, float radius,
+ float strength, bool curve = true) {
+ PathStroke st;
+ st.points = std::move(pts);
+ st.view = glm::vec3(0.0f, 0.0f, -1.0f);
+ st.radius = radius;
+ st.strength = strength;
+ st.curve = curve;
+ std::string err;
+ strokePath(d, recipe, type, st, err);
+}
+
+} // namespace
+
+// Sculpts the preview of a brush (a recipe when given, else `type`) with the same code real strokes use,
+// on the shared ball (see kBallRadius).
+std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type) {
+ if (type == kPaintBrush) {
+ // Polypaint: a coloured S on the ball; white elsewhere, so the material shows as on the others.
+ Mesh m = makeIcosphere(kBallDetail, kBallRadius);
+ m.ensureColors(glm::vec3(1.0f));
+ for (uint32_t v = 0; v < m.vertexCount(); ++v) {
+ const glm::vec3 p = m.positions[v];
+ const float curve = 0.24f * std::sin((p.x / 0.56f + 1.0f) * 3.14159265f);
+ const float d2 = std::abs(p.y - curve);
+ if (p.z > 0.0f && std::abs(p.x) < 0.6f && d2 < 0.12f) {
+ const float t = std::clamp((0.12f - d2) / 0.04f, 0.0f, 1.0f);
+ m.colors[v] = glm::mix(m.colors[v], glm::vec3(0.78f, 0.16f, 0.06f), t);
+ }
+ }
+ return std::make_unique<Mesh>(std::move(m));
+ }
+ Document d;
+ d.setMesh(makeIcosphere(kBallDetail, kBallRadius));
+ const float r = 0.17f;
+ if (recipe) {
+ stroke(d, recipe, BrushType::Standard, frontCurve(), r, 0.9f);
+ return sceneMesh(d);
+ }
+ // Each brush gets a mark of its own shape that shows what it does, so the shelf tells them apart at a glance
+ // (the same S everywhere left only a few pixels of difference between Standard, Clay, Inflate and Pinch).
+ constexpr float kPi = 3.14159265f;
+ const auto bt = BrushType(type);
+ switch (bt) {
+ case BrushType::Clay: // three parallel strips laid on like clay
+ for (int i = -1; i <= 1; ++i) {
+ const float dx = 0.3f * float(i);
+ stroke(d, nullptr, bt, line({dx - 0.28f, -0.42f, 2.0f}, {dx + 0.12f, 0.42f, 2.0f}), 0.15f, 1.0f, false);
+ }
+ break;
+ case BrushType::ClayBuildup: // a hash of square, flat-topped bars, built up in two directions
+ for (float o : {-0.2f, 0.2f}) {
+ stroke(d, nullptr, bt, line({-0.5f, o, 2.0f}, {0.5f, o, 2.0f}), 0.13f, 0.1f, false);
+ stroke(d, nullptr, bt, line({o, -0.5f, 2.0f}, {o, 0.5f, 2.0f}), 0.13f, 0.1f, false);
+ }
+ break;
+ case BrushType::DamStandard: // one deep, sharp diagonal cut
+ stroke(d, nullptr, bt, line({-0.55f, 0.45f, 2.0f}, {0.55f, -0.45f, 2.0f}), 0.2f, 1.0f, false);
+ stroke(d, nullptr, bt, line({-0.55f, 0.45f, 2.0f}, {0.55f, -0.45f, 2.0f}), 0.2f, 1.0f, false);
+ break;
+ case BrushType::Crease: // a curved groove, like a smile line
+ stroke(d, nullptr, bt, arc(0.0f, 0.42f, 0.62f, kPi * 1.18f, kPi * 1.82f), 0.17f, 1.0f);
+ stroke(d, nullptr, bt, arc(0.0f, 0.42f, 0.62f, kPi * 1.18f, kPi * 1.82f), 0.17f, 1.0f);
+ break;
+ case BrushType::Move: // the silhouette pulled out into a broad soft lobe on the upper left
+ stroke(d, nullptr, bt, line({-0.5f, 0.45f, 2.0f}, {-0.78f, 0.72f, 2.0f}), 0.5f, 1.0f, false);
+ break;
+ case BrushType::SnakeHook:
+ // A curling horn pulled out of the front into the tile's top right corner (the only room past the ball's
+ // silhouette; the ball fills the tile's height). It drags in the view plane, as in the viewport.
+ stroke(d, nullptr, bt, line({0.3f, 0.3f, 2.0f}, {0.86f, 0.86f, 2.0f}), 0.26f, 1.0f, false);
+ break;
+ case BrushType::Inflate: // a ring, puffed up
+ stroke(d, nullptr, bt, arc(0.0f, 0.0f, 0.38f, 0.0f, 2.0f * kPi, 32), 0.2f, 1.0f);
+ break;
+ case BrushType::Pinch: // a raised chevron pinched to a sharp crest
+ stroke(d, nullptr, BrushType::Standard, {{-0.5f, 0.35f, 2.0f}, {0.0f, -0.3f, 2.0f}, {0.5f, 0.35f, 2.0f}}, 0.22f, 1.0f, false);
+ for (int pass = 0; pass < 2; ++pass)
+ stroke(d, nullptr, bt, {{-0.5f, 0.35f, 2.0f}, {0.0f, -0.3f, 2.0f}, {0.5f, 0.35f, 2.0f}}, 0.22f, 1.0f, false);
+ break;
+ case BrushType::Smooth: { // a bumpy ridge, its right half smoothed away
+ for (int i = 0; i < 7; ++i)
+ for (int pass = 0; pass < 4; ++pass)
+ stroke(d, nullptr, BrushType::Standard, {glm::vec3(-0.6f + 0.2f * float(i), 0.0f, 2.0f)}, 0.13f, 1.0f, false);
+ for (int pass = 0; pass < 3; ++pass)
+ stroke(d, nullptr, bt, line({0.12f, 0.0f, 2.0f}, {0.8f, 0.0f, 2.0f}), 0.26f, 1.0f, false);
+ break;
+ }
+ case BrushType::Flatten: // a dome with a flat facet planed across its top
+ for (int pass = 0; pass < 3; ++pass)
+ stroke(d, nullptr, BrushType::Standard, {glm::vec3(0.0f, 0.0f, 2.0f)}, 0.5f, 1.0f, false);
+ for (int pass = 0; pass < 3; ++pass)
+ stroke(d, nullptr, bt, line({-0.15f, 0.05f, 2.0f}, {0.15f, -0.05f, 2.0f}), 0.32f, 1.0f, false);
+ break;
+ case BrushType::Trim: { // a ridge cut down to hard planes along its length
+ const auto ridge = line({-0.6f, -0.35f, 2.0f}, {0.6f, 0.35f, 2.0f});
+ stroke(d, nullptr, BrushType::Standard, ridge, 0.24f, 1.0f, false);
+ stroke(d, nullptr, BrushType::Clay, ridge, 0.24f, 1.0f, false);
+ stroke(d, nullptr, bt, line({-0.3f, -0.17f, 2.0f}, {0.3f, 0.17f, 2.0f}), 0.24f, 1.0f, false);
+ break;
+ }
+ case BrushType::Nudge: { // an upright ridge slid sideways in the middle (broad and gentle: a narrow, strong
+ // nudge across a sharp ridge tore it)
+ const auto ridge = line({-0.1f, -0.6f, 2.0f}, {-0.1f, 0.6f, 2.0f});
+ stroke(d, nullptr, BrushType::Standard, ridge, 0.22f, 1.0f, false);
+ stroke(d, nullptr, bt, line({-0.15f, 0.0f, 2.0f}, {0.15f, 0.0f, 2.0f}), 0.36f, 0.3f, false);
+ break;
+ }
+ case BrushType::Layer: // a ring raised to one flat height per stroke; two strokes, two steps (a square path's
+ // corners were dabbed twice and pinched)
+ for (int pass = 0; pass < 2; ++pass)
+ stroke(d, nullptr, bt, arc(0.0f, 0.0f, 0.36f, 0.0f, 2.0f * kPi, 48), 0.24f, 1.0f);
+ break;
+ case BrushType::Vdm: // one stamp of the built-in Horn
+ stroke(d, nullptr, bt, {glm::vec3(0.0f, -0.05f, 2.0f)}, 0.45f, 0.5f, false);
+ break;
+ case BrushType::KelvinGrab: // the silhouette pulled out into a smooth, bulging lobe
+ d.sculptor.kelvinlet.squash = 1.0f;
+ stroke(d, nullptr, bt, line({-0.45f, 0.45f, 2.0f}, {-0.8f, 0.8f, 2.0f}), 0.45f, 0.5f, false);
+ break;
+ case BrushType::KelvinTwist: // a raised bar twisted into an S
+ stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
+ stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
+ stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {0.45f, 0.0f, 2.0f}), 0.45f, 0.5f, false);
+ break;
+ case BrushType::KelvinScale: // a ring of bumps pinched toward the middle
+ for (int i = 0; i < 6; ++i) {
+ const float a = float(i) * kPi / 3.0f;
+ for (int pass = 0; pass < 3; ++pass)
+ stroke(d, nullptr, BrushType::Standard, {glm::vec3(0.4f * std::cos(a), 0.4f * std::sin(a), 2.0f)}, 0.12f, 1.0f, false);
+ }
+ stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {-0.5f, 0.0f, 2.0f}), 0.4f, 0.5f, false);
+ break;
+ case BrushType::KelvinSnake: // a smooth tapering horn pulled out past the silhouette, into the bottom right corner
+ stroke(d, nullptr, bt, line({0.25f, -0.2f, 2.0f}, {0.88f, -0.84f, 2.0f}), 0.26f, 0.7f, false);
+ break;
+ case BrushType::DetailClone: // a row of horns along a curve
+ stroke(d, nullptr, bt, arc(0.0f, -0.25f, 0.55f, kPi * 0.15f, kPi * 0.85f), 0.12f, 0.5f);
+ break;
+ default: // Standard: a soft rounded S
+ stroke(d, nullptr, bt, frontCurve(1.15f), 0.19f, 1.0f);
+ break;
+ }
+ return sceneMesh(d);
+}
+
+} // namespace sf
diff --git a/src/app/BrushPreview.h b/src/app/BrushPreview.h
new file mode 100644
index 00000000..7d59deeb
--- /dev/null
+++ b/src/app/BrushPreview.h
@@ -0,0 +1,30 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// The brush previews' sculpting (no GL): every built-in brush and recipe leaves its mark on the same clay ball with
+// the code real strokes use (strokePath). ThumbnailCache renders the result; tests/test_brush_previews.cpp checks
+// the shapes.
+#pragma once
+
+#include "core/BrushRecipe.h"
+#include "core/Mesh.h"
+
+#include <memory>
+
+namespace sf {
+
+class Document;
+
+// Every brush preview is the same clay ball, sculpted on its front and shot from the same camera with the
+// same material, so the shelf and the pickers read as one icon set.
+constexpr float kBallRadius = 0.9f;
+constexpr int kBallDetail = 6; // ~82k triangles: fine enough for crisp strokes at preview size
+
+// One mesh of every visible Part of `doc` (positions, triangles and vertex paint), for a preview; null when empty.
+std::unique_ptr<Mesh> sceneMesh(Document& doc);
+
+// The preview of a brush: a recipe when given, else the built-in `type` (a BrushType, or kPaintBrush). Strokes look
+// along -z at the front of the ball.
+std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type);
+
+} // namespace sf
diff --git a/src/app/Config.cpp b/src/app/Config.cpp
index 7174c9cf..447cdec1 100644
--- a/src/app/Config.cpp
+++ b/src/app/Config.cpp
@@ -1163,6 +1163,17 @@ void drawInterfaceSection(App& app) {
ui::HelpText("Tooltip delay", nullptr,
"How long to point at an icon-only button (or a clipped label) before its name appears.",
"Preferences > Interface");
+ // Notices: mode chips over the 3D view and the like (Discord 11-02: "I don't need to see it there forever").
+ bool notices = p.showNotices;
+ if (ui::Checkbox(tr("Show hints and notices"), &notices)) app.setShowNotices(notices);
+ ui::HelpText("Show hints and notices", nullptr,
+ "Short notices over the 3D view, such as \"Strokes start off the model\" for a few seconds after you turn "
+ "that on. Off: none show. A notice's x hides just that one.",
+ "Preferences > Interface");
+ ImGui::BeginDisabled(p.hiddenNotices.empty());
+ if (ImGui::Button(tr("Reset hidden notices"), ImVec2(-FLT_MIN, 0))) app.resetHiddenNotices();
+ ImGui::EndDisabled();
+ ui::HelpText("Reset hidden notices", nullptr, "Shows again the notices you hid with their x.", "Preferences > Interface");
ImGui::Checkbox(tr("One sub-palette open"), &p.oneSubpalette);
ui::HelpText("One sub-palette open", nullptr,
"Opening a sub-palette closes the others in that palette. Shift+click opens more than one.",
diff --git a/src/app/Config.h b/src/app/Config.h
index 72e0a278..70b75013 100644
--- a/src/app/Config.h
+++ b/src/app/Config.h
@@ -14,6 +14,7 @@
#include "core/Tablet.h"
#include <string>
+#include <vector>
namespace sf {
@@ -54,6 +55,11 @@ struct UiPrefs {
float dyntopoSmoothRemesh = 1.0f;
bool airStrokes = false; // start strokes off the model (#62): a left-drag on the background sculpts once it
// reaches the surface instead of turning the view (off: it turns the view, ZBrush)
+ // Preferences > Interface > Show hints and notices: mode chips over the 3D view (Strokes start off the model...)
+ // and other notices that would show every time. Off hides them all; a notice's own x hides just that one
+ // (`hiddenNotices`, App::hideNotice), until Reset hidden notices. Both are kept in project.json (no Store Config).
+ bool showNotices = true;
+ std::vector<std::string> hiddenNotices;
bool showAxes = true; // Draw > Camera > Axes: the X / Y / Z gizmo in the canvas corner (#31)
bool cursorFollowsSurface = true; // the brush ring lies on the surface under the pointer, as in SculptGL (#25)
// Preferences > Interface > Timeline position (#63): the Sculpt Timeline strip along the top of the viewport
diff --git a/src/app/Console.cpp b/src/app/Console.cpp
index 8dc92b31..00025f4c 100644
--- a/src/app/Console.cpp
+++ b/src/app/Console.cpp
@@ -407,7 +407,7 @@ void Console::draw(App& app, const CanvasRect& rect) {
x += bs + gap;
}
ImGui::SetCursorScreenPos(ImVec2(x, y));
- if (ImGui::Button(ICON_LC_X "###console_close", ImVec2(bs, bs))) closeRequested_ = true;
+ if (ui::GlyphButton("###console_close", ICON_LC_X, ImVec2(bs, bs))) closeRequested_ = true;
const std::string key = app.actions_.shortcutText("ui.console");
ui::HelpText("Close the console", key.c_str(), "Hide the console. The log and the session script are kept.", "Script");
ui::DelayedTooltip(("Close " + key).c_str());
diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cpp
index 64f74029..a134ba2d 100644
--- a/src/app/I18nSpanish.cpp
+++ b/src/app/I18nSpanish.cpp
@@ -55,6 +55,8 @@ constexpr Entry kSpanish[] = {
{"Green", "Verde"},
{"Amber", "Ámbar"},
{"Scanlines & glow", "Líneas de barrido y brillo"},
+ {"Show hints and notices", "Mostrar avisos y consejos"},
+ {"Reset hidden notices", "Restablecer avisos ocultos"},
{"ZBrush-style", "Estilo ZBrush"},
{"AI brush provider", "Proveedor del pincel IA"},
{"Autosave", "Autoguardado"},
diff --git a/src/app/Input.cpp b/src/app/Input.cpp
index 2ab4aec6..985ebecd 100644
--- a/src/app/Input.cpp
+++ b/src/app/Input.cpp
@@ -708,16 +708,80 @@ void App::airStrokeRelease() {
}
void App::drawAirStrokeIndicator() {
- if (!uiPrefs_.airStrokes) return;
+ // (ThinkingPolygons, Discord 11-02: on for good, the chip shouldn't stay on screen for good.)
+ airStrokeChipShown_ = drawModeChip("air_strokes", uiPrefs_.airStrokes, tr("Strokes start off the model"), airStrokeChip_,
+ timelineTopInset_ + 10.0f * uiScale_); // (below a top timeline)
+}
+
+bool App::noticeShown(const std::string& id) const {
+ return uiPrefs_.showNotices &&
+ std::find(uiPrefs_.hiddenNotices.begin(), uiPrefs_.hiddenNotices.end(), id) == uiPrefs_.hiddenNotices.end();
+}
+
+void App::hideNotice(const std::string& id) {
+ if (std::find(uiPrefs_.hiddenNotices.begin(), uiPrefs_.hiddenNotices.end(), id) == uiPrefs_.hiddenNotices.end())
+ uiPrefs_.hiddenNotices.push_back(id);
+ saveProjectPrefs();
+}
+
+void App::setShowNotices(bool on) {
+ uiPrefs_.showNotices = on;
+ saveProjectPrefs();
+}
+
+void App::resetHiddenNotices() {
+ uiPrefs_.hiddenNotices.clear();
+ saveProjectPrefs();
+}
+
+bool App::drawModeChip(const char* id, bool on, const char* text, ModeChip& chip, float y) {
+ const double now = ImGui::GetTime(); // (the UI's clock, which UI tests step)
+ if (chip.seen && on != chip.last) {
+ chip.until = on ? now + kModeChipSeconds : 0.0;
+ if (on) // keep drawing through the fade (the redraw loop's clock is SDL's)
+ activeUntil_ = std::max(activeUntil_, double(SDL_GetTicksNS()) * 1e-9 + kModeChipSeconds + 0.1);
+ }
+ chip.seen = true;
+ chip.last = on;
+ if (!on || now >= chip.until || !noticeShown(id)) return false;
+ // Fades out over its last half second.
+ const float alpha = float(std::clamp((chip.until - now) / 0.5, 0.0, 1.0));
const CanvasRect c = canvasRect();
- const char* text = tr("Strokes start off the model");
- const ImVec2 size = ImGui::CalcTextSize(text);
- const float pad = 6.0f * uiScale_;
- const ImVec2 at(c.x + (c.w - size.x) * 0.5f, c.y + timelineTopInset_ + 10.0f * uiScale_); // (below a top timeline)
- ImDrawList* dl = ImGui::GetForegroundDrawList();
- dl->AddRectFilled(ImVec2(at.x - pad, at.y - pad * 0.5f), ImVec2(at.x + size.x + pad, at.y + size.y + pad * 0.5f),
- IM_COL32(0, 0, 0, 110), 4.0f * uiScale_);
- dl->AddText(at, theme::u32(theme::accent), text);
+ const float s = uiScale_, pad = 6.0f * s;
+ const char* close = ICON_LC_X;
+ const ImVec2 size = ImGui::CalcTextSize(text), xs = ImGui::CalcTextSize(close);
+ const ImVec2 box(size.x + xs.x + 3.0f * pad, size.y + pad);
+ const ImVec2 at(std::floor(c.x + (c.w - box.x) * 0.5f), std::floor(c.y + y - pad * 0.5f));
+ // A small window of its own, so a click on it is the chip's and never starts a stroke.
+ ImGui::SetNextWindowPos(at);
+ ImGui::SetNextWindowSize(box);
+ ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
+ ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
+ ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(1, 1));
+ const std::string name = std::string("##modechip.") + id;
+ bool hidden = false;
+ if (ImGui::Begin(name.c_str(), nullptr,
+ ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoSavedSettings |
+ ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove)) {
+ ImGui::BringWindowToDisplayFront(ImGui::GetCurrentWindow()); // over a palette window under it, as drawn
+ hidden = ImGui::InvisibleButton((std::string("##hide_notice.") + id).c_str(), box);
+ const bool hovered = ImGui::IsItemHovered();
+ ImDrawList* dl = ImGui::GetWindowDrawList();
+ dl->AddRectFilled(at, ImVec2(at.x + box.x, at.y + box.y), IM_COL32(0, 0, 0, int(110 * alpha)), 4.0f * s);
+ dl->AddText(ImVec2(at.x + pad, at.y + pad * 0.5f), theme::u32(theme::accent, alpha), text);
+ ui::CentredGlyph(dl, nullptr, ImVec2(at.x + box.x - xs.x - 1.5f * pad, at.y), ImVec2(at.x + box.x - 0.5f * pad, at.y + box.y),
+ theme::u32(hovered ? theme::text : theme::textDim, alpha), close);
+ ui::DelayedTooltip("Don't show this again (Preferences > Interface > Reset hidden notices brings it back)");
+ ImGui::LogText("%s", text);
+ }
+ ImGui::End();
+ ImGui::PopStyleVar(3);
+ if (hidden) {
+ hideNotice(id);
+ status_ = std::string(text) + ": notice hidden (Preferences > Interface > Reset hidden notices)";
+ return false;
+ }
+ return true;
}
} // namespace sf
diff --git a/src/app/LightBox.cpp b/src/app/LightBox.cpp
index 0f234bba..50d7397d 100644
--- a/src/app/LightBox.cpp
+++ b/src/app/LightBox.cpp
@@ -186,7 +186,7 @@ void LightBox::rootEntries(App& app, std::vector<AssetEntry>& out) {
std::vector<AssetEntry> files = scan(userDir, true);
for (const std::string& p : app.recentFiles_)
if (isProjectFile(p) &&
- std::none_of(files.begin(), files.end(), [&](const AssetEntry& e) { return e.path == p; })) {
+ std::none_of(files.begin(), files.end(), [&](const AssetEntry& e) { return samePath(e.path, p); })) {
AssetEntry e;
e.kind = AssetKind::Project;
e.name = utf8(fsPath(p).stem());
@@ -651,14 +651,18 @@ void LightBox::drawHeader(App& app, float width) {
buttonW(ICON_LC_SMARTPHONE) + 8.0f * scale;
const float feedbackW =
buttonW(compactFeedback ? ICON_LC_MESSAGE_SQUARE_PLUS : ICON_LC_MESSAGE_SQUARE_PLUS " Fixes & suggestions");
- return saveW + filterW + rowsW + folderW + feedbackW + closeW + 4 * 8.0f * scale;
+ return saveW + filterW + rowsW + folderW + feedbackW + 4 * 8.0f * scale;
};
- const float room = right - leftEnd - 8.0f;
+ // The close button is pinned to the right edge (#80: on a 720p screen the group ran past it and hid it); the
+ // rest gets what is left between the tabs and it, clipped if even the compact group doesn't fit.
+ const float groupRight = right - closeW - 8.0f * scale;
+ const float room = groupRight - leftEnd - 8.0f;
if (room < groupW()) compact = true;
// A shorter filter before an icon-only "Fixes & suggestions" (it is the startup screen's way to reach us).
if (room < groupW() && filterW - (groupW() - room) < 70.0f * scale) compactFeedback = true;
if (room < groupW()) filterW = std::max(70.0f * scale, filterW - (groupW() - room));
- ImGui::SetCursorScreenPos(ImVec2(std::max(leftEnd + 8.0f, right - groupW()), origin.y));
+ ImGui::SetCursorScreenPos(ImVec2(std::max(leftEnd + 8.0f, groupRight - groupW()), origin.y));
+ ImGui::PushClipRect(ImVec2(leftEnd, origin.y), ImVec2(groupRight, origin.y + kHeader * scale), true);
if (quickTab) {
if (ImGui::Button(compact ? ICON_LC_SAVE "###QuickSave now" : ICON_LC_SAVE " Save now###QuickSave now"))
app.quickSave();
@@ -698,9 +702,11 @@ void LightBox::drawHeader(App& app, float width) {
"https://github.com/islandmed/SculptForge/issues/new/choose";
}
ui::HelpAction(app, "help.feedback");
- ImGui::SameLine(0, 8 * scale);
- if (ImGui::Button(ICON_LC_X "##lbclose", ImVec2(closeW, 0))) open_ = false;
- ui::HelpText("Close Library", ",", "Hide the Library (comma toggles it).", "Library");
+ ImGui::PopClipRect();
+ ImGui::SameLine();
+ ImGui::SetCursorScreenPos(ImVec2(right - closeW, origin.y));
+ if (ui::GlyphButton("##lbclose", ICON_LC_X, ImVec2(closeW, closeW))) open_ = false;
+ ui::HelpText("Close Library", ",", "Hide the Library (comma toggles it; Esc closes it).", "Library");
const float y = origin.y + kHeader * scale - 2.0f;
dl->AddLine(ImVec2(origin.x - 8, y), ImVec2(right + 8, y), kHeaderLine, 1.0f);
@@ -731,6 +737,10 @@ void LightBox::draw(App& app, const CanvasRect& canvas) {
layout.lightboxTab = libraryTabId(place_.tab);
layout.lightboxRows = std::clamp(layout.lightboxRows, 1, 4);
app.libraryScanner_.poll(ImGui::GetTime());
+ // Esc closes the Library (#80), unless a picker, a pop-up or a text field has the keys (they take Esc first).
+ if (open_ && ImGui::IsKeyPressed(ImGuiKey_Escape, false) && !ImGui::GetIO().WantCaptureKeyboard &&
+ !ImGui::IsAnyItemActive() && !ImGui::IsPopupOpen("", ImGuiPopupFlags_AnyPopupId | ImGuiPopupFlags_AnyPopupLevel))
+ open_ = false;
if (!open_) {
pressing_ = tileDrag_ = false;
return;
diff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cpp
index d3df4918..42a5418f 100644
--- a/src/app/PanelProject.cpp
+++ b/src/app/PanelProject.cpp
@@ -117,6 +117,10 @@ void App::initProject() {
// remembers neither and keeps the Classic look with the ZBrush-style layout; the new-look card offers the
// new default once (PanelSupport.cpp).
newLookCardDone_ = prefs["new_look_card_done"].asBool(false);
+ uiPrefs_.showNotices = prefs["show_notices"].asBool(true);
+ uiPrefs_.hiddenNotices.clear();
+ for (const Json& id : prefs["hidden_notices"].items())
+ if (id.isString() && uiPrefs_.hiddenNotices.size() < 256) uiPrefs_.hiddenNotices.push_back(id.asString());
if (!uiPrefs_.lookSaved && !uiConfigDeterministic_) {
UiPrefs saved = uiPrefs_;
if (!lookFromJson(prefs["ui_look"], saved)) {
@@ -189,6 +193,10 @@ void App::saveProjectPrefs() {
prefs.set("ui_look", std::move(look));
}
prefs.set("new_look_card_done", newLookCardDone_);
+ prefs.set("show_notices", uiPrefs_.showNotices); // (kept here, so they last without Store Config)
+ Json hidden = Json::array();
+ for (const std::string& id : uiPrefs_.hiddenNotices) hidden.push(id);
+ prefs.set("hidden_notices", std::move(hidden));
std::ofstream(fsPath(prefDir_ + "project.json"), std::ios::binary | std::ios::trunc) << prefs.dump(true);
}
diff --git a/src/app/RadialMenu.cpp b/src/app/RadialMenu.cpp
index 35ab0836..653b4fab 100644
--- a/src/app/RadialMenu.cpp
+++ b/src/app/RadialMenu.cpp
@@ -546,7 +546,7 @@ void App::drawRadialMenusSection() {
if (ImGui::Button(ICON_LC_CHEVRON_DOWN "##radial.down", ImVec2(rowH, 0))) move = 1;
ImGui::EndDisabled();
ImGui::SameLine();
- const bool remove = ImGui::Button(ICON_LC_X "##radial.remove", ImVec2(rowH, 0));
+ const bool remove = ui::GlyphButton("##radial.remove", ICON_LC_X, ImVec2(rowH, 0));
if (selected) {
ImGui::Indent(rowH * 0.5f);
char label[kRadialLabelMax + 1];
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index e947616f..c0d234ec 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -72,8 +72,10 @@ void tileFrame(ImDrawList* dl, const CanvasRect& r, bool focused) {
dl->PopClipRect();
}
+// `frame` false: the caller draws the tile's frame itself, after the contents (shelves, #98).
bool beginShellWindow(const char* name, const CanvasRect& r, const ImVec4& bg, ImVec2 padding,
- ImGuiWindowFlags extra = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse) {
+ ImGuiWindowFlags extra = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse,
+ bool frame = true) {
ImGui::SetNextWindowPos(ImVec2(r.x, r.y));
ImGui::SetNextWindowSize(ImVec2(r.w, r.h));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding);
@@ -84,7 +86,7 @@ bool beginShellWindow(const char* name, const CanvasRect& r, const ImVec4& bg, I
const bool open = ImGui::Begin(name, nullptr, kShellFlags | extra);
ImGui::PopStyleColor();
ImGui::PopStyleVar(4);
- if (open) tileFrame(ImGui::GetWindowDrawList(), r, sameRect(r, g_focus));
+ if (open && frame) tileFrame(ImGui::GetWindowDrawList(), r, sameRect(r, g_focus));
return open;
}
@@ -216,11 +218,9 @@ void drawBrushIcon(ImDrawList* dl, ImVec2 c, float r, int type) {
}
// Glyph centred in a box, in `font` (or the current one).
+// (A lone icon is centred by its ink: ui::CentredGlyph.)
void centredText(ImDrawList* dl, ImFont* font, ImVec2 a, ImVec2 b, ImU32 col, const char* text) {
- if (!font) font = ImGui::GetFont();
- const float size = font->FontSize;
- const ImVec2 ts = font->CalcTextSizeA(size, FLT_MAX, 0.0f, text);
- dl->AddText(font, size, ImVec2(std::floor((a.x + b.x - ts.x) * 0.5f), std::floor((a.y + b.y - ts.y) * 0.5f)), col, text);
+ ui::CentredGlyph(dl, font ? font : ImGui::GetFont(), a, b, col, text);
}
// Text clipped to `width` with an ellipsis.
@@ -1043,9 +1043,8 @@ void App::drawTitleStrip(const ShellGeometry& g) {
dl->AddRectFilled(p, ImVec2(p.x + windowButtonW, p.y + buttonH),
theme::u32(close ? theme::danger : theme::frameHover), theme::rounding(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);
+ ui::CentredGlyph(dl, nullptr, p, ImVec2(p.x + windowButtonW, p.y + buttonH),
+ theme::u32(hovered && close ? theme::text : theme::textDim), glyph);
if (close) {
if (clicked) requestQuit();
ui::HelpAction(*this, "file.quit");
@@ -1864,7 +1863,8 @@ void App::drawShelf(int shelf, const CanvasRect& r) {
: shelf == kShelfBottom ? ImVec2(6.0f * s, 3.0f * s)
: shelf == kShelfLeft ? ImVec2(6.0f * s, 6.0f * s)
: ImVec2(4.0f * s, 6.0f * s);
- if (!beginShellWindow(kShelfWindows[shelf], r, theme::shellBg, pad)) {
+ if (!beginShellWindow(kShelfWindows[shelf], r, theme::shellBg, pad,
+ ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse, false)) {
ImGui::End();
return;
}
@@ -1958,6 +1958,9 @@ void App::drawShelf(int shelf, const CanvasRect& r) {
ImGui::EndDragDropTarget();
}
}
+ // The frame last, over the shelf's buttons: drawn first, the right shelf's tall buttons covered its sides and
+ // the accent outline showed in pieces (#98).
+ tileFrame(dl, r, sameRect(r, g_focus));
ImGui::End();
}
diff --git a/src/app/ShellGeometry.h b/src/app/ShellGeometry.h
index 4e73ce04..0f2d7248 100644
--- a/src/app/ShellGeometry.h
+++ b/src/app/ShellGeometry.h
@@ -11,6 +11,16 @@
namespace sf {
+// Whether a window saved as full screen opens full screen again (#35). Not on macOS (#41, #85): there full screen is a
+// Space of its own, and entered at start-up the traffic lights and menu bar can't be revealed; the window comes back
+// maximised instead.
+#if defined(__APPLE__)
+constexpr bool kMacWindows = true;
+#else
+constexpr bool kMacWindows = false;
+#endif
+constexpr bool restoresFullscreen(bool savedFullscreen, bool mac = kMacWindows) { return savedFullscreen && !mac; }
+
struct ShellGeometry {
CanvasRect notchBand; // h 0 unless the top of the window is unsafe (camera notch)
CanvasRect title, paletteBar;
diff --git a/src/app/Thumbnails.cpp b/src/app/Thumbnails.cpp
index 2a37084d..0fe2f82f 100644
--- a/src/app/Thumbnails.cpp
+++ b/src/app/Thumbnails.cpp
@@ -3,6 +3,7 @@
#include "app/Thumbnails.h"
#include "app/AssetLibrary.h"
+#include "app/BrushPreview.h"
#include "core/Commands.h"
#include "core/Document.h"
#include "core/Matcap.h"
@@ -41,39 +42,6 @@ template <class T> bool ready(const std::future<T>& f) {
ImTextureID texId(unsigned tex) { return ImTextureID(uintptr_t(tex)); }
-// One mesh of every visible SubTool of `doc` (positions, triangles and polypaint), for the preview.
-std::unique_ptr<Mesh> sceneMesh(Document& doc) {
- auto out = std::make_unique<Mesh>();
- bool colors = false;
- for (int i = 0; i < doc.subtoolCount(); ++i)
- colors |= doc.subtools[size_t(i)].visible &&
- doc.subtoolMesh(i).colors.size() == doc.subtoolMesh(i).positions.size() &&
- !doc.subtoolMesh(i).colors.empty();
- for (int i = 0; i < doc.subtoolCount(); ++i) {
- if (!doc.subtools[size_t(i)].visible) continue;
- const Mesh& m = doc.subtoolMesh(i);
- const uint32_t base = uint32_t(out->positions.size());
- out->positions.insert(out->positions.end(), m.positions.begin(), m.positions.end());
- if (colors) {
- if (m.colors.size() == m.positions.size())
- out->colors.insert(out->colors.end(), m.colors.begin(), m.colors.end());
- else
- out->colors.insert(out->colors.end(), m.positions.size(), glm::vec3(1.0f));
- }
- const bool hidden = m.hidden.size() == m.triangles.size();
- for (size_t t = 0; t < m.triangles.size(); ++t)
- if (!hidden || !m.hidden[t]) out->triangles.push_back(m.triangles[t] + glm::uvec3(base));
- }
- if (out->triangles.empty()) return nullptr;
- out->rebuildTopology();
- out->recomputeAllNormals();
- return out;
-}
-
-// Every brush preview is the same clay ball, sculpted on its front and shot from the same camera with the
-// same material, so the shelf and the pickers read as one icon set.
-constexpr float kBallRadius = 0.9f;
-constexpr int kBallDetail = 6; // ~82k triangles: fine enough for crisp strokes at preview size
constexpr float kBallPitch = -8.0f; // degrees; a touch from above
constexpr float kBallFill = 0.97f; // the ball's share of the tile's height: framed tight, so the mark reads at shelf size
@@ -83,170 +51,6 @@ float ballDistance() {
return kBallRadius / (kBallFill * std::tan(fovY * 0.5f));
}
-// An S across the front of the ball, as stroke points in front of it (strokes look along -z).
-std::vector<glm::vec3> frontCurve(float width = 1.0f) {
- std::vector<glm::vec3> pts;
- for (int i = 0; i <= 8; ++i) {
- const float u = float(i) / 8.0f;
- pts.emplace_back((-0.56f + 1.12f * u) * width, 0.24f * std::sin(u * 6.2831853f), 2.0f);
- }
- return pts;
-}
-std::vector<glm::vec3> line(glm::vec3 a, glm::vec3 b) { return {a, b}; }
-// Points on a circle of radius `r` around (cx, cy) on the front of the ball, from angle a0 to a1 (radians).
-std::vector<glm::vec3> arc(float cx, float cy, float r, float a0, float a1, int n = 24) {
- std::vector<glm::vec3> pts;
- for (int i = 0; i <= n; ++i) {
- const float a = a0 + (a1 - a0) * float(i) / float(n);
- pts.emplace_back(cx + r * std::cos(a), cy + r * std::sin(a), 2.0f);
- }
- return pts;
-}
-
-void stroke(Document& d, const BrushRecipe* recipe, BrushType type, std::vector<glm::vec3> pts, float radius,
- float strength, bool curve = true) {
- PathStroke st;
- st.points = std::move(pts);
- st.view = glm::vec3(0.0f, 0.0f, -1.0f);
- st.radius = radius;
- st.strength = strength;
- st.curve = curve;
- std::string err;
- strokePath(d, recipe, type, st, err);
-}
-
-// Sculpts the preview of a brush (a recipe when given, else `type`) with the same code real strokes use,
-// on the shared ball (see kBallRadius).
-std::unique_ptr<Mesh> sculptBrushPreview(const BrushRecipe* recipe, int type) {
- if (type == kPaintBrush) {
- // Polypaint: a coloured S on the ball; white elsewhere, so the material shows as on the others.
- Mesh m = makeIcosphere(kBallDetail, kBallRadius);
- m.ensureColors(glm::vec3(1.0f));
- for (uint32_t v = 0; v < m.vertexCount(); ++v) {
- const glm::vec3 p = m.positions[v];
- const float curve = 0.24f * std::sin((p.x / 0.56f + 1.0f) * 3.14159265f);
- const float d2 = std::abs(p.y - curve);
- if (p.z > 0.0f && std::abs(p.x) < 0.6f && d2 < 0.12f) {
- const float t = std::clamp((0.12f - d2) / 0.04f, 0.0f, 1.0f);
- m.colors[v] = glm::mix(m.colors[v], glm::vec3(0.78f, 0.16f, 0.06f), t);
- }
- }
- return std::make_unique<Mesh>(std::move(m));
- }
- Document d;
- d.setMesh(makeIcosphere(kBallDetail, kBallRadius));
- const float r = 0.17f;
- if (recipe) {
- stroke(d, recipe, BrushType::Standard, frontCurve(), r, 0.9f);
- return sceneMesh(d);
- }
- // Each brush gets a mark of its own shape that shows what it does, so the shelf tells them apart at a glance
- // (the same S everywhere left only a few pixels of difference between Standard, Clay, Inflate and Pinch).
- constexpr float kPi = 3.14159265f;
- const auto bt = BrushType(type);
- switch (bt) {
- case BrushType::Clay: // three parallel strips laid on like clay
- for (int i = -1; i <= 1; ++i) {
- const float dx = 0.3f * float(i);
- stroke(d, nullptr, bt, line({dx - 0.28f, -0.42f, 2.0f}, {dx + 0.12f, 0.42f, 2.0f}), 0.15f, 1.0f, false);
- }
- break;
- case BrushType::ClayBuildup: // a hash of square, flat-topped bars, built up in two directions
- for (float o : {-0.2f, 0.2f}) {
- stroke(d, nullptr, bt, line({-0.5f, o, 2.0f}, {0.5f, o, 2.0f}), 0.13f, 0.1f, false);
- stroke(d, nullptr, bt, line({o, -0.5f, 2.0f}, {o, 0.5f, 2.0f}), 0.13f, 0.1f, false);
- }
- break;
- case BrushType::DamStandard: // one deep, sharp diagonal cut
- stroke(d, nullptr, bt, line({-0.55f, 0.45f, 2.0f}, {0.55f, -0.45f, 2.0f}), 0.2f, 1.0f, false);
- stroke(d, nullptr, bt, line({-0.55f, 0.45f, 2.0f}, {0.55f, -0.45f, 2.0f}), 0.2f, 1.0f, false);
- break;
- case BrushType::Crease: // a curved groove, like a smile line
- stroke(d, nullptr, bt, arc(0.0f, 0.42f, 0.62f, kPi * 1.18f, kPi * 1.82f), 0.17f, 1.0f);
- stroke(d, nullptr, bt, arc(0.0f, 0.42f, 0.62f, kPi * 1.18f, kPi * 1.82f), 0.17f, 1.0f);
- break;
- case BrushType::Move: // the silhouette pulled out into a broad soft lobe on the upper left
- stroke(d, nullptr, bt, line({-0.5f, 0.45f, 2.0f}, {-0.78f, 0.72f, 2.0f}), 0.5f, 1.0f, false);
- break;
- case BrushType::SnakeHook:
- // SnakeHook pulls out along the stroke; the path heads out past the silhouette to the side.
- stroke(d, nullptr, bt, line({0.15f, 0.05f, 2.0f}, {0.95f, 0.5f, 2.0f}), 0.26f, 1.0f, false);
- break;
- case BrushType::Inflate: // a ring, puffed up
- stroke(d, nullptr, bt, arc(0.0f, 0.0f, 0.38f, 0.0f, 2.0f * kPi, 32), 0.2f, 1.0f);
- break;
- case BrushType::Pinch: // a raised chevron pinched to a sharp crest
- stroke(d, nullptr, BrushType::Standard, {{-0.5f, 0.35f, 2.0f}, {0.0f, -0.3f, 2.0f}, {0.5f, 0.35f, 2.0f}}, 0.22f, 1.0f, false);
- for (int pass = 0; pass < 2; ++pass)
- stroke(d, nullptr, bt, {{-0.5f, 0.35f, 2.0f}, {0.0f, -0.3f, 2.0f}, {0.5f, 0.35f, 2.0f}}, 0.22f, 1.0f, false);
- break;
- case BrushType::Smooth: { // a bumpy ridge, its right half smoothed away
- for (int i = 0; i < 7; ++i)
- for (int pass = 0; pass < 4; ++pass)
- stroke(d, nullptr, BrushType::Standard, {glm::vec3(-0.6f + 0.2f * float(i), 0.0f, 2.0f)}, 0.13f, 1.0f, false);
- for (int pass = 0; pass < 3; ++pass)
- stroke(d, nullptr, bt, line({0.12f, 0.0f, 2.0f}, {0.8f, 0.0f, 2.0f}), 0.26f, 1.0f, false);
- break;
- }
- case BrushType::Flatten: // a dome with a flat facet planed across its top
- for (int pass = 0; pass < 3; ++pass)
- stroke(d, nullptr, BrushType::Standard, {glm::vec3(0.0f, 0.0f, 2.0f)}, 0.5f, 1.0f, false);
- for (int pass = 0; pass < 3; ++pass)
- stroke(d, nullptr, bt, line({-0.15f, 0.05f, 2.0f}, {0.15f, -0.05f, 2.0f}), 0.32f, 1.0f, false);
- break;
- case BrushType::Trim: { // a ridge cut down to hard planes along its length
- const auto ridge = line({-0.6f, -0.35f, 2.0f}, {0.6f, 0.35f, 2.0f});
- stroke(d, nullptr, BrushType::Standard, ridge, 0.24f, 1.0f, false);
- stroke(d, nullptr, BrushType::Clay, ridge, 0.24f, 1.0f, false);
- stroke(d, nullptr, bt, line({-0.3f, -0.17f, 2.0f}, {0.3f, 0.17f, 2.0f}), 0.24f, 1.0f, false);
- break;
- }
- case BrushType::Nudge: { // an upright ridge slid sideways in the middle
- const auto ridge = line({0.0f, -0.6f, 2.0f}, {0.0f, 0.6f, 2.0f});
- stroke(d, nullptr, BrushType::Standard, ridge, 0.2f, 1.0f, false);
- stroke(d, nullptr, BrushType::Clay, ridge, 0.2f, 1.0f, false);
- stroke(d, nullptr, bt, line({-0.05f, 0.0f, 2.0f}, {0.3f, 0.0f, 2.0f}), 0.3f, 0.15f, false);
- break;
- }
- case BrushType::Layer: // a square frame raised to one flat height per stroke; two strokes, two steps
- for (int pass = 0; pass < 2; ++pass)
- stroke(d, nullptr, bt,
- {{-0.38f, -0.38f, 2.0f}, {0.38f, -0.38f, 2.0f}, {0.38f, 0.38f, 2.0f}, {-0.38f, 0.38f, 2.0f}, {-0.38f, -0.38f, 2.0f}},
- 0.24f, 1.0f, false);
- break;
- case BrushType::Vdm: // one stamp of the built-in Horn
- stroke(d, nullptr, bt, {glm::vec3(0.0f, -0.05f, 2.0f)}, 0.45f, 0.5f, false);
- break;
- case BrushType::KelvinGrab: // the silhouette pulled out into a smooth, bulging lobe
- d.sculptor.kelvinlet.squash = 1.0f;
- stroke(d, nullptr, bt, line({-0.45f, 0.45f, 2.0f}, {-0.8f, 0.8f, 2.0f}), 0.45f, 0.5f, false);
- break;
- case BrushType::KelvinTwist: // a raised bar twisted into an S
- stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
- stroke(d, nullptr, BrushType::Standard, line({-0.5f, 0.0f, 2.0f}, {0.5f, 0.0f, 2.0f}), 0.16f, 1.0f, false);
- stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {0.45f, 0.0f, 2.0f}), 0.45f, 0.5f, false);
- break;
- case BrushType::KelvinScale: // a ring of bumps pinched toward the middle
- for (int i = 0; i < 6; ++i) {
- const float a = float(i) * kPi / 3.0f;
- for (int pass = 0; pass < 3; ++pass)
- stroke(d, nullptr, BrushType::Standard, {glm::vec3(0.4f * std::cos(a), 0.4f * std::sin(a), 2.0f)}, 0.12f, 1.0f, false);
- }
- stroke(d, nullptr, bt, line({0.0f, 0.0f, 2.0f}, {-0.5f, 0.0f, 2.0f}), 0.4f, 0.5f, false);
- break;
- case BrushType::KelvinSnake: // a tapering horn pulled out past the silhouette
- stroke(d, nullptr, bt, line({0.3f, 0.3f, 2.0f}, {1.1f, 0.85f, 2.0f}), 0.24f, 0.5f, false);
- break;
- case BrushType::DetailClone: // a row of horns along a curve
- stroke(d, nullptr, bt, arc(0.0f, -0.25f, 0.55f, kPi * 0.15f, kPi * 0.85f), 0.12f, 0.5f);
- break;
- default: // Standard: a soft rounded S
- stroke(d, nullptr, bt, frontCurve(1.15f), 0.19f, 1.0f);
- break;
- }
- return sceneMesh(d);
-}
-
} // namespace
ThumbnailCache::ThumbnailCache() = default;
diff --git a/src/app/Ui.cpp b/src/app/Ui.cpp
index d4948557..94571aea 100644
--- a/src/app/Ui.cpp
+++ b/src/app/Ui.cpp
@@ -126,6 +126,30 @@ bool IsChoiceAction(std::string_view id) {
id.substr(0, 16) == "subtool.shading_" || id.substr(0, 8) == "uv.mode_";
}
+void CentredGlyph(ImDrawList* dl, ImFont* font, ImVec2 a, ImVec2 b, ImU32 col, const char* glyph) {
+ if (!font) font = ImGui::GetFont();
+ const float size = ImGui::GetFontSize() > 0.0f && font == ImGui::GetFont() ? ImGui::GetFontSize() : font->FontSize;
+ unsigned int c = 0;
+ const int n = ImTextCharFromUtf8(&c, glyph, nullptr);
+ const ImFontGlyph* g = n > 0 && glyph[n] == '\0' ? font->FindGlyphNoFallback(ImWchar(c)) : nullptr;
+ if (!g || g->X1 <= g->X0 || g->Y1 <= g->Y0) {
+ const ImVec2 ts = font->CalcTextSizeA(size, FLT_MAX, 0.0f, glyph);
+ dl->AddText(font, size, ImVec2(std::floor((a.x + b.x - ts.x) * 0.5f), std::floor((a.y + b.y - ts.y) * 0.5f)), col, glyph);
+ return;
+ }
+ // The ink box (X0..X1, Y0..Y1, offsets included) relative to where AddText puts the pen, at this size.
+ const float k = size / font->FontSize;
+ const float x = (a.x + b.x) * 0.5f - (g->X0 + g->X1) * 0.5f * k, y = (a.y + b.y) * 0.5f - (g->Y0 + g->Y1) * 0.5f * k;
+ dl->AddText(font, size, ImVec2(std::round(x), std::round(y)), col, glyph);
+}
+
+bool GlyphButton(const char* id, const char* glyph, ImVec2 size) {
+ const bool clicked = ImGui::Button(id, size);
+ CentredGlyph(ImGui::GetWindowDrawList(), nullptr, ImGui::GetItemRectMin(), ImGui::GetItemRectMax(),
+ ImGui::GetColorU32(ImGuiCol_Text), glyph);
+ return clicked;
+}
+
bool Checkbox(const char* label, bool* v) {
const bool changed = ImGui::Checkbox(tr(label), v);
if (!*v) {
diff --git a/src/app/Ui.h b/src/app/Ui.h
index 651d72de..0b94dd3e 100644
--- a/src/app/Ui.h
+++ b/src/app/Ui.h
@@ -36,6 +36,11 @@ void DrawOnMark(ImDrawList* drawList, ImVec2 min, ImVec2 max, bool side = false)
void Segmented(App& app, std::initializer_list<const char*> actionIds, float width = -1.0f);
// ImGui::Checkbox with an outline round the box while it is unchecked, so an off box doesn't vanish on panelBg.
bool Checkbox(const char* label, bool* v);
+// A one-icon button ("x", "-") with the glyph centred by its ink, not its advance and the icon font's baseline offset,
+// which left Lucide's X low and to one side (#98). `id` is an ImGui id ("##lbclose").
+bool GlyphButton(const char* id, const char* glyph, ImVec2 size);
+// Draws a one-icon `glyph` centred by its ink in the rect a..b (a longer text is centred by its size).
+void CentredGlyph(ImDrawList* drawList, ImFont* font, ImVec2 a, ImVec2 b, ImU32 col, const char* glyph);
// Ctrl-hover help for the last item.
void HelpText(const char* title, const char* shortcut, const char* description, const char* path = nullptr);
void HelpAction(App& app, const char* actionId);
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index fcef8be5..73c38939 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -465,6 +465,9 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "look") return double(app_.uiPrefs_.look.look); // 0 Classic, 1 Forge Terminal, 2 Phosphor, 3 Blueprint
if (name == "shell_layout") return double(app_.uiPrefs_.shellLayout); // 0 ZBrush-style, 1 SculptForge
if (name == "air_strokes") return app_.uiPrefs_.airStrokes ? 1.0 : 0.0;
+ if (name == "air_strokes_chip") return app_.airStrokeChipShown_ ? 1.0 : 0.0; // the mode chip over the 3D view
+ if (name == "hidden_notices") return double(app_.uiPrefs_.hiddenNotices.size());
+ if (name == "show_notices") return app_.uiPrefs_.showNotices ? 1.0 : 0.0;
if (name == "space_held") return app_.spaceHeld_ ? 1.0 : 0.0;
if (name == "radial_open") return app_.radial_.menu >= 0 ? 1.0 : 0.0;
if (name == "radial_menu") return double(app_.radial_.menu); // -1: none open
diff --git a/src/app/UserGuide.cpp b/src/app/UserGuide.cpp
index 60d38af8..1985ff69 100644
--- a/src/app/UserGuide.cpp
+++ b/src/app/UserGuide.cpp
@@ -622,7 +622,7 @@ void UserGuide::drawToolbar(App& app) {
ui::HelpText("Search", "Ctrl+F", "Find every place in the guide that mentions all of these words.", "Help > User Guide");
if (query_[0]) {
ImGui::SameLine(0, 2.0f * s);
- if (ImGui::Button(ICON_LC_X "##guide_clear")) query_[0] = '\0';
+ if (ui::GlyphButton("##guide_clear", ICON_LC_X, ImVec2(ImGui::GetFrameHeight(), 0))) query_[0] = '\0';
ui::DelayedTooltip("Clear the search");
}
if (lastQuery_ != query_) {
diff --git a/src/core/PathStroke.cpp b/src/core/PathStroke.cpp
index 7ffd51f3..2f7b8a0a 100644
--- a/src/core/PathStroke.cpp
+++ b/src/core/PathStroke.cpp
@@ -153,9 +153,10 @@ int strokePath(Document& doc, const BrushRecipe* recipe, BrushType type, const P
for (size_t i = 1; i < samples.size(); ++i) doc.sculptor.grab(mesh, doc.bvh, samples[i] - samples[i - 1]);
dabs = int(samples.size());
}
- } else if ((type == BrushType::KelvinGrab || type == BrushType::KelvinSnake) && !recipe) {
- // Elastic grab and Snake: the grabbed point follows the path (in the view plane, as the cursor drags it;
- // a ray would hit the surface behind a pulled shape), in small steps.
+ } else if ((type == BrushType::SnakeHook || type == BrushType::KelvinGrab || type == BrushType::KelvinSnake) && !recipe) {
+ // Tendril, Elastic grab and Elastic Tendril: the grabbed point follows the path (in the view plane, as the
+ // cursor drags it in App::snakeHookTo; a ray would hit the surface behind a pulled shape, or miss past the
+ // silhouette), in small steps.
RayHit hit;
if (project(samples.front(), hit)) {
DabParams p = base;
diff --git a/tests/test_brush_previews.cpp b/tests/test_brush_previews.cpp
new file mode 100644
index 00000000..d68821ba
--- /dev/null
+++ b/tests/test_brush_previews.cpp
@@ -0,0 +1,91 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// The brush shelf previews (app/BrushPreview.cpp): every built-in brush sculpts its mark on the clay ball, and the
+// marks keep their shape. Tendril and Elastic Tendril pull a long horn out past the silhouette (they used to show a
+// tiny spike when the preview path ran off the ball), and no preview leaves torn, folded or degenerate triangles
+// (Layer's pinched corners, Nudge's torn ridge).
+#include "TestHarness.h"
+
+#include "app/AssetLibrary.h"
+#include "app/BrushPreview.h"
+#include "core/Sculpt.h"
+
+#include <algorithm>
+#include <cmath>
+#include <cstdlib>
+
+using namespace sf;
+
+namespace {
+
+struct PreviewShape {
+ float reach = 0.0f; // how far the mesh sticks out past the ball's silhouette (in the xy view plane)
+ float lift = 0.0f; // the largest change of a vertex's distance from the centre (in or out)
+ int degenerate = 0; // triangles with (nearly) no area
+ int folded = 0; // neighbouring triangles turned back on each other (> 150 degrees apart)
+};
+
+PreviewShape measure(const Mesh& m) {
+ PreviewShape s;
+ for (const glm::vec3& p : m.positions) {
+ s.reach = std::max(s.reach, glm::length(glm::vec2(p)) - kBallRadius);
+ s.lift = std::max(s.lift, std::abs(glm::length(p) - kBallRadius));
+ }
+ std::vector<glm::vec3> normals(m.triangles.size());
+ for (size_t t = 0; t < m.triangles.size(); ++t) {
+ const glm::uvec3 tri = m.triangles[t];
+ const glm::vec3 a = m.positions[tri.x], b = m.positions[tri.y], c = m.positions[tri.z];
+ const glm::vec3 n = glm::cross(b - a, c - a);
+ const float area2 = glm::length(n);
+ const float longest = std::max({glm::length(b - a), glm::length(c - b), glm::length(a - c)});
+ if (area2 < 1e-12f || longest <= 0.0f) {
+ ++s.degenerate;
+ continue;
+ }
+ normals[t] = n / area2;
+ }
+ // Folds: across each edge (found by its sorted vertex pair), the two triangles' normals.
+ std::vector<std::pair<uint64_t, uint32_t>> edges;
+ edges.reserve(m.triangles.size() * 3);
+ for (size_t t = 0; t < m.triangles.size(); ++t)
+ for (int k = 0; k < 3; ++k) {
+ const uint32_t u = m.triangles[t][k], v = m.triangles[t][(k + 1) % 3];
+ edges.emplace_back((uint64_t(std::min(u, v)) << 32) | std::max(u, v), uint32_t(t));
+ }
+ std::sort(edges.begin(), edges.end());
+ for (size_t i = 0; i + 1 < edges.size(); ++i)
+ if (edges[i].first == edges[i + 1].first &&
+ glm::dot(normals[edges[i].second], normals[edges[i + 1].second]) < -0.866f)
+ ++s.folded;
+ return s;
+}
+
+} // namespace
+
+TEST(brush_previews) {
+ const bool verbose = std::getenv("SF_BRUSH_PREVIEW_METRICS") != nullptr;
+ std::vector<int> brushes;
+ for (int t = 0; t < int(BrushType::Count); ++t)
+ if (BrushType(t) != BrushType::Morph) brushes.push_back(t); // (Morph needs a morph target; not on the shelf)
+ brushes.push_back(kPaintBrush);
+ for (int t : brushes) {
+ const auto mesh = sculptBrushPreview(nullptr, t);
+ CHECK(mesh != nullptr);
+ if (!mesh) continue;
+ const PreviewShape s = measure(*mesh);
+ const char* name = t == kPaintBrush ? "Paint" : brushLabel(BrushType(t));
+ if (verbose)
+ std::printf(" %-16s reach %.3f lift %.3f degenerate %d folded %d\n", name, s.reach, s.lift, s.degenerate,
+ s.folded);
+ CHECK(s.degenerate == 0);
+ CHECK(s.folded == 0);
+ if (s.degenerate || s.folded) std::printf(" (%s)\n", name);
+ if (t != kPaintBrush) CHECK(s.lift > 0.01f); // every brush leaves a mark
+ }
+ // Tendril and Elastic Tendril pull a horn well past the silhouette, as a drag in the viewport does.
+ for (BrushType t : {BrushType::SnakeHook, BrushType::KelvinSnake}) {
+ const auto mesh = sculptBrushPreview(nullptr, int(t));
+ CHECK(mesh && measure(*mesh).reach >= 0.25f);
+ }
+}
diff --git a/tests/test_lightbox.cpp b/tests/test_lightbox.cpp
index f52b2342..beb6206b 100644
--- a/tests/test_lightbox.cpp
+++ b/tests/test_lightbox.cpp
@@ -233,3 +233,21 @@ TEST(brush_popup_letter_keys) {
CHECK(letterBadges(names, filterByTyped(names, ""), "").empty());
CHECK(typedName("Clay Buildup!") == "claybuildup");
}
+
+// #90: Library > Projects listed each project twice on Windows: the User folder is joined with "/", recent files are
+// native "\" paths, and the two were compared as text.
+TEST(library_same_path) {
+ const bool win = true;
+ CHECK(samePath("C:\\Users\\Ann\\Documents\\SculptForge\\Projects\\Head.sfproj",
+ "C:/Users/Ann/Documents/SculptForge/Projects/Head.sfproj", win));
+ CHECK(samePath("C:\\Users\\Ann\\Documents\\SculptForge/Projects/head.SFPROJ",
+ "c:/users/ann/documents/sculptforge\\projects\\Head.sfproj", win));
+ CHECK(samePath("C:/Users/Ann//Documents/./SculptForge/Projects/../Projects/Head.sfproj",
+ "C:\\Users\\Ann\\Documents\\SculptForge\\Projects\\Head.sfproj", win));
+ CHECK(!samePath("C:/Users/Ann/Projects/Head.sfproj", "C:/Users/Ann/Projects/Hand.sfproj", win));
+ CHECK(pathKey("C:\\A\\B\\", win) == "c:/a/b");
+ // Elsewhere case matters and "\" is a character of the name, but the rest still normalises.
+ CHECK(samePath("/home/ann/SculptForge//Projects/./Head.sfproj", "/home/ann/SculptForge/Projects/Head.sfproj", false));
+ CHECK(!samePath("/home/ann/Projects/Head.sfproj", "/home/ann/Projects/head.sfproj", false));
+ CHECK(samePath("/a/b.sfproj", "/a/b.sfproj"));
+}
diff --git a/tests/test_shell_layout.cpp b/tests/test_shell_layout.cpp
index 338f12bd..93a22e1f 100644
--- a/tests/test_shell_layout.cpp
+++ b/tests/test_shell_layout.cpp
@@ -159,3 +159,15 @@ TEST(shell_right_shelf_undo_redo) {
CHECK(fromJson(now, back, err));
CHECK(back.rightShelf.size() == 1);
}
+
+// #85 (regression of #41): on macOS a window saved full screen comes back maximised, never straight into full screen
+// (its traffic lights couldn't be reached); elsewhere it comes back full screen.
+TEST(window_restore_fullscreen) {
+ CHECK(!restoresFullscreen(true, true));
+ CHECK(!restoresFullscreen(false, true));
+ CHECK(restoresFullscreen(true, false));
+ CHECK(!restoresFullscreen(false, false));
+#if defined(__APPLE__)
+ CHECK(!restoresFullscreen(true));
+#endif
+}
diff --git a/tests/ui/library_small_screen.sfui b/tests/ui/library_small_screen.sfui
new file mode 100644
index 00000000..2b469d5c
--- /dev/null
+++ b/tests/ui/library_small_screen.sfui
@@ -0,0 +1,22 @@
+# The Library on a small screen (#80): run at 1280x720 by CMake (ui_library_small_screen). The close button stays on
+# screen and clickable, and Esc closes the Library.
+run new_sphere subdivisions=3
+key ,
+expect_value lightbox_open == 1
+click "Library/Brush"
+wait_idle 60
+shot library-brush
+click "Library/##lbclose"
+expect_value lightbox_open == 0
+
+key ,
+expect_value lightbox_open == 1
+key escape
+expect_value lightbox_open == 0
+
+# The right shelf's outline is drawn over its buttons, not under them (#98).
+run ui_look look=forge
+wait 0.2
+hover_window 0.79 0.4
+wait_idle 30
+shot right-shelf-outline
diff --git a/tests/ui/notices.sfui b/tests/ui/notices.sfui
new file mode 100644
index 00000000..ed517732
--- /dev/null
+++ b/tests/ui/notices.sfui
@@ -0,0 +1,54 @@
+# Notices (Discord 11-02, ThinkingPolygons: "This is meant to be my default, I don't need to see it there forever").
+# A mode chip over the 3D view shows for a few seconds after its setting changes, then goes; its x hides it for good
+# (until Preferences > Interface > Reset hidden notices); Show hints and notices off hides them all.
+run ui_look look=classic layout=zbrush # the Classic look and the ZBrush-style palette bar, as air_strokes.sfui
+run new_sphere subdivisions=3
+expect_value show_notices == 1
+expect_value hidden_notices == 0
+expect_value air_strokes_chip == 0 # off (the default): no chip
+
+# Turned on: the chip shows, then goes by itself; the setting stays on.
+click "Preferences##palette.preferences"
+click "Input##preferences.input"
+click "Start strokes off the model##input.air_strokes"
+expect_value air_strokes == 1
+expect_value air_strokes_chip == 1
+expect_text Strokes start off the model
+shot chip
+wait 4.5
+expect_value air_strokes_chip == 0
+expect_value air_strokes == 1
+expect_no_text Strokes start off the model
+
+# Off and on again: back for a few seconds; its x hides it for good.
+click "Start strokes off the model##input.air_strokes"
+click "Start strokes off the model##input.air_strokes"
+expect_value air_strokes_chip == 1
+key escape # (a click outside the open Preferences only closes it)
+click "##hide_notice.air_strokes"
+expect_value air_strokes_chip == 0
+expect_value hidden_notices == 1
+expect_status notice hidden
+click "Preferences##palette.preferences"
+expect "Start strokes off the model##input.air_strokes"
+click "Start strokes off the model##input.air_strokes"
+click "Start strokes off the model##input.air_strokes"
+expect_value air_strokes_chip == 0
+
+# Reset hidden notices brings it back; Show hints and notices off hides every notice.
+click "Interface##preferences.interface"
+click "Reset hidden notices"
+expect_value hidden_notices == 0
+shot preferences-notices
+click "Show hints and notices"
+expect_value show_notices == 0
+click "Input##preferences.input"
+click "Start strokes off the model##input.air_strokes"
+click "Start strokes off the model##input.air_strokes"
+expect_value air_strokes_chip == 0
+click "Interface##preferences.interface"
+click "Show hints and notices"
+expect_value show_notices == 1
+click "Input##preferences.input"
+click "Start strokes off the model##input.air_strokes"
+expect_value air_strokes == 0
diff --git a/tests/ui/whats_new.sfui b/tests/ui/whats_new.sfui
index 0e5cf4b3..7f691fd3 100644
--- a/tests/ui/whats_new.sfui
+++ b/tests/ui/whats_new.sfui
@@ -5,8 +5,9 @@ click "Help##palette.help"
click "What's New##help.whats_new"
expect_value guide_open == 1
expect_guide whats-new.md
+expect_text "Version 0.10.9"
+expect_text "Brush previews fixed"
expect_text "Version 0.10.8"
-expect_text "Tablets in mouse mode work again"
expect_text "Version 0.10.7"
expect_text "Version 0.10.6"
expect_text "Version 0.10.5"