Show source tile patterns only during crop editing

This commit is contained in:
Dandaedre 2026-11-14 14:27:48 +01:00
parent 88d6eee625
commit e440d91ed5
7 changed files with 44 additions and 10 deletions

View File

@ -2784,8 +2784,9 @@ impl Editor {
Stroke::new(1.0_f32, color),
StrokeKind::Inside,
);
if (self.show_pattern && !self.outline_layers)
|| (self.edit_content && self.layout.selected() == Some(i))
if self.edit_content
&& ((self.show_pattern && !self.outline_layers)
|| self.layout.selected() == Some(i))
{
format_ui::paint_pattern(
p,
@ -4957,6 +4958,27 @@ mod tests {
assert_eq!(*app.layout.layers(), before);
}
#[test]
fn source_tiles_only_render_during_crop_editing_even_with_saved_pattern_enabled() {
for show_pattern in [false, true] {
let ctx = egui::Context::default();
let mut app = Editor {
show_pattern,
..Default::default()
};
let colors = theme::palette(&ctx).pattern;
let tiles = |output: &egui::FullOutput| {
output.shapes.iter().any(|shape| {
matches!(&shape.shape, egui::Shape::Rect(rect) if colors.contains(&rect.fill))
})
};
assert!(!tiles(&frame(&mut app, &ctx, vec![])));
app.edit_content = true;
assert!(tiles(&frame(&mut app, &ctx, vec![])));
app.edit_content = false;
assert!(!tiles(&frame(&mut app, &ctx, vec![])));
}
}
#[test]
fn double_click_enters_crop_mode_without_changing_geometry() {
for target in [Some(0), Some(1), None] {
let mut app = Editor::default();
@ -5070,7 +5092,7 @@ mod tests {
frame(&mut app, &ctx, vec![mouse(pos, false)]);
for label in [
"Keep aspect ratio when resizing",
"Show source-coordinate test pattern in viewport",
"Show source patterns on other layers while cropping",
"Show toolbar icon names",
] {
let output = frame(&mut app, &ctx, vec![]);

View File

@ -156,7 +156,7 @@ impl Editor {
self.resize_ratio_option(ui);
ui.checkbox(
&mut self.show_pattern,
"Show source-coordinate test pattern in viewport",
"Show source patterns on other layers while cropping",
);
let after = self.application_settings(ui.ctx());
if before != after {
@ -408,7 +408,7 @@ mod tests {
for label in [
"Show toolbar icon names",
"Keep aspect ratio when resizing",
"Show source-coordinate test pattern in viewport",
"Show source patterns on other layers while cropping",
] {
click_label(&mut app, &ctx, label);
}
@ -463,7 +463,10 @@ mod tests {
fn main_menu_routes_view_options_and_selection_commands() {
for (section, action) in [
("View", "Fit screen"),
("Options", "Show source-coordinate test pattern in viewport"),
(
"Options",
"Show source patterns on other layers while cropping",
),
("Edit", "Select all editable layers"),
] {
let mut app = Editor {

View File

@ -54,7 +54,7 @@ impl Editor {
}
ui.separator();
ui.checkbox(&mut self.show_toolbar_icon_names, "Show toolbar icon names");
ui.checkbox(&mut self.show_pattern, "Show source-coordinate test pattern in viewport");
ui.checkbox(&mut self.show_pattern, "Show source patterns on other layers while cropping");
ui.weak("Themes also apply to the viewport. Imported pictures retain their colors.");
}
Section::Editing => {

View File

@ -32,7 +32,7 @@ unknown theme names are rejected. There are no numeric coordinates or units.
| `recent_themes` | 1–3 unique theme IDs, newest first; first must equal `theme`; default `["midra"]` |
| `show_toolbar_icon_names` | Boolean; default false |
| `keep_aspect_ratio` | Boolean; default true |
| `show_source_pattern` | Boolean; default false |
| `show_source_pattern` | Boolean; default false. Shows source patterns on other layers only during crop editing; normal editing always hides patterns. |
| `snapping` | Object with required boolean fields `enabled` (false), `pixels` (true), `screen_edges` (true), `layer_edges` (true); unknown fields rejected |
Loaded once at startup before the editor appears. Explicit Options changes save

View File

@ -102,7 +102,7 @@ Editor object:
| `keep_aspect_ratio` | Boolean for layer resizing |
| `viewport_zoom` | Positive fit-relative scale, 0.0001–256 |
| `viewport_pan` | `[x, y]`, viewport pan in screen-coordinate pixels; finite, absolute value at most 1e9 |
| `show_source_pattern` | Boolean source-coordinate preview setting |
| `show_source_pattern` | Boolean: show source patterns on other layers during crop editing; normal editing always hides patterns |
| `show_toolbar_icon_names` | Boolean: show names beneath toolbar icons; false by default |
| `outline_layers` | Boolean: transparent layer fill for reference alignment; selection/handles remain visible |

View File

@ -566,7 +566,7 @@ visible box and source/input crop unchanged, and leaves visual editing active.
The reset is undoable.
The toolbar’s **Viewport options** cog contains **Keep aspect ratio when resizing**
and **Show source-coordinate test pattern in viewport**. Both apply immediately
and **Show source patterns on other layers while cropping**. Both apply immediately
and are preserved in saved projects. Crop editing always previews source content
and keeps its proportions, independently of these layer/view preferences.
@ -873,3 +873,10 @@ for the current zoom, input dimensions and visible box. Typing or dragging beyon
an edge stops at that edge; reducing zoom clamps existing offsets to the new
bounds. An axis with no spare content stays at zero. These adjustments apply
immediately and support Undo without an offset-range error.
The tiled source pattern is hidden during normal layout editing, including when
loading saved projects/settings with source-pattern display enabled. Double-click
a layer or open its Crop properties to show its pattern and faded cropped overflow;
leaving crop editing hides them again. **Show source patterns on other layers
while cropping** optionally displays patterns on the other layers during that
mode only (except outline-only layers).

View File

@ -4,6 +4,8 @@
## Unreleased
- Hide tiled source patterns outside crop editing, even with saved pattern display enabled. Double-click/Crop properties reveals the selected layer’s pattern; the existing preference now shows other layers’ patterns only while cropping.
- Constrain Crop-tab X/Y offsets to the valid content bounds, including after zoom decreases; typed and dragged edits clamp to the edge instead of producing offset-range errors. Undo remains available.
- Remove redundant position/size and output Apply buttons and their close prompts; names/folders commit on Enter or focus loss with Undo. Rename staged source and clipboard/SVG actions to “Apply source changes” and “Import mapped values”; Midra sends remain explicit.