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.

Discord bugs for 0.10.10: frames while unfocused, Part kept after jobs, pen triple-click, stroke popup shapes

islandmed50d16cd8718a
diff --git a/changes/fix-0.10.10-discord-bugs.md b/changes/fix-0.10.10-discord-bugs.md
new file mode 100644
index 00000000..f6da3056
--- /dev/null
+++ b/changes/fix-0.10.10-discord-bugs.md
@@ -0,0 +1,35 @@
+---
+whats_new: **Shapes in the stroke popup**: press **G** and pick Mask Pen, Lasso or Rect, or Cut Line, Lasso, Rect or
+ Polyline. A plain drag then masks or cuts with that shape, no Ctrl or Ctrl+Shift held (with a mask shape on, Ctrl
+ unmasks). Pick it again to turn it off.
+whats_new: **Background jobs keep your Part**: a Quad Remesh, Voxel Remesh, Auto UV or Unwrap that finishes after you
+ picked another Part puts its result on its own Part; the Part you picked stays active.
+highlight: Mask and Cut shapes in the stroke popup, no keys held
+added: **Stroke popup > Shapes** (Discord, Darth): Mask Pen, Mask Lasso, Mask Rect, Cut Line, Cut Lasso, Cut Rect and
+ Cut Polyline. Picking one latches Mask or Select with that shape, so a plain drag masks or cuts with it; with Mask
+ latched a held Ctrl unmasks. The cursor label names the shape (e.g. "Cut Line").
+fixed: The active Part no longer switches by itself (Discord, Oslen): a background job (Quad Remesh, Voxel Remesh with
+ Keep Texture, Auto UV, UV Editor Unwrap) that finished after another Part was picked made its own Part active
+ again, and cut short a stroke in progress. Its result now goes onto its own Part, waits for a stroke to end, and
+ the status bar says where it went.
+fixed: A triple-click no longer switches the Part while a pen is in range: a Wacom side button set to Double Click
+ (the Intuos 3 default) followed by a tap counted as one (Discord, Oslen).
+fixed: With two screens, an unfocused window kept drawing only what a background job asked for: a Sculpt Timeline
+ timelapse render and the hardware calibration stopped until the pointer came back (Discord, Tiagoffcruz). Full
+ screen no longer minimises when you click on another monitor.
+fixed: A Smooth, Mask or Select latch from the stroke popup came back after picking another brush and then the first
+ one again.
+testers:
+ - Windows, two monitors: start Geometry > QRemesh on a dense mesh, click into another app on the other screen;
+ the progress keeps moving and the result appears without moving the pointer back.
+ - Windows, two monitors, full screen (F11): click on the other monitor; SculptForge stays up.
+ - Two Parts: start Quad Remesh on one, pick the other while it runs; when it finishes the second Part stays
+ active and the status bar says "(on <Part>; <other> stays the active Part)". Undo on the first Part undoes it.
+ - Wacom with the side button set to Double Click: hover the pen over another Part, press the button, tap; the
+ Part doesn't change.
+ - G > Shapes > Cut Line, then a plain drag across the model: it cuts (Tool > Cut sets Away / In / Add / Clip).
+ G > Shapes > Mask Lasso: a plain drag masks, Ctrl+drag unmasks. Pick it again: strokes sculpt.
+---
+Branch fix/0.10.10-discord-bugs. Darth's "Ctrl+Shift+drag Cut / Ctrl+drag Mask Lasso does nothing" did not reproduce
+(mouse, pen, zoomed in, both input styles, Ctrl held over the panel first: all work and are covered by ui_cut_tool,
+ui_mask_lasso, ui_stroke_popup); the reply asks him for his OS, input style and what the status bar says.
diff --git a/docs/guide/sculpting.md b/docs/guide/sculpting.md
index 017a5ebd..04bba19e 100644
--- a/docs/guide/sculpting.md
+++ b/docs/guide/sculpting.md
@@ -354,15 +354,20 @@ Notes:
### The stroke popup
Press <kbd>G</kbd> (<kbd>Z</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:
+the **Stroke** tile on the left shelf. The top row holds the stroke types, then come the modifiers and the shapes:
| 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> |
+| **Mask** | Strokes paint the mask (<kbd>Alt</kbd> or <kbd>Ctrl</kbd> unmasks). | <kbd>Ctrl</kbd> |
| **Select** | Strokes draw the selection (hide) shape. | <kbd>Ctrl</kbd>+<kbd>Shift</kbd> |
+**Shapes** pick how Mask and Select draw: **Mask Pen**, **Mask Lasso** and **Mask Rect** turn Mask on with that
+shape, **Cut Line**, **Cut Lasso**, **Cut Rect** and **Cut Polyline** turn Select on with that Cut shape. A plain drag
+then masks or cuts with it, no keys held (with a mask shape, <kbd>Ctrl</kbd>+drag unmasks; **Tool > Cut** still sets
+Away, In, Add or Clip). The label next to the brush cursor names the shape. Pick it again to go back to sculpting.
+
- **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
diff --git a/docs/guide/shortcuts.md b/docs/guide/shortcuts.md
index 4eefd4c0..66552774 100644
--- a/docs/guide/shortcuts.md
+++ b/docs/guide/shortcuts.md
@@ -134,7 +134,7 @@ generated from SculptForge's action registry, the same source as the Controls wi
| Action | Keys | What it does |
|---|---|---|
| Steady Stroke | <kbd>L</kbd> | Steady Stroke on or off, with every stroke type (Dots, Drag Stamp, Slide Stamp, Spray): the brush trails the cursor on a string and only moves once the string is taut, for steady lines without hand shake. |
-| Stroke popup | <kbd>G</kbd> | 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. |
+| Stroke popup | <kbd>G</kbd> | A grid at the cursor with the stroke types, the modifiers (Add / Sub, Smooth, Mask, Select) and the mask and Cut shapes. Hold the key, point at one and let go; or tap the key and click. Smooth, Mask, Select and the shapes stay on without holding Shift or Ctrl, until you pick them again or another brush. |
### Tool
diff --git a/src/app/App.cpp b/src/app/App.cpp
index d8fe2ad4..0d961139 100644
--- a/src/app/App.cpp
+++ b/src/app/App.cpp
@@ -103,6 +103,8 @@ bool App::init(const AppOptions& options) {
if (!options.uiTest.empty()) SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
// The pen tip's mouse events come from the app, not SDL (App::penMouseEvents, #95).
SDL_SetHint(SDL_HINT_PEN_MOUSE_EVENTS, "0");
+ // Full screen on one monitor stays up when the pointer clicks on another (Windows multi-monitor, Discord).
+ SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
if (!headless && options.demo.empty()) applyCachedThreadCount(); // the hardware profile's threads, before any brush work
if (!SDL_Init(SDL_INIT_VIDEO)) {
SDL_Log("SDL_Init failed: %s", SDL_GetError());
@@ -138,6 +140,8 @@ bool App::init(const AppOptions& options) {
return false;
}
wintab_.open(window_); // Windows: pressure from a tablet driver without Windows Ink (Wintab.h)
+ // Focused from the start when the window system says so: the FOCUS_GAINED event can come before the loop runs.
+ windowFocused_ = (SDL_GetWindowFlags(window_) & SDL_WINDOW_INPUT_FOCUS) != 0;
if (rememberWindow_) { // #35: where and how big it was last time
if (saved.placed) SDL_SetWindowPosition(window_, saved.x, saved.y);
if (restoresFullscreen(saved.fullscreen)) SDL_SetWindowFullscreen(window_, true);
@@ -627,6 +631,7 @@ bool App::wantsFrames(double now) const {
!dabQueue_.empty() || // a stroke's dabs still waiting (drainStrokeDabs) are placed a few each frame
strokeFinishing_ || solverBusy() || // the solver thread is placing a stroke's dabs (AsyncStroke.cpp)
backgroundBusy() || playingLayer_ >= 0 || faceTakePlaying_ ||
+ timelapseBusy() || hardwareCalibrating() || // both render a step per frame: they stop when the frames do
spaceMouseMoving() || // a held SpaceMouse cap sends no events, but the view keeps moving (SpaceMouse.cpp)
perf_.framesStill < 10; // the view just moved: Fast Navigation's full-quality frame comes after it stops
}
@@ -1444,8 +1449,10 @@ void App::onMouseDown(float x, float y, Uint8 button) {
if (captureMouseDown(x, y)) return; // Capture from view: the drag draws the square (PanelKelvinlet.cpp)
// A triple-click on another SubTool makes it the active one and frames it (#43). (Its first two clicks
// don't sculpt it: brushes work on the active SubTool only.)
- // Not from a pen: quick taps of a stippling pen counted as a triple-click and switched the Part.
- if (mouseClicks_ >= 3 && !lastInputPen_ && !wintabPen_ && !(mod & (SDL_KMOD_SHIFT | SDL_KMOD_CTRL | SDL_KMOD_ALT | SDL_KMOD_GUI)) &&
+ // Not from a pen: quick taps of a stippling pen counted as a triple-click and switched the Part. Nor while
+ // a pen hovers: a Wacom side button set to Double Click (the Intuos 3 default) and a tap made one (Discord).
+ const bool penNear = penInProximity_ && SDL_GetTicksNS() - lastPenNs_ < 1000000000ull;
+ if (mouseClicks_ >= 3 && !lastInputPen_ && !wintabPen_ && !penNear && !(mod & (SDL_KMOD_SHIFT | SDL_KMOD_CTRL | SDL_KMOD_ALT | SDL_KMOD_GUI)) &&
insertType_.empty() && doc_.subtoolCount() > 1) {
const int target = pickSubtool(x, y);
if (target >= 0 && target != doc_.activeSubtool) {
diff --git a/src/app/App.h b/src/app/App.h
index c8018048..dc97a3e8 100644
--- a/src/app/App.h
+++ b/src/app/App.h
@@ -602,6 +602,8 @@ private:
// The Cut shapes share the Ctrl+Shift drag with SelectRect / SelectLasso (PanelCut.cpp).
enum class SelectShape { Pen, Lasso, Rect, CutLine, CutLasso, CutRect, CutPolyline };
static bool isCutShape(SelectShape s) { return s >= SelectShape::CutLine; }
+ static SelectShape selectShapeOf(StrokeShape shape); // the stroke popup's shapes (StrokePopup.cpp)
+ bool strokeShapeOn(StrokeShape shape) const; // its latch is on with this shape
enum class SelectTarget { Hide, Mask };
void beginSelection(float x, float y, SelectTarget target, SelectShape shape);
void selectionMove(float x, float y);
@@ -1244,6 +1246,20 @@ private:
float subtoolClickX_ = 0.0f, subtoolClickY_ = 0.0f;
Uint64 subtoolClickNs_ = 0; // when the Alt press on another Part began (a long pen press isn't a click)
void partSelected(const char* how);
+ // A background job's result (Auto UV, Voxel Remesh, QRemesh, Unwrap) goes onto the Part it ran on, and the
+ // active Part stays the one the user is on (Discord: "the active Part switches by itself" when a job finished
+ // after picking another Part). JobPart makes the job's Part active for the result; its destructor goes back
+ // and the status bar says where the result went. Results wait while a stroke is on (jobWaitsForStroke).
+ struct JobPart {
+ JobPart(App& app, int index);
+ ~JobPart();
+ JobPart(const JobPart&) = delete;
+ JobPart& operator=(const JobPart&) = delete;
+ App& app;
+ uint32_t back = 0;
+ bool switched = false;
+ };
+ bool jobWaitsForStroke() const;
Uint64 clickClockNs() const; // the status bar names the new active Part and how it was chosen
uint32_t renamingSubtool_ = 0; // SubTool id being renamed inline (0: none)
uint32_t listedActiveSubtool_ = 0; // the list scrolls to the active SubTool when it changes
@@ -2028,6 +2044,7 @@ private:
void registerTimelineUiActions(); // view.timeline, timeline.timelapse, help.benchmark
void startTimelapse(const std::string& path, int width, int height, float seconds, int fps);
bool timelapseStep(double budgetSeconds); // renders frames for up to the budget; false when finished
+ bool timelapseBusy() const; // a timelapse is rendering (a few frames each app frame)
int runTimelapseCli(); // sculptforge FILE --timelapse out.mp4
void startProofMode(); // Help > Benchmark, sculptforge --benchmark
bool proofSkippedScenes() const; // the benchmark skipped a scene: too little free memory
diff --git a/src/app/PanelRetopo.cpp b/src/app/PanelRetopo.cpp
index 80dd0e47..95a2168e 100644
--- a/src/app/PanelRetopo.cpp
+++ b/src/app/PanelRetopo.cpp
@@ -254,6 +254,7 @@ void App::pollVoxelRemesh() {
status_ = "Voxel Remesh (keeping the texture): " + std::to_string(int(voxelRemesh_->progress->load() * 100.0f)) + "%";
return;
}
+ if (jobWaitsForStroke()) return; // (the result lands when the stroke ends)
const std::unique_ptr<VoxelRemeshJob> job = std::move(voxelRemesh_);
if (!job->done.get()) {
status_ = *job->error;
@@ -266,8 +267,7 @@ void App::pollVoxelRemesh() {
status_ = "Voxel Remesh skipped: the Part changed while it was being remeshed";
return;
}
- if (index != doc_.activeSubtool) doc_.selectSubtool(index);
- if (doc_.sculptor.strokeActive()) endStroke();
+ const JobPart part(*this, index);
doc_.replaceMeshUndoable(std::move(*job->result), "Remesh"); // as the remesh command
CommandResult r{true, "Remeshed to " + std::to_string(doc_.mesh.triangleCount()) + " triangles" + *job->note};
if (const std::string notice = doc_.takeNotice(); !notice.empty()) r.message += ". " + notice; // levels dropped
@@ -289,6 +289,7 @@ void App::pollQRemesh() {
status_ = "Quad Remesh: " + std::to_string(int(qremesh_->progress->load() * 100.0f)) + "%";
return;
}
+ if (jobWaitsForStroke()) return; // (the result lands when the stroke ends)
const std::unique_ptr<QRemeshJob> job = std::move(qremesh_);
if (!job->done.get()) {
status_ = *job->error;
@@ -302,8 +303,7 @@ void App::pollQRemesh() {
status_ = "Quad Remesh skipped: the Part changed while it was being remeshed";
return;
}
- if (index != doc_.activeSubtool) doc_.selectSubtool(index);
- if (doc_.sculptor.strokeActive()) endStroke();
+ const JobPart part(*this, index);
lastQRemeshStats_ = *job->stats;
haveQRemeshStats_ = true;
CommandResult r{true, applyQRemesh(doc_, std::move(*job->result), job->keepOriginal, *job->stats) + *job->textureNote};
diff --git a/src/app/PanelSubTools.cpp b/src/app/PanelSubTools.cpp
index b52559da..d9482f58 100644
--- a/src/app/PanelSubTools.cpp
+++ b/src/app/PanelSubTools.cpp
@@ -146,6 +146,24 @@ void App::partSelected(const char* how) {
status_ = "Active Part: " + doc_.activeSubtoolInfo().name + " (" + how + ")";
}
+App::JobPart::JobPart(App& a, int index) : app(a) {
+ if (index < 0 || index == app.doc_.activeSubtool) return;
+ back = app.doc_.activeSubtoolInfo().id;
+ switched = true;
+ app.doc_.selectSubtool(index);
+}
+
+App::JobPart::~JobPart() {
+ if (!switched) return;
+ const std::string done = app.doc_.activeSubtoolInfo().name;
+ const int i = app.doc_.subtoolIndex(back);
+ if (i < 0 || i == app.doc_.activeSubtool) return;
+ app.doc_.selectSubtool(i);
+ app.status_ += " (on " + done + "; " + app.doc_.activeSubtoolInfo().name + " stays the active Part)";
+}
+
+bool App::jobWaitsForStroke() const { return drag_ == Drag::Stroke || doc_.sculptor.strokeActive() || !dabQueue_.empty(); }
+
void App::updateSubtoolThumbnails() {
// #43: what each SubTool looks like now; the schedule picks at most one to render this frame, from the GPU
// buffers syncScene just brought up to date (never a CPU render, never a re-upload: cheap on 30M+ meshes).
diff --git a/src/app/PanelTexture.cpp b/src/app/PanelTexture.cpp
index fb38f86d..a667b336 100644
--- a/src/app/PanelTexture.cpp
+++ b/src/app/PanelTexture.cpp
@@ -223,6 +223,7 @@ void App::pollAutoUv() {
status_ = "Auto UV: " + std::to_string(int(autoUv_->progress->load() * 100.0f)) + "%";
return;
}
+ if (jobWaitsForStroke()) return; // (the result lands when the stroke ends)
const std::unique_ptr<AutoUvJob> job = std::move(autoUv_);
const bool makeTexture = std::exchange(textureAfterAutoUv_, false);
if (!job->done.get()) {
@@ -237,8 +238,7 @@ void App::pollAutoUv() {
status_ = "Auto UV skipped: the mesh changed while it was being unwrapped";
return;
}
- if (index != doc_.activeSubtool) doc_.selectSubtool(index);
- if (doc_.sculptor.strokeActive()) endStroke();
+ const JobPart part(*this, index);
Mesh m = doc_.mesh;
// A painted texture and its layers move onto the new UVs, in the same undo step (core/TextureTransfer.h).
const std::string note = setUvsKeepingTexture(m, std::move(job->result->uvs));
diff --git a/src/app/PanelTimeline.cpp b/src/app/PanelTimeline.cpp
index 92b709ce..32d3dc3a 100644
--- a/src/app/PanelTimeline.cpp
+++ b/src/app/PanelTimeline.cpp
@@ -232,6 +232,8 @@ void App::startTimelapse(const std::string& path, int width, int height, float s
status_ = "Rendering the timelapse...";
}
+bool App::timelapseBusy() const { return timelineUi_ && timelineUi_->job; }
+
bool App::timelapseStep(double budgetSeconds) {
if (!timelineUi_ || !timelineUi_->job) return false;
TimelapseJob& j = *timelineUi_->job;
diff --git a/src/app/PanelUvEditor.cpp b/src/app/PanelUvEditor.cpp
index bb7d022e..7f2e08ce 100644
--- a/src/app/PanelUvEditor.cpp
+++ b/src/app/PanelUvEditor.cpp
@@ -681,6 +681,7 @@ struct UvEditorUi {
app.status_ = "Unwrapping: " + std::to_string(int(s.job->progress->load() * 100.0f)) + "%";
return;
}
+ if (app.jobWaitsForStroke()) return; // (the result lands when the stroke ends)
const std::unique_ptr<UvEditorState::Job> job = std::move(s.job);
++s.unwraps;
if (!job->done.get()) {
@@ -694,8 +695,7 @@ struct UvEditorUi {
app.status_ = "Unwrap skipped: the mesh changed while it was being unwrapped";
return;
}
- if (index != app.doc_.activeSubtool) app.doc_.selectSubtool(index);
- if (app.doc_.sculptor.strokeActive()) app.endStroke();
+ const App::JobPart part(app, index);
UvEditStep step(app.doc_, std::string("Unwrap (") + uvUnwrapMethodLabel(job->method) + ")", job->keepTexture);
mesh().uvs = std::move(job->result->uvs);
const std::string note = step.commit();
diff --git a/src/app/StrokePopup.cpp b/src/app/StrokePopup.cpp
index 5ad141a7..b7d64862 100644
--- a/src/app/StrokePopup.cpp
+++ b/src/app/StrokePopup.cpp
@@ -4,7 +4,8 @@
// 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, Z 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
+// the latched modifiers Smooth, Mask and Select, then the mask and Cut shapes (they latch Mask or Select with that
+// shape: a plain drag masks or cuts with it, Discord 11-03). 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.
@@ -40,6 +41,23 @@ constexpr ModifierLook kModifiers[] = {
"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));
+// The shapes (Discord 11-03): what they latch is in the corner, the shape under the icon.
+struct ShapeLook {
+ const char* label;
+ const char* glyph;
+ const char* kind; // "Mask" or "Cut"
+ const char* help;
+};
+constexpr ShapeLook kShapes[] = {
+ {"Pen", ICON_LC_PEN_TOOL, "Mask", "Strokes paint the mask (Ctrl erases it), no key held, until you pick it again or another brush."},
+ {"Lasso", ICON_LC_LASSO, "Mask", "A drag draws a lasso and masks inside it (Ctrl unmasks), no key held, until you pick it again."},
+ {"Rect", ICON_LC_SQUARE_DASHED, "Mask", "A drag draws a rectangle and masks inside it (Ctrl unmasks), no key held, until you pick it again."},
+ {"Line", ICON_LC_SLASH, "Cut", "A drag draws a Cut line (Alt: the other side), no key held, until you pick it again. Tool > Cut sets the mode."},
+ {"Lasso", ICON_LC_SCISSORS, "Cut", "A drag draws a Cut lasso, no key held, until you pick it again. Tool > Cut sets the mode."},
+ {"Rect", ICON_LC_SQUARE_DASHED, "Cut", "A drag draws a Cut rectangle, no key held, until you pick it again. Tool > Cut sets the mode."},
+ {"Polyline", ICON_LC_WAYPOINTS, "Cut", "Clicks place a Cut polyline's points (the first point closes it, Enter ends it), no key held."},
+};
+static_assert(std::size(kShapes) == size_t(kStrokePopupShapes));
StrokePopupGeometry popupGeometry(float s) {
StrokePopupGeometry g;
@@ -60,9 +78,10 @@ void App::registerStrokePopupActions() {
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.description = "A grid at the cursor with the stroke types, the modifiers (Add / Sub, Smooth, Mask, Select) and "
+ "the mask and Cut shapes. Hold the key, point at one and let go; or tap the key and click. Smooth, "
+ "Mask, Select and the shapes 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)
@@ -84,6 +103,24 @@ void App::setStrokeLatch(StrokeLatch latch) {
" until you pick " + strokeLatchName(latch) + " again or another brush";
}
+App::SelectShape App::selectShapeOf(StrokeShape shape) {
+ switch (shape) {
+ case StrokeShape::MaskPen: return SelectShape::Pen;
+ case StrokeShape::MaskLasso: return SelectShape::Lasso;
+ case StrokeShape::MaskRect: return SelectShape::Rect;
+ case StrokeShape::CutLine: return SelectShape::CutLine;
+ case StrokeShape::CutLasso: return SelectShape::CutLasso;
+ case StrokeShape::CutRect: return SelectShape::CutRect;
+ default: return SelectShape::CutPolyline;
+ }
+}
+
+bool App::strokeShapeOn(StrokeShape shape) const {
+ const StrokeLatch latch = strokeLatch();
+ if (latch != strokeShapeLatch(shape)) return false;
+ return (latch == StrokeLatch::Mask ? maskShape_ : hideShape_) == selectShapeOf(shape);
+}
+
void App::openStrokePopup(bool held, int key) {
if (strokePopup_.open && !strokePopup_.held) { // tapped open, its key (or the button) again: close
closeStrokePopup();
@@ -118,6 +155,20 @@ void App::pickStrokePopupItem(int item, bool close) {
closeStrokePopup();
return;
}
+ if (strokePopupIsShape(item)) { // the shape, latched: a plain drag masks or cuts with it (Discord 11-03)
+ const StrokeShape shape = strokePopupShape(item);
+ const bool off = strokeShapeOn(shape);
+ const StrokeLatch latch = strokeShapeLatch(shape);
+ (latch == StrokeLatch::Mask ? maskShape_ : hideShape_) = selectShapeOf(shape);
+ setStrokeLatch(off ? StrokeLatch::None : latch);
+ const ShapeLook& look = kShapes[int(shape)];
+ if (!off)
+ status_ = std::string(look.kind) + " " + look.label + " on: " +
+ (latch == StrokeLatch::Mask ? "drags mask without Ctrl (Ctrl unmasks)" : "drags cut without Ctrl+Shift") +
+ " until you pick it again or another brush";
+ if (close) closeStrokePopup();
+ return;
+ }
const StrokeModifier m = strokePopupModifier(item);
if (m == StrokeModifier::Add || m == StrokeModifier::Sub) {
invertToggle_ = m == StrokeModifier::Sub;
@@ -189,13 +240,19 @@ void App::drawStrokePopup() {
const float s = uiScale_;
ImDrawList* fg = ImGui::GetForegroundDrawList();
const StrokeLatch latch = strokeLatch();
+ // Another brush picked ends the latch for good: going back to the first brush doesn't bring it back.
+ if (latch == StrokeLatch::None) strokeLatch_.latch = StrokeLatch::None;
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);
+ std::string label = strokeLatchName(latch); // with the shape it draws: "Mask Lasso", "Cut Line"
+ for (int i = 0; i < kStrokePopupShapes; ++i)
+ if (StrokeShape(i) != StrokeShape::MaskPen && strokeShapeOn(StrokeShape(i)))
+ label = std::string(kShapes[i].kind) + " " + kShapes[i].label;
+ const char* text = label.c_str();
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);
@@ -221,25 +278,27 @@ void App::drawStrokePopup() {
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);
+ auto header = [&](int section, const char* title, const char* note) {
+ const float y = o.y + g.sectionTop(section);
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");
+ header(0, "Stroke", "Let go over one, or click \xc2\xb7 Esc");
+ header(1, "Modifiers", "Smooth, Mask, Select stay on");
+ header(2, "Shapes", "Drag with no key held");
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 stroke = strokePopupIsStroke(item), shape = strokePopupIsShape(item);
+ const StrokeModifier mod = stroke || shape ? StrokeModifier::Count : strokePopupModifier(item);
const bool on = stroke ? strokeType_ == StrokeType(item)
+ : shape ? strokeShapeOn(strokePopupShape(item))
: mod == StrokeModifier::Add ? !invertToggle_
: mod == StrokeModifier::Sub ? invertToggle_
: latch == strokeModifierLatch(mod);
@@ -248,19 +307,23 @@ void App::drawStrokePopup() {
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;
+ const char* label = stroke ? strokeTypeName(StrokeType(item))
+ : shape ? kShapes[int(strokePopupShape(item))].label
+ : kModifiers[int(mod)].label;
if (stroke) {
drawStrokeIcon(fg, a, iconB, StrokeType(item));
} else {
- const ModifierLook& look = kModifiers[int(mod)];
+ const char* glyph = shape ? kShapes[int(strokePopupShape(item))].glyph : kModifiers[int(mod)].glyph;
+ // The keys a modifier stands for, or what a shape does (Mask, Cut), in the corner.
+ const char* corner = shape ? kShapes[int(strokePopupShape(item))].kind : kModifiers[int(mod)].keys;
const float fs = g.tile * 0.42f;
- const ImVec2 gs = ImGui::GetFont()->CalcTextSizeA(fs, FLT_MAX, 0.0f, look.glyph);
+ const ImVec2 gs = ImGui::GetFont()->CalcTextSizeA(fs, FLT_MAX, 0.0f, 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);
+ theme::u32(on ? theme::accent : theme::text), glyph);
+ if (*corner) {
+ const ImVec2 ks = tiny->CalcTextSizeA(tiny->FontSize, FLT_MAX, 0.0f, corner);
fg->AddText(tiny, tiny->FontSize, ImVec2(b.x - ks.x - 4.0f * s, a.y + 3.0f * s), theme::u32(theme::textDim),
- look.keys);
+ corner);
}
}
const ImVec2 ls = small->CalcTextSizeA(small->FontSize, FLT_MAX, 0.0f, label);
@@ -269,7 +332,8 @@ void App::drawStrokePopup() {
}
// 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 char* help = strokePopupIsShape(strokePopup_.hover) ? kShapes[int(strokePopupShape(strokePopup_.hover))].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));
diff --git a/src/app/Tablet.cpp b/src/app/Tablet.cpp
index 5eef2ef6..2d940ec6 100644
--- a/src/app/Tablet.cpp
+++ b/src/app/Tablet.cpp
@@ -393,6 +393,8 @@ SDL_Keymod App::inputMods(bool latch) const {
}
if (latch) { // the stroke popup's Smooth / Mask / Select (StrokePopup.cpp)
const StrokeLatchKeys k = strokeLatchKeys(strokeLatch());
+ // Mask latched: the mask is what a plain drag does, so a held Ctrl unmasks (as Ctrl+Alt; Discord 11-03).
+ if (k.ctrl && !k.shift && (mods & (SDL_KMOD_CTRL | SDL_KMOD_GUI)) && !(mods & SDL_KMOD_SHIFT)) mods |= SDL_KMOD_LALT;
if (k.shift) mods |= SDL_KMOD_LSHIFT;
if (k.ctrl) mods |= SDL_KMOD_LCTRL;
}
diff --git a/src/app/UiTest.cpp b/src/app/UiTest.cpp
index 586e1b6f..9e561da8 100644
--- a/src/app/UiTest.cpp
+++ b/src/app/UiTest.cpp
@@ -36,7 +36,8 @@
// 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;
+// lazy add sub smooth mask select mask_pen mask_lasso mask_rect cut_line cut_lasso cut_rect
+// cut_polyline, or outside: just right of the panel); 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)
@@ -142,7 +143,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, 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 (the Lazy Stroke type),
+// 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, then the shapes 10-16), stroke_latch (0 none, 1 Smooth, 2 Mask, 3 Select), invert_toggle, lazy_mouse (the Lazy Stroke type),
// steady_stroke (Steady Stroke on, any type), steady_lag (px from the pointer to the brush on
// its string), steady_catch_up, world_size, world_radius_mm, draw_size_exact (px, unrounded),
// precision_active (Shift+Alt mid-stroke), precision_lag (px from the pointer to the brush),
@@ -216,7 +217,8 @@
// pen_stream ink|huion ink: the pen's events (and SDL's); huion: the driver also sends mouse events of its own
// beside the pen's, a press at each touch whose release never comes
// window_focus 1|0 the window gains or loses keyboard focus; mouse_leave: the pointer leaves the window
-// (another screen); values: focus_frames (1 while focus keeps it drawing),
+// (another screen); values: focus_frames (1 while focus keeps it drawing), wants_frames (1
+// while anything keeps the idle loop drawing: input, a job, an animation),
// pen_mouse_down, ui_left_down (the panels hold the left button), soft_cursor
// mouse_move U V a plain mouse (not the pen) moves to a point on the model, e.g. the stray mouse
// events Windows Ink sends beside the pen's
@@ -829,6 +831,7 @@ double Demo::query(const std::string& name, bool& known) const {
if (name == "panel_drag_scroll_y") return double(ui::DragScrollY()); // that panel's scroll after the last one
if (name == "drag_cursor") return double(dragCursor_); // the system cursor during the last button_drag (#88)
if (name == "viewport_cursor") return app_.cursorKind_; // the system cursor: 0 arrow, 100 crosshair (#73)
+ if (name == "wants_frames") return app_.wantsFrames(double(SDL_GetTicksNS()) * 1e-9) ? 1.0 : 0.0;
if (name == "focus_frames") return app_.focusKeepsDrawing(double(SDL_GetTicksNS()) * 1e-9) ? 1.0 : 0.0;
if (name == "pen_mouse_down") return app_.penMouseDown_ ? 1.0 : 0.0;
if (name == "ui_left_down") return ImGui::IsMouseDown(ImGuiMouseButton_Left) ? 1.0 : 0.0;
@@ -1322,8 +1325,10 @@ 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 const char* kItems[] = {"dots", "drag_stamp", "slide_stamp", "spray", "lazy",
+ "add", "sub", "smooth", "mask", "select",
+ "mask_pen", "mask_lasso", "mask_rect", "cut_line", "cut_lasso",
+ "cut_rect", "cut_polyline"};
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)
@@ -1346,7 +1351,7 @@ bool Demo::parseStep(int line, const std::vector<std::string>& w, std::string& e
if (pen && !penIn_) penProximity(true);
*from = pen && penIn_ ? penAt_ : mouse_;
ImVec2 last;
- if (!app_.strokePopupItemScreen(item == -2 ? kStrokePopupItems - 1 : item, last)) {
+ if (!app_.strokePopupItemScreen(item == -2 ? strokePopupItem(StrokeModifier::Select) : item, last)) {
fail(line, "the stroke popup isn't open");
return true;
}
diff --git a/src/core/StrokePopup.cpp b/src/core/StrokePopup.cpp
index 5323d359..d4acd22d 100644
--- a/src/core/StrokePopup.cpp
+++ b/src/core/StrokePopup.cpp
@@ -35,26 +35,34 @@ StrokeLatch strokeModifierLatch(StrokeModifier m) {
}
}
+namespace {
+
+int sectionOf(int item) { return strokePopupIsStroke(item) ? 0 : strokePopupIsShape(item) ? 2 : 1; }
+int sectionCount(int section) { return section == 0 ? kStrokePopupStrokes : section == 1 ? kStrokePopupModifiers : kStrokePopupShapes; }
+int sectionFirst(int section) { return section == 0 ? 0 : section == 1 ? kStrokePopupStrokes : kStrokePopupStrokes + kStrokePopupModifiers; }
+
+} // namespace
+
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
+ const int r = rows(kStrokePopupStrokes) + rows(kStrokePopupModifiers) + rows(kStrokePopupShapes);
+ const float h = 2.0f * pad + 3.0f * header + float(r) * itemSize().y + float(r - 1) * gap + 2.0f * gap; // + the breaks
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;
+float StrokePopupGeometry::sectionTop(int section) const {
+ float y = pad;
+ for (int s = 0; s < section && s < 2; ++s) y += header + float(rows(sectionCount(s))) * (itemSize().y + gap) + gap;
+ return y;
}
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 section = sectionOf(item);
+ const int i = item - sectionFirst(section);
const int col = i % columns, row = i / columns;
- return {pad + float(col) * (tile + gap), sectionTop(mod) + header + float(row) * (itemSize().y + gap)};
+ return {pad + float(col) * (tile + gap), sectionTop(section) + header + float(row) * (itemSize().y + gap)};
}
int StrokePopupGeometry::itemAt(glm::vec2 p) const {
diff --git a/src/core/StrokePopup.h b/src/core/StrokePopup.h
index 9b2f38b3..ea6ee80c 100644
--- a/src/core/StrokePopup.h
+++ b/src/core/StrokePopup.h
@@ -26,17 +26,27 @@ 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.
+// The grid's items: the stroke types first (item i = StrokeType(i)), then the modifiers, then the shapes.
enum class StrokeModifier { Add, Sub, Smooth, Mask, Select, Count };
+// Shapes (Discord 11-03): a mask or Cut shape picked here latches Mask or Select with that shape, so a plain drag
+// masks with it or cuts with it, no Ctrl or Ctrl+Shift held (with the Mask latch on, Ctrl unmasks).
+enum class StrokeShape { MaskPen, MaskLasso, MaskRect, CutLine, CutLasso, CutRect, CutPolyline, Count };
constexpr int kStrokePopupStrokes = int(StrokeType::Count);
constexpr int kStrokePopupModifiers = int(StrokeModifier::Count);
-constexpr int kStrokePopupItems = kStrokePopupStrokes + kStrokePopupModifiers;
+constexpr int kStrokePopupShapes = int(StrokeShape::Count);
+constexpr int kStrokePopupItems = kStrokePopupStrokes + kStrokePopupModifiers + kStrokePopupShapes;
inline bool strokePopupIsStroke(int item) { return item >= 0 && item < kStrokePopupStrokes; }
+inline bool strokePopupIsShape(int item) {
+ return item >= kStrokePopupStrokes + kStrokePopupModifiers && item < kStrokePopupItems;
+}
inline StrokeModifier strokePopupModifier(int item) { return StrokeModifier(item - kStrokePopupStrokes); }
+inline StrokeShape strokePopupShape(int item) { return StrokeShape(item - kStrokePopupStrokes - kStrokePopupModifiers); }
inline int strokePopupItem(StrokeModifier m) { return kStrokePopupStrokes + int(m); }
+inline int strokePopupItem(StrokeShape s) { return kStrokePopupStrokes + kStrokePopupModifiers + int(s); }
StrokeLatch strokeModifierLatch(StrokeModifier m); // Smooth / Mask / Select; None for Add and Sub
+inline StrokeLatch strokeShapeLatch(StrokeShape s) { return s <= StrokeShape::MaskRect ? StrokeLatch::Mask : StrokeLatch::Select; }
-// Two sections, each a titled block of rows: Stroke, then Modifiers. All sizes in pixels (already scaled).
+// Three sections, each a titled block of rows: Stroke, Modifiers, Shapes. 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
@@ -48,7 +58,7 @@ struct StrokePopupGeometry {
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
+ float sectionTop(int section) const; // a section's title (0 Stroke, 1 Modifiers, 2 Shapes), 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
};
diff --git a/tests/test_stroke_popup.cpp b/tests/test_stroke_popup.cpp
index 9b2d5d0f..d5ce6235 100644
--- a/tests/test_stroke_popup.cpp
+++ b/tests/test_stroke_popup.cpp
@@ -29,7 +29,7 @@ glm::vec2 centre(const StrokePopupGeometry& g, int item) { return g.itemMin(item
} // namespace
TEST(stroke_popup_items) {
- CHECK(kStrokePopupItems == int(StrokeType::Count) + 5);
+ CHECK(kStrokePopupItems == int(StrokeType::Count) + 5 + 7);
CHECK(strokePopupIsStroke(0));
CHECK(strokePopupIsStroke(int(StrokeType::LazyMouse)));
CHECK(!strokePopupIsStroke(kStrokePopupStrokes));
@@ -38,6 +38,15 @@ TEST(stroke_popup_items) {
CHECK(strokeModifierLatch(StrokeModifier::Add) == StrokeLatch::None);
CHECK(strokeModifierLatch(StrokeModifier::Sub) == StrokeLatch::None);
CHECK(strokeModifierLatch(StrokeModifier::Select) == StrokeLatch::Select);
+ // The shapes (Discord 11-03): the mask shapes latch Mask, the Cut shapes Select.
+ CHECK(!strokePopupIsShape(strokePopupItem(StrokeModifier::Select)));
+ CHECK(strokePopupIsShape(strokePopupItem(StrokeShape::MaskPen)));
+ CHECK(strokePopupIsShape(kStrokePopupItems - 1));
+ CHECK(!strokePopupIsShape(kStrokePopupItems));
+ CHECK(strokePopupShape(strokePopupItem(StrokeShape::CutRect)) == StrokeShape::CutRect);
+ CHECK(strokeShapeLatch(StrokeShape::MaskRect) == StrokeLatch::Mask);
+ CHECK(strokeShapeLatch(StrokeShape::CutLine) == StrokeLatch::Select);
+ CHECK(strokeShapeLatch(StrokeShape::CutPolyline) == StrokeLatch::Select);
}
TEST(stroke_popup_every_item_hits_itself) {
@@ -56,6 +65,12 @@ TEST(stroke_popup_layout) {
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);
+ // The shapes below the modifiers, under a title of their own, five to a row.
+ const int pen = strokePopupItem(StrokeShape::MaskPen), line = strokePopupItem(StrokeShape::CutLine);
+ CHECK(g.itemMin(pen).x == g.itemMin(0).x);
+ CHECK(g.itemMin(pen).y >= g.itemMin(add).y + g.itemSize().y + g.header);
+ CHECK(g.itemMin(pen + 5).y > g.itemMin(pen).y);
+ CHECK(g.itemMin(line).y == g.itemMin(pen).y);
// Everything fits inside the panel, with the padding left over.
const glm::vec2 size = g.size();
for (int i = 0; i < kStrokePopupItems; ++i) {
@@ -71,7 +86,8 @@ TEST(stroke_popup_misses) {
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({30.0f, g.sectionTop(1) + 4.0f}) == -1); // the Modifiers title
+ CHECK(g.itemAt({30.0f, g.sectionTop(2) + 4.0f}) == -1); // the Shapes 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);
diff --git a/tests/ui/background_frames.sfui b/tests/ui/background_frames.sfui
new file mode 100644
index 00000000..57725385
--- /dev/null
+++ b/tests/ui/background_frames.sfui
@@ -0,0 +1,18 @@
+# Two screens (Discord, Windows 11): with the pointer on the other screen and the focus in another app, whatever runs
+# here keeps drawing (progress bars, a remesh, a timelapse, the hardware calibration); only an idle app rests.
+run new_sphere subdivisions=6
+click "Geometry##tool.geometry"
+window_focus 0
+mouse_leave
+expect_value focus_frames == 0
+click "QRemesh/Quad Remesh"
+expect_value qremesh_running == 1
+expect_value wants_frames == 1
+wait_idle 120
+expect_status quads
+# Nothing runs now: with no focus and no pointer the app rests.
+wait 2
+expect_value wants_frames == 0
+window_focus 1
+key escape
+expect_value wants_frames == 1
diff --git a/tests/ui/job_keeps_part.sfui b/tests/ui/job_keeps_part.sfui
new file mode 100644
index 00000000..46475647
--- /dev/null
+++ b/tests/ui/job_keeps_part.sfui
@@ -0,0 +1,17 @@
+# Discord (Windows 11, Wacom): "the active Part switches by itself". A background job (here QRemesh) that finished
+# after another Part was picked made its own Part active again. Now its result goes onto its own Part, the Part the
+# user picked stays active, and the status bar says where the result went.
+run new_sphere subdivisions=6
+click "Geometry##tool.geometry"
+click "QRemesh/Quad Remesh"
+expect_value qremesh_running == 1
+# Another Part while it runs (appended: it becomes the active one).
+run subtool_append type=cube name=Cube
+expect_value active_subtool == 1
+wait_idle 120
+expect_value active_subtool == 1
+expect_status stays the active Part
+run subtool_select index=0
+expect_value quads > 100
+key ctrl+z
+expect_value quads == 0
diff --git a/tests/ui/stroke_popup.sfui b/tests/ui/stroke_popup.sfui
index 29e982f6..c17187c9 100644
--- a/tests/ui/stroke_popup.sfui
+++ b/tests/ui/stroke_popup.sfui
@@ -3,7 +3,7 @@
# 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
+# the model still turns the view. The mask and Cut shapes latch Mask or Select with that shape. 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
@@ -98,6 +98,7 @@ key escape
key 2
expect_value stroke_latch == 0
key 1
+expect_value stroke_latch == 0
# 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
@@ -113,6 +114,52 @@ expect_value stroke_type == 4
expect_value stroking == 0
pen_out
+# Shapes (Discord 11-03): a mask or Cut shape picked here latches Mask or Select with it, so a plain drag masks or
+# cuts with that shape; with the Mask latch on, Ctrl unmasks. Picked again: off.
+run mask_clear
+key x
+expect_value symmetry_x == 0
+key g
+stroke_popup_item mask_rect
+shot hover_mask_rect
+stroke_popup_item mask_rect click
+expect_value stroke_latch == 2
+expect_value mask_shape == 2
+expect_value stroke_popup_open == 1
+key escape
+expect_status Mask Rect on
+hover_model 0.5 0.5
+shot mask_rect_latched
+expect_value masked == 0
+view_drag 0.3 0.3 0.6 0.7
+expect_value masked > 100
+expect_value can_undo == 1
+remember masked r
+hold ctrl
+view_drag 0.3 0.3 0.45 0.7
+hold none
+expect_value masked < $r
+expect_value masked > 0
+run mask_clear
+# Cut Line: a plain drag across the sphere cuts it, one undo step.
+remember triangles full
+key g
+stroke_popup_item cut_line click
+expect_value stroke_latch == 3
+expect_value hide_shape == 3
+shot shapes
+key escape
+view_drag 0.25 0.3 0.75 0.7
+expect_status Cut Away
+expect_value triangles != $full
+key ctrl+z
+expect_value triangles == $full
+key g
+stroke_popup_item cut_line click
+expect_value stroke_latch == 0
+key escape
+key x
+
# 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
diff --git a/tests/ui/triple_click.sfui b/tests/ui/triple_click.sfui
index 10670fab..c803f9d5 100644
--- a/tests/ui/triple_click.sfui
+++ b/tests/ui/triple_click.sfui
@@ -18,3 +18,14 @@ expect_status Active Part: Cube
expect_value camera_distance < $far
expect_value edited_subtools == 0
shot triple_click_frame
+
+# A pen in range (Discord, Wacom Intuos 3): its side button's Double Click (the driver's default) and a tap made a
+# triple-click that switched the Part. While a pen hovers, mouse triple-clicks don't switch; once it's gone they do.
+key f
+pen_hover 0.5 0.5
+click_subtool Sphere 0.5 0.5 3
+expect_value active_subtool == 1
+pen_out
+wait 1.1
+click_subtool Sphere 0.5 0.5 3
+expect_value active_subtool == 0