mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 18:23:52 -06:00
canvas: the document selection look, slide-wide ruler numbers; Home's font box opens on a click
The selection box draws round handles with a neutral rim, a thin neutral frame and the circular-arrow rotate handle, and dashes the frame while its text is edited, in place of the separate dashed outline. The text ruler numbers from the slide's edge across the strip. The Home font box opens its list on a name click. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5fae147c51
commit
106e5f6fb7
@@ -1,11 +1,10 @@
|
||||
//! Selection decoration; engine pointer gestures own every document edit.
|
||||
|
||||
use craft::behavior::geometry::quad::{BoxAllow, BoxRules, BoxState};
|
||||
use craft::behavior::kurbo::{BezPath, Point, Rect};
|
||||
use craft::behavior::kurbo::{Point, Rect};
|
||||
use craft::draw::ui::transform::TransformReach;
|
||||
use craft::draw::ui::{AdjustHandles, RotateZone, TransformBox};
|
||||
use craft::draw::ui::{AdjustHandles, BoxLook, RotateZone, TransformBox};
|
||||
use craft::ui::canvas::CanvasSpace;
|
||||
use craft::ui::canvas_controls::SelectionOutline;
|
||||
use craft::ui::contract::{Bind, Props as _, Show as _};
|
||||
use craft::ui::primitives::{Draw, HandleShape, PaintShape, StrokeWidth};
|
||||
use craft::ui::style::{Flags, State, StateSet, StyleCx};
|
||||
@@ -23,8 +22,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
let Some(sh) = st.shape(*id) else { continue };
|
||||
let x = deckcraft_engine::cmd::xfrm_of(&st.doc, &st.selection, sh);
|
||||
let a = x.affine();
|
||||
let start = Rect::new(0.0, 0.0, x.w, x.h);
|
||||
let quad = BoxState::from_rect(start).quad.map(|q| a * q);
|
||||
if sh.is_line() {
|
||||
let glued = match &sh.kind {
|
||||
deckcraft_model::ShapeKind::Connector { start, end, .. } => [start.is_some(), end.is_some()],
|
||||
@@ -58,16 +55,6 @@ pub(crate) fn show(app: &mut SlideApp, ui: &mut egui::Ui, space: &CanvasSpace) {
|
||||
});
|
||||
continue;
|
||||
}
|
||||
let editing_this = editing_shape(st, sh);
|
||||
if editing_this {
|
||||
let mut path = BezPath::new();
|
||||
path.move_to(quad[0]);
|
||||
for point in &quad[1..] {
|
||||
path.line_to(*point);
|
||||
}
|
||||
path.close_path();
|
||||
SelectionOutline::dashed("Text frame", &[path]).id(ui.id().with(("text_frame", *id))).show_at(ui, space.view.rect);
|
||||
}
|
||||
let Some((_, control)) = selection_box(st, sh) else { continue };
|
||||
control.id(ui.id().with(("selection", *id))).show_at(ui, space.view.rect);
|
||||
if !sh.locked {
|
||||
@@ -121,7 +108,7 @@ pub(super) fn selection_box(st: &deckcraft_engine::DocState, sh: &deckcraft_mode
|
||||
let control = TransformBox::new("Selection", Bind::given(state), start, 0.0)
|
||||
.reach(TransformReach::Shown)
|
||||
.rotate_zone(if editing { RotateZone::Band } else { RotateZone::Handle })
|
||||
.round_handles(true)
|
||||
.look(if editing { BoxLook::DocumentEditing } else { BoxLook::Document })
|
||||
.reference_point(false)
|
||||
.rules(rules)
|
||||
.enabled(!sh.locked);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use craft::behavior::kurbo::Point;
|
||||
use craft::behavior::{EditEvent, RulerUnits, Ticks};
|
||||
use craft::text::ui::DocUnit;
|
||||
use craft::text::ui::ruler::{ParagraphModel, RulerValues, TabAlign, TabLeader, TabStop, TextRuler};
|
||||
use craft::text::ui::ruler::{ParagraphModel, RulerNumbers, RulerValues, TabAlign, TabLeader, TabStop, TextRuler};
|
||||
use craft::ui::canvas::{CanvasSpace, RulerText, Rulers};
|
||||
use craft::ui::contract::{Bind, Show as _};
|
||||
use craft::ui::runtime::env::UnitKind;
|
||||
@@ -64,6 +64,7 @@ pub(crate) fn show_text_ruler(app: &mut SlideApp, ui: &mut egui::Ui, space: &Can
|
||||
.corner(corner)
|
||||
.scale(space.view.zoom as f32)
|
||||
.origin(space.view.to_screen(Point::new(number("x"), 0.0)).x)
|
||||
.numbers(RulerNumbers::document(number("x") as f32))
|
||||
.unit(doc_unit(unit))
|
||||
.kind(app.ruler_tab_kind)
|
||||
.show_at(ui, top.union(corner));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Home ribbon controls over the registered command surface.
|
||||
|
||||
use craft::font_manager::picker::{FontPicker, FontPickerKind, HostFontGroup};
|
||||
use craft::font_manager::picker::{FontPicker, FontPickerKind, HostFontGroup, NameClick};
|
||||
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::ui::buttons::{Arrangement, Button, IconButton, PopupMark, SplitButton, SplitMenu, ToggleButton};
|
||||
use craft::ui::contract::{Bind, Entry, Gap, PopupKind, Props, Show, ShowContainer, TooltipSpec, Trigger};
|
||||
@@ -126,6 +126,7 @@ fn font(app: &mut SlideApp, ui: &mut Ui, state: &Value) {
|
||||
let actions = [Word::plain("Rescan Installed Fonts").into()];
|
||||
let picked = FontPicker::new(Word::plain("Font"), Bind::given(family), fonts::catalog())
|
||||
.kind(FontPickerKind::Plain)
|
||||
.name_click(NameClick::OpensList)
|
||||
.host(&groups)
|
||||
.actions(&actions)
|
||||
.enabled(commands::resolve(ui.ctx(), "format.font").enabled)
|
||||
|
||||
Reference in New Issue
Block a user