Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge remote-tracking branch 'upstream/main' into fix/7316-color-chips-centre

Hector Villarrealdbdd8ff66e6c
diff --cc crates/ui-egui/src/panels.rs
index 191f2c47b,04e775439..59f3908bc
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@@ -293,77 -294,73 +294,75 @@@ pub fn toolbar(app: &mut PhotocraftApp
reveal_focused_control(ui);
});
ui.add_space(if t.pro { 8.0 } else { 14.0 });
- color_chips(app, ui, double);
+ // Centred in the tool column as it is before the tools scroll: a scroll bar widens the
+ // UI it is in, and the chips moved over by its width (#7316).
+ color_chips(app, ui, double, full.width());
- if t.pro {
- ui.add_space(8.0);
-
- let layout = if double { egui::Layout::left_to_right(egui::Align::Min) } else { egui::Layout::top_down(egui::Align::Min) };
+ ui.add_space(8.0);
- ui.with_layout(layout, |ui| {
- let quick_mask = app.session.active().is_some_and(|s| s.doc.quick_mask.is_some());
- if icons::button_with_icon_size_tip(
- ui,
- "square-dashed",
- bx,
- (bx * 0.52).round(),
- quick_mask,
- if quick_mask { tl!("Edit in Standard Mode (Q)") } else { tl!("Edit in Quick Mask Mode (Q)") },
- tool_tips,
- )
- .clicked()
- {
- let _ = crate::menus::invoke(app, &ctx, "select.editInQuickMaskMode", json!({}));
- }
- let sm = icons::button_with_icon_size_tip(ui, "app-window", bx, (bx * 0.52).round(), false, tl!("Change Screen Mode (F)"), tool_tips);
- paint_toolbar_flyout_indicator(ui, &t, &sm);
-
- // Right-click, or click and hold like the tool flyouts (#4444), lists the modes,
- // like Photoshop's flyout. The release that ends a hold doesn't cycle the mode.
- let held_id = sm.id.with("held");
- let was_held = ui.data(|d| d.get_temp::<bool>(held_id)).unwrap_or(false);
- let held_for = sm.is_pointer_button_down_on().then(|| ui.input(|i| i.pointer.press_start_time().map(|t0| i.time - t0))).flatten();
- if let Some(seconds) = held_for
- && seconds < 0.35
- {
- ui.ctx().request_repaint_after(std::time::Duration::from_secs_f64(0.35 - seconds));
- }
- let long_press = !was_held && held_for.is_some_and(|seconds| seconds >= 0.35);
- if long_press {
- ui.data_mut(|d| d.insert_temp(held_id, true));
- } else if was_held && !sm.is_pointer_button_down_on() {
- ui.data_mut(|d| d.remove::<bool>(held_id));
- }
- let cycle = sm.clicked() && !was_held;
- if cycle {
- let _ = crate::menus::invoke(app, &ctx, "view.screenMode.cycle", json!({}));
- }
- let open = if sm.secondary_clicked() || long_press {
- Some(egui::SetOpenCommand::Bool(true))
- } else if cycle {
- Some(egui::SetOpenCommand::Bool(false))
- } else {
- None
- };
- // The release ending the hold counts as a click; it mustn't close the list it opened.
- let close = if was_held || long_press { egui::PopupCloseBehavior::IgnoreClicks } else { egui::PopupCloseBehavior::CloseOnClick };
- egui::Popup::menu(&sm).open_memory(open).close_behavior(close).at_pointer_fixed().show(|ui| {
- ui.set_min_width(220.0);
- for (id, label) in [
- ("view.screenMode.standard", tl!("Standard Screen Mode")),
- ("view.screenMode.fullScreenWithMenuBar", tl!("Full Screen Mode With Menu Bar")),
- ("view.screenMode.fullScreen", tl!("Full Screen Mode")),
- ] {
- let on = crate::view_cmds::checked(app, id).unwrap_or(false);
- if ui.add(egui::Button::selectable(on, label)).clicked() {
- let _ = crate::menus::invoke(app, &ctx, id, json!({}));
- ui.close();
- }
+ let layout = if double { egui::Layout::left_to_right(egui::Align::Min) } else { egui::Layout::top_down(egui::Align::Min) };
+
+ ui.with_layout(layout, |ui| {
+ let quick_mask = app.session.active().is_some_and(|s| s.doc.quick_mask.is_some());
+ if icons::button_with_icon_size_tip(
+ ui,
+ "square-dashed",
+ bx,
+ (bx * 0.52).round(),
+ quick_mask,
+ if quick_mask { tl!("Edit in Standard Mode (Q)") } else { tl!("Edit in Quick Mask Mode (Q)") },
+ tool_tips,
+ )
+ .clicked()
+ {
+ let _ = crate::menus::invoke(app, &ctx, "select.editInQuickMaskMode", json!({}));
+ }
+ let sm = icons::button_with_icon_size_tip(ui, "app-window", bx, (bx * 0.52).round(), false, tl!("Change Screen Mode (F)"), tool_tips);
+ paint_toolbar_flyout_indicator(ui, &t, &sm);
+
+ // Right-click, or click and hold like the tool flyouts (#4444), lists the modes,
+ // like Photoshop's flyout. The release that ends a hold doesn't cycle the mode.
+ let held_id = sm.id.with("held");
+ let was_held = ui.data(|d| d.get_temp::<bool>(held_id)).unwrap_or(false);
+ let held_for = sm.is_pointer_button_down_on().then(|| ui.input(|i| i.pointer.press_start_time().map(|t0| i.time - t0))).flatten();
+ if let Some(seconds) = held_for
+ && seconds < 0.35
+ {
+ ui.ctx().request_repaint_after(std::time::Duration::from_secs_f64(0.35 - seconds));
+ }
+ let long_press = !was_held && held_for.is_some_and(|seconds| seconds >= 0.35);
+ if long_press {
+ ui.data_mut(|d| d.insert_temp(held_id, true));
+ } else if was_held && !sm.is_pointer_button_down_on() {
+ ui.data_mut(|d| d.remove::<bool>(held_id));
+ }
+ let cycle = sm.clicked() && !was_held;
+ if cycle {
+ let _ = crate::menus::invoke(app, &ctx, "view.screenMode.cycle", json!({}));
+ }
+ let open = if sm.secondary_clicked() || long_press {
+ Some(egui::SetOpenCommand::Bool(true))
+ } else if cycle {
+ Some(egui::SetOpenCommand::Bool(false))
+ } else {
+ None
+ };
+ // The release ending the hold counts as a click; it mustn't close the list it opened.
+ let close = if was_held || long_press { egui::PopupCloseBehavior::IgnoreClicks } else { egui::PopupCloseBehavior::CloseOnClick };
+ egui::Popup::menu(&sm).open_memory(open).close_behavior(close).at_pointer_fixed().show(|ui| {
+ ui.set_min_width(220.0);
+ for (id, label) in [
+ ("view.screenMode.standard", tl!("Standard Screen Mode")),
+ ("view.screenMode.fullScreenWithMenuBar", tl!("Full Screen Mode With Menu Bar")),
+ ("view.screenMode.fullScreen", tl!("Full Screen Mode")),
+ ] {
+ let on = crate::view_cmds::checked(app, id).unwrap_or(false);
+ if ui.add(egui::Button::selectable(on, label)).clicked() {
+ let _ = crate::menus::invoke(app, &ctx, id, json!({}));
+ ui.close();
}
- });
+ }
});
- }
+ });
});
}