mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 05:14:24 +00:00
Draw stories: AddBeside readout from the measuring run too; the transform story shows the reference point
This commit is contained in:
@@ -75,19 +75,26 @@ fn on_canvas<'a>(ui: &mut Ui, data: &mut StoryData, rect: Rect, handles: impl Fn
|
||||
(handles(body.rect).show_at(ui, body.rect), name_clicked)
|
||||
});
|
||||
let last = data.note("clicked", None::<(AddSide, bool)>);
|
||||
let Some((output, name_clicked)) = shown.inner else { return StoryOutput::default() };
|
||||
if let Some(side) = output.added {
|
||||
*last = Some((side, output.copy));
|
||||
}
|
||||
// A measuring run shows no canvas body; the readout still shows, so the card keeps its line.
|
||||
let (facts, hovered) = match shown.inner {
|
||||
Some((output, name_clicked)) => {
|
||||
if let Some(side) = output.added {
|
||||
*last = Some((side, output.copy));
|
||||
}
|
||||
let hovered = output.hovered;
|
||||
// The artboard's name is a button too: its click is a click of the story.
|
||||
let mut facts = StoryOutput::from(output);
|
||||
facts.clicked |= name_clicked;
|
||||
(facts, hovered)
|
||||
}
|
||||
None => (StoryOutput::default(), None),
|
||||
};
|
||||
let named = |template: &str, side: AddSide| craft_i18n::fmt(template, &[("side", side_name(&sides, side))]);
|
||||
let readout = match (output.hovered, *last) {
|
||||
let readout = match (hovered, *last) {
|
||||
(Some(side), _) => named(words.hovered.as_str(), side),
|
||||
(None, Some((side, copy))) => named(if copy { words.copy.as_str() } else { words.clicked.as_str() }, side),
|
||||
(None, None) => words.none.as_str().to_owned(),
|
||||
};
|
||||
// The artboard's name is a button too: its click is a click of the story.
|
||||
let mut facts = StoryOutput::from(output);
|
||||
facts.clicked |= name_clicked;
|
||||
facts.readout(readout)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,11 @@ impl TransformKept {
|
||||
}
|
||||
}
|
||||
|
||||
/// The persisted settings the story starts from: the defaults with Show Reference Point on, so the point shows.
|
||||
fn sample_settings() -> TransformSettings {
|
||||
TransformSettings { show_reference_point: true, ..TransformSettings::default() }
|
||||
}
|
||||
|
||||
/// A session on the layer, its box at `state`.
|
||||
fn open(state: BoxState, settings: &TransformSettings) -> TransformSession<()> {
|
||||
TransformSession::with_state(FRAME, state).settings(settings)
|
||||
@@ -67,9 +72,9 @@ fn open(state: BoxState, settings: &TransformSettings) -> TransformSession<()> {
|
||||
#[story(TransformOverlay<'static, ()>, covers = [Default])]
|
||||
fn transform_phase(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let words = Env::of(ui).words::<TransformStoryWords>();
|
||||
let first = data.value("settings", TransformSettings::default()).clone();
|
||||
let first = data.value("settings", sample_settings()).clone();
|
||||
let kept = story_tool(data, || TransformKept::new(&first));
|
||||
let settings = data.value("settings", TransformSettings::default());
|
||||
let settings = data.value("settings", sample_settings());
|
||||
// The bar shows before the canvas, as the app's options bar does: its edits reach the session on this pass.
|
||||
let bar = TransformBar::new("Free Transform", &kept.borrow().session, Bind::bound(settings)).show(ui);
|
||||
let settings = settings.clone();
|
||||
|
||||
Reference in New Issue
Block a user