diff --git a/crates/ui-egui/src/gradient_ui.rs b/crates/ui-egui/src/gradient_ui.rs index 181dd38a99a..dedea0685ce 100644 --- a/crates/ui-egui/src/gradient_ui.rs +++ b/crates/ui-egui/src/gradient_ui.rs @@ -689,21 +689,13 @@ enum Marker { Mid(usize), } -/// The editor window keeps its combined strip; Properties exposes two separate tracks. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -enum Strip { - Combined, - Color, - Opacity, -} - -fn strip_key(app: &PhotocraftApp, sink: Sink, strip: Strip) -> egui::Id { +fn strip_key(app: &PhotocraftApp, sink: Sink) -> egui::Id { // Layer IDs can repeat in different documents. Tool presets belong to the session. let document = match sink { Sink::Layer(_) => app.session.active().map(|s| s.doc.id), Sink::Preset => None, }; - sink.key().with((strip, document)) + sink.key().with(document) } /// What a stops editor instance edits: a Gradient Fill layer (`gradient.fill.stop`) or the @@ -790,12 +782,12 @@ fn preset_stop_color(app: &mut PhotocraftApp, i: usize) { } fn stops_editor_for(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { - let key = strip_key(app, sink, Strip::Combined).with("selection"); + let key = strip_key(app, sink).with("selection"); if ui.data(|d| d.get_temp::(key)).is_none() { ui.data_mut(|d| d.insert_temp(key, Marker::Color(0))); } - stop_strip(app, ui, sink, f, Strip::Combined); - properties_panel::stop_fields(app, ui, sink, Strip::Combined); + stop_strip(app, ui, sink, f); + properties_panel::stop_fields(app, ui, sink); } /// Keep selection on a stop after the engine sorts its new position. @@ -825,20 +817,14 @@ fn selection_after_edit(f: &Fill, p: &Value, previous: Option) -> Option Some(if opacity { Marker::Opacity(at) } else { Marker::Color(at) }) } -fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, strip: Strip) { +fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill) { let Fill::Gradient { stops, .. } = &f else { return }; let t = Tokens::get(ui.ctx()); let w = ui.available_width().max(120.0); - let combined = strip == Strip::Combined; - let (outer, resp) = ui.allocate_exact_size(vec2(w, if combined { 58.0 } else { 48.0 }), Sense::click_and_drag()); + let (outer, resp) = ui.allocate_exact_size(vec2(w, 58.0), Sense::click_and_drag()); // Name the strip for accessibility (and so tests and agents can find it). - let strip_label = match strip { - Strip::Combined => "Gradient stops", - Strip::Color => "Color stops", - Strip::Opacity => "Opacity stops", - }; - resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tl!(strip_label))); - let top = outer.top() + if combined { 16.0 } else { 4.0 }; + resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), tl!("Gradient stops"))); + let top = outer.top() + 16.0; let bar = Rect::from_min_max(pos2(outer.left() + 8.0, top), pos2(outer.right() - 8.0, top + 24.0)); let x_of = |loc: f32| bar.left() + loc.clamp(0.0, 1.0) * bar.width(); let loc_of = |x: f32| ((x - bar.left()) / bar.width().max(1.0)).clamp(0.0, 1.0); @@ -850,18 +836,9 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, s let (fg, bg) = (app.session.tools.foreground, app.session.tools.background); let shown = pending.as_ref().and_then(|p| cmds::apply_stop(&f, p, fg, bg).ok()).unwrap_or_else(|| f.clone()); let mut track_fill = shown.clone(); - if let Fill::Gradient { stops, opacity_stops, reverse, .. } = &mut track_fill { + if let Fill::Gradient { reverse, .. } = &mut track_fill { // All markers address un-reversed positions; Reverse applies to the canvas output. *reverse = false; - match strip { - Strip::Color => opacity_stops.clear(), - Strip::Opacity => { - for (_, color) in stops { - *color = photocraft_color::Color::BLACK; - } - } - Strip::Combined => {} - } } if let Some(ramp) = gf::Ramp::new(&track_fill) { paint_ramp(ui.painter(), bar, |u| ramp.sample(u)); @@ -875,36 +852,28 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, s sorted.sort_by(|a, b| a.0.total_cmp(&b.0)); let mut ops: Vec<(f32, f32)> = if os.is_empty() { vec![(0.0, 1.0), (1.0, 1.0)] } else { os.clone() }; ops.sort_by(|a, b| a.0.total_cmp(&b.0)); - let key = strip_key(app, sink, strip); + let key = strip_key(app, sink); let selection_key = key.with("selection"); let selected: Option = ui.data(|d| d.get_temp(selection_key)); let dragging: Option = ui.data(|d| d.get_temp(key)); // Markers. let p = ui.painter(); - for (i, (loc, c)) in sorted.iter().enumerate().filter(|_| strip != Strip::Opacity) { + for (i, (loc, c)) in sorted.iter().enumerate() { let x = x_of(*loc); let sel = dragging.or(selected) == Some(Marker::Color(i)); let tip = pos2(x, bar.bottom() + 1.0); let body = Rect::from_center_size(pos2(x, bar.bottom() + 10.0), vec2(10.0, 10.0)); let rgb = c.to_rgb(); let color = c32([rgb[0], rgb[1], rgb[2], 1.0]); - if combined { - p.add(egui::Shape::convex_polygon( - vec![tip, pos2(x + 5.0, body.top()), pos2(x - 5.0, body.top())], - if sel { t.accent } else { t.text_dim }, - Stroke::NONE, - )); - p.rect_filled(body, 1.0, color); - p.rect_stroke(body, 1.0, Stroke::new(1.0, if sel { t.accent } else { t.text_dim }), StrokeKind::Outside); - } else { - p.circle_filled(body.center(), 5.0, color); - p.circle_stroke(body.center(), 5.0, Stroke::new(1.0, t.text)); - if sel { - p.circle_stroke(body.center(), 7.0, Stroke::new(1.5, t.accent)); - } - } + p.add(egui::Shape::convex_polygon( + vec![tip, pos2(x + 5.0, body.top()), pos2(x - 5.0, body.top())], + if sel { t.accent } else { t.text_dim }, + Stroke::NONE, + )); + p.rect_filled(body, 1.0, color); + p.rect_stroke(body, 1.0, Stroke::new(1.0, if sel { t.accent } else { t.text_dim }), StrokeKind::Outside); } - if sink.midpoints() && strip != Strip::Opacity { + if sink.midpoints() { for i in 0..sorted.len().saturating_sub(1) { let (a, b) = (sorted[i].0, sorted[i + 1].0); if b - a > 1e-3 { @@ -914,33 +883,22 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, s } } } - for (i, (loc, a)) in ops.iter().enumerate().filter(|_| strip != Strip::Color) { + for (i, (loc, a)) in ops.iter().enumerate() { let x = x_of(*loc); let sel = dragging.or(selected) == Some(Marker::Opacity(i)); - let y = if combined { bar.top() - 10.0 } else { bar.bottom() + 10.0 }; + let y = bar.top() - 10.0; let body = Rect::from_center_size(pos2(x, y), vec2(10.0, 10.0)); let color = Color32::from_gray((a.clamp(0.0, 1.0) * 255.0) as u8); - if combined { - p.add(egui::Shape::convex_polygon( - vec![pos2(x, bar.top() - 1.0), pos2(x + 5.0, body.bottom()), pos2(x - 5.0, body.bottom())], - if sel { t.accent } else { t.text_dim }, - Stroke::NONE, - )); - p.rect_filled(body, 1.0, color); - p.rect_stroke(body, 1.0, Stroke::new(1.0, if sel { t.accent } else { t.text_dim }), StrokeKind::Outside); - } else { - p.circle_filled(body.center(), 5.0, color); - p.circle_stroke(body.center(), 5.0, Stroke::new(1.0, t.text)); - if sel { - p.circle_stroke(body.center(), 7.0, Stroke::new(1.5, t.accent)); - } - } + p.add(egui::Shape::convex_polygon( + vec![pos2(x, bar.top() - 1.0), pos2(x + 5.0, body.bottom()), pos2(x - 5.0, body.bottom())], + if sel { t.accent } else { t.text_dim }, + Stroke::NONE, + )); + p.rect_filled(body, 1.0, color); + p.rect_stroke(body, 1.0, Stroke::new(1.0, if sel { t.accent } else { t.text_dim }), StrokeKind::Outside); } // Interaction. let hit = |pos: Pos2| -> Option { - if strip == Strip::Opacity { - return (pos.y > bar.bottom()).then(|| ops.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0)).flatten().map(Marker::Opacity); - } if pos.y > bar.bottom() { if let Some(i) = sorted.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0 && pos.y >= bar.bottom() + 3.0) { return Some(Marker::Color(i)); @@ -955,7 +913,7 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, s }) .map(Marker::Mid); } - if combined && pos.y < bar.top() { + if pos.y < bar.top() { return ops.iter().position(|(l, _)| (x_of(*l) - pos.x).abs() <= 6.0).map(Marker::Opacity); } None @@ -1033,7 +991,7 @@ fn stop_strip(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, f: Fill, s return; } let loc = loc_of(pos.x); - let opacity = strip == Strip::Opacity || (combined && pos.y < bar.center().y); + let opacity = pos.y < bar.center().y; let p = if opacity { sink.params(json!({"action": "add", "kind": "opacity", "location": loc})) } else { diff --git a/crates/ui-egui/src/gradient_ui/editor_tests.rs b/crates/ui-egui/src/gradient_ui/editor_tests.rs index 43f470c65b7..8bc5019ddf0 100644 --- a/crates/ui-egui/src/gradient_ui/editor_tests.rs +++ b/crates/ui-egui/src/gradient_ui/editor_tests.rs @@ -62,7 +62,7 @@ fn top_opacity_and_bottom_color_select_their_own_fields_in_both_editor_modes() { assert!(h.query_by_label("Opacity stops").is_none()); assert!(h.get_all_by_label("Color").any(|n| n.accesskit_node().role() == egui::accesskit::Role::Button)); select(&mut h, 0.5, true); - let key = strip_key(h.state(), sink, Strip::Combined).with("selection"); + let key = strip_key(h.state(), sink).with("selection"); assert_eq!(h.ctx.data(|d| d.get_temp::(key)), Some(Marker::Opacity(1))); assert!(h.query_by_label("Color").is_none(), "opacity selection hides color controls"); select(&mut h, 0.5, false); @@ -106,7 +106,7 @@ fn editor_location_follows_reordered_color_and_opens_existing_picker() { let (mut h, sink) = editor(layer); select(&mut h, 0.0, false); type_number(&mut h, 0, "70", true); - let key = strip_key(h.state(), sink, Strip::Combined).with("selection"); + let key = strip_key(h.state(), sink).with("selection"); assert_eq!(h.ctx.data(|d| d.get_temp::(key)), Some(Marker::Color(1))); assert!(matches!(sink.fill(h.state()).unwrap(), Fill::Gradient { stops, .. } if (stops[1].0 - 0.7).abs() < 1e-5)); h.get_all_by_label("Color").find(|n| n.accesskit_node().role() == egui::accesskit::Role::Button).unwrap().click(); @@ -125,7 +125,7 @@ fn editor_opacity_location_changes_only_opacity_in_both_modes() { let Fill::Gradient { stops, opacity_stops, .. } = sink.fill(h.state()).unwrap() else { panic!() }; assert_eq!(stops, before, "opacity location must not move a color stop"); assert!((opacity_stops[1].0 - 0.7).abs() < 1e-5); - let key = strip_key(h.state(), sink, Strip::Combined).with("selection"); + let key = strip_key(h.state(), sink).with("selection"); assert_eq!(h.ctx.data(|d| d.get_temp::(key)), Some(Marker::Opacity(1))); } } diff --git a/crates/ui-egui/src/gradient_ui/properties_panel.rs b/crates/ui-egui/src/gradient_ui/properties_panel.rs index 03817c402e5..39b961ee207 100644 --- a/crates/ui-egui/src/gradient_ui/properties_panel.rs +++ b/crates/ui-egui/src/gradient_ui/properties_panel.rs @@ -14,36 +14,26 @@ const STYLES: [(GradientStyle, &str); 5] = [ pub(super) fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) { let document = app.session.active().map(|s| s.doc.id); ui.push_id(("gradient-properties", document, layer.id.0), |ui| { - options(app, ui, layer); - for (strip, title) in [(Strip::Color, "Color stops"), (Strip::Opacity, "Opacity stops")] { - let section_id = if strip == Strip::Color { "gradient-fill-colors" } else { "gradient-fill-opacity" }; - if props_layout::section(ui, section_id, title) { - // Fetch current state after a preceding control committed, not the panel's snapshot. - if let Some(fill) = current_fill(app, layer.id) { - let key = strip_key(app, Sink::Layer(layer.id), strip).with("selection"); - if ui.data(|d| d.get_temp::(key)).is_none() { - ui.data_mut(|d| d.insert_temp(key, if strip == Strip::Color { Marker::Color(0) } else { Marker::Opacity(0) })); - } - stop_strip(app, ui, Sink::Layer(layer.id), fill, strip); - stop_fields(app, ui, Sink::Layer(layer.id), strip); - } - } - } + layer_controls(app, ui, layer); }); } pub(super) fn editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) { let document = app.session.active().map(|s| s.doc.id); ui.push_id(("gradient-editor-layer", document, layer.id.0), |ui| { - if props_layout::section(ui, "gradient-editor-stops", "Gradient") - && let Some(fill) = current_fill(app, layer.id) - { - stops_editor_for(app, ui, Sink::Layer(layer.id), fill); - } - options(app, ui, layer); + layer_controls(app, ui, layer); }); } +fn layer_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) { + if props_layout::section(ui, "gradient-fill-stops", "Gradient") + && let Some(fill) = current_fill(app, layer.id) + { + stops_editor_for(app, ui, Sink::Layer(layer.id), fill); + } + options(app, ui, layer); +} + fn options(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) { let Some(Fill::Gradient { angle, scale, style, reverse, dither, align, .. }) = fill_of(layer).cloned() else { return }; if props_layout::section(ui, "gradient-fill-options", "Gradient Options") { @@ -143,18 +133,17 @@ fn style_button(ui: &mut egui::Ui, style: GradientStyle, selected: bool, name: & response.on_hover_text(tl!(name)) } -pub(super) fn stop_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink, strip: Strip) { +pub(super) fn stop_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink) { let Some(Fill::Gradient { mut stops, mut opacity_stops, midpoints, .. }) = sink.fill(app) else { return }; stops.sort_by(|a, b| a.0.total_cmp(&b.0)); if opacity_stops.is_empty() { opacity_stops = vec![(0.0, 1.0), (1.0, 1.0)]; } opacity_stops.sort_by(|a, b| a.0.total_cmp(&b.0)); - let key = strip_key(app, sink, strip).with("selection"); - let default = if strip == Strip::Opacity { Marker::Opacity(0) } else { Marker::Color(0) }; - let selected = ui.data(|d| d.get_temp::(key)).unwrap_or(default); + let key = strip_key(app, sink).with("selection"); + let selected = ui.data(|d| d.get_temp::(key)).unwrap_or(Marker::Color(0)); let (index, location, count) = match selected { - Marker::Color(i) if strip != Strip::Opacity => { + Marker::Color(i) => { let Some((location, color)) = stops.get(i) else { ui.data_mut(|d| d.remove::(key)); return; @@ -175,7 +164,7 @@ pub(super) fn stop_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink }); (i, *location, stops.len()) } - Marker::Opacity(i) if strip != Strip::Color => { + Marker::Opacity(i) => { let Some((location, opacity)) = opacity_stops.get(i) else { ui.data_mut(|d| d.remove::(key)); return; @@ -185,7 +174,7 @@ pub(super) fn stop_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink } (i, *location, opacity_stops.len()) } - Marker::Mid(i) if strip != Strip::Opacity => { + Marker::Mid(i) => { if stops.get(i).is_none() || stops.get(i.saturating_add(1)).is_none() { ui.data_mut(|d| d.remove::(key)); return; @@ -195,7 +184,6 @@ pub(super) fn stop_fields(app: &mut PhotocraftApp, ui: &mut egui::Ui, sink: Sink } return; } - _ => return, }; let kind = if matches!(selected, Marker::Opacity(_)) { "opacity" } else { "color" }; if let Some(value) = numeric_row(ui, &format!("{kind}-location-{index}"), "Location", location * 100.0, 0.0..=100.0, "%") { @@ -255,6 +243,17 @@ mod tests { current_fill(app, state.active_layer.unwrap()).unwrap() } + fn click_strip(h: &mut Harness<'_, PhotocraftApp>, location: f32, y: f32) { + let rect = h.get_by_label("Gradient stops").rect(); + let pos = pos2(rect.left() + 8.0 + (rect.width() - 16.0) * location, rect.top() + y); + h.event(egui::Event::PointerMoved(pos)); + h.run_steps(1); + h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE }); + h.run_steps(1); + h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); + h.run_steps(3); + } + #[test] fn style_icons_edit_the_selected_layer_with_one_undo_step() { let mut h = Harness::builder().with_size(vec2(280.0, 800.0)).build_ui_state(panel, app()); @@ -278,21 +277,17 @@ mod tests { } #[test] - fn separate_tracks_add_only_their_own_kind_and_keep_color_picker_working() { + fn combined_strip_adds_only_the_clicked_kind_and_keeps_color_picker_working() { let mut h = Harness::builder().with_size(vec2(280.0, 800.0)).build_ui_state(panel, app()); PhotocraftApp::setup_context(&h.ctx, theme::ThemeKind::ProMedium); h.run_steps(3); - for (title, opacity) in [("Color stops", false), ("Opacity stops", true)] { + assert!(h.query_by_label("Color stops").is_none()); + assert!(h.query_by_label("Opacity stops").is_none()); + assert!(h.get_by_label("Gradient stops").rect().bottom() < h.get_by_label("Gradient Options").rect().top()); + for opacity in [false, true] { let before = fill(h.state()); let count = h.state().session.active().unwrap().history.past_len(); - let rect = h.query_all_by_label(title).find(|n| n.rect().height() > 40.0).unwrap().rect(); - let pos = rect.center(); - h.event(egui::Event::PointerMoved(pos)); - h.run_steps(1); - h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE }); - h.run_steps(1); - h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); - h.run_steps(3); + click_strip(&mut h, 0.5, if opacity { 22.0 } else { 34.0 }); let after = fill(h.state()); let Fill::Gradient { stops: old_colors, opacity_stops: old_opacity, .. } = &before else { panic!() }; let Fill::Gradient { stops: colors, opacity_stops, .. } = &after else { panic!() }; @@ -310,7 +305,13 @@ mod tests { assert_eq!(fill(h.state()), after); h.run_steps(2); } - // Selected color remains independently editable even after editing opacity. + // The selected opacity's fields are replaced when a bottom color handle is selected. + assert!(h.query_all_by_label("Color").all(|n| n.rect().width() < 80.0)); + let before = fill(h.state()); + let count = h.state().session.active().unwrap().history.past_len(); + click_strip(&mut h, 0.0, 50.0); + assert_eq!(fill(h.state()), before); + assert_eq!(h.state().session.active().unwrap().history.past_len(), count); h.query_all_by_label("Color").find(|n| n.rect().width() > 80.0).unwrap().click(); h.run_steps(2); assert!(!h.state().ui.dialogs.is_empty()); @@ -321,10 +322,11 @@ mod tests { let mut h = Harness::builder().with_size(vec2(280.0, 800.0)).build_ui_state(panel, app()); PhotocraftApp::setup_context(&h.ctx, theme::ThemeKind::ProMedium); h.run_steps(3); + click_strip(&mut h, 0.0, 6.0); let before = fill(h.state()); let count = h.state().session.active().unwrap().history.past_len(); - // Angle, scale, color location, opacity, opacity location. - h.get_all_by_role(egui::accesskit::Role::SpinButton).nth(3).unwrap().click(); + // Selected opacity and location precede angle and scale. + h.get_all_by_role(egui::accesskit::Role::SpinButton).next().unwrap().click(); h.run_steps(2); h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); h.event(egui::Event::Text("35".into())); @@ -346,10 +348,11 @@ mod tests { PhotocraftApp::setup_context(&h.ctx, theme::ThemeKind::ProMedium); h.run_steps(3); assert!(h.get_all_by_label("Delete").next().unwrap().accesskit_node().is_disabled(), "two colors cannot be reduced further"); - assert!(!h.get_all_by_label("Delete").nth(1).unwrap().accesskit_node().is_disabled(), "three opacity points can be reduced"); + click_strip(&mut h, 0.0, 6.0); + assert!(!h.get_all_by_label("Delete").next().unwrap().accesskit_node().is_disabled(), "three opacity points can be reduced"); let before = fill(h.state()); let count = h.state().session.active().unwrap().history.past_len(); - h.get_all_by_label("Delete").nth(1).unwrap().click(); + h.get_all_by_label("Delete").next().unwrap().click(); h.run_steps(3); let after = fill(h.state()); let Fill::Gradient { stops: old_colors, opacity_stops: old_opacity, .. } = &before else { panic!() }; @@ -357,11 +360,12 @@ mod tests { assert_eq!(colors, old_colors); assert_eq!(opacity_stops, &old_opacity[1..]); assert_eq!(h.state().session.active().unwrap().history.past_len(), count + 1); - assert!(h.get_all_by_label("Delete").nth(1).unwrap().accesskit_node().is_disabled(), "two opacity points cannot be reduced further"); + click_strip(&mut h, 0.5, 6.0); + assert!(h.get_all_by_label("Delete").next().unwrap().accesskit_node().is_disabled(), "two opacity points cannot be reduced further"); h.state_mut().run("edit.undo", json!({})).unwrap(); assert_eq!(fill(h.state()), before); h.run_steps(3); - assert!(!h.get_all_by_label("Delete").nth(1).unwrap().accesskit_node().is_disabled()); + assert!(!h.get_all_by_label("Delete").next().unwrap().accesskit_node().is_disabled()); h.state_mut().run("edit.redo", json!({})).unwrap(); assert_eq!(fill(h.state()), after); } @@ -377,10 +381,8 @@ mod tests { let rect = h.get_by_label(name).rect(); assert!(rect.right() <= 260.0 && rect.left() >= 0.0, "{theme:?}: {name} {rect:?}"); } - for title in ["Color stops", "Opacity stops"] { - let rect = h.query_all_by_label(title).find(|n| n.rect().height() > 40.0).unwrap().rect(); - assert!(rect.right() <= 260.0, "{theme:?}: {title} {rect:?}"); - } + let rect = h.get_by_label("Gradient stops").rect(); + assert!(rect.right() <= 260.0, "{theme:?}: {rect:?}"); } } @@ -409,8 +411,8 @@ mod tests { h.run_steps(3); let before = fill(h.state()); let count = h.state().session.active().unwrap().history.past_len(); - let rect = h.query_all_by_label("Color stops").find(|n| n.rect().height() > 40.0).unwrap().rect(); - let from = pos2(rect.left() + 8.0, rect.top() + 38.0); + let rect = h.get_by_label("Gradient stops").rect(); + let from = pos2(rect.left() + 8.0, rect.top() + 50.0); let to = pos2(rect.left() + 8.0 + (rect.width() - 16.0) * 0.7, from.y); h.event(egui::Event::PointerMoved(from)); h.run_steps(1); @@ -424,7 +426,7 @@ mod tests { h.run_steps(3); assert_eq!(h.state().session.active().unwrap().history.past_len(), count + 1); assert!(matches!(fill(h.state()), Fill::Gradient { stops, .. } if (stops[1].0 - 0.7).abs() < 1e-5)); - let key = strip_key(h.state(), Sink::Layer(id), Strip::Color).with("selection"); + let key = strip_key(h.state(), Sink::Layer(id)).with("selection"); assert_eq!(h.ctx.data(|d| d.get_temp::(key)), Some(Marker::Color(1))); h.get_all_by_label("Delete").next().unwrap().click(); h.run_steps(3); diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index acc88646c70..335ae28734b 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2433,9 +2433,5 @@ fontWeight Italic Kurzíva Previous Document Předchozí dokument W x H x Resolution Š x V x Rozlišení Front Image Přední obraz - - Color stops Barevné zarážky - - Opacity stops Zarážky krytí Search settings… Hledat nastavení… No matching settings Žádná odpovídající nastavení diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 872e6b6a071..9a2be43ae4c 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2471,9 +2471,5 @@ fontWeight Italic Kursiv Previous Document Vorheriges Dokument W x H x Resolution B x H x Auflösung Front Image Vorderes Bild - - Color stops Farb-Steuerelemente - - Opacity stops Deckkraft-Steuerelemente Search settings… Einstellungen durchsuchen… No matching settings Keine passenden Einstellungen diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 7cee051ebf6..58df5ad70bd 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3541,9 +3541,5 @@ fontWeight Thin Πολύ λεπτά Previous Document Προηγούμενο έγγραφο W x H x Resolution Π x Υ x Ανάλυση Front Image Μπροστινή εικόνα - - Color stops Σημεία χρώματος - - Opacity stops Σημεία αδιαφάνειας Search settings… Αναζήτηση ρυθμίσεων… No matching settings Δεν βρέθηκαν ρυθμίσεις diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index cd7469f5aa5..4815e5b2446 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2512,9 +2512,5 @@ fontWeight Italic Cursiva Previous Document Documento anterior W x H x Resolution An. x Al. x Resolución Front Image Imagen frontal - - Color stops Paradas de color - - Opacity stops Paradas de opacidad Search settings… Buscar ajustes… No matching settings No hay ajustes que coincidan diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index f332d3ff3cc..21f72327592 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2851,9 +2851,5 @@ fontWeight Italic Italique Previous Document Document précédent W x H x Resolution L x H x Résolution Front Image Image de premier plan - - Color stops Étapes de couleur - - Opacity stops Étapes d'opacité Search settings… Rechercher des réglages… No matching settings Aucun réglage correspondant diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index ffdf8fc1216..efd0962b32c 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2838,9 +2838,5 @@ fontWeight Italic Miring Previous Document Dokumen Sebelumnya W x H x Resolution L x T x Resolusi Front Image Gambar Depan - - Color stops Titik warna - - Opacity stops Titik opasitas Search settings… Cari pengaturan… No matching settings Tidak ada pengaturan yang cocok diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index a8f24fb8f6a..c7bb027e799 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2502,9 +2502,5 @@ fontWeight Italic Corsivo Previous Document Documento precedente W x H x Resolution L x A x Risoluzione Front Image Immagine in primo piano - - Color stops Interruzioni colore - - Opacity stops Interruzioni opacità Search settings… Cerca impostazioni… No matching settings Nessuna impostazione corrispondente diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 50fb77fafaf..1a9dd16e1ce 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3452,9 +3452,5 @@ fontWeight Italic 斜体 Previous Document 前のドキュメント W x H x Resolution 幅 x 高さ x 解像度 Front Image 前面の画像 - - Color stops カラーストップ - - Opacity stops 不透明度ストップ Search settings… 設定を検索… No matching settings 一致する設定はありません diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 33aba49e16e..991fc3328e6 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3011,9 +3011,5 @@ fontWeight Italic 기울임 Previous Document 이전 문서 W x H x Resolution 폭 x 높이 x 해상도 Front Image 전면 이미지 - - Color stops 색상 정지점 - - Opacity stops 불투명도 정지점 Search settings… 설정 검색… No matching settings 일치하는 설정 없음 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 87b4815007c..4836d7e8b31 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3610,10 +3610,6 @@ cameraRaw Whites Witten Previous Document Vorig document W x H x Resolution B x H x Resolutie Front Image Voorste afbeelding - - Color stops Kleurstops - - Opacity stops Dekkingsstops Search settings… Instellingen zoeken… No matching settings Geen overeenkomende instellingen PhotoCraft — Screen Color Picker PhotoCraft — Schermkleurkiezer diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index fb4c2f07995..f33ce9990ea 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -3452,9 +3452,5 @@ cameraRaw Roughness Chropowatość Previous Document Poprzedni dokument W x H x Resolution Szer. x Wys. x Rozdzielczość Front Image Obraz na wierzchu - - Color stops Punkty koloru - - Opacity stops Punkty krycia Search settings… Szukaj ustawień… No matching settings Brak pasujących ustawień diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 645e8034eca..11b69ca234a 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2859,9 +2859,5 @@ fontWeight Italic Itálico Previous Document Documento anterior W x H x Resolution L x A x Resolução Front Image Imagem frontal - - Color stops Pontos de cor - - Opacity stops Pontos de opacidade Search settings… Pesquisar configurações… No matching settings Nenhuma configuração encontrada diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index d2dd8cb7498..7163992a154 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2717,9 +2717,5 @@ fontWeight Italic Курсив W x H x Resolution Ш x В x Разрешение Front Image Изображение переднего плана Swaps height and width Меняет местами высоту и ширину - - Color stops Цветовые точки - - Opacity stops Точки непрозрачности Search settings… Поиск настроек… No matching settings Нет подходящих настроек diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 26154f7e700..6ca10067a02 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -3538,10 +3538,6 @@ cameraRaw Masking Маскування Previous Document Попередній документ W x H x Resolution Ш x В x Роздільна здатність Front Image Зображення переднього плану - - Color stops Колірні точки - - Opacity stops Точки непрозорості Search settings… Пошук налаштувань… No matching settings Немає відповідних налаштувань PhotoCraft — Screen Color Picker PhotoCraft — Піпетка кольору екрана diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 6fb8f86442f..a39ab4cfce0 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2441,9 +2441,5 @@ fontWeight Italic 斜体 Previous Document 上一个文档 W x H x Resolution 宽 x 高 x 分辨率 Front Image 前面的图像 - - Color stops 颜色色标 - - Opacity stops 不透明度色标 Search settings… 搜索设置… No matching settings 没有匹配的设置 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index ae5d4ad2a5f..4454a7d61bd 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2410,9 +2410,5 @@ fontWeight Italic 斜體 Previous Document 上一個文件 W x H x Resolution 寬 x 高 x 解析度 Front Image 前面的影像 - - Color stops 顏色色標 - - Opacity stops 不透明度色標 Search settings… 搜尋設定… No matching settings 沒有符合的設定 diff --git a/crates/ui-egui/src/layer_props_ui.rs b/crates/ui-egui/src/layer_props_ui.rs index f9a9ac34bb9..eeb3d779759 100644 --- a/crates/ui-egui/src/layer_props_ui.rs +++ b/crates/ui-egui/src/layer_props_ui.rs @@ -251,8 +251,9 @@ mod tests { h.run_steps(3); let sections = crate::props_layout::sections_drawn(&h.ctx); assert_eq!(sections.iter().any(|(title, _)| title == "Align and Distribute"), !gradient); - assert_eq!(sections.iter().any(|(title, _)| title == "Color stops"), gradient); - assert_eq!(sections.iter().any(|(title, _)| title == "Opacity stops"), gradient); + assert_eq!(sections.iter().any(|(title, _)| title == "Gradient"), gradient); + assert_eq!(sections.iter().any(|(title, _)| title == "Gradient Options"), gradient); + assert!(!sections.iter().any(|(title, _)| title == "Color stops" || title == "Opacity stops")); } }