Compare commits

..

12 Commits

Author SHA1 Message Date
Ian Chua fc2a88ba72 fix: isolate browser sessions in plugin ui callbacks 2026-11-19 14:26:05 +08:00
Ian Chua 113b42da33 Merge branch 'main' into fix/isolate-plugin-browser-session 2026-11-18 18:14:21 +08:00
Ian Chua 3838002bc8 feat: serialize permission grant for create and delete files (#17478)
* feat: serialize permission grant for create and delete files

* test: expect saved copytree permissions in hardlink audit test

* refactor: simplify plugin filesystem and permission handling

* fix: show triggering paths in plugin permission prompts

* fix: require subtree consent for recursive plugin deletes

* fix: tests

* fix: Windows short-path aliases in plugin audit checks

* fix: correct plugin folder permission display and consent text
2026-11-18 17:50:29 +08:00
HanifKoh 0c80c412a1 Put Prusa CORE One Overhang Speeds in the Right Slots (#17605)
PrusaSlicer's overhang_speed_0..3 count from the steepest overhang
(0% overlap) up, while Orca's overhang_1_4..4_4_speed count from the
mildest. The MK4S base preset maps them that way (_3 -> 1_4, _2 -> 2_4,
_1 -> 3_4, _0 -> 4_4), but the CORE One process presets put
PrusaSlicer's _2 and _3 overrides in the 50% and 75% slots, and the
CORE One L presets put _3 in the 50% slot. As a result steeper
overhangs could print faster than milder ones, e.g. 0.20mm STRUCTURAL
@CORE One 0.4 ran 25% overhangs at 30 mm/s and 50% overhangs at
45 mm/s.

Rename the keys to the slots the mapping gives, without changing any
value. Five CORE One MMU3 presets also wrote their own overhang speeds
in a mixed-up order, including 0 (no slowdown) for the mildest
overhangs; drop those keys so they inherit their corrected CORE One
parents. PrusaSlicer has no separate MMU3 print presets.
2026-11-18 16:40:58 +08:00
Ian Chua e740246f7e Merge branch 'main' into fix/isolate-plugin-browser-session 2026-11-04 14:42:59 +08:00
Ian Chua 20c01cfc7e Merge branch 'main' into fix/isolate-plugin-browser-session 2026-10-23 18:28:35 +08:00
Ian Chua 3ba5ddfe19 fix: Share isolated WebView sessions per plugin profile 2026-10-23 16:34:44 +08:00
Ian Chua 83de33416e Merge branch 'main' into fix/isolate-plugin-browser-session 2026-10-23 16:17:08 +08:00
Ian Chua 15030ef560 Merge branch 'main' into fix/isolate-plugin-browser-session 2026-10-16 22:23:03 +08:00
Ian Chua b29f06a0ab fix: clang-tidy 2026-10-12 18:49:28 +08:00
Ian Chua 9ec0d39592 Merge branch 'main' into fix/isolate-plugin-browser-session 2026-10-12 18:35:44 +08:00
Ian Chua 0b9b05ed85 fix: Isolate plugin's webview browser sessions 2026-10-12 16:44:24 +08:00
367 changed files with 5775 additions and 9580 deletions
+103 -33
View File
@@ -24,7 +24,9 @@ Permissions are stored per plugin key. A plugin can hold:
| Field | Kind | Governs |
| --- | --- | --- |
| `fs_read` | target list | Read-shaped filesystem events. Targets are exact paths or `<dir>/*` trees. |
| `fs_readwrite` | target list | Write-shaped and read/write filesystem events mapped to `FsReadWrite`: a write-mode `open`, rename, chmod, utime, copy, move, archive extraction, and similar. Same target matching as `fs_read`. A write-mode `open` can create a file, but this grant does not cover events mapped to `FsCreate` or `FsDelete`, which have no persistent grant list. |
| `fs_readwrite` | target list | Write-shaped and read/write filesystem events mapped to `FsReadWrite`: a write-mode `open`, rename, chmod, utime, copy, move, archive extraction, and similar. Same target matching as `fs_read`. A write-mode `open` can create a file, but this grant does not cover events mapped to `FsCreate` or `FsDelete`. |
| `fs_create` | folder list | Filesystem create events such as `os.mkdir` and `os.symlink`. |
| `fs_delete` | folder list | Filesystem delete events such as `os.remove` and `shutil.rmtree`. |
| `network_http` | target list | Network targets, consulted together with `network_socket` for both HTTP and socket events. A canonical `scheme://host` entry is host-wide and covers both layers; a URL with a path, port, query or trailing slash is exact; a bare host or legacy address tuple covers raw sockets. |
| `network_socket` | target list | The same network matching, kept as a separate list so a plugin can declare socket access without an HTTP URL. |
| `process` | target list | Process creation and process replacement: `os.system`, `subprocess.Popen`, `os.spawn*`, `os.exec*`, `pty.spawn`, `_winapi.CreateProcess`, and similar. Targets match the audited value verbatim. |
@@ -32,19 +34,24 @@ Permissions are stored per plugin key. A plugin can hold:
| `events` | target list | Audited events that expose no target, keyed as `<Category>:<event>`, for example `Socket:socket.__new__`. Matched verbatim. |
| `full_access` | boolean | Turns off the permission decision for the plugin. See "Full access". |
Filesystem create and delete events (`os.mkdir`, `os.symlink`, `tempfile.mkstemp`,
`os.remove`, `shutil.rmtree`, and similar) are audited, but they have no persistent grant
list. A `fs_read` or `fs_readwrite` grant does not cover these events, although a write grant
can create a file through `open()`. Without full access, each such
event outside an allowed root is prompted only when it can be answered inline. On the wx
main thread a Yes applies only to the operation that raised it and is not saved. Off the
main thread the event is denied immediately and an informational denial is shown instead;
there is no Yes/No prompt, no saved grant, and no promise that a later attempt will be
approved.
Create and delete grants are independent of read and read/write grants. An empty list grants
no folders; an absolute folder path grants operations directly inside that folder, while a path
ending in `/*` also covers its subfolders; a list containing only `*` grants all folders. Runtime approval stores
the parent folder of the audited target, except for a recursive delete, whose consent is
transient and is never stored. A delete grant covers existing entries in that folder,
not just entries created by the plugin. The unconditional denied paths still apply.
A recursive delete (`shutil.rmtree`) is a subtree operation: a plain folder grant is
insufficient even when it names the target folder or its parent. It requires either a saved
delete tree grant whose root covers the target, or explicit one-time consent for that canonical
subtree. A tree grant rooted exactly at the target covers the entries inside it but not the
final removal of the target folder itself, which is an entry in the parent; the operation asks
for consent unless the parent is granted separately. The consent applies only to the operation
that requested it and the nested deletes it performs inside that subtree.
### Target matching
- Exact filesystem entries match the audited path verbatim. An absolute exact entry also
- Read and read/write exact filesystem entries match the audited path verbatim. An absolute exact entry also
matches an equivalent canonical path, including a symlink alias or a relative target resolved
against the current working directory. Relative exact entries match only verbatim, so their
equivalence scope cannot move with the working directory. Canonical equivalence fails closed
@@ -56,6 +63,23 @@ approved.
root must be absolute on the current platform: a relative root never matches, even when a
target is spelled exactly like the entry, so the scope cannot float with the process
working directory.
- Create and delete folder grants compare canonical parent directories; a final symlink is
governed by the folder containing the link. Link creation checks the destination folder;
a hardlink also requires write access to its source because writes through either name
affect the same file. Both source and destination remain
subject to the denied-path check. An unresolved parent
does not match a folder grant. Recursive deletion is checked as a subtree operation: an
exact folder grant does not cover it, but a delete tree grant does, and a one-time consent
covers the target subtree for that operation only. A target-rooted tree grant covers the
entries inside the target but not removing the target folder itself; that final removal needs
a grant for the containing folder or one-time consent. Nested delete entries inside an
approved subtree are allowed while the operation runs, provided they stay inside the canonical
subtree and are reached through standard-library frames. Scope is decided by the entry's
containing folder: deleting a symlink acts on the link entry, never on its destination.
Intermediate `..` components are resolved after symlinks, never lexically folded before
them, and a final `..` fails closed. A
symlink or `..` that would leave the subtree is judged on its own, and denied paths stay
blocked.
- Network entries can be an HTTP URL, a canonical `scheme://host`, a bare host, a
`host:port` pair, or a legacy persisted address tuple such as `('host', 443)`.
`normalize_network_url` reduces a URL to lowercase `scheme://host`; path, query,
@@ -101,10 +125,12 @@ order:
before allowed roots, before a granted operation and before full access, so no grant
can make a denied path reachable.
2. **Covered by a granted operation.** When a granted root operation is still running,
nested events raised through its standard-library frames are allowed without another
prompt. The coverage is bounded to the operation frame and does not extend to plugin
or third-party frames it calls back into. A nested `urllib.Request` is judged on its
own URL, including when it follows a redirect.
nested events raised through its standard-library frames are generally allowed without
another prompt. Delete operations still check nested delete events against their
own grants, or against the canonical subtree recorded by a one-time recursive-delete
consent started by this operation. The coverage is bounded to the operation frame and does
not extend to plugin or third-party frames it calls back into. A nested `urllib.Request`
is judged on its own URL, including when it follows a redirect.
3. **Implicit allowed root or standard-library read.** A filesystem target inside an
allowed root is allowed; a read of the interpreter's standard library is also allowed.
See "Implicit access".
@@ -143,18 +169,17 @@ An event that is not covered by a saved grant or an implicit rule is either put
user or denied. If the caller is on the wx main thread and no audit prompt is active, the
modal runs inline. Otherwise, as on the Script workflow, the plugin-load worker, or the
slicing worker, the current event is denied and the prompt is queued for the GUI thread.
`AuditPromptQueue` serializes every audit prompt -- runtime events, create/delete
informational denials, and load-time declarations -- so at most one is shown at a time,
`AuditPromptQueue` serializes runtime prompts, one-time recursive-delete consent, and
load-time declarations, so at most one is shown at a time,
including during a modal dialog's nested event loop. An event raised inside that loop is
queued and denied instead of opening a second dialog; the queued prompt opens after the
active dialog has closed.
For a category with a persistent grant list, a Yes saves the grant and a later matching
attempt can succeed without another prompt. Create and delete do not support persistent
grants: they use the inline Yes/No prompt only when it can be shown immediately on the GUI
thread, while a queued request for them is an OK-only informational denial with no Yes/No
choice. Blocking a worker on a marshalled modal is avoided because the UI thread can itself
be parked on the slicing worker. A load worker does block on its declared-permission answer:
attempt can succeed without another prompt. Create and delete approvals save the target's
parent folder, so a worker can retry after the queued Yes. Recursive delete instead uses
one-time consent, as described below. Blocking a worker on a marshalled modal is avoided
because the UI thread can itself be parked on the slicing worker. A load worker does block on its declared-permission answer:
shutdown or plugin unload cancels queued requests and active requests whose accepted answer
has not begun committing, releasing waiting workers with a denial. An admission that races
that cancellation is discarded as soon as it becomes visible. A cancelled load stops being
@@ -164,10 +189,27 @@ screen, but its answer is ignored unless committing won the race. An ordinary lo
a cancellation: its queued runtime prompt stays actionable, so the user can approve the event
whose denial aborted the load and then retry with the saved grant.
Runtime approvals store the target observed by the audit hook. A URL with a path, port or
Runtime approvals store the target observed by the audit hook, except that create and delete
approvals store its parent folder. A URL with a path, port or
query is therefore an exact grant; a bare host remains usable for raw sockets. The
declared form and the runtime form are not normalized by the same code path.
A recursive delete is different: a Yes grants consent for the canonical target subtree for
that operation only. The prompt shows the subtree root and states that the consent is not
saved; a filesystem, drive, or network share root gets an explicit warning that its whole
filesystem, drive, or network share is covered. Nested deletes inside that subtree proceed
during the same operation; after it ends, the same target asks again. Denied paths stay blocked
throughout. When the prompt cannot run inline, the current attempt is denied and a Yes from the
posted dialog is kept as a short-lived, single-use approval bound to the plugin key and
canonical target. The posted prompt says it applies to the next matching attempt within one
minute after approval; the next matching attempt consumes it. A different plugin, a different
target, a reused or an expired approval does not. A prompt already open for the same plugin and
target is not posted again, so a retry loop cannot queue duplicate dialogs. The pending-prompt
set is bounded; at capacity, new prompts are denied rather than evicting a dialog that is
already queued. A permission edit, revocation, or reinstall invalidates the plugin's transient
approvals and pending prompt keys; a dialog callback already queued becomes a no-op instead of
recreating a stale approval.
## Implicit access
Some access needs no grant because it is part of the plugin system's normal operation:
@@ -180,6 +222,12 @@ Some access needs no grant because it is part of the plugin system's normal oper
- A per-call scoped root can be added. The G-code post-process hook grants the folder
containing the exported G-code file so the plugin can edit it; the root is scoped to
that call.
- A delete inside a writable allowed root is scoped by the entry's containing folder. Deleting
a symlink that lives in the root is therefore implicit even when the link points outside,
because the operation removes the link entry; an outside link that points into the root is
not implicit. A recursive delete inside a writable root records its target subtree as the
running operation, so its fd-based reads do not trigger a separate prompt and its nested
deletes cannot leave that subtree.
### Denied paths
@@ -198,8 +246,10 @@ The following are denied before any allowed root or full-access check:
## Persistence and editing
Grants and install state live in `.install_state.json` in the plugin root. The
`permissions` object stores `fs_read`, `fs_readwrite`, `network_http`,
`network_socket`, `process`, `threading`, `events`, and `full_access`. The file is
`permissions` object stores `fs_read`, `fs_readwrite`, `fs_create`, `fs_delete`, `network_http`,
`network_socket`, `process`, `threading`, `events`, and `full_access`. It never stores a
recursive-delete consent: that approval and any retry approval are in memory only, so accepting
one does not widen the plugin's saved delete scope. The file is
written by `write_install_state`, the single writer for the sidecar schema. In-process
reads and read-modify-write operations are synchronized. Writes prepare a complete
replacement in the plugin directory and replace the sidecar only after the write succeeds.
@@ -253,7 +303,8 @@ targets; unchanged entries, including grants written by an older release, are ca
byte-for-byte. New filesystem targets must be absolute on the current
platform: a POSIX path starts at `/`, and a Windows path names a drive plus root or a UNC
share. A `*` is accepted only as the final `/*` of a folder tree, and `..` components are
refused. The matcher also refuses to widen a relative tree root, so a relative tree entry
refused for filesystem grants. Create and delete use absolute folder paths, optional final `/*`
tree grants, or the all-folders mode. The matcher also refuses to widen a relative tree root, so a relative tree entry
saved by hand or carried over from an older release never authorizes. New network targets
must be a full `http://` or `https://` URL; the writer stores `normalize_network_url`'s canonical
lowercase `scheme://host`, dropping port, path, query and fragment. Bare hosts, other
@@ -265,6 +316,11 @@ while full access is on are inert and apply again when full access is off. Turni
on does not delete the stored lists. A permission change affects subsequent audit decisions,
not operations already authorized.
The dialog also asks for confirmation before granting create or delete access to all folders.
On Linux and macOS, create and delete operations using a directory file descriptor are checked
against its resolved path. If that path cannot be resolved, the operation is denied, even with
full access.
## Full access
Full access is a per-plugin boolean that turns off the permission decision. It does not
@@ -312,6 +368,17 @@ never treated as an opt-out.
- **Denied paths are a direct-access block.** Path laundering through a symlink,
hardlink, subprocess, or Windows 8.3 short name is outside the model. A tree grant is
canonicalized for matching, but the deny check itself is base-name and component based.
- **A recursive delete stops at a denied path.** Consent for the subtree does not override the
deny registry. A protected entry inside the tree makes `shutil.rmtree` fail with
`PermissionError` (or be skipped by `ignore_errors`), leaving that entry and any unvisited
entries in place. This is deliberate: protected paths stay protected.
- **fd-based recursive deletes expose only partial paths.** `shutil.rmtree` reads with
`os.scandir(fd)` and opens entries with `dir_fd`; those audit events carry an integer
descriptor or a relative name rather than the full path. The running operation frame covers
them normally, and each relative entry name is still checked, so denied entries stay blocked.
A relative `os.open` target is canonicalized against the process working directory, so a
working directory containing a denied keyword can over-block nested opens. That fails closed
and does not widen access.
- **`data_dir()` is shared and writable.** Every plugin can write anywhere in the
application data directory, including other plugin package files. Only the
install-state sidecar and the denied names and keywords are blocked there.
@@ -325,18 +392,21 @@ never treated as an opt-out.
be re-entered as an absolute path to take effect.
- **An off-main-thread prompt denies the current event.** A persistable grant is saved
only if the user later accepts, so the first attempt from a worker fails with
`PermissionError`. Create and delete have no persistable grant and no retryable approval:
off the main thread they are denied and only an informational denial is shown, while the
inline main-thread prompt covers only the operation that raised it.
- **A running root operation is not re-evaluated.** Revoking full access or changing a
grant affects later top-level operations, not an operation whose root frame already
recorded coverage.
`PermissionError`; a later attempt can succeed after approval. A recursive-delete consent is
instead kept as a short-lived, single-use retry approval bound to the plugin and canonical
target, valid for the next matching attempt within one minute after approval, and is never
persisted. Duplicate prompts for the same plugin and target are not posted.
- **A running root operation is generally not re-evaluated.** Revoking full access or changing a
grant affects later top-level operations, not an operation whose root frame already recorded
coverage. Nested delete events within a delete operation are checked separately, or covered
by the one-time subtree consent recorded on that operation.
## File and symbol map
- `src/slic3r/plugin/PluginAuditManager.hpp` / `.cpp` - `PluginAuditManager`,
`install_hook`, `audit_plugin_event`, `decide_audited_event`, `request_permissions`,
`request_permission`, `AuditPromptQueue`, `check_path_access`,
`request_permission`, `request_recursive_delete_consent`, `delete_target_inside_approved_subtree`,
`delete_target_inside_writable_allowed_root`, `AuditPromptQueue`, `check_path_access`,
`network_permission_matches`, `default_denied_filenames`, `default_denied_path_keywords`,
`ScopedPluginAuditContext`.
- `src/slic3r/plugin/PluginFsUtils.hpp` / `.cpp` - `PluginPermissions`,
+5 -4
View File
@@ -144,11 +144,12 @@ A consequence of running Script on a non-main thread: the audit permission promp
the main thread. `request_permission` in `src/slic3r/plugin/PluginAuditManager.cpp` queues the dialog
for the GUI thread and denies the current event. For permissions with persistent grants, accepting
the prompt saves a grant for a later attempt, so a Script sees a denial on the first attempt and can
succeed on a later one. Create and delete have no persistent grant: an asynchronous denial instead
shows an informational dialog, without offering an approval and without promising a retry. This
matches the behavior for the plugin-load worker and the slicing worker.
succeed on a later one. Create and delete approvals save the target's parent folder in the same way.
Recursive-delete consent is instead a one-time approval for the next matching attempt within one
minute, bound to the plugin and canonical target. It is never saved. The plugin-load worker and the
slicing worker follow the same behavior.
`AuditPromptQueue` serializes runtime prompts, informational denials and load-time declared-permission
`AuditPromptQueue` serializes runtime prompts, recursive-delete consent and load-time declared-permission
prompts. Only one is shown at a time, including during a modal dialog's nested event loop. A load
worker waits for its declared-permission answer; shutdown or plugin unload cancels pending requests
and active requests whose accepted answers have not started committing, releasing waiting workers
+6 -208
View File
@@ -1,32 +1,12 @@
# Tooltip illustrations
Three sets of tooltips carry a picture under their text: a still image, or a short animation that
loops while the tooltip is open.
- The texture-displacement panel's settings. Several of them describe a shape rather than a number -
what Rotation turns, what Tile repeats, what Invert turns inside out - and a sentence about a shape
is read twice and understood once.
- The tools of the toolbar over the 3D view: the gizmos, and the main and assemble view tools before
them (Add, Add plate, Orient, Arrange, the instance and split tools, Variable layer height, Assembly
view). A tool's name says little about what it does until it has been used once, and an icon even
less; a few seconds of the tool at work says it outright.
- The controls in every other gizmo's panel: Move, Rotate and Scale, Cut, Mesh Boolean, the painting
tools, Text and SVG, Measure and Assemble, Simplify and Brim Ears. Pictures go only to the controls
that are a shape, a placement or a behaviour; a number or a plain on/off gets text alone.
Both go through `slic3r/GUI/IllustratedTooltip.hpp`, which keeps the part that has to stay the same
everywhere: when a tooltip appears, and how its pictures are decoded and played. Where it goes and how
wide it is are left to the owner.
The wx windows - the settings tabs, the sidebar, dialogs - have tooltips of the same kind, drawn by
`slic3r/GUI/IllustratedTipPopup.hpp` instead of ImGui; see [The wx tooltips](#the-wx-tooltips). The two
share the picture struct (`IllustratedTooltip::Media` is `TipMedia`), the decoder and the timing, so a
picture looks and plays the same in both.
The texture-displacement panel's tooltips can carry a picture under their text: a still image, or a
short animation that loops while the tooltip is open. Several settings in that panel describe a shape
rather than a number - what Rotation turns, what Tile repeats, what Invert turns inside out - and a
sentence about a shape is read twice and understood once.
## Where a tooltip is drawn
### The texture-displacement panel
`GLGizmoTextureDisplacement::panel_tooltip()` replaces `ImGuiWrapper::tooltip()` throughout the panel.
It differs in two ways.
@@ -45,49 +25,9 @@ tooltip near the bottom edge on screen.
It also gives the tooltip a fixed width rather than one derived from its text, because a picture has
to be laid out against something, and a column of tooltips that are all one width is steadier to read.
### The gizmo toolbar
`GLGizmosManager::render_toolbar_tooltip()` draws the tooltip of the toolbar icon under the pointer,
in place of the one-line name `GLCanvas3D`'s own tooltip used to show for it. It goes under the icon,
centred on it and kept inside the canvas, so reading along the toolbar never covers the next icons.
It shows the tool's name and shortcut in bold, a sentence on what the tool is for, and one picture -
three, captioned, for Mesh Boolean's three operations. When the tool cannot be opened yet, the reason
`get_name()` gives for that follows the name, dimmed.
The text and pictures for each tool are a table in `GLGizmosManager.cpp` (`toolbar_tip()`), keyed by
the gizmo type, next to the list of gizmos it describes.
The tools before the gizmos belong to `GLCanvas3D`'s main and assemble view toolbars, and
`GLCanvas3D::_render_toolbar_tooltip()` gives them the same tooltip, from a table keyed by the tool's
name (`toolbar_item_tip()`). The title is the tool's existing tooltip, shortcuts included, so its
wording and translations stay as they were. A tool whose menu is open under it (Arrange, Variable layer
height) keeps the plain tooltip, which would otherwise land on its own menu. From the moment the pointer
reaches a tool with a picture, the plain tooltip that follows the mouse is held back, also during the
wait, so the two never take turns.
### The gizmo panels
`GLGizmoBase::panel_tooltip()` is called right after the control it explains, on every frame, and
checks the hover itself, so a panel needs no `if (IsItemHovered())` around it. It goes through
`IllustratedTooltip::item_tooltip()`, which places the tooltip beside the panel's root window - to the
right, or to the left when there is no room - level with the control. `GizmoObjectManipulation`, which
draws the Move, Rotate and Scale panels but is not a gizmo, calls `item_tooltip()` directly.
`slider_with_tooltip()` covers ImGuiWrapper's sliders, whose last item is the edit button beside the
slider rather than the slider itself.
The hover test allows disabled items, since a control that cannot be used is the one whose tooltip
has to say why. For the same reason the tooltip resets the style alpha that `disabled_begin()` halves,
and it pushes the tooltip colours itself (`ImGuiWrapper::push_tooltip_style()`), because a call from
inside a combo or popup would otherwise inherit that popup's light background under the tooltip's text.
The painting tools share one table of text and pictures, `GLGizmoPainterBase::painter_tooltip()`, so a
tool that appears in several of the four panels reads the same in all of them.
## Where the pictures live
`resources/images/texture_displacement/`, `resources/images/gizmo_toolbar/` and
`resources/images/gizmos/<panel>/`, as PNG, JPG, BMP or GIF; the folder is given when the
`IllustratedTooltip` is made, and the panels name their files with the subfolder (`"cut/connector_plug.png"`). A tooltip names them by file:
`resources/images/texture_displacement/`, as PNG, JPG, BMP or GIF. A tooltip names them by file:
```cpp
hover_tip(_u8L("Repeats the texture across the painted area. ..."),
@@ -130,12 +70,7 @@ same frame again.
## Decoding and playback
`slic3r/GUI/AnimatedTexture.hpp` decodes a file once (`decode_illustration()`, which the wx tooltips
use too) and uploads one GL texture per frame. The wx tooltips scale the decoded frames to the size they
are drawn at, in physical pixels, and play them on their own timer, rather than through
`wxAnimationCtrl`, which draws at the file's size, plays a native animation on GTK that does not
reliably restart from its first frame, and composites frames differently per platform; the last couple
of dozen decoded pictures are kept. Stills go
`slic3r/GUI/AnimatedTexture.hpp` decodes a file once and uploads one GL texture per frame. Stills go
through `wxImage`; GIFs go through `wxGIFDecoder`, whose raw palette indices are composited here frame
by frame, replaying the disposal method each frame asks for. That replay is what makes an animation
look continuous: a GIF frame is a sub-rectangle drawn over what came before it, so an animation that
@@ -153,145 +88,8 @@ Which frame is drawn is measured on a real clock, not `ImGui::GetTime()`. Nothin
than seconds. On a canvas that renders only when asked, that is not a clock at all: an animation driven
by it crawls while the canvas is idle and races while a moving mouse is rendering it flat out.
## The wx tooltips
`set_illustrated_tooltip(window, text, media)` replaces `SetToolTip()` for a wx control, and
`hover_illustrated_tooltip(window, item, text, media)` serves a window that draws several controls
itself and reports the one under the pointer on each mouse move: the option labels and undo icons of
`OG_CustomCtrl`, the cells of the object list, the items of a drop-down list. A tooltip without pictures
is drawn the same way, so the controls of a page all look alike. The `_deferred` variants take a
`TipMediaSource` instead of the pictures, which is asked when the tooltip opens; the settings use it,
since their pictures depend on the value chosen at that moment and looking them up is not free.
They follow the 3D view's rules: the same waits, nothing while a mouse button is down or an editable
text field in the control has the keyboard, and animations from their first frame each time. A click,
a key or the wheel hides the tooltip; it comes back, after the full wait, once the pointer moves again,
as the 3D view's does after a control has been let go. It also goes when the pointer leaves the control,
when the application is deactivated, and when the control is hidden, moved or destroyed. Text wraps at
the width of the 3D view's tooltips (300 DIP, its 20 em) and pictures are at most 150 DIP tall, laid out
side by side at equal widths with their captions under them. Colours are the dark mode palette of the
drop-down lists, in both themes, and the 3D view's tooltips use the same ones
(`ImGuiWrapper::push_tooltip_style()`): every tooltip in the application looks the same, and the
pictures, drawn on dark, sit the same way in all of them.
### Where it goes
Beside the control, never under the mouse and never on the control, and off the controls around it
where there is room, the way the texture-displacement panel's tooltips sit beside the panel:
- For a control inside a popup - an item of a drop-down list - beside the popup, level with the item:
below the item it would cover the next items, which are what the user is choosing between.
- For a control in a column of controls - the sidebar with the settings pages, a side panel - beside
the column, level with the control, so it covers the 3D view rather than the next rows of the page.
The column is found by walking up from the control: the outermost window below the top-level one that
is at least as tall as it is wide and at most three fifths of the top-level window's width.
- In a dialog, beside the dialog. Not on Wayland, where a tooltip is kept inside its window.
- On a page that spans its window - a settings page in its own window, on Wayland or when the window
fills the screen - to the right of the page's column of controls, level with the control. The page is
the first window above the control that is at least three fifths of the top-level window's width; the
column ends at the right edge of the narrower windows in it, so a G-code editor that spans the page
does not push the tooltip off the window. Never to the left of the column, which is over its labels.
- On Wayland, in a dialog with no room for it inside: beside the dialog after all. The screen is unknown
there, so the popup leaves its position to the compositor with `gdk_window_move_to_rect()`: to the
right of the dialog, level with the control, flipped to the left when the right has no room.
- Otherwise - a toolbar, a page as wide as the window - or when there is no room on either side: below
the control, level with its left edge, and above it when there is no room below.
It is kept inside the work area of the control's display; on Wayland, where screen coordinates are
relative to the window and the displays are unknown, inside the window the control is in.
There is one popup window for all of them, a plain `wxPopupWindow` that draws everything itself and has
no children. Not a `wxPopupTransientWindow` (Orca's `PopupWindow`): that kind grabs the pointer on GTK,
captures it on macOS and dismisses itself on its own terms, and a tooltip must do none of that. It never
takes the focus or the activation. macOS orders it in without activating it; on GTK it is a popup
window, override-redirect on X11 and an `xdg_popup` without a grab of its own on Wayland. On Windows its
`Show()` uses `SW_SHOWNOACTIVATE` and the window has `WS_EX_NOACTIVATE`, because `wxPopupWindow::Show()`
would activate it, taking the activation from an open drop-down list, which closes when it loses it.
Its parent is the top-level window of the control, and it is recreated when the pointer moves to a
control in another window: that makes it the owned window on Windows and a popup of the right surface on
Wayland, where it is placed relative to that surface.
On Wayland a tooltip over an open drop-down list is a popup of the list, and GDK gives it the list's
grab, so the compositor hands it the keyboard while it is up and the main window reports a
deactivation. `DropDown::ShouldDismissOnTopWindowDeactivate()` ignores that deactivation while the
tooltip is shown, as `PopupWindow` already does for GTK's own tooltips, and the drop-down list hides the
tooltip before it hides itself, since GDK refuses to unmap the parent of a mapped popup.
### Following the pointer
The pointer is followed by binding the enter, motion and leave events of the window and of every window
inside it, not by a timer asking `wxFindWindowAtPoint()`, which needs the global pointer position that
Wayland does not give. The windows inside matter because Orca's composite widgets (`TextInput`,
`::ComboBox`, `SpinInput`) are a frame with a native text field in it, and the pointer is over the
field. Moving between the frame and the field produces a leave and an enter; a leave whose position is
still inside the control is ignored, and any other waits 40 ms for the pointer to come back. The
handlers are free functions that look the window up when an event arrives, and each window is bound
once however often its tooltip is set, so a window that dies while its tooltip waits or shows leaves
nothing dangling. A click, a key, the wheel and the application's deactivation are caught by an event
filter, which sees them before any control does.
A window with an illustrated tooltip shows no native one besides it. Some widgets set one of their own
later: `::ComboBox` and `PresetComboBox` show the selected value, and `TextInput` forwards its tooltip to
its text field. Some code adds to a setting's tooltip the plain way: the settings tabs and the object
table prepend why an option is disabled. So native tooltips are removed from the window and the windows
inside it whenever the pointer moves over it, and a native tooltip on the window itself that still
contains the text it was given is taken as the new text, while any other is dropped.
### Settings
The text of a print, filament or printer setting's tooltip is its definition in `PrintConfig.cpp`, as
`Field::get_tooltip_text()` formats it: the wiki link, the default value, the restrictions. The pictures
are kept apart, in `slic3r/GUI/SettingTips*.cpp`, one file per group of settings so the groups are
edited independently, and `setting_tip(key)` builds the table and looks a setting up in it. A setting
can have pictures shown whatever its value (`media`), and an enum one picture per value (`values`,
keyed by the value's name as stored). A filament's override of a printer setting (`filament_z_hop_types`
overrides `z_hop_types`, as listed by `is_filament_extruder_override_key()`) shows the pictures of the
setting it overrides unless it has its own, so the two tabs show the same ones. The table holds
translated captions, so it is rebuilt on each lookup; it is looked up when a tooltip opens, never on a
paint or a mouse move.
Every field of a settings page goes through `Field::set_tooltip()`, and the label beside it shows the
same pictures with the label's own text, whether the label is a `wxStaticText` or drawn by
`OG_CustomCtrl`. For an enum the tooltip shows the setting's pictures and then the picture of the value
chosen at that moment, captioned with the value's label unless it has a caption of its own, and it is
redrawn if the value changes while it is up.
### Values in the drop-down list
While a setting's drop-down list is open, the item under the pointer shows its value's picture beside
the list, once the pointer has rested on it. `DropDown` reports the item under the pointer to a handler
the field sets (`DropDown::SetItemHoverHandler()`), which passes it on as a `hover_illustrated_tooltip`
with the item's row; a value without a picture shows nothing. An item is matched to its value by its
text, not its index, since some lists leave values out or are filled elsewhere.
## Turning the pictures off
The "Show pictures in tooltips" preference (`show_tooltip_pictures`, on by default) leaves every
tooltip as its text alone. Nothing else about it changes: it waits the same, opens in the same place
and is as wide as its text needs. Nothing is decoded while it is off, and the wx tooltips do not ask their `TipMediaSource`, so the
settings' pictures are not looked up either.
## Making one
### The toolbar
`scripts/gen_gizmo_tips.py` draws the toolbar's set (`scripts/gizmo_tips/toolbar.py`, the main toolbar's
tools included) and the gizmo
panels' sets (one module each in `scripts/gizmo_tips/`, except that `gizmos_anim.py` draws the loops of
several panels and names each by its panel's folder). Each picture is a scene - a model on the
print bed with the tool's handles, the pointer and the brush drawn over it - rendered by a small ray
marcher from signed distance functions, which makes a cut, a boolean operation or an embossed letter a
line of arithmetic each. The view is the plater's default, from the front right and above, so the
pictures look like the view the user is in. The model is grey; the one accent colour marks what the
tool made or acts on: a painted area, a cut face, a selected face, the second part.
The animations either loop with no step (Move, Rotate, Scale, Simplify and the embossing ones swing
from one end of the change to the other and back) or show an action once and hold its result before
starting over (the painting tools, Cut, Lay on Face, Assemble, Brim Ears). Frames that repeat are merged
into one longer frame by the GIF encoder.
### The texture-displacement panel
`scripts/gen_texture_displacement_tips.py` draws the lot, in four languages, picked by what the
setting actually is:
-3
View File
@@ -189,9 +189,6 @@ src/slic3r/GUI/SceneBenchmark.cpp
src/slic3r/GUI/Search.cpp
src/slic3r/GUI/SettingsIndex.cpp
src/slic3r/GUI/SpeedDialDialog.cpp
src/slic3r/GUI/SettingTipsFilament.cpp
src/slic3r/GUI/SettingTipsPrinter.cpp
src/slic3r/GUI/SettingTipsProcess.cpp
src/slic3r/GUI/Selection.cpp
src/slic3r/GUI/SelectMachine.cpp
src/slic3r/GUI/PrePrintChecker.cpp
Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Some files were not shown because too many files have changed in this diff Show More