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.

Stroke popup: a grid at the cursor with the stroke types and latched modifiers (G; J in Blender style)

islandmedeae8307b3b7d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5607791..2ef67d09 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,13 @@ All notable changes to SculptForge are listed here. The format follows
## [Unreleased]
+### Added
+- Stroke popup: press G (J in the Blender style; any key in Preferences > Hotkeys) or the new button under the Stroke
+ tile for a grid at the cursor with the stroke types and the modifiers Add / Sub, Smooth, Mask and Select. Hold the
+ key, point and let go (a hovering pen works too), or tap it and click. Smooth, Mask and Select stay on without
+ holding Shift or Ctrl until you pick them again or another brush; a label at the cursor shows which. A plain grid,
+ not a ring. The stroke type is now saved with the project. (Suggested on Discord.)
+
## [0.10.8] - 2026-11-02
### Fixed
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dd947ce2..0782e241 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -125,6 +125,7 @@ add_library(sculptforge_core STATIC
src/core/UpdateCheck.cpp
src/core/Tablet.cpp
src/core/RadialMenu.cpp
+ src/core/StrokePopup.cpp
src/core/SpaceMouse.cpp
src/io/ObjIO.cpp
src/io/FbxIO.cpp
@@ -326,6 +327,7 @@ if(SCULPTFORGE_BUILD_APP)
src/app/SpaceMouse.cpp
src/app/Input.cpp
src/app/RadialMenu.cpp
+ src/app/StrokePopup.cpp
src/render/GL.cpp
src/render/Camera.cpp
src/render/Clusters.cpp
@@ -644,6 +646,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 stroke popup on a UI scaled 1.5x: it opens under the cursor and its items are where they're drawn.
+ add_test(NAME ui_stroke_popup_scaled COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/stroke_popup.sfui
+ --size 2400x1350 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/stroke_popup_scaled)
+ set_tests_properties(ui_stroke_popup_scaled 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)
@@ -669,7 +675,7 @@ if(SCULPTFORGE_BUILD_TESTS)
# The system clipboard is one per desktop (one X server under CI's xvfb-run), and on X11 every SDL program asks a
# new clipboard owner what it holds: a program that quits meanwhile makes the owner's answer fail (BadWindow).
# Scripts that set, read or paste it (or click a Copy / Paste button) run alone under ctest -j.
- foreach(t ${SCULPTFORGE_UI_TESTS} shell_layout_1080 help_console_1080 size_popup_scaled user_guide_1080)
+ foreach(t ${SCULPTFORGE_UI_TESTS} shell_layout_1080 help_console_1080 size_popup_scaled stroke_popup_scaled user_guide_1080)
string(REGEX REPLACE "_1080$|_scaled$" "" base ${t})
get_filename_component(base ${base} NAME_WE)
set(script ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/${base}.sfui)
diff --git a/REPLY.md b/REPLY.md
new file mode 100644
index 00000000..cdc171cb
--- /dev/null
+++ b/REPLY.md
@@ -0,0 +1,7 @@
+Thanks for the idea, it's in 0.10.9: **the stroke popup**. Press **G** (J in the Blender keys) or the new button under the Stroke tile and a plain grid opens right at the cursor: Dots, Drag Stamp, Slide Stamp, Spray and Lazy Stroke on top, and Add / Sub, Smooth, Mask and Select below, with big icons and labels.
+
+- Hold G, point, let go: picked. Or tap G and click. Works with a hovering pen too.
+- Smooth, Mask and Select **stay on** without holding Shift or Ctrl, until you pick them again or pick another brush. A small label by the cursor shows which one is on, so no more Ctrl+Shift / Alt juggling mid-stroke.
+- The key can be changed in Preferences > Hotkeys.
+
+Guide: Sculpting > Strokes > The stroke popup. Tell us how it feels in your workflow, especially on a tablet.
diff --git a/TESTERS.md b/TESTERS.md
new file mode 100644
index 00000000..79d71184
--- /dev/null
+++ b/TESTERS.md
@@ -0,0 +1,9 @@
+# Testers: Stroke popup, 0.10.9
+- Press and hold **G** over the model, move onto **Spray**, let go. Is Spray picked (the Stroke tile changes)? Does the grid open with your current stroke right under the pointer?
+- Tap **G** (quick press). The grid should stay open: click **Lazy Stroke**, it closes. Tap again, click **Mask**, then **Sub**: the grid stays open and both light up. Press **Esc**.
+- With **Mask** on, sculpt a plain stroke: does it mask without holding Ctrl? Is there a small "Mask" label next to the cursor? Drag beside the model: does the view still turn (not invert the mask)?
+- Pick another brush on the bottom shelf: does Mask turn itself off?
+- **Pen tablets (Windows first)**: hover the pen (tip up) while holding G, move onto an item, let go of G. Then tap G and tap an item with the pen tip. Does the tip tap ever sculpt the model under the grid? Tell us your tablet model and driver.
+- Click the grid button under the **Stroke** tile on the left shelf: does the grid open next to it?
+- At 150% / 200% Windows scaling, are the icons, labels and the key hints (Alt, Shift, Ctrl) sharp and not cut off? Send a screenshot.
+- Blender input style: is it **J** there (G stays the Move brush)?
diff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.md
index 70824b17..b0dbc323 100644
--- a/docs/guide/sculpting.md
+++ b/docs/guide/sculpting.md
@@ -319,6 +319,29 @@ Notes:
- Mask strokes (<kbd>Ctrl</kbd>) always use dots, even when Drag Stamp or Slide Stamp is selected.
- Custom brushes set their own dab spacing and can add jitter (see [Brush Lab](brush-lab.md)).
+### The stroke popup
+
+Press <kbd>G</kbd> (<kbd>J</kbd> in the Blender style) for a grid under the cursor, or click the grid button under
+the **Stroke** tile on the left shelf. The top row holds the stroke types, the bottom row the modifiers:
+
+| Modifier | What it does | Instead of holding |
+|---|---|---|
+| **Add** / **Sub** | Brushes add to or subtract from the surface (the same switch as Add / Sub on the top shelf). | <kbd>Alt</kbd> |
+| **Smooth** | Strokes smooth. | <kbd>Shift</kbd> |
+| **Mask** | Strokes paint the mask (<kbd>Alt</kbd> still unmasks). | <kbd>Ctrl</kbd> |
+| **Select** | Strokes draw the selection (hide) shape. | <kbd>Ctrl</kbd>+<kbd>Shift</kbd> |
+
+- **Hold and let go**: hold <kbd>G</kbd>, move over an item and let go. It opens with your current stroke under the
+ pointer, so letting go without moving changes nothing. A pen hovering over the tablet works the same.
+- **Tap and click**: tap <kbd>G</kbd> and the grid stays open. Click a stroke to pick it (the grid closes); click a
+ modifier to switch it (the grid stays open, so you can set a stroke too). <kbd>Esc</kbd> or a click beside the
+ grid closes it. The click never touches the model.
+- **Smooth, Mask and Select stay on** until you pick the same one again or pick another brush. A small label next
+ to the brush cursor shows which one is on. Dragging beside the model still turns the view.
+- Change the key in **Preferences > Hotkeys** (*Stroke popup*), or hold <kbd>Ctrl</kbd>+<kbd>Alt</kbd> and click the shelf button, then press the new key.
+
+The stroke type you picked is saved with the project.
+
> **ZBrush:** Drag Stamp, Slide Stamp, Spray and Lazy Stroke match ZBrush's DragRect, DragDot, Spray and LazyMouse. Freehand and Dots are the same thing here.
> Roll and curve strokes are not available yet.
diff --git a/docs/guide/whats-new.md b/docs/guide/whats-new.md
index d8920df6..1db89fcc 100644
--- a/docs/guide/whats-new.md
+++ b/docs/guide/whats-new.md
@@ -5,6 +5,13 @@ 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
+
+- **Stroke popup**: press <kbd>G</kbd> (<kbd>J</kbd> in the Blender style) or the button under the **Stroke**
+ tile for a grid at the cursor: the stroke types plus **Add**, **Sub**, **Smooth**, **Mask** and **Select**. Hold
+ the key, point and let go, or tap it and click. Smooth, Mask and Select stay on without holding
+ <kbd>Shift</kbd> or <kbd>Ctrl</kbd>. See [Strokes](sculpting.md#the-stroke-popup).
+
## 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..11be67f0 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -1138,6 +1138,7 @@ void App::handleEvent(const SDL_Event& event) {
mapPenPosition(e); // a tablet in mouse mode moves the cursor relatively (#54), for the canvas and the UI
if (supportCardEvent(e)) return; // the support card at launch takes clicks and keys while open
if (radialMouseEvent(e)) return; // clicks on an open radial menu, and the buttons that open one (RadialMenu.cpp)
+ if (strokePopupMouseEvent(e)) return; // clicks on the open stroke popup (StrokePopup.cpp)
ImGui_ImplSDL3_ProcessEvent(&e);
const ImGuiIO& io = ImGui::GetIO();
@@ -1153,6 +1154,7 @@ void App::handleEvent(const SDL_Event& event) {
break;
case SDL_EVENT_WINDOW_FOCUS_LOST:
if (radial_.hold != RadialHold::None) closeRadialMenu(); // its key or button's release won't come here
+ if (strokePopup_.held) closeStrokePopup();
spaceHeld_ = false; // Space let go in another window never reaches us
break;
case SDL_EVENT_WINDOW_CLOSE_REQUESTED:
@@ -1203,6 +1205,7 @@ void App::handleEvent(const SDL_Event& event) {
if (e.key.key == SDLK_SPACE) spaceHeld_ = false;
if (e.key.key == SDLK_SPACE) quickMenuKeyUp(); // a held Space closes the QuickMenu when let go
radialKeyUp(e.key.key); // a radial menu's held key: run the slot pointed at
+ strokePopupKeyUp(e.key.key); // the stroke popup's held key: pick the item pointed at
break;
case SDL_EVENT_DROP_FILE:
if (e.drop.data) openPathConfirmed(e.drop.data);
@@ -1300,6 +1303,7 @@ void App::onMouseDown(float x, float y, Uint8 button) {
mouseX_ = x;
mouseY_ = y;
const SDL_Keymod mod = inputMods();
+ const SDL_Keymod nav = inputMods(false); // (navigation ignores the stroke popup's latched Smooth / Mask / Select)
// A pen button is already driving the view: touching down with the tip keeps navigating.
if (penNavButton_ && (drag_ == Drag::Orbit || drag_ == Drag::Pan)) return;
dragFromPen_ = lastInputPen_;
@@ -1392,26 +1396,26 @@ void App::onMouseDown(float x, float y, Uint8 button) {
// Blender: a drag beside the model navigates as the middle button would (Shift pans, Ctrl zooms).
const SDL_Keymod keys = SDL_GetModState();
drag_ = (keys & SDL_KMOD_SHIFT) ? Drag::Pan : ctrlDown(keys) ? Drag::Zoom : Drag::Orbit;
- } else if (maskMod && !(mod & SDL_KMOD_ALT) && previewLod_ < 0) {
+ } else if (ctrlDown(nav) && !(nav & SDL_KMOD_SHIFT) && !(nav & SDL_KMOD_ALT) && previewLod_ < 0) {
drag_ = Drag::MaskCanvas; // click inverts, drag draws a mask rectangle (PanelMasking.cpp)
maskCanvasX_ = x;
maskCanvasY_ = y;
maskCanvasMoved_ = false;
} else {
// Dragging on empty space navigates (ZBrush style).
- drag_ = (mod & SDL_KMOD_ALT) ? Drag::Pan : ctrlDown(mod) ? Drag::Zoom : Drag::Orbit;
+ drag_ = (nav & SDL_KMOD_ALT) ? Drag::Pan : ctrlDown(nav) ? Drag::Zoom : Drag::Orbit;
panFromAlt_ = drag_ == Drag::Pan;
// ZBrush: Shift+click, let go of Shift, then drag turns the view about its own axis (Z).
- rollPending_ = drag_ == Drag::Orbit && (mod & SDL_KMOD_SHIFT);
+ rollPending_ = drag_ == Drag::Orbit && (nav & SDL_KMOD_SHIFT);
rollStartX_ = x;
rollStartY_ = y;
}
} else if (button == SDL_BUTTON_RIGHT) {
// ZBrush's right-click navigation: rotate (Shift snaps), Alt pans (release Alt to zoom), Ctrl zooms.
- drag_ = (mod & SDL_KMOD_ALT) ? Drag::Pan : ctrlDown(mod) ? Drag::Zoom : Drag::Orbit;
- panFromAlt_ = (mod & SDL_KMOD_ALT) != 0;
+ drag_ = (nav & SDL_KMOD_ALT) ? Drag::Pan : ctrlDown(nav) ? Drag::Zoom : Drag::Orbit;
+ panFromAlt_ = (nav & SDL_KMOD_ALT) != 0;
} else if (button == SDL_BUTTON_MIDDLE) {
- drag_ = (mod & SDL_KMOD_CTRL) ? Drag::Zoom : Drag::Pan;
+ drag_ = (nav & SDL_KMOD_CTRL) ? Drag::Zoom : Drag::Pan;
}
}
@@ -1461,10 +1465,10 @@ void App::onMouseMove(float x, float y, float dx, float dy, bool fromPen) {
dy = rightClick_.dy;
}
// ZBrush: start a pan with Alt, then let go of Alt while still dragging to zoom.
- if (drag_ == Drag::Pan && panFromAlt_ && !(inputMods() & SDL_KMOD_ALT)) drag_ = Drag::Zoom;
+ if (drag_ == Drag::Pan && panFromAlt_ && !(inputMods(false) & SDL_KMOD_ALT)) drag_ = Drag::Zoom;
// Shift+press on the background: letting go of Shift before the drag gets going rolls the view instead.
if (rollPending_ && drag_ == Drag::Orbit) {
- if (!(inputMods() & SDL_KMOD_SHIFT)) {
+ if (!(inputMods(false) & SDL_KMOD_SHIFT)) {
drag_ = Drag::Roll;
rollPending_ = false;
} else if (std::hypot(x - rollStartX_, y - rollStartY_) > 6.0f) {
@@ -1514,7 +1518,7 @@ void App::orbitBy(float dx, float dy) {
if (uiPrefs_.turntable || forceTurntable_) orbitRaw_.orbit(dx, dy);
else orbitRaw_.orbitFree(dx, dy);
// Holding Shift snaps to the nearest view along an axis; letting go continues from where the cursor took it.
- if (inputMods() & SDL_KMOD_SHIFT) camera_.setOrientation(Camera::snapped(orbitRaw_.orientation()));
+ if (inputMods(false) & SDL_KMOD_SHIFT) camera_.setOrientation(Camera::snapped(orbitRaw_.orientation()));
else camera_.setOrientation(orbitRaw_.orientation());
}
@@ -1587,6 +1591,10 @@ void App::onKey(SDL_Keycode key, SDL_Keymod mod) {
closeRadialMenu();
return;
}
+ if (key == SDLK_ESCAPE && strokePopup_.open) {
+ closeStrokePopup();
+ return;
+ }
if (key == SDLK_ESCAPE && !insertType_.empty()) { // Append > Insert (#34) off
insertType_.clear();
status_ = "Insert off";
@@ -2271,6 +2279,7 @@ void App::drawUi() {
drawLightBoxUi(); // thumbnails, the LightBox over the canvas, pickers, size / strength pop-ups
drawQuickMenu(); // Space (Input.cpp)
drawRadialMenu(); // radial menus (RadialMenu.cpp)
+ drawStrokePopup(); // the stroke popup and a latched modifier's label at the cursor (StrokePopup.cpp)
drawSubToolPopups();
if (showBrushLab_) drawBrushLab();
drawBrushGallery();
diff --git a/src/app/App.h b/src/app/App.h
index 34fbdfa2..f87f86e0 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -30,6 +30,7 @@
#include "core/AutoUv.h"
#include "core/QRemesh.h"
#include "core/RadialMenu.h"
+#include "core/StrokePopup.h"
#include "core/Stroke.h"
#include "core/StrokePath.h"
#include "core/SurfaceCursor.h"
@@ -1195,6 +1196,7 @@ private:
bool canvasNavButton(const char* id, const char* icon, const char* label, int mode); // right-shelf Move/Zoom/Rotate
void drawBrushTile(const char* id, ImVec2 size);
void drawStrokeTile(const char* id, ImVec2 size);
+ void drawStrokeIcon(ImDrawList* dl, ImVec2 a, ImVec2 b, StrokeType type); // the shelf tile's picture
void drawAlphaTile(const char* id, ImVec2 size);
void drawMaterialTile(const char* id, ImVec2 size);
void drawColorWidget(float width);
@@ -1665,6 +1667,38 @@ private:
int openedFrame = -1;
int ran = -1; // the slot run last (UI tests)
} radial_;
+ // ---- The stroke popup (StrokePopup.cpp, core/StrokePopup.h; Discord 11-02) ----
+ // One key (stroke.popup, G; J in the Blender style) or the left shelf's button opens a grid at the cursor: the
+ // stroke types and the modifiers Add / Sub, Smooth, Mask, Select. Hold the key, point, let go: picked. Tap it:
+ // the grid stays open for a click (a stroke closes it, a modifier toggles and leaves it open). Esc cancels.
+ // Smooth, Mask and Select latch: strokes act as if Shift, Ctrl or Ctrl+Shift were held until the same item is
+ // picked again or another brush is picked.
+ void registerStrokePopupActions();
+ void openStrokePopup(bool held, int key);
+ void closeStrokePopup() { strokePopup_.open = false; }
+ void pickStrokePopupItem(int item, bool close);
+ bool strokePopupMouseEvent(const SDL_Event& e); // true: the popup used the event
+ void strokePopupKeyUp(SDL_Keycode key);
+ void drawStrokePopup();
+ bool strokePopupItemScreen(int item, ImVec2& out) const; // an item's centre, window pixels (UI tests)
+ StrokeLatch strokeLatch() const; // the latch in effect (None once another brush was picked)
+ void setStrokeLatch(StrokeLatch latch);
+ struct StrokePopupOpen {
+ bool open = false;
+ ImVec2 at{0, 0}; // the panel's top-left
+ double openedAt = 0.0; // seconds (a short press is a tap)
+ bool held = false; // its key holds it open; false: tapped open, stays until a click or Esc
+ int key = 0; // the held key (SDL_Keycode)
+ int hover = -1; // the item under the pointer
+ int picked = -1; // the item picked last (UI tests)
+ } strokePopup_;
+ struct StrokeLatchState {
+ StrokeLatch latch = StrokeLatch::None;
+ BrushType brush = BrushType::Standard; // the brush it was latched with: picking another ends it
+ int custom = -1;
+ bool paint = false;
+ } strokeLatch_;
+ uint32_t strokePopupSwallowUp_ = 0; // mouse buttons whose press the popup took: their release is its too
SDL_Keycode keyDown_ = SDLK_UNKNOWN; // the key onKey is handling: a radial menu's key holds the pie open
uint32_t radialSwallowUp_ = 0; // mouse buttons whose press the pie took: their release is its too
std::optional<Json> radialPending_; // radial menus read from ui.json before the actions existed
@@ -1724,7 +1758,10 @@ private:
void penButton(int button, bool down, float x, float y);
void penLeft(); // out of proximity: ends what the pen was doing
float strokePressure() const; // pressure after the global curve; 1 for the mouse
- SDL_Keymod inputMods() const; // the keyboard's modifiers plus those a pen button holds (Alt, Shift)
+ // The keyboard's modifiers plus those a pen button holds (Alt, Shift) and, with latch, the stroke popup's
+ // latched modifier (Shift for Smooth, Ctrl for Mask, Ctrl+Shift for Select). Navigation reads it without the
+ // latch: a latched Mask still lets a drag beside the model turn the view.
+ SDL_Keymod inputMods(bool latch = true) const;
bool erasing() const; // the pen's eraser end is drawing
PenAction eraserAction() const { return uiPrefs_.tablet.eraser; }
void firstDab(float x, float y); // the stroke's first dab, once the pen reports a real pressure
diff --git a/src/app/Gizmo.cpp b/src/app/Gizmo.cpp
index 86ab3cfa..78e6fb8f 100644
--- a/src/app/Gizmo.cpp
+++ b/src/app/Gizmo.cpp
@@ -509,7 +509,7 @@ void App::gizmoDragTo(float x, float y) {
if (h == H::None) return;
glm::vec3 o, d;
canvasRay(x, y, o, d);
- const bool snap = (inputMods() & SDL_KMOD_SHIFT) != 0;
+ const bool snap = (inputMods(false) & SDL_KMOD_SHIFT) != 0;
const glm::mat3& f = gizmo_.startFrame;
const glm::vec3 c = gizmo_.startPivot;
const int axis = axisOf(h);
@@ -732,7 +732,7 @@ void App::drawGizmo() {
const ImVec2 mouse(mouseX_, mouseY_);
const bool overCanvas = !ImGui::GetIO().WantCaptureMouse && canvasRect().contains(mouse.x, mouse.y);
gizmo_.hover = drag_ == Drag::Gizmo ? gizmo_.handle
- : drag_ == Drag::None && overCanvas && !ctrlDown(inputMods()) ? gizmoHandleAt(mouse.x, mouse.y)
+ : drag_ == Drag::None && overCanvas && !ctrlDown(inputMods(false)) ? gizmoHandleAt(mouse.x, mouse.y)
: H::None;
ImDrawList* dl = ImGui::GetBackgroundDrawList(); // under the panels, over the model
const CanvasRect cr = canvasRect();
diff --git a/src/app/Input.cpp b/src/app/Input.cpp
index 2ab4aec6..ca342864 100644
--- a/src/app/Input.cpp
+++ b/src/app/Input.cpp
@@ -208,6 +208,7 @@ void App::registerInputActions() {
return {ok, status_};
}});
registerViewActions();
+ registerStrokePopupActions(); // StrokePopup.cpp
applyInputStyle();
}
@@ -289,6 +290,7 @@ void App::applyInputStyle() {
{"draw.paint", {"P", "P", ""}},
{"ui.picker.material", {"M", "M", ""}},
{"stroke.lazy", {"L", "L", "L / Shift+S"}},
+ {"stroke.popup", {"G", "G", "J"}}, // (Blender's G is its Move brush)
{"mask.clear", {"Ctrl+Shift+A", "Ctrl+Shift+A", "Alt+M / Ctrl+Shift+A"}},
{"geometry.lower_res", {"Shift+D", "Shift+D", "Alt+1 / Shift+D"}},
{"geometry.higher_res", {"D", "D", "Alt+2 / D"}},
@@ -556,6 +558,7 @@ void App::openQuickMenu() {
quickMenu_.open = false;
return;
}
+ closeStrokePopup();
quickMenu_.open = true;
quickMenu_.at = ImVec2(mouseX_, mouseY_);
quickMenu_.openedAt = ImGui::GetTime();
diff --git a/src/app/PanelKelvinlet.cpp b/src/app/PanelKelvinlet.cpp
index 3fab2ad8..9aa1c1bc 100644
--- a/src/app/PanelKelvinlet.cpp
+++ b/src/app/PanelKelvinlet.cpp
@@ -300,7 +300,7 @@ void App::registerKelvinletActions() {
bool App::captureMouseDown(float x, float y) {
if (!capture_.armed) return false;
capture_.anchor = capture_.current = glm::vec2(x, y);
- capture_.circle = (inputMods() & SDL_KMOD_SHIFT) != 0;
+ capture_.circle = (inputMods(false) & SDL_KMOD_SHIFT) != 0;
drag_ = Drag::Capture;
return true;
}
diff --git a/src/app/PanelProject.cpp b/src/app/PanelProject.cpp
index d3df4918..5ab2d1a4 100644
--- a/src/app/PanelProject.cpp
+++ b/src/app/PanelProject.cpp
@@ -330,6 +330,7 @@ void App::storeProjectSettings() {
brush.set("rgb_intensity", double(rgbIntensity_));
brush.set("focal_shift", double(focalShift_));
brush.set("invert", invertToggle_);
+ brush.set("stroke", strokeTypeName(strokeType_));
brush.set("front_faces_only", frontFacesOnly_);
brush.set("connected_only", uiPrefs_.connectedOnly);
brush.set("view_falloff", uiPrefs_.viewFalloff);
@@ -454,6 +455,9 @@ void App::applyProjectSettings() {
rgbIntensity_ = std::clamp(rgbIntensity_, 0.0f, 1.0f);
focalShift_ = std::clamp(focalShift_, -1.0f, 1.0f);
readBool(b, "invert", invertToggle_);
+ if (b["stroke"].isString())
+ for (int i = 0; i < int(StrokeType::Count); ++i)
+ if (b["stroke"].asString() == strokeTypeName(StrokeType(i))) strokeType_ = StrokeType(i);
readBool(b, "smooth_keep_volume", smoothKeepVolume_);
readBool(b, "front_faces_only", frontFacesOnly_);
readBool(b, "connected_only", uiPrefs_.connectedOnly);
diff --git a/src/app/RadialMenu.cpp b/src/app/RadialMenu.cpp
index 35ab0836..7129d1fb 100644
--- a/src/app/RadialMenu.cpp
+++ b/src/app/RadialMenu.cpp
@@ -179,6 +179,7 @@ void App::openRadialMenu(int menu, RadialHold hold, int code) {
}
if (drag_ != Drag::None) return; // not in the middle of a stroke or a view drag
quickMenu_.open = false;
+ closeStrokePopup();
const float s = uiScale_;
// Keep the whole pie on the canvas; the flick is measured from wherever its centre ends up.
const CanvasRect c = canvasRect();
diff --git a/src/app/Shell.cpp b/src/app/Shell.cpp
index e947616f..8cbaaf7a 100644
--- a/src/app/Shell.cpp
+++ b/src/app/Shell.cpp
@@ -2335,24 +2335,12 @@ void App::drawBrushTile(const char* id, ImVec2 size) {
ui::HelpText("Brush", "B", "The active brush. Click for the brush picker; the bottom shelf holds favourites.", "Left shelf");
}
-void App::drawStrokeTile(const char* id, ImVec2 size) {
+void App::drawStrokeIcon(ImDrawList* dl, ImVec2 a, ImVec2 b, StrokeType type) {
const float s = uiScale_;
- if (const HeldBrushItem* held = heldBrushCurrent(heldBrush())) { // Ctrl / Ctrl+Shift: the mask's stroke
- ImVec2 a, b;
- const bool clicked = tileFrame(id, size, fontSmall_, held->stroke, s, a, b);
- drawHeldBrushIcon(ImGui::GetWindowDrawList(), a, b, held->icon, heldBrush() == HeldBrush::Select);
- if (clicked) openPicker(Picker::Stroke, ImVec2(ImGui::GetItemRectMax().x + 4.0f * s, ImGui::GetItemRectMin().y));
- ui::HelpText("Stroke", nullptr, "Ctrl held: the mask's stroke, Dots (Mask Pen), Lasso or Rect (Ctrl+Shift: the "
- "selection's). Click with Ctrl held to choose.", "Left shelf");
- return;
- }
- ImVec2 a, b;
- const bool clicked = tileFrame(id, size, fontSmall_, strokeTypeName(strokeType_), s, a, b);
- ImDrawList* dl = ImGui::GetWindowDrawList();
const ImU32 col = IM_COL32(235, 235, 235, 230);
const float w = b.x - a.x, h = b.y - a.y;
auto at = [&](float u, float v) { return ImVec2(a.x + w * u, a.y + h * v); };
- switch (strokeType_) {
+ switch (type) {
case StrokeType::Dots: // ZBrush's dotted arc
for (int i = 0; i < 7; ++i) {
const float u = float(i) / 6.0f;
@@ -2395,6 +2383,22 @@ void App::drawStrokeTile(const char* id, ImVec2 size) {
}
default: break;
}
+}
+
+void App::drawStrokeTile(const char* id, ImVec2 size) {
+ const float s = uiScale_;
+ if (const HeldBrushItem* held = heldBrushCurrent(heldBrush())) { // Ctrl / Ctrl+Shift: the mask's stroke
+ ImVec2 a, b;
+ const bool clicked = tileFrame(id, size, fontSmall_, held->stroke, s, a, b);
+ drawHeldBrushIcon(ImGui::GetWindowDrawList(), a, b, held->icon, heldBrush() == HeldBrush::Select);
+ if (clicked) openPicker(Picker::Stroke, ImVec2(ImGui::GetItemRectMax().x + 4.0f * s, ImGui::GetItemRectMin().y));
+ ui::HelpText("Stroke", nullptr, "Ctrl held: the mask's stroke, Dots (Mask Pen), Lasso or Rect (Ctrl+Shift: the "
+ "selection's). Click with Ctrl held to choose.", "Left shelf");
+ return;
+ }
+ ImVec2 a, b;
+ const bool clicked = tileFrame(id, size, fontSmall_, strokeTypeName(strokeType_), s, a, b);
+ drawStrokeIcon(ImGui::GetWindowDrawList(), a, b, strokeType_);
if (clicked) openPicker(Picker::Stroke, ImVec2(ImGui::GetItemRectMax().x + 4.0f * s, ImGui::GetItemRectMin().y));
ui::HelpText("Stroke", nullptr, "How dabs follow the cursor: Dots, Drag Stamp, Slide Stamp, Spray or Lazy Stroke. Click to choose.",
"Left shelf");
diff --git a/src/app/StrokePopup.cpp b/src/app/StrokePopup.cpp
new file mode 100644
index 00000000..ffd6f1fb
--- /dev/null
+++ b/src/app/StrokePopup.cpp
@@ -0,0 +1,278 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// The stroke popup (Discord 11-02: "a popup for stroke type selection; the constant Ctrl+Shift / Alt combinations
+// interrupt the thought process"). One key (stroke.popup: G, J in the Blender style) or the left shelf's button
+// opens a plain grid at the cursor, the current stroke under the pointer: the stroke types, then Add / Sub and
+// the latched modifiers Smooth, Mask and Select. Hold the key, point, let go: picked (a pen hovering works the
+// same). Tap the key: the grid stays open; a click on a stroke picks it and closes, a click on a modifier toggles
+// it and leaves the grid open, a click beside it or Esc closes it. The click never reaches the model. The grid's
+// geometry and the latch rules are in core/StrokePopup.h.
+#include "app/App.h"
+#include "app/Theme.h"
+#include "app/Ui.h"
+
+#include <IconsLucide.h>
+
+#include <algorithm>
+#include <cfloat>
+#include <iterator>
+#include <string>
+
+namespace sf {
+
+namespace {
+
+constexpr double kStrokePopupTapSeconds = 0.25; // let go sooner without pointing at an item: a tap, it stays open
+
+struct ModifierLook {
+ const char* label;
+ const char* glyph;
+ const char* keys; // what it saves holding (the ZBrush keys; the latches stand for them in every style)
+ const char* help;
+};
+constexpr ModifierLook kModifiers[] = {
+ {"Add", ICON_LC_CIRCLE_PLUS, "", "Brushes add to the surface."},
+ {"Sub", ICON_LC_CIRCLE_MINUS, "Alt", "Brushes subtract from the surface."},
+ {"Smooth", ICON_LC_WAVES, "Shift", "Strokes smooth, as with Shift held, until you pick Smooth again or another brush."},
+ {"Mask", ICON_LC_VENETIAN_MASK, "Ctrl", "Strokes paint the mask, as with Ctrl held, until you pick Mask again or another brush."},
+ {"Select", ICON_LC_LASSO_SELECT, "Ctrl+Shift",
+ "Strokes draw the selection (hide) shape, as with Ctrl+Shift held, until you pick Select again or another brush."},
+};
+static_assert(std::size(kModifiers) == size_t(kStrokePopupModifiers));
+
+StrokePopupGeometry popupGeometry(float s) {
+ StrokePopupGeometry g;
+ g.tile = 64.0f * s;
+ g.label = 20.0f * s;
+ g.gap = 6.0f * s;
+ g.header = 22.0f * s;
+ g.pad = 10.0f * s;
+ g.columns = 5;
+ return g;
+}
+
+} // namespace
+
+void App::registerStrokePopupActions() {
+ Action a;
+ a.id = "stroke.popup";
+ a.label = "Stroke popup";
+ a.icon = ICON_LC_LAYOUT_GRID;
+ a.palette = "Stroke";
+ a.description = "A grid at the cursor with the stroke types and the modifiers (Add / Sub, Smooth, Mask, Select). "
+ "Hold the key, point at one and let go; or tap the key and click. Smooth, Mask and Select stay on "
+ "without holding Shift or Ctrl, until you pick them again or another brush.";
+ a.run = [this] { openStrokePopup(keyDown_ != SDLK_UNKNOWN, int(keyDown_)); };
+ a.checked = [this] { return strokePopup_.open; };
+ actions_.add(std::move(a)); // (its key depends on the input style: applyInputStyle in Input.cpp)
+}
+
+StrokeLatch App::strokeLatch() const {
+ const StrokeLatchState& l = strokeLatch_;
+ if (l.latch == StrokeLatch::None) return StrokeLatch::None;
+ const bool sameBrush = brush_ == l.brush && doc_.activeBrush == l.custom && paintMode_ == l.paint && !guidesMode_;
+ return sameBrush ? l.latch : StrokeLatch::None;
+}
+
+void App::setStrokeLatch(StrokeLatch latch) {
+ strokeLatch_ = {latch, brush_, doc_.activeBrush, paintMode_};
+ status_ = latch == StrokeLatch::None
+ ? std::string("Modifiers off: strokes sculpt")
+ : std::string(strokeLatchName(latch)) + " on: strokes " +
+ (latch == StrokeLatch::Smooth ? "smooth" : latch == StrokeLatch::Mask ? "mask" : "select") +
+ " until you pick " + strokeLatchName(latch) + " again or another brush";
+}
+
+void App::openStrokePopup(bool held, int key) {
+ if (strokePopup_.open && !strokePopup_.held) { // tapped open, its key (or the button) again: close
+ closeStrokePopup();
+ return;
+ }
+ if (drag_ != Drag::None) return; // not in the middle of a stroke or a view drag
+ quickMenu_.open = false;
+ closeRadialMenu();
+ const StrokePopupGeometry g = popupGeometry(uiScale_);
+ // The current stroke under the pointer (a quick tap and let go changes nothing), the whole grid on the canvas.
+ const glm::vec2 cur = g.itemMin(int(strokeType_)) + g.itemSize() * 0.5f;
+ const glm::vec2 size = g.size();
+ const CanvasRect c = canvasRect();
+ ImVec2 at(mouseX_ - cur.x, mouseY_ - cur.y);
+ at.x = c.w > size.x ? std::clamp(at.x, c.x, c.x + c.w - size.x) : c.x;
+ at.y = c.h > size.y ? std::clamp(at.y, c.y, c.y + c.h - size.y) : c.y;
+ strokePopup_.open = true;
+ strokePopup_.at = at;
+ strokePopup_.openedAt = ImGui::GetTime();
+ strokePopup_.held = held;
+ strokePopup_.key = key;
+ strokePopup_.hover = -1;
+}
+
+void App::pickStrokePopupItem(int item, bool close) {
+ if (item < 0 || item >= kStrokePopupItems) return;
+ strokePopup_.picked = item;
+ if (strokePopupIsStroke(item)) {
+ strokeType_ = StrokeType(item);
+ status_ = std::string("Stroke: ") + strokeTypeName(strokeType_);
+ closeStrokePopup();
+ return;
+ }
+ const StrokeModifier m = strokePopupModifier(item);
+ if (m == StrokeModifier::Add || m == StrokeModifier::Sub) {
+ invertToggle_ = m == StrokeModifier::Sub;
+ status_ = invertToggle_ ? "Sub: brushes subtract (Alt adds for one stroke)"
+ : "Add: brushes add (Alt subtracts for one stroke)";
+ } else {
+ setStrokeLatch(toggledStrokeLatch(strokeLatch(), strokeModifierLatch(m)));
+ }
+ if (close) closeStrokePopup();
+}
+
+void App::strokePopupKeyUp(SDL_Keycode key) {
+ if (!strokePopup_.open || !strokePopup_.held || SDL_Keycode(strokePopup_.key) != key) return;
+ const StrokePopupGeometry g = popupGeometry(uiScale_);
+ const int item = g.itemAt({mouseX_ - strokePopup_.at.x, mouseY_ - strokePopup_.at.y});
+ const bool tap = ImGui::GetTime() - strokePopup_.openedAt < kStrokePopupTapSeconds;
+ // It opens with the current stroke under the pointer: let go there quickly and it was a tap (stays open for a
+ // click); pointed at another item, or held a moment, and let go: that item.
+ if (item >= 0 && (!tap || item != int(strokeType_))) {
+ pickStrokePopupItem(item, true);
+ return;
+ }
+ if (tap) {
+ strokePopup_.held = false;
+ return;
+ }
+ closeStrokePopup(); // held and let go beside the items: nothing
+}
+
+bool App::strokePopupMouseEvent(const SDL_Event& e) {
+ if (e.type != SDL_EVENT_MOUSE_BUTTON_DOWN && e.type != SDL_EVENT_MOUSE_BUTTON_UP) return false;
+ const int button = e.button.button;
+ const uint32_t bit = button >= 0 && button < 32 ? 1u << button : 0u;
+ if (e.type == SDL_EVENT_MOUSE_BUTTON_UP) {
+ if (!(strokePopupSwallowUp_ & bit)) return false;
+ strokePopupSwallowUp_ &= ~bit; // the press went to the popup: so does the release
+ return true;
+ }
+ if (!strokePopup_.open) return false;
+ // Open: a left click (mouse or pen tip) on an item picks it; inside the panel elsewhere does nothing; any
+ // other click closes it. Nothing reaches the canvas or the panels under it.
+ strokePopupSwallowUp_ |= bit;
+ if (button == SDL_BUTTON_LEFT) {
+ const StrokePopupGeometry g = popupGeometry(uiScale_);
+ const glm::vec2 p(e.button.x - strokePopup_.at.x, e.button.y - strokePopup_.at.y);
+ const int item = g.itemAt(p);
+ if (item >= 0) {
+ strokePopup_.held = false; // (its key's release must not pick again)
+ pickStrokePopupItem(item, false);
+ return true;
+ }
+ const glm::vec2 size = g.size();
+ if (p.x >= 0.0f && p.y >= 0.0f && p.x < size.x && p.y < size.y) return true;
+ }
+ closeStrokePopup();
+ return true;
+}
+
+bool App::strokePopupItemScreen(int item, ImVec2& out) const {
+ if (!strokePopup_.open || item < 0 || item >= kStrokePopupItems) return false;
+ const StrokePopupGeometry g = popupGeometry(uiScale_);
+ const glm::vec2 c = g.itemMin(item) + g.itemSize() * 0.5f;
+ out = ImVec2(strokePopup_.at.x + c.x, strokePopup_.at.y + c.y);
+ return true;
+}
+
+void App::drawStrokePopup() {
+ const float s = uiScale_;
+ ImDrawList* fg = ImGui::GetForegroundDrawList();
+ const StrokeLatch latch = strokeLatch();
+ if (!strokePopup_.open) {
+ // A latched modifier shows beside the brush cursor: strokes do something other than sculpt.
+ const ImGuiIO& io = ImGui::GetIO();
+ if (latch != StrokeLatch::None && !io.WantCaptureMouse && canvasRect().contains(mouseX_, mouseY_) &&
+ radial_.menu < 0 && !quickMenu_.open) {
+ ImFont* font = fontSmall_ ? fontSmall_ : ImGui::GetFont();
+ const char* text = strokeLatchName(latch);
+ const ImVec2 ts = font->CalcTextSizeA(font->FontSize, FLT_MAX, 0.0f, text);
+ const ImVec2 a(mouseX_ + 14.0f * s, mouseY_ + 14.0f * s);
+ const ImVec2 b(a.x + ts.x + 12.0f * s, a.y + ts.y + 6.0f * s);
+ fg->AddRectFilled(a, b, theme::u32(theme::panelBg, 0.92f), (b.y - a.y) * 0.5f);
+ fg->AddRect(a, b, theme::u32(theme::accent), (b.y - a.y) * 0.5f, 0, 1.0f * s);
+ fg->AddText(font, font->FontSize, ImVec2(a.x + 6.0f * s, a.y + 3.0f * s), theme::u32(theme::textBright), text);
+ }
+ return;
+ }
+ if (ImGui::IsKeyPressed(ImGuiKey_Escape, false)) {
+ closeStrokePopup();
+ return;
+ }
+ const StrokePopupGeometry g = popupGeometry(s);
+ const ImVec2 o = strokePopup_.at;
+ const glm::vec2 size = g.size();
+ strokePopup_.hover = g.itemAt({mouseX_ - o.x, mouseY_ - o.y});
+ const float round = theme::rounding(6.0f * s);
+ fg->AddRectFilled(ImVec2(o.x + 2 * s, o.y + 3 * s), ImVec2(o.x + size.x + 2 * s, o.y + size.y + 3 * s),
+ IM_COL32(0, 0, 0, 90), round); // a soft shadow
+ fg->AddRectFilled(o, ImVec2(o.x + size.x, o.y + size.y), theme::u32(theme::panelBg, 0.97f), round);
+ fg->AddRect(o, ImVec2(o.x + size.x, o.y + size.y), theme::u32(theme::border), round, 0, 1.0f);
+
+ ImFont* small = fontSmall_ ? fontSmall_ : ImGui::GetFont();
+ ImFont* tiny = fontTiny_ ? fontTiny_ : small;
+ auto header = [&](bool modifiers, const char* title, const char* note) {
+ const float y = o.y + g.sectionTop(modifiers);
+ const float ty = y + (g.header - small->FontSize) * 0.5f - 1.0f * s;
+ fg->AddText(small, small->FontSize, ImVec2(o.x + g.pad, ty), theme::u32(theme::textDim), title);
+ const ImVec2 ns = tiny->CalcTextSizeA(tiny->FontSize, FLT_MAX, 0.0f, note);
+ fg->AddText(tiny, tiny->FontSize, ImVec2(o.x + size.x - g.pad - ns.x, y + (g.header - tiny->FontSize) * 0.5f - 1.0f * s),
+ theme::u32(theme::textDim), note);
+ };
+ header(false, "Stroke", "Let go over one, or click \xc2\xb7 Esc");
+ header(true, "Modifiers", "Smooth, Mask, Select stay on");
+
+ const glm::vec2 is = g.itemSize();
+ for (int item = 0; item < kStrokePopupItems; ++item) {
+ const glm::vec2 m = g.itemMin(item);
+ const ImVec2 a(o.x + m.x, o.y + m.y), b(a.x + is.x, a.y + is.y);
+ const ImVec2 iconB(b.x, a.y + g.tile);
+ const bool stroke = strokePopupIsStroke(item);
+ const StrokeModifier mod = stroke ? StrokeModifier::Count : strokePopupModifier(item);
+ const bool on = stroke ? strokeType_ == StrokeType(item)
+ : mod == StrokeModifier::Add ? !invertToggle_
+ : mod == StrokeModifier::Sub ? invertToggle_
+ : latch == strokeModifierLatch(mod);
+ const bool hot = item == strokePopup_.hover;
+ const float r = theme::rounding(4.0f * s);
+ fg->AddRectFilled(a, b, theme::u32(hot ? theme::buttonHover : on ? theme::toggleOn : theme::tile), r);
+ fg->AddRect(a, b, theme::u32(hot || on ? theme::accent : theme::tileBorder, hot ? 1.0f : on ? 0.8f : 1.0f), r, 0,
+ (hot ? 2.0f : 1.0f) * s);
+ const char* label = stroke ? strokeTypeName(StrokeType(item)) : kModifiers[int(mod)].label;
+ if (stroke) {
+ drawStrokeIcon(fg, a, iconB, StrokeType(item));
+ } else {
+ const ModifierLook& look = kModifiers[int(mod)];
+ const float fs = g.tile * 0.42f;
+ const ImVec2 gs = ImGui::GetFont()->CalcTextSizeA(fs, FLT_MAX, 0.0f, look.glyph);
+ fg->AddText(ImGui::GetFont(), fs, ImVec2(a.x + (g.tile - gs.x) * 0.5f, a.y + (g.tile - gs.y) * 0.5f + 2.0f * s),
+ theme::u32(on ? theme::accent : theme::text), look.glyph);
+ if (*look.keys) { // the keys it stands for, in the corner
+ const ImVec2 ks = tiny->CalcTextSizeA(tiny->FontSize, FLT_MAX, 0.0f, look.keys);
+ fg->AddText(tiny, tiny->FontSize, ImVec2(b.x - ks.x - 4.0f * s, a.y + 3.0f * s), theme::u32(theme::textDim),
+ look.keys);
+ }
+ }
+ const ImVec2 ls = small->CalcTextSizeA(small->FontSize, FLT_MAX, 0.0f, label);
+ fg->AddText(small, small->FontSize, ImVec2(a.x + (is.x - ls.x) * 0.5f, iconB.y + (g.label - ls.y) * 0.5f - 2.0f * s),
+ theme::u32(on || hot ? theme::textBright : theme::textOff), label);
+ }
+ // The hovered item's line of help under the panel (Ctrl-hover help doesn't reach a foreground drawing).
+ if (strokePopup_.hover >= 0 && !strokePopupIsStroke(strokePopup_.hover)) {
+ const char* help = kModifiers[int(strokePopupModifier(strokePopup_.hover))].help;
+ const ImVec2 hs = small->CalcTextSizeA(small->FontSize, FLT_MAX, 0.0f, help);
+ const ImVec2 a(o.x, o.y + size.y + 4.0f * s), b(o.x + hs.x + 14.0f * s, a.y + hs.y + 8.0f * s);
+ fg->AddRectFilled(a, b, theme::u32(theme::panelBg, 0.95f), theme::rounding(4.0f * s));
+ fg->AddText(small, small->FontSize, ImVec2(a.x + 7.0f * s, a.y + 4.0f * s), theme::u32(theme::text), help);
+ }
+}
+
+} // namespace sf
diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cpp
index 625505e2..c8b3ea99 100644
--- a/src/app/Tablet.cpp
+++ b/src/app/Tablet.cpp
@@ -225,7 +225,7 @@ float App::strokePressure() const {
return uiPrefs_.tablet.curve.apply(penTracker_.raw());
}
-SDL_Keymod App::inputMods() const {
+SDL_Keymod App::inputMods(bool latch) const {
SDL_Keymod mods = SDL_GetModState();
if (blenderStyle()) mods = blenderMods(mods); // Blender's Ctrl inverts, its Mask brush masks (Input.cpp)
if (mayaStyle()) { // Maya: Ctrl inverts (as ZBrush's Alt), Ctrl+Alt masks (as ZBrush's Ctrl)
@@ -241,6 +241,11 @@ SDL_Keymod App::inputMods() const {
if (a == PenAction::Invert) mods |= SDL_KMOD_LALT;
else if (a == PenAction::Smooth) mods |= SDL_KMOD_LSHIFT;
}
+ if (latch) { // the stroke popup's Smooth / Mask / Select (StrokePopup.cpp)
+ const StrokeLatchKeys k = strokeLatchKeys(strokeLatch());
+ if (k.shift) mods |= SDL_KMOD_LSHIFT;
+ if (k.ctrl) mods |= SDL_KMOD_LCTRL;
+ }
return mods;
}
diff --git a/src/app/UiLayout.cpp b/src/app/UiLayout.cpp
index 28ad4b0a..1c487f2d 100644
--- a/src/app/UiLayout.cpp
+++ b/src/app/UiLayout.cpp
@@ -35,7 +35,8 @@ UiLayout standardLayout() {
"draw.dynamic", "widget.dyntopo_detail", "sep",
"transform.symmetry_x", "transform.symmetry_y", "transform.symmetry_z", "transform.symmetry_radial", "sep", "draw.pressure_strength",
"draw.pressure_size", "widget.points"};
- l.leftShelf = {"widget.tile.brush", "widget.tile.stroke", "widget.tile.alpha", "widget.tile.material", "widget.color"};
+ l.leftShelf = {"widget.tile.brush", "widget.tile.stroke", "stroke.popup", "widget.tile.alpha", "widget.tile.material",
+ "widget.color"};
l.rightShelf = {"edit.undo", "edit.redo", "sep",
"view.frame", "widget.nav.move", "widget.nav.zoom", "widget.nav.rotate", "sep",
"view.polyf", "view.polygroups", "view.mask", "view.polypaint", "sep",
@@ -120,6 +121,12 @@ bool fromJson(const Json& j, UiLayout& l, std::string& error, int shellLayout) {
out.topShelf.insert(at, {"draw.dynamic", "widget.dyntopo_detail", "sep"});
}
readStrings(j["leftShelf"], out.leftShelf);
+ // Version 4 added the stroke popup's button under the Stroke tile: put it into stored left shelves.
+ if (int(j["version"].asNumber(1)) < 4 && j["leftShelf"].isArray() &&
+ std::find(out.leftShelf.begin(), out.leftShelf.end(), "stroke.popup") == out.leftShelf.end()) {
+ const auto tile = std::find(out.leftShelf.begin(), out.leftShelf.end(), "widget.tile.stroke");
+ if (tile != out.leftShelf.end()) out.leftShelf.insert(tile + 1, "stroke.popup");
+ }
readStrings(j["rightShelf"], out.rightShelf);
// Version 3 added Undo and Redo at the top of the right shelf (#43): put them into stored ones.
if (int(j["version"].asNumber(1)) < 3 && j["rightShelf"].isArray() &&
diff --git a/src/app/UiLayout.h b/src/app/UiLayout.h
index 49e22783..5d65b999 100644
--- a/src/app/UiLayout.h
+++ b/src/app/UiLayout.h
@@ -20,7 +20,8 @@ struct CanvasRect {
};
struct UiLayout {
- int version = 3; // 2: the top shelf has Dynamic; 3: the right shelf has Undo / Redo (older stored layouts get them on load)
+ int version = 4; // 2: the top shelf has Dynamic; 3: the right shelf has Undo / Redo; 4: the left shelf has the stroke
+ // popup (older stored layouts get them on load)
bool shelvesVisible = true, paletteBarVisible = true, leftHanded = false;
bool leftTrayOpen = false, rightTrayOpen = true;
float leftTrayWidth = 300, rightTrayWidth = 300; // logical px
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index fcef8be5..d1ba6d25 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -35,6 +35,9 @@
// move_view rotate_x rotate_y rotate_z rotate_view scale_x scale_y scale_z scale_uniform;
// keep: leave the button down (a shot mid-drag), then `release`
// gizmo_hover HANDLE move the mouse onto a Gizmo 3D handle (it lights up, for screenshots)
+// stroke_popup_item ITEM [click] [S] glide onto an item of the open stroke popup (dots drag_stamp slide_stamp spray
+// lazy add sub smooth mask select, or outside: just right of it); click: press and let go;
+// pen: with the pen, hovering (its tip taps for click)
// drag_landmark N DX DY [S] left-drag Make sculptable's face landmark N (0-7, FaceLandmarks order) by DX DY pixels
// orbit DX DY right-drag on the background, in pixels (with the held modifiers)
// axis_click +x|-x|+y|-y|+z|-z click that end of the axis gizmo in the canvas corner (it snaps to that side view)
@@ -129,7 +132,7 @@
// size_popup_open (the S / U / I / O slider), size_knob_x / size_knob_y (its knob, pixels),
// quickmenu_open, right_click_menu, space_camera, space_held, air_strokes, radial_open / radial_menu (-1 none) / radial_held /
// radial_hover / radial_ran (radial menus: open, the menu, held by its key or button, the
-// slot pointed at, the slot run last), radial_menus, radial_slots_N, lazy_mouse, input_style (0 ZBrush, 1 SculptForge, 2 Blender), turntable,
+// slot pointed at, the slot run last), radial_menus, radial_slots_N, stroke_popup_open / stroke_popup_held / stroke_popup_hover / stroke_popup_picked (the stroke popup: items are strokes 0-4, then Add, Sub, Smooth, Mask, Select), stroke_latch (0 none, 1 Smooth, 2 Mask, 3 Select), invert_toggle, lazy_mouse, input_style (0 ZBrush, 1 SculptForge, 2 Blender), turntable,
// camera_ortho, mask_brush (Blender's Mask brush on), shortcut_conflicts (keys two actions
// claim), brush_type (BrushType
// index, -1 for a custom brush or Paint), last_dab_x / last_dab_y (window pixels), paint_r
@@ -467,6 +470,12 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "air_strokes") return app_.uiPrefs_.airStrokes ? 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 == "stroke_popup_open") return app_.strokePopup_.open ? 1.0 : 0.0;
+ if (name == "stroke_popup_held") return app_.strokePopup_.open && app_.strokePopup_.held ? 1.0 : 0.0;
+ if (name == "stroke_popup_hover") return double(app_.strokePopup_.hover); // item: strokes 0-4, Add 5 ... Select 9
+ if (name == "stroke_popup_picked") return double(app_.strokePopup_.picked); // -1: none yet
+ if (name == "stroke_latch") return double(int(app_.strokeLatch())); // 0 none, 1 Smooth, 2 Mask, 3 Select
+ if (name == "invert_toggle") return app_.invertToggle_ ? 1.0 : 0.0;
if (name == "radial_menu") return double(app_.radial_.menu); // -1: none open
if (name == "radial_held") return app_.radial_.menu >= 0 && app_.radial_.hold != App::RadialHold::None ? 1.0 : 0.0;
if (name == "radial_hover") return double(app_.radial_.hover);
@@ -1160,6 +1169,58 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
});
}
wait(0.1f);
+ } else if (verb == "stroke_popup_item") {
+ if (!need(1)) return false;
+ static const char* kItems[] = {"dots", "drag_stamp", "slide_stamp", "spray", "lazy",
+ "add", "sub", "smooth", "mask", "select"};
+ static_assert(std::size(kItems) == size_t(kStrokePopupItems));
+ int item = w[1] == "outside" ? -2 : -1;
+ for (int i = 0; i < int(std::size(kItems)); ++i)
+ if (w[1] == kItems[i]) item = i;
+ if (item == -1) {
+ error = "unknown stroke popup item '" + w[1] + "'";
+ return false;
+ }
+ bool click = false, pen = false;
+ float seconds = 0.2f;
+ for (size_t i = 2; i < w.size(); ++i) {
+ if (w[i] == "click") click = true;
+ else if (w[i] == "pen") pen = true;
+ else seconds = num(i, seconds);
+ }
+ auto from = std::make_shared<ImVec2>();
+ auto to = std::make_shared<ImVec2>();
+ steps_.push_back([this, line, item, from, to, seconds, pen](float t) {
+ if (t == 0.0f) {
+ if (pen && !penIn_) penProximity(true);
+ *from = pen && penIn_ ? penAt_ : mouse_;
+ ImVec2 last;
+ if (!app_.strokePopupItemScreen(item == -2 ? kStrokePopupItems - 1 : item, last)) {
+ fail(line, "the stroke popup isn't open");
+ return true;
+ }
+ *to = item == -2 ? ImVec2(last.x + 120.0f * app_.uiScale_, last.y) : last;
+ }
+ const float k = std::min(t / seconds, 1.0f);
+ const ImVec2 p(from->x + (to->x - from->x) * k, from->y + (to->y - from->y) * k);
+ if (pen) penMove(p.x, p.y); // hovering, the tip up
+ else mouseMotion(p.x, p.y);
+ return t >= seconds;
+ });
+ if (click) {
+ steps_.push_back([this, pen](float t) {
+ if (t == 0.0f) return false; // a frame of hover first
+ if (pen) {
+ penTouch(true, false);
+ penTouch(false, false);
+ } else {
+ mouseButton(true, SDL_BUTTON_LEFT);
+ mouseButton(false, SDL_BUTTON_LEFT);
+ }
+ return true;
+ });
+ }
+ wait(0.1f);
} else if (verb == "drag_item") {
if (!need(3)) return false;
const std::string label = w[1];
diff --git a/src/core/StrokePopup.cpp b/src/core/StrokePopup.cpp
new file mode 100644
index 00000000..5323d359
--- /dev/null
+++ b/src/core/StrokePopup.cpp
@@ -0,0 +1,70 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "core/StrokePopup.h"
+
+#include <cmath>
+
+namespace sf {
+
+const char* strokeLatchName(StrokeLatch latch) {
+ switch (latch) {
+ case StrokeLatch::Smooth: return "Smooth";
+ case StrokeLatch::Mask: return "Mask";
+ case StrokeLatch::Select: return "Select";
+ default: return "";
+ }
+}
+
+StrokeLatchKeys strokeLatchKeys(StrokeLatch latch) {
+ switch (latch) {
+ case StrokeLatch::Smooth: return {true, false};
+ case StrokeLatch::Mask: return {false, true};
+ case StrokeLatch::Select: return {true, true};
+ default: return {};
+ }
+}
+
+StrokeLatch toggledStrokeLatch(StrokeLatch now, StrokeLatch picked) { return picked == now ? StrokeLatch::None : picked; }
+
+StrokeLatch strokeModifierLatch(StrokeModifier m) {
+ switch (m) {
+ case StrokeModifier::Smooth: return StrokeLatch::Smooth;
+ case StrokeModifier::Mask: return StrokeLatch::Mask;
+ case StrokeModifier::Select: return StrokeLatch::Select;
+ default: return StrokeLatch::None;
+ }
+}
+
+glm::vec2 StrokePopupGeometry::size() const {
+ const int cols = columns > 0 ? columns : 1;
+ const float w = 2.0f * pad + float(cols) * tile + float(cols - 1) * gap;
+ const int r = rows(kStrokePopupStrokes) + rows(kStrokePopupModifiers);
+ const float h = 2.0f * pad + 2.0f * header + float(r) * itemSize().y + float(r - 1) * gap + gap; // + the break
+ return {w, h};
+}
+
+float StrokePopupGeometry::sectionTop(bool modifiers) const {
+ if (!modifiers) return pad;
+ const int r = rows(kStrokePopupStrokes);
+ return pad + header + float(r) * (itemSize().y + gap) + gap;
+}
+
+glm::vec2 StrokePopupGeometry::itemMin(int item) const {
+ if (columns <= 0 || item < 0 || item >= kStrokePopupItems) return {-1.0f, -1.0f};
+ const bool mod = !strokePopupIsStroke(item);
+ const int i = mod ? item - kStrokePopupStrokes : item;
+ const int col = i % columns, row = i / columns;
+ return {pad + float(col) * (tile + gap), sectionTop(mod) + header + float(row) * (itemSize().y + gap)};
+}
+
+int StrokePopupGeometry::itemAt(glm::vec2 p) const {
+ if (!std::isfinite(p.x) || !std::isfinite(p.y) || columns <= 0) return -1;
+ const glm::vec2 s = itemSize();
+ for (int item = 0; item < kStrokePopupItems; ++item) {
+ const glm::vec2 a = itemMin(item);
+ if (p.x >= a.x && p.x < a.x + s.x && p.y >= a.y && p.y < a.y + s.y) return item;
+ }
+ return -1;
+}
+
+} // namespace sf
diff --git a/src/core/StrokePopup.h b/src/core/StrokePopup.h
new file mode 100644
index 00000000..9b2f38b3
--- /dev/null
+++ b/src/core/StrokePopup.h
@@ -0,0 +1,56 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// The stroke popup (Discord 11-02): one key opens a plain grid at the cursor with the stroke types and the common
+// stroke modifiers (Add / Sub, and Smooth, Mask, Select kept on without holding Shift, Ctrl or Ctrl+Shift), so a
+// stroke change needs no key combination. A flat grid, not a pie ring. Independent of SDL and ImGui so it can be
+// unit tested: the grid's geometry, which item a point is over, and the latched modifiers. The app side (opening,
+// hold-and-release, clicks, drawing) is src/app/StrokePopup.cpp.
+#pragma once
+
+#include "core/Stroke.h"
+
+#include <glm/glm.hpp>
+
+namespace sf {
+
+// A modifier kept on until it is picked again (or another brush is picked): strokes act as if its keys were held.
+enum class StrokeLatch { None, Smooth, Mask, Select };
+const char* strokeLatchName(StrokeLatch latch); // "Smooth", "Mask", "Select"; "" for None
+// The keys a latch stands for (the ZBrush meanings the sculpting code reads): Smooth = Shift, Mask = Ctrl,
+// Select = Ctrl+Shift.
+struct StrokeLatchKeys {
+ bool shift = false, ctrl = false;
+};
+StrokeLatchKeys strokeLatchKeys(StrokeLatch latch);
+// Picking the latch that is on turns it off; picking another switches to it.
+StrokeLatch toggledStrokeLatch(StrokeLatch now, StrokeLatch picked);
+
+// The grid's items: the stroke types first (item i = StrokeType(i)), then the modifiers.
+enum class StrokeModifier { Add, Sub, Smooth, Mask, Select, Count };
+constexpr int kStrokePopupStrokes = int(StrokeType::Count);
+constexpr int kStrokePopupModifiers = int(StrokeModifier::Count);
+constexpr int kStrokePopupItems = kStrokePopupStrokes + kStrokePopupModifiers;
+inline bool strokePopupIsStroke(int item) { return item >= 0 && item < kStrokePopupStrokes; }
+inline StrokeModifier strokePopupModifier(int item) { return StrokeModifier(item - kStrokePopupStrokes); }
+inline int strokePopupItem(StrokeModifier m) { return kStrokePopupStrokes + int(m); }
+StrokeLatch strokeModifierLatch(StrokeModifier m); // Smooth / Mask / Select; None for Add and Sub
+
+// Two sections, each a titled block of rows: Stroke, then Modifiers. All sizes in pixels (already scaled).
+struct StrokePopupGeometry {
+ float tile = 72.0f; // the square icon area of an item
+ float label = 30.0f; // the item's label and key hint under the icon
+ float gap = 6.0f; // between items
+ float header = 22.0f; // a section's title above its rows
+ float pad = 10.0f; // around everything
+ int columns = 5;
+
+ glm::vec2 itemSize() const { return {tile, tile + label}; }
+ int rows(int count) const { return columns > 0 ? (count + columns - 1) / columns : 0; }
+ glm::vec2 size() const; // the whole panel
+ float sectionTop(bool modifiers) const; // a section's title, from the panel's top
+ glm::vec2 itemMin(int item) const; // an item's top-left, from the panel's top-left
+ int itemAt(glm::vec2 p) const; // the item under p (panel space); -1 over a gap, a title or outside
+};
+
+} // namespace sf
diff --git a/tests/test_shell_layout.cpp b/tests/test_shell_layout.cpp
index 338f12bd..815ea754 100644
--- a/tests/test_shell_layout.cpp
+++ b/tests/test_shell_layout.cpp
@@ -8,6 +8,7 @@
#include "app/ShellGeometry.h"
+#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
@@ -159,3 +160,22 @@ TEST(shell_right_shelf_undo_redo) {
CHECK(fromJson(now, back, err));
CHECK(back.rightShelf.size() == 1);
}
+
+TEST(shell_left_shelf_stroke_popup) {
+ // The stroke popup's button sits under the Stroke tile; a layout stored before it (version < 4) gets it there.
+ const UiLayout l = standardLayout();
+ const auto tile = std::find(l.leftShelf.begin(), l.leftShelf.end(), "widget.tile.stroke");
+ CHECK(tile != l.leftShelf.end() && tile + 1 != l.leftShelf.end() && *(tile + 1) == "stroke.popup");
+ Json old = toJson(l);
+ old.set("version", 3.0);
+ old.set("leftShelf", shelfJson({"widget.tile.brush", "widget.tile.stroke", "widget.color"}));
+ UiLayout back;
+ std::string err;
+ CHECK(fromJson(old, back, err));
+ CHECK(back.leftShelf.size() == 4 && back.leftShelf[2] == "stroke.popup" && back.leftShelf[3] == "widget.color");
+ // A current layout the user took it out of stays without it.
+ Json now = toJson(l);
+ now.set("leftShelf", shelfJson({"widget.tile.stroke"}));
+ CHECK(fromJson(now, back, err));
+ CHECK(back.leftShelf.size() == 1);
+}
diff --git a/tests/test_stroke_popup.cpp b/tests/test_stroke_popup.cpp
new file mode 100644
index 00000000..9b2d5d0f
--- /dev/null
+++ b/tests/test_stroke_popup.cpp
@@ -0,0 +1,95 @@
+// SculptForge - open source digital sculpting
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+// The stroke popup (core/StrokePopup.h): the grid's geometry, which item a point is over, and the latched
+// modifiers (Smooth / Mask / Select kept on without their keys).
+#include "TestHarness.h"
+
+#include "core/StrokePopup.h"
+
+#include <cmath>
+
+using namespace sf;
+
+namespace {
+
+StrokePopupGeometry geometry() {
+ StrokePopupGeometry g;
+ g.tile = 60.0f;
+ g.label = 20.0f;
+ g.gap = 5.0f;
+ g.header = 18.0f;
+ g.pad = 8.0f;
+ g.columns = 5;
+ return g;
+}
+
+glm::vec2 centre(const StrokePopupGeometry& g, int item) { return g.itemMin(item) + g.itemSize() * 0.5f; }
+
+} // namespace
+
+TEST(stroke_popup_items) {
+ CHECK(kStrokePopupItems == int(StrokeType::Count) + 5);
+ CHECK(strokePopupIsStroke(0));
+ CHECK(strokePopupIsStroke(int(StrokeType::LazyMouse)));
+ CHECK(!strokePopupIsStroke(kStrokePopupStrokes));
+ CHECK(!strokePopupIsStroke(-1));
+ CHECK(strokePopupModifier(strokePopupItem(StrokeModifier::Mask)) == StrokeModifier::Mask);
+ CHECK(strokeModifierLatch(StrokeModifier::Add) == StrokeLatch::None);
+ CHECK(strokeModifierLatch(StrokeModifier::Sub) == StrokeLatch::None);
+ CHECK(strokeModifierLatch(StrokeModifier::Select) == StrokeLatch::Select);
+}
+
+TEST(stroke_popup_every_item_hits_itself) {
+ const StrokePopupGeometry g = geometry();
+ for (int i = 0; i < kStrokePopupItems; ++i) CHECK(g.itemAt(centre(g, i)) == i);
+ // Corners: the top-left pixel is in, the far edge is the next item's gap.
+ CHECK(g.itemAt(g.itemMin(3)) == 3);
+ CHECK(g.itemAt(g.itemMin(3) + glm::vec2(g.tile, 1.0f)) == -1);
+}
+
+TEST(stroke_popup_layout) {
+ const StrokePopupGeometry g = geometry();
+ // Strokes on the first row, left to right; the modifiers on a row of their own below a title.
+ CHECK(g.itemMin(1).x > g.itemMin(0).x);
+ CHECK(g.itemMin(1).y == g.itemMin(0).y);
+ const int add = strokePopupItem(StrokeModifier::Add);
+ CHECK(g.itemMin(add).x == g.itemMin(0).x);
+ CHECK(g.itemMin(add).y >= g.itemMin(0).y + g.itemSize().y + g.header);
+ // Everything fits inside the panel, with the padding left over.
+ const glm::vec2 size = g.size();
+ for (int i = 0; i < kStrokePopupItems; ++i) {
+ const glm::vec2 b = g.itemMin(i) + g.itemSize();
+ CHECK(b.x <= size.x - g.pad + 0.01f);
+ CHECK(b.y <= size.y - g.pad + 0.01f);
+ }
+ CHECK(std::abs(size.x - (2 * 8.0f + 5 * 60.0f + 4 * 5.0f)) < 0.01f);
+}
+
+TEST(stroke_popup_misses) {
+ const StrokePopupGeometry g = geometry();
+ CHECK(g.itemAt({-1.0f, 40.0f}) == -1);
+ CHECK(g.itemAt({2.0f, 2.0f}) == -1); // the padding
+ CHECK(g.itemAt({30.0f, g.pad + 4.0f}) == -1); // the Stroke title
+ CHECK(g.itemAt({30.0f, g.sectionTop(true) + 4.0f}) == -1); // the Modifiers title
+ CHECK(g.itemAt({g.size().x + 10.0f, 50.0f}) == -1);
+ CHECK(g.itemAt({NAN, 50.0f}) == -1);
+ CHECK(g.itemAt({INFINITY, INFINITY}) == -1);
+ StrokePopupGeometry none = g;
+ none.columns = 0;
+ CHECK(none.itemAt({30.0f, 60.0f}) == -1);
+ CHECK(none.itemMin(0).x < 0.0f);
+ CHECK(g.itemMin(kStrokePopupItems).x < 0.0f);
+}
+
+TEST(stroke_popup_latch) {
+ CHECK(toggledStrokeLatch(StrokeLatch::None, StrokeLatch::Mask) == StrokeLatch::Mask);
+ CHECK(toggledStrokeLatch(StrokeLatch::Mask, StrokeLatch::Mask) == StrokeLatch::None);
+ CHECK(toggledStrokeLatch(StrokeLatch::Mask, StrokeLatch::Smooth) == StrokeLatch::Smooth);
+ CHECK(strokeLatchKeys(StrokeLatch::None).shift == false && strokeLatchKeys(StrokeLatch::None).ctrl == false);
+ CHECK(strokeLatchKeys(StrokeLatch::Smooth).shift && !strokeLatchKeys(StrokeLatch::Smooth).ctrl);
+ CHECK(!strokeLatchKeys(StrokeLatch::Mask).shift && strokeLatchKeys(StrokeLatch::Mask).ctrl);
+ CHECK(strokeLatchKeys(StrokeLatch::Select).shift && strokeLatchKeys(StrokeLatch::Select).ctrl);
+ CHECK(std::string(strokeLatchName(StrokeLatch::Select)) == "Select");
+ CHECK(std::string(strokeLatchName(StrokeLatch::None)).empty());
+}
diff --git a/tests/ui/stroke_popup.sfui b/tests/ui/stroke_popup.sfui
new file mode 100644
index 00000000..40d21263
--- /dev/null
+++ b/tests/ui/stroke_popup.sfui
@@ -0,0 +1,127 @@
+# The stroke popup (Discord 11-02): G (J in the Blender style) opens a grid at the cursor with the stroke types and
+# the modifiers Add / Sub, Smooth, Mask, Select, the current stroke under the pointer. Hold G, point, let go:
+# picked. Tap G: it stays open; a click on a stroke picks it and closes, a click on a modifier toggles it and stays
+# open, Esc or a click beside it closes it; the click never reaches the model. Smooth, Mask and Select latch:
+# strokes act as with Shift, Ctrl or Ctrl+Shift held, until picked again or another brush is picked; a drag beside
+# the model still turns the view. A pen hovering works as the mouse. The left shelf's button opens it too. CMake
+# runs this again with the UI scaled 1.5x (ui_stroke_popup_scaled).
+run new_sphere subdivisions=4
+camera 0 0
+expect_shortcut stroke.popup G
+expect_value shortcut_conflicts == 0
+expect_value stroke_type == 0
+expect_value stroke_latch == 0
+
+# Hold G: open, held, Dots under the pointer. Point at Spray and let go: Spray.
+hover_window 0.5 0.5
+key_down g
+expect_value stroke_popup_open == 1
+expect_value stroke_popup_held == 1
+expect_value stroke_popup_hover == 0
+shot open
+stroke_popup_item spray
+expect_value stroke_popup_hover == 3
+shot hover_spray
+key_up g
+expect_value stroke_popup_open == 0
+expect_value stroke_type == 3
+expect_value stroke_popup_picked == 3
+
+# Held, then let go beside the grid after a moment: closed, nothing picked.
+hover_window 0.5 0.5
+key_down g
+stroke_popup_item outside
+wait 0.3
+key_up g
+expect_value stroke_popup_open == 0
+expect_value stroke_type == 3
+expect_value stroke_popup_picked == 3
+
+# Tapped: it stays open. A click on Dots picks it and closes; the model isn't touched.
+hover_window 0.5 0.5
+snapshot
+key g
+expect_value stroke_popup_open == 1
+expect_value stroke_popup_held == 0
+stroke_popup_item dots click
+expect_value stroke_popup_open == 0
+expect_value stroke_type == 0
+expect_value stroking == 0
+expect_value moved == 0
+
+# Modifiers: a click toggles and the grid stays open. Sub, then Mask latched; Esc closes, they stay on.
+key g
+stroke_popup_item sub click
+expect_value invert_toggle == 1
+expect_value stroke_popup_open == 1
+stroke_popup_item mask click
+expect_value stroke_latch == 2
+expect_value stroke_popup_open == 1
+shot modifiers
+stroke_popup_item select
+shot hover_select
+key escape
+expect_value stroke_popup_open == 0
+expect_value stroke_latch == 2
+
+# Mask latched: a plain stroke masks (no Ctrl held) and doesn't move the surface; the label shows at the cursor.
+expect_value masked == 0
+hover_model 0.5 0.5
+shot mask_latched
+stroke 0.3 0.5 0.7 0.5
+expect_value masked > 50
+expect_value moved == 0
+remember masked m
+# A drag beside the model turns the view (a held Ctrl would invert the mask there instead).
+remember camera_yaw yaw
+drag 0.8 0.25 0.85 0.3
+expect_value masked == $m
+expect_value camera_yaw != $yaw
+
+# Picked again: off. Add back on; a stroke sculpts again.
+key g
+stroke_popup_item mask click
+expect_value stroke_latch == 0
+stroke_popup_item add click
+expect_value invert_toggle == 0
+key escape
+
+# Picking another brush ends a latch.
+key g
+stroke_popup_item smooth click
+expect_value stroke_latch == 1
+key escape
+key 2
+expect_value stroke_latch == 0
+key 1
+
+# A pen hovering: hold G, hover over Slide Stamp, let go. Tapped open, the pen's tip taps Lazy Stroke.
+pen_hover 0.5 0.5
+key_down g
+stroke_popup_item slide_stamp pen
+expect_value stroke_popup_hover == 2
+key_up g
+expect_value stroke_type == 2
+key g
+stroke_popup_item lazy pen click
+expect_value stroke_popup_open == 0
+expect_value stroke_type == 4
+expect_value stroking == 0
+pen_out
+
+# The left shelf's button opens it (tapped open), a click on Dots closes it.
+click "Stroke popup##stroke.popup"
+expect_value stroke_popup_open == 1
+expect_value stroke_popup_held == 0
+shot from_shelf
+stroke_popup_item dots click
+expect_value stroke_popup_open == 0
+expect_value stroke_type == 0
+
+# The ZBrush style: G too. The Blender style: J (its G is the Move brush).
+input_style zbrush
+expect_shortcut stroke.popup G
+expect_value shortcut_conflicts == 0
+input_style blender
+expect_shortcut stroke.popup J
+expect_value shortcut_conflicts == 0