mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-02 02:36:14 -06:00
Ribbon group content, value menus, font size box and SmartArt layout pictures
- Transitions: Sound and Duration are labelled fields, Timing stacks in three rows with step arrows; the Loop Until Next Sound box the old ribbon lacked is gone (transition.sound still takes loop). - Insert: Video and Audio short labels. - View: Ruler, Gridlines and Guides labels, "Zoom" split label, "Grid Options" without dots. - Table Design: Shading is a small swatch split; Layout: horizontal alignment is icon-only. - SmartArt Design: Insert Picture on Add Shape's row. - Value menus mark the current value with the selection fill (ValueMark::Fill at the root). - The font size box opens its list on a click on the number. - SmartArt layout pictures draw without the transparency grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5a3bae4cc0
commit
02a6625c5e
@@ -121,13 +121,15 @@ pub(crate) fn smartart_gallery(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<
|
||||
.max_rows(20)
|
||||
.show_items(ui, &source, &mut |kind, item| {
|
||||
let label = layouts.iter().find(|(name, _)| name == kind).map_or(*kind, |(_, label)| *label);
|
||||
// Layout pictures are opaque drawings on the tile: no transparency grid behind them.
|
||||
let preview = Picture::rendered(label, pictures.key(kind, true), &thumbs, &pictures)
|
||||
.aspect(ThumbAspect::new(96, 60))
|
||||
.extent(PictureSize::Thumb(craft::ui::list::ThumbSize::Large));
|
||||
.extent(PictureSize::Thumb(craft::ui::list::ThumbSize::Large))
|
||||
.checker(false);
|
||||
item.tip(move |ui| {
|
||||
preview.show(ui);
|
||||
});
|
||||
Tile::new(label).picture(ThumbAspect::new(96, 60), Picture::rendered("", pictures.key(kind, false), &thumbs, &pictures))
|
||||
Tile::new(label).picture(ThumbAspect::new(96, 60), Picture::rendered("", pictures.key(kind, false), &thumbs, &pictures).checker(false))
|
||||
});
|
||||
if let Some(kind) = activated(&out.response.events) {
|
||||
let mut args = extra;
|
||||
|
||||
@@ -12,7 +12,7 @@ use craft::ui::primitives::{IconMark, IconSpec};
|
||||
use craft::ui::runtime::commands::{self, CommandRef};
|
||||
use craft::ui::runtime::env::{Env, Word};
|
||||
use craft::ui::style::DataColor;
|
||||
use craft::ui::text::{NumberField, NumberPick};
|
||||
use craft::ui::text::{NumberField, NumberPick, PresetClick};
|
||||
use egui::{Color32, Ui};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
@@ -151,6 +151,7 @@ fn font(app: &mut SlideApp, ui: &mut Ui, state: &Value) {
|
||||
deckcraft_engine::cmd::format::SIZES.iter().map(|size| Entry::new(NumberPick::Number(*size), size.to_string())).collect();
|
||||
let size = NumberField::new(Word::plain("Font size"), Bind::given(state["size"].as_f64()))
|
||||
.presets(&presets)
|
||||
.preset_click(PresetClick::OpensList)
|
||||
.enabled(commands::resolve(ui.ctx(), "format.size").enabled)
|
||||
.show(ui);
|
||||
if let Some(Some(size)) = size.events.committed() {
|
||||
|
||||
@@ -194,8 +194,8 @@ pub(crate) fn insert(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
}
|
||||
});
|
||||
row.group(RibbonGroup::new("media", "Media", Icon::Video.id().into()), |ui| {
|
||||
Button::command("app.insertVideoDialog").icon(Icon::Video.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
Button::command("app.insertAudioDialog").icon(Icon::Audio.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
Button::command("app.insertVideoDialog").label("Video").icon(Icon::Video.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
Button::command("app.insertAudioDialog").label("Audio").icon(Icon::Audio.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::ui::buttons::{Arrangement, Button};
|
||||
use craft::ui::contract::{Entry, Gap, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::controls::disclosure::DisclosureGlyph;
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::runtime::commands::{self, CommandRef};
|
||||
|
||||
@@ -34,11 +34,22 @@ pub(crate) fn smartart_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
.tooltip("Type and organise the diagram's text")
|
||||
.show(ui);
|
||||
Stack::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let opener = Button::new("Add Shape")
|
||||
.icon(Icon::Plus.id())
|
||||
.trailing_icon(DisclosureGlyph::menu_button())
|
||||
.enabled(menu_enabled(ui, "smartArt.addNode"))
|
||||
.show(ui);
|
||||
// Insert Picture stands on Add Shape's row, after it.
|
||||
let opener = Row::new().gap(Gap::Tight).show(ui, |ui, _| {
|
||||
let opener = Button::new("Add Shape")
|
||||
.icon(Icon::Plus.id())
|
||||
.trailing_icon(DisclosureGlyph::menu_button())
|
||||
.enabled(menu_enabled(ui, "smartArt.addNode"))
|
||||
.show(ui);
|
||||
Button::command(CommandRef::with_params("app.smartArtPictureDialog", json!({"id": gid, "index": at})))
|
||||
.icon(Icon::Picture.id())
|
||||
.label("Insert Picture")
|
||||
.enabled(kind.starts_with("picture") && n > 0)
|
||||
.tooltip("Put a picture in the selected node's picture placeholder")
|
||||
.show(ui);
|
||||
opener
|
||||
});
|
||||
let Some(opener) = opener.inner else { return };
|
||||
Menu::new("Add Shape").opened_by(&opener.response, Trigger::Click).show(ui, |ui, cx| {
|
||||
for (label, position) in [
|
||||
("Add Shape After", "after"),
|
||||
@@ -61,12 +72,6 @@ pub(crate) fn smartart_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
Button::command(CommandRef::with_params(command, json!({"id": gid, "index": at}))).icon(icon.id()).label(label).show(ui);
|
||||
}
|
||||
});
|
||||
Button::command(CommandRef::with_params("app.smartArtPictureDialog", json!({"id": gid, "index": at})))
|
||||
.icon(Icon::Picture.id())
|
||||
.label("Insert Picture")
|
||||
.enabled(kind.starts_with("picture") && n > 0)
|
||||
.tooltip("Put a picture in the selected node's picture placeholder")
|
||||
.show(ui);
|
||||
});
|
||||
row.group(RibbonGroup::new("diagram.layouts", "Layouts", Icon::Layout.id().into()), |ui| {
|
||||
let opener = Button::new("Layouts")
|
||||
|
||||
@@ -95,18 +95,21 @@ pub(crate) fn table_design(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
row.group(RibbonGroup::new("table.shading", "Shading", Icon::Shading.id().into()), |ui| {
|
||||
let accent = app.color_scheme().get(deckcraft_color::SchemeSlot::Accent1);
|
||||
let accent = Color32::from_rgb(accent.r, accent.g, accent.b);
|
||||
SplitButton::<()>::command(
|
||||
CommandRef::with_params("table.cellFill", json!({"color": "accent1"})),
|
||||
SplitMenu::Body(Box::new(|ui, cx| {
|
||||
if let Some(pick) = color_menu(app, ui, cx, shading_key, Some("No Fill")) {
|
||||
apply_shading(app, pick);
|
||||
}
|
||||
})),
|
||||
)
|
||||
.label("Shading")
|
||||
.arrangement(Arrangement::Stacked)
|
||||
.icon(IconSpec::svg(Icon::Shading.id()).with_mark(IconMark::weighted_bar(DataColor::from(accent), 3.5)))
|
||||
.show(ui);
|
||||
// A small swatch split on the group's top row, as the font colour's.
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
SplitButton::<()>::command(
|
||||
CommandRef::with_params("table.cellFill", json!({"color": "accent1"})),
|
||||
SplitMenu::Body(Box::new(|ui, cx| {
|
||||
if let Some(pick) = color_menu(app, ui, cx, shading_key, Some("No Fill")) {
|
||||
apply_shading(app, pick);
|
||||
}
|
||||
})),
|
||||
)
|
||||
.label("Shading")
|
||||
.icon(IconSpec::svg(Icon::Shading.id()).with_mark(IconMark::bar(DataColor::from(accent))))
|
||||
.icon_only()
|
||||
.show(ui);
|
||||
});
|
||||
});
|
||||
let pen_key = "ribbon.tableDesign.penColor";
|
||||
if let Some(Some(color)) = take_color_answer(app, pen_key) {
|
||||
@@ -278,7 +281,7 @@ pub(crate) fn table_layout(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
(Icon::AlignCenter, "Center", "format.alignCenter"),
|
||||
(Icon::AlignRight, "Align Right", "format.alignRight"),
|
||||
] {
|
||||
ToggleButton::command(id).icon(icon.id()).label(label).show(ui);
|
||||
ToggleButton::command(id).icon(icon.id()).label(label).icon_only().show(ui);
|
||||
}
|
||||
});
|
||||
Row::new().show(ui, |ui, _| {
|
||||
|
||||
@@ -7,11 +7,13 @@ use craft::menu::ribbon::{Gallery, GalleryFace, GalleryItem, GalleryMore, Ribbon
|
||||
use craft::ui::buttons::{Arrangement, Button, ToggleButton};
|
||||
use craft::ui::choice::Checkbox;
|
||||
use craft::ui::contract::{Bind, BodyCx, Entry, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
use craft::ui::form::Field;
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::menu::{Menu, MenuItem};
|
||||
use craft::ui::pickers::Select;
|
||||
use craft::ui::primitives::ContentPainterCx;
|
||||
use craft::ui::text::NumberField;
|
||||
use craft::ui::text::{NumberField, StepArrows};
|
||||
use craft::ui::tile_grid::{CaptionPlace, Tile, TileGrid};
|
||||
use egui::{CornerRadius, Rect, Stroke, Ui, pos2, vec2};
|
||||
use serde_json::{Value, json};
|
||||
@@ -121,9 +123,11 @@ pub(crate) fn transitions(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
entries.push(Entry::separator());
|
||||
let other = Entry::new(SoundChoice::Other, "Other Sound…").stepped(false);
|
||||
entries.push(if app.host.files().can_pick() { other } else { other.disabled_reason("Choosing a sound file needs the desktop app") });
|
||||
let output = Select::new("Sound:", Bind::given(value), &entries).placeholder(name).show(ui);
|
||||
let mut field = Field::new("Sound").id_salt("sound").show(ui, |ui, _| {
|
||||
Select::new("Sound", Bind::given(value.clone()), &entries).placeholder(name.clone()).show(ui).events.committed().cloned()
|
||||
});
|
||||
let looping = cur.as_ref().is_some_and(|t| t.sound_loop);
|
||||
if let Some(choice) = output.events.committed() {
|
||||
if let Some(choice) = field.settle(|_, value| value.take()).flatten() {
|
||||
match choice {
|
||||
SoundChoice::None => {
|
||||
let _ = app.run("transition.sound", json!({"none": true}));
|
||||
@@ -138,40 +142,58 @@ pub(crate) fn transitions(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
SoundChoice::Stored => {}
|
||||
}
|
||||
}
|
||||
let output = Checkbox::new(Bind::given(looping)).label("Loop Until Next Sound").enabled(has_sound).show(ui);
|
||||
if let Some(looping) = output.events.committed() {
|
||||
let _ = app.run("transition.sound", json!({"loop": looping}));
|
||||
}
|
||||
});
|
||||
row.group(RibbonGroup::new("timing", "Timing", Icon::Duration.id().into()), |ui| {
|
||||
let duration = cur.as_ref().map(|t| t.duration_ms as f64 / 1000.0).unwrap_or(1.0);
|
||||
let output = NumberField::new("Duration:", Bind::given(Some(duration))).range(0.0..=f64::MAX).step(0.25).unit("s").show(ui);
|
||||
if let Some(seconds) = output.events.committed().and_then(|value| *value) {
|
||||
let _ = app.run("transition.timing", json!({"duration": (seconds * 1000.0).round() as u64}));
|
||||
}
|
||||
let click = cur.as_ref().is_none_or(|t| t.advance_on_click);
|
||||
let output = Checkbox::new(Bind::given(click)).label("On Mouse Click").show(ui);
|
||||
if let Some(click) = output.events.committed() {
|
||||
let _ = app.run("transition.timing", json!({"onClick": click}));
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let after = cur.as_ref().and_then(|t| t.advance_after_ms);
|
||||
let output = Checkbox::new(Bind::given(after.is_some())).label("After:").show(ui);
|
||||
if let Some(on) = output.events.committed() {
|
||||
let _ = app.run("transition.timing", json!({"after": if *on { json!(after.unwrap_or(0)) } else { Value::Null }}));
|
||||
}
|
||||
let output =
|
||||
NumberField::new("After", Bind::given(Some(after.unwrap_or(0) as f64 / 1000.0))).range(0.0..=f64::MAX).step(1.0).unit("s").show(ui);
|
||||
if let Some(seconds) = output.events.committed().and_then(|value| *value) {
|
||||
let _ = app.run("transition.timing", json!({"after": (seconds * 1000.0).round() as u64}));
|
||||
}
|
||||
});
|
||||
// Duration, On Mouse Click and After stand in three rows, as the old ribbon stacked them.
|
||||
Stack::new().show(ui, |ui, _| timing(app, ui, cur.as_ref()));
|
||||
});
|
||||
row.group(RibbonGroup::new("apply", "Apply To All", Icon::ApplyToAll.id().into()), |ui| {
|
||||
Button::command("transition.applyAll").label("Apply\nTo All").icon(Icon::ApplyToAll.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
});
|
||||
}
|
||||
|
||||
/// The Timing group's labelled Duration field, On Mouse Click, and the After check box with its field, over the
|
||||
/// current transition `cur`.
|
||||
fn timing(app: &mut SlideApp, ui: &mut Ui, cur: Option<&deckcraft_model::Transition>) {
|
||||
let duration = cur.map(|t| t.duration_ms as f64 / 1000.0).unwrap_or(1.0);
|
||||
let mut field = Field::new("Duration").id_salt("duration").show(ui, |ui, _| {
|
||||
NumberField::new("Duration", Bind::given(Some(duration)))
|
||||
.range(0.0..=f64::MAX)
|
||||
.step(0.25)
|
||||
.unit("s")
|
||||
.step_arrows(StepArrows::Trailing)
|
||||
.show(ui)
|
||||
.events
|
||||
.committed()
|
||||
.copied()
|
||||
.flatten()
|
||||
});
|
||||
if let Some(seconds) = field.settle(|_, value| value.take()).flatten() {
|
||||
let _ = app.run("transition.timing", json!({"duration": (seconds * 1000.0).round() as u64}));
|
||||
}
|
||||
let click = cur.is_none_or(|t| t.advance_on_click);
|
||||
let output = Checkbox::new(Bind::given(click)).label("On Mouse Click").show(ui);
|
||||
if let Some(click) = output.events.committed() {
|
||||
let _ = app.run("transition.timing", json!({"onClick": click}));
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
let after = cur.and_then(|t| t.advance_after_ms);
|
||||
let output = Checkbox::new(Bind::given(after.is_some())).label("After:").show(ui);
|
||||
if let Some(on) = output.events.committed() {
|
||||
let _ = app.run("transition.timing", json!({"after": if *on { json!(after.unwrap_or(0)) } else { Value::Null }}));
|
||||
}
|
||||
let output = NumberField::new("After", Bind::given(Some(after.unwrap_or(0) as f64 / 1000.0)))
|
||||
.range(0.0..=f64::MAX)
|
||||
.step(1.0)
|
||||
.unit("s")
|
||||
.step_arrows(StepArrows::Trailing)
|
||||
.show(ui);
|
||||
if let Some(seconds) = output.events.committed().and_then(|value| *value) {
|
||||
let _ = app.run("transition.timing", json!({"after": (seconds * 1000.0).round() as u64}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn paint_transition_tile(cx: &ContentPainterCx<'_>, r: Rect, id: &str) {
|
||||
let p = &cx.painter;
|
||||
let (accent, well, sunken, border, on_accent) = cx.with_draw(|draw| {
|
||||
|
||||
@@ -39,11 +39,11 @@ pub(crate) fn view(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
row.group(RibbonGroup::new("show", "Show", Icon::Gridlines.id().into()), |ui| {
|
||||
Stack::new().show(ui, |ui, _| {
|
||||
Checkbox::new(Bind::given(app.ui.ruler)).command("view.ruler").show(ui);
|
||||
Checkbox::new(Bind::given(app.ui.gridlines)).command("view.gridlines").show(ui);
|
||||
Checkbox::new(Bind::given(app.ui.guides)).command("view.guides").show(ui);
|
||||
Checkbox::new(Bind::given(app.ui.ruler)).command("view.ruler").label("Ruler").show(ui);
|
||||
Checkbox::new(Bind::given(app.ui.gridlines)).command("view.gridlines").label("Gridlines").show(ui);
|
||||
Checkbox::new(Bind::given(app.ui.guides)).command("view.guides").label("Guides").show(ui);
|
||||
});
|
||||
Button::command("view.gridOptions").icon(Icon::Gridlines.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
Button::command("view.gridOptions").label("Grid Options").icon(Icon::Gridlines.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
ToggleButton::command("view.notes").icon(Icon::Notes.id()).arrangement(Arrangement::Stacked).show(ui);
|
||||
});
|
||||
row.group(RibbonGroup::new("zoom", "Zoom", Icon::ZoomGlass.id().into()), |ui| {
|
||||
@@ -51,6 +51,7 @@ pub(crate) fn view(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
[400, 200, 150, 100, 75, 66, 50, 33].into_iter().map(|pct| Entry::new(Some(pct), format!("{pct}%"))).collect();
|
||||
entries.push(Entry::new(None, "Fit"));
|
||||
let picked = SplitButton::command("view.zoomDialog", SplitMenu::Entries(&entries))
|
||||
.label("Zoom")
|
||||
.arrow_label("Zoom options")
|
||||
.icon(Icon::ZoomGlass.id())
|
||||
.arrangement(Arrangement::Stacked)
|
||||
|
||||
@@ -275,13 +275,15 @@ pub fn app_sizes() -> std::sync::Arc<craft::theme::AppSizes> {
|
||||
|
||||
/// The app's root values before the frame's own: [`RootEnv`](craft::ui::runtime::env::RootEnv) with DeckCraft's sizes,
|
||||
/// and number fields that write their number and unit as one run at their start, to two decimals ("1.39″", "0.75 pt")
|
||||
/// and whole percents, as the old app's fields did.
|
||||
/// and whole percents, as the old app's fields did. Value menus (Zoom, Change Colors, Paste) mark their current value
|
||||
/// with the selection fill and no radio circles, as the old app's plain lists did.
|
||||
pub fn root_env() -> craft::ui::runtime::env::RootEnv {
|
||||
let mut root = craft::ui::runtime::env::RootEnv::new();
|
||||
root.sizes = app_sizes();
|
||||
root.values.set(craft::ui::text::NumberLook::Inline);
|
||||
root.values.set(craft::ui::text::NumberPrecision::Hundredths);
|
||||
root.values.set(craft::ui::runtime::env::InchSpelling::Mark);
|
||||
root.values.set(craft::ui::menu::ValueMark::Fill);
|
||||
root
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user