Crop: Straighten gets its label and a spirit-level glyph (#10888)

This commit is contained in:
Raghav Krishna committed 2026-11-10 17:47:27 +05:30
1 parent 7091cb6b8c
commit aa12046847
6 files changed
+60 -2

No files matched your search

+2 -1
View File
@@ -42,11 +42,12 @@ next to them.
| `epaint_default_fonts::EGUI_ICONS` (build input; deflated into `OUT_DIR/egui_fonts/egui-icons.ttf.deflate`, registered by `crates/ui-egui/src/egui_fonts.rs`) | egui-icons, five-glyph subset of emoji-icon-font | John Slegers | [egui fork at 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts), [original](https://github.com/jslegers/emoji-icon-font); egui subset, unmodified here | MIT; Copyright (c) 2014 John Slegers; full upstream notice in [NOTICE](NOTICE) |
| `assets/fonts/Inter-Regular.ttf`, `Inter-Medium.ttf`, `Inter-SemiBold.ttf` | Inter 4.001 (UI font) | The Inter Project Authors (Rasmus Andersson) | <https://github.com/rsms/inter> | SIL OFL 1.1, [`assets/fonts/OFL-Inter.txt`](assets/fonts/OFL-Inter.txt) |
| `assets/fonts/JetBrainsMono-Regular.ttf` | JetBrains Mono 2.305 (numeric font) | The JetBrains Mono Project Authors | <https://github.com/JetBrains/JetBrainsMono> | SIL OFL 1.1, [`assets/fonts/OFL-JetBrainsMono.txt`](assets/fonts/OFL-JetBrainsMono.txt) |
| `assets/icons/*.svg` except `slice-knife.svg`, `slice-select.svg`, `font-similar.svg`, `font-variable.svg`, `sampler.svg`, `artboard.svg`, `perspective-crop.svg`, `frame-placeholder.svg`, `ellipse-dashed.svg`, `gradient.svg`, `type-mask.svg`, `type-mask-vertical.svg`, `text-warp.svg`, `clip-below.svg`, `clip-release.svg`, `layer-mask.svg`, `adjustment-layer.svg`, `brush-replace.svg`, `history-brush.svg`, `quick-selection.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg`, `direct-select.svg`, `convert-point.svg`, `pen-add-anchor.svg`, `pen-delete-anchor.svg`, `pen-freeform.svg`, `pen-curvature.svg`, `bandage-sparkle.svg`, `painting-symmetry.svg`, `symmetry-*.svg`, `path-op-*.svg` and `marquee-{row,column}.svg`, `align-edge-*.svg` and `distribute-*.svg`, `crop-overlay-*.svg`, `vertical-align-*.svg` (116 files; `star-filled.svg` is `star.svg` with a solid fill) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/*.svg` except `slice-knife.svg`, `slice-select.svg`, `font-similar.svg`, `font-variable.svg`, `sampler.svg`, `artboard.svg`, `perspective-crop.svg`, `frame-placeholder.svg`, `ellipse-dashed.svg`, `gradient.svg`, `type-mask.svg`, `type-mask-vertical.svg`, `text-warp.svg`, `clip-below.svg`, `clip-release.svg`, `layer-mask.svg`, `adjustment-layer.svg`, `brush-replace.svg`, `history-brush.svg`, `quick-selection.svg`, `eraser-background.svg`, `eraser-magic.svg`, `lasso-magnetic.svg`, `direct-select.svg`, `convert-point.svg`, `pen-add-anchor.svg`, `pen-delete-anchor.svg`, `pen-freeform.svg`, `pen-curvature.svg`, `bandage-sparkle.svg`, `painting-symmetry.svg`, `symmetry-*.svg`, `path-op-*.svg` and `marquee-{row,column}.svg`, `align-edge-*.svg` and `distribute-*.svg`, `crop-overlay-*.svg`, `vertical-align-*.svg`, `spirit-level.svg` (116 files; `star-filled.svg` is `star.svg` with a solid fill) | Lucide icons | Lucide Icons and Contributors | <https://github.com/lucide-icons/lucide> (`icons/<name>.svg`; `align-*` are now named `text-align-*` upstream) | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/{check,chevron-down,chevron-left,chevron-right,chevron-up,chevrons-left,chevrons-right,circle,clock,compass,info,link,link-2,lock,minus,monitor,moon,move,navigation,plus,search,square,trash,triangle,type,x,zoom-in}.svg` | Lucide icons derived from Feather (subset of the row above) | Cole Bemis (Feather), Lucide Contributors | <https://github.com/feathericons/feather> via Lucide | MIT (Feather) and ISC (Lucide), [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) |
| `assets/icons/slice-knife.svg` | Slice tool glyph | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/slice-select.svg` | Slice Select tool glyph | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/crop-overlay-*.svg` | Crop overlay glyphs: Rule of Thirds, Grid, Diagonal, Triangle, Golden Ratio and Golden Spiral inside the crop-mark frame | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/spirit-level.svg` | Straighten tool glyph: a spirit level with its vial and bubble under a dotted arc | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/sampler.svg` | Color Sampler tool glyph: a target reticle marking a sampled pixel | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/font-similar.svg`, `assets/icons/font-variable.svg` | Font menu filter glyphs: two waves (Show Similar Fonts) and a T over a slider (Show Variable Fonts), drawn on the 24 px icon grid | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
| `assets/icons/convert-point.svg` | Convert Point tool glyph: an angle with a square anchor on its apex, drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 |
+16
View File
@@ -0,0 +1,16 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect x="3" y="10" width="18" height="7" rx="2" />
<path d="M8 12v3M16 12v3" />
<circle cx="12" cy="13.5" r="1.1" />
<path d="M8.5 8.4q3.5-2.6 7 0" stroke-dasharray="0.6 1.6" />
</svg>

After

Width:  |  Height:  |  Size: 394 B

+1
View File
@@ -152,6 +152,7 @@ pub static ICONS: &[(&str, &[u8])] = &[
("slice-select", include_bytes!("../../../assets/icons/slice-select.svg")),
("sliders-horizontal", include_bytes!("../../../assets/icons/sliders-horizontal.svg")),
("sparkles", include_bytes!("../../../assets/icons/sparkles.svg")),
("spirit-level", include_bytes!("../../../assets/icons/spirit-level.svg")),
("spline", include_bytes!("../../../assets/icons/spline.svg")),
("square", include_bytes!("../../../assets/icons/square.svg")),
("square-dashed", include_bytes!("../../../assets/icons/square-dashed.svg")),
+6 -1
View File
@@ -176,7 +176,12 @@ pub fn draw(app: &PhotocraftApp, painter: &egui::Painter, to_screen: impl Fn([f6
/// The options-bar Straighten button (Photoshop's level icon), lit while armed.
pub fn options_button(s: &mut Straighten, ui: &mut egui::Ui) {
if crate::icons::button(ui, "ruler", 24.0, s.armed, tl!("Straighten the image by drawing a line on it")).clicked() {
// One button, icon and label, as the reference options bar shows it; lit while armed.
let t = crate::theme::Tokens::get(ui.ctx());
let tint = if s.armed { t.accent_text } else { t.icon };
let button =
egui::Button::image_and_text(crate::icons::image("spirit-level", 16.0, tint), tl!("Straighten")).selected(s.armed).min_size(egui::vec2(0.0, 24.0));
if ui.add(button).on_hover_text(tl!("Straighten the image by drawing a line on it")).clicked() {
s.toggle();
}
}
@@ -0,0 +1,34 @@
//! #10888: the Crop options bar's chrome. The Straighten button carries the reference label and
//! the new spirit-level glyph; the rest of the item's checks land with their controls.
use egui_kittest::Harness;
use egui_kittest::kittest::Queryable;
use photocraft_ui_egui::crop_straighten::{self, Straighten};
fn harness() -> Harness<'static, Straighten> {
let h = Harness::builder()
.with_size(egui::vec2(260.0, 60.0))
.with_max_steps(64)
.build_ui_state(|ui, s: &mut Straighten| crop_straighten::options_button(s, ui), Straighten::default());
// The SVG glyph needs the app's image loaders; the label and the click do not.
photocraft_ui_egui::PhotocraftApp::setup_context(&h.ctx, Default::default());
h
}
#[test]
fn the_straighten_button_shows_its_label_and_arms() {
let mut h = harness();
h.run();
assert!(h.query_by_label("Straighten").is_some(), "the button carries the reference label");
h.get_by_label("Straighten").click();
h.run();
assert!(h.state().armed, "the button arms straighten");
h.get_by_label("Straighten").click();
h.run();
assert!(!h.state().armed, "clicking again disarms it");
}
#[test]
fn the_straighten_glyph_is_embedded() {
assert!(photocraft_ui_egui::icons::exists("spirit-level"));
}
+1
View File
@@ -21,6 +21,7 @@ mod crop_ctrl_straighten;
mod crop_default_mode;
mod crop_defaults;
mod crop_frame_look;
mod crop_options_bar_chrome;
mod crop_overlay_icons;
mod crop_popup_keys;
mod crop_shift_corner;