Merge look-fix2 app work (slot 4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-29 20:44:32 +00:00
co-authored by Claude Opus 5.5
6 changed files with 57 additions and 13 deletions
+1 -1
View File
@@ -83,7 +83,7 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut Ui) {
let mut ask = None;
let mut view = space.target();
let pages = if empty { Vec::new() } else { vec![PageFrame::new(document)] };
Pasteboard::new(Word::plain("Slide pasteboard"), &pages).border(PageBorder::DropShadow).show_at(ui, body.rect);
Pasteboard::new(Word::plain("Slide pasteboard"), &pages).border(PageBorder::Line).show_at(ui, body.rect);
if empty {
let mut prompt = Text::new(Word::plain("Click to add first slide")).role(TypeRole::Heading).shade(Shade::Muted);
let extent = prompt.measure_in(ui, Proposal::Width(body.rect.width()));
+5
View File
@@ -1,5 +1,6 @@
use craft::behavior::kurbo::{Point, Rect, Vec2};
use craft::behavior::{Axis, EditEvent};
use craft::theme::Rgba;
use craft::ui::canvas::{CanvasSpace, Guide, GuideKey, GuideLine};
use craft::ui::canvas_controls::{CanvasGrid, GridCrowding, GuideReadout, Guides};
use craft::ui::contract::{Bind, Show as _};
@@ -9,6 +10,9 @@ use serde_json::json;
use crate::SlideApp;
/// The drawing guides' ink: one see-through mid grey in every theme, so a guide reads on any slide.
const GUIDE_INK: Rgba = Rgba([120, 120, 120, 170]);
/// Selected guide indices and the document guide list they identify; never saved.
#[derive(Clone, Debug, Default, PartialEq)]
pub(crate) struct GuideSelection {
@@ -60,6 +64,7 @@ pub(crate) fn show_guides(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasS
.map(|(index, guide)| {
let mut value = Guide::new(GuideKey::new(index as u64), if guide.vertical { Axis::Y } else { Axis::X }, guide.pos);
value.line = GuideLine::Dashed;
value.color = Some(GUIDE_INK);
value.span = Some((0.0, if guide.vertical { size.height } else { size.width }));
value
})
+2 -2
View File
@@ -115,9 +115,9 @@ pub(super) fn selection_box(st: &deckcraft_engine::DocState, sh: &deckcraft_mode
Some((state, control))
}
/// Paints engine-owned points with the framework handle look and state.
/// Paints engine-owned points with the selection box's handle look and state.
pub(super) fn paint_handle(draw: &Draw<'_>, style: &StyleCx<'_>, shape: HandleShape, at: egui::Pos2, selected: bool, locked: bool) {
let look = style.handle();
let look = BoxLook::Document.handle_look(style);
let mut state = StateSet::default();
state.flags.set(Flags::SELECTED, selected);
if locked {
+2 -1
View File
@@ -30,7 +30,8 @@ pub(crate) fn paint(draw: &Draw<'_>, cx: &ToolContext<'_>, app: &SlideApp) {
SmartLine::new(a, b).dashed()
})
.collect();
cx.paint_smart_guides(&SmartGuides::new(&lines, &[]));
// Smart guides take the accent, as a dragged guide does.
cx.paint_smart_guides(&SmartGuides::new(&lines, &[]).color(DataColor::new(accent.egui())));
if let Some(rect) = tool.marquee {
cx.paint_marquee(&Marquee::rect("Selection band", rect).look(MarqueeLook::Band));
}
+18
View File
@@ -181,3 +181,21 @@ fn tabs_dialog_sets_clears_and_applies_on_ok() {
h.state_mut().session.execute("edit.undo", &json!({})).unwrap();
assert_eq!(ruler(&mut h), before, "one undo restores both the stops and the default interval");
}
/// The slide rulers label whole inches and centimetres, never closer than a label needs at any zoom, and write a
/// minus sign left of and above the slide's edge.
#[test]
fn slide_rulers_label_whole_units_with_room_and_sign_the_far_side() {
use craft::ui::canvas::CENTIMETRE_LABEL_STEP_MIN;
use deckcraft_geom::Unit;
for unit in [Unit::Inches, Unit::Centimeters] {
let units = super::rulers::ruler_text(unit).units;
for zoom in [0.05, 0.2, 0.5, 1.0, 2.0, 8.0] {
let (step, _) = units.step(zoom, 0.0);
assert_eq!(step.fract(), 0.0, "{unit:?} at zoom {zoom}: labels on whole units, step {step}");
let apart = step / units.per_doc * zoom;
assert!(apart >= f64::from(CENTIMETRE_LABEL_STEP_MIN), "{unit:?} at zoom {zoom}: labels {apart} points apart");
}
assert!(units.label_value(-1.0, 1.0) < 0.0, "{unit:?}: a label left of the slide is negative");
}
}
+29 -9
View File
@@ -1,8 +1,8 @@
use craft::behavior::kurbo::Point;
use craft::behavior::{EditEvent, RulerUnits, Ticks};
use craft::behavior::{EditEvent, RulerUnits, TickLabels, Ticks};
use craft::text::ui::DocUnit;
use craft::text::ui::ruler::{ParagraphModel, RulerNumbers, RulerValues, TabAlign, TabLeader, TabStop, TextRuler};
use craft::ui::canvas::{CanvasSpace, RulerText, Rulers};
use craft::ui::canvas::{CENTIMETRE_LABEL_STEP_MIN, CanvasSpace, RulerText, Rulers};
use craft::ui::contract::{Bind, Show as _};
use craft::ui::runtime::env::UnitKind;
use deckcraft_geom::Unit;
@@ -10,16 +10,36 @@ use serde_json::json;
use crate::SlideApp;
/// The document's unit scale and tick rule for both canvas rulers.
/// The document's unit scale and tick rule for both canvas rulers, numbered from the slide's edge with a minus sign
/// before it.
// PLAN: plan error: canvas-w6 must supply ruler_text(prefs.units) to Canvas::rulers; Rulers owns no unit prop.
pub(super) fn ruler_text(unit: Unit) -> RulerText {
let kind = match unit {
Unit::Inches => UnitKind::Inches,
Unit::Centimeters => UnitKind::Centimetres,
Unit::Points => UnitKind::Points,
Unit::Pixels => UnitKind::Pixels,
let (kind, ticks) = match unit {
Unit::Inches => (UnitKind::Inches, Ticks::Custom(inch_steps)),
Unit::Centimeters => (UnitKind::Centimetres, Ticks::Custom(centimetre_steps)),
Unit::Points => (UnitKind::Points, Ticks::decimal(false)),
Unit::Pixels => (UnitKind::Pixels, Ticks::decimal(true)),
};
RulerText::new(RulerUnits::new(1.0 / unit.points_per_unit(), Ticks::decimal(unit == Unit::Pixels)), kind)
RulerText::new(RulerUnits::new(1.0 / unit.points_per_unit(), ticks).with_labels(TickLabels::Signed), kind)
}
/// A label every inch with quarter-inch ticks.
fn inch_steps(points_per_inch: f64) -> (f64, u32) {
whole_steps(points_per_inch, 4)
}
/// A label every centimetre with half-centimetre ticks.
fn centimetre_steps(points_per_cm: f64) -> (f64, u32) {
whole_steps(points_per_cm, 2)
}
/// Every whole unit labelled with `subdivisions` ticks to it; where a unit is too narrow for its label, every 2, 5, 10
/// and so on units, halved.
fn whole_steps(points_per_unit: f64, subdivisions: u32) -> (f64, u32) {
const STEPS: [f64; 7] = [1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0];
let room = f64::from(CENTIMETRE_LABEL_STEP_MIN);
let step = STEPS.into_iter().find(|step| step * points_per_unit >= room).unwrap_or(1000.0);
(step, if step > 1.0 { 2 } else { subdivisions })
}
/// The document's unit as the text controls take it: the ruler's, and the Tabs dialog it opens.