mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:47:56 +01:00
Merge branch 'port/deckcraft/cfix/app-3' into port/deckcraft/area/app
This commit is contained in:
commit
e08397aa21
10 files changed
+29
-21
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use craft::host::files::{Picked, ScriptedFiles};
|
||||
use craft::host::{Picked, ScriptedFiles};
|
||||
|
||||
use deckcraft_engine::Session;
|
||||
use egui_kittest::Harness;
|
||||
|
||||
@@ -273,11 +273,15 @@ mod feature_name_tests {
|
||||
let mut session = Session::with_new();
|
||||
session.execute("slide.new", &json!({"layout": "blank"})).unwrap();
|
||||
session.execute("insert.smartArt", &json!({"kind": "process", "items": ["Plan", "Build"]})).unwrap();
|
||||
let mut h = crate::test_harness::harness(session, crate::Services::default());
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
h.state_mut().control_rx = Some(rx);
|
||||
let mut h = crate::test_harness::harness_with(
|
||||
session,
|
||||
crate::Services::default(),
|
||||
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)),
|
||||
|p| p.control = Some(craft::automation::control::ControlChannel::new(rx)),
|
||||
);
|
||||
let saved = "SmartArt Design";
|
||||
let (request, reply) = crate::control::ControlRequest::new("ui.set", json!({"tab": saved}));
|
||||
let (request, reply) = craft::automation::control::ControlRequest::new("ui.set", json!({"tab": saved}));
|
||||
tx.send(request).unwrap();
|
||||
h.run_steps(3);
|
||||
let response = reply.try_recv().expect("the tab request was answered");
|
||||
|
||||
@@ -163,7 +163,7 @@ pub(crate) fn animations(app: &mut SlideApp, row: &mut RibbonRow<'_>) {
|
||||
});
|
||||
});
|
||||
let armed = app.session.anim_painter.is_some();
|
||||
super::home::painter_toggle(app, ui, Icon::AnimationPainter, "Animation\nPainter", "animation.painter", armed);
|
||||
super::home::painter_toggle(app, ui, Icon::AnimationPainter, "Animation\nPainter", "animation.painter", armed, "Animation Painter (double-click to keep it on)");
|
||||
});
|
||||
});
|
||||
row.group(RibbonGroup::new("timing", "Timing", Icon::Duration.id().into()), |ui| {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::{Icon, ShapeId, SlideApp, Ui, json};
|
||||
use super::{Icon, SlideApp, Ui, json};
|
||||
use deckcraft_model::ShapeId;
|
||||
use craft::menu::ribbon::{RibbonGroup, RibbonRow};
|
||||
use craft::ui::buttons::{Arrangement, Button, SplitButton, SplitMenu};
|
||||
use craft::ui::contract::{Bind, BodyCx, Entry, PopupKind, Props as _, Show as _, ShowContainer as _, Trigger};
|
||||
@@ -23,13 +24,13 @@ const ROTATE: [(&str, &str, Icon); 4] = [
|
||||
("Flip Horizontal", "arrange.flipHorizontal", Icon::FlipH),
|
||||
];
|
||||
|
||||
fn command_rows(ui: &mut Ui, rows: &[(&str, &str, Icon)]) {
|
||||
fn command_rows(ui: &mut Ui, rows: &[(&'static str, &'static str, Icon)]) {
|
||||
for (label, id, icon) in rows {
|
||||
MenuItem::command(*id).label(*label).icon(icon.id()).show(ui);
|
||||
}
|
||||
}
|
||||
|
||||
fn entries(ui: &Ui, rows: &[(&str, &str, Icon)]) -> Vec<Entry<CommandRef>> {
|
||||
fn entries(ui: &Ui, rows: &[(&'static str, &'static str, Icon)]) -> Vec<Entry<CommandRef>> {
|
||||
rows.iter()
|
||||
.map(|(label, id, icon)| {
|
||||
let command = CommandRef::new(*id);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use super::{Color32, Rect, SlideApp, Stroke, Ui, Value, json, pos2, theme};
|
||||
use super::{SlideApp, Ui, Value, json};
|
||||
use crate::theme;
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
use craft::ui::contract::{ActivateOn, Bind, BodyCx, CollectionEvent, Props as _, SelectMode, Show as _, ShowCollection as _};
|
||||
use craft::ui::display::{Picture, PictureSize};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use super::arrange::{arrange_group, size_group};
|
||||
use super::galleries::{apply_line_answer, cref_param, effects_menu, outline_menu, quick_styles, shapes_gallery};
|
||||
use super::{Color32, Icon, Rect, SlideApp, Stroke, Ui, json, pos2};
|
||||
use super::{Icon, SlideApp, Ui, json};
|
||||
use egui::{Color32, Rect, Stroke, pos2};
|
||||
use crate::panels::color_row::{color_menu, take_color_answer};
|
||||
use craft::behavior::{Selection, SelectionChange};
|
||||
use craft::keymap::CommandRef;
|
||||
@@ -257,7 +258,7 @@ fn warp_grid(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>, label: &str,
|
||||
let selection =
|
||||
presets.iter().find(|(id, _)| *id == current.as_deref().unwrap_or("none")).map(|(id, _)| Selection::single(*id)).unwrap_or_default();
|
||||
let source = craft::behavior::keyed(presets, |(id, _)| *id);
|
||||
let grid = TileGrid::new(label)
|
||||
let grid = TileGrid::new(label.to_owned())
|
||||
.select(SelectMode::Single)
|
||||
.selection(Bind::given(selection))
|
||||
.allow_empty(false)
|
||||
|
||||
@@ -105,7 +105,7 @@ pub(super) fn zoom_menu(app: &mut SlideApp, ui: &mut Ui, cx: &mut BodyCx<'_>) {
|
||||
for (i, label) in items.iter().enumerate() {
|
||||
let was = app.insert_zoom.picked.contains(&i);
|
||||
let mut on = was;
|
||||
Checkbox::new(Bind::bound(&mut on)).label(label.as_str()).show(ui);
|
||||
Checkbox::new(Bind::bound(&mut on)).label(label.clone()).show(ui);
|
||||
if on != was {
|
||||
if on {
|
||||
app.insert_zoom.picked.push(i);
|
||||
|
||||
@@ -195,8 +195,7 @@ fn show_with_clip() -> (egui_kittest::Harness<'static, SlideApp>, ShapeId, Pos2)
|
||||
harness.run_steps(2);
|
||||
let doc = harness.state().session.active().unwrap().doc.clone();
|
||||
let view = harness.state().show.as_ref().unwrap().view;
|
||||
let slide = Rect::from_two_pos(view.to_screen(Point::ZERO), view.to_screen(Point::new(doc.slide_size.width, doc.slide_size.height)));
|
||||
let bar = slide_media_bars(slide, &doc, 0)[0].3;
|
||||
let bar = slide_media_bars(view, &doc, 0)[0].3;
|
||||
let track = pos2(bar.min.x + bar.width() * 0.8, bar.center().y);
|
||||
(harness, id, track)
|
||||
}
|
||||
@@ -447,7 +446,7 @@ fn initialize_inline_frames(show: &mut Show, ctx: &egui::Context, host: &craft::
|
||||
|
||||
fn uploaded_picture(ctx: &egui::Context, id: egui::TextureId) -> Arc<egui::ColorImage> {
|
||||
let delta = ctx.tex_manager().write().take_delta();
|
||||
let image = delta.set.into_iter().rev().find(|(key, _)| *key == id).expect("the shown picture was uploaded").1.image;
|
||||
let image = delta.set.get(&id).and_then(|deltas| deltas.last()).expect("the shown picture was uploaded").image.clone();
|
||||
let egui::ImageData::Color(image) = image;
|
||||
image
|
||||
}
|
||||
|
||||
@@ -135,7 +135,9 @@ fn canvas_pass(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>, show: &mut
|
||||
bars::show(ui, show, p.doc, p.room);
|
||||
}
|
||||
let mut media_wake = None;
|
||||
with_env(ui, |env| env.values.set(*p.zoom.scheme), |ui| {
|
||||
with_env(ui, |env| {
|
||||
env.values.set(*p.zoom.scheme);
|
||||
}, |ui| {
|
||||
let mut child = ui.new_child(UiBuilder::new().id_salt("show.canvas.room").max_rect(room));
|
||||
Canvas::new(Word::plain("Slide show"))
|
||||
.document(target)
|
||||
@@ -177,7 +179,6 @@ fn canvas_pass(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>, show: &mut
|
||||
picture,
|
||||
)
|
||||
.picture()
|
||||
.checkerboard(None)
|
||||
.show_at(ui, pass.rect);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use super::*;
|
||||
use craft::host::files::{Picked, ScriptedFiles};
|
||||
use craft::host::{Picked, ScriptedFiles};
|
||||
use craft::ui::runtime::commands::{ClipItem, ClipboardHandle};
|
||||
use craft::ui::runtime::env::WindowKey;
|
||||
use craft::ui::runtime::windows::WindowHost;
|
||||
@@ -508,7 +508,7 @@ fn new_window_shows_the_same_document_on_its_own_slide() {
|
||||
assert_eq!(again["slide"], 0, "opening again keeps the window's slide");
|
||||
|
||||
app.session.execute("file.close", &json!({})).unwrap();
|
||||
doc_window::show(app, &ctx);
|
||||
let _ = ctx.run_ui(egui::RawInput::default(), |ui| doc_window::show(app, ui));
|
||||
assert!(app.doc_window.is_none(), "closing the presentation closes the extra window");
|
||||
assert!(app.session.active().is_none());
|
||||
}
|
||||
@@ -1410,7 +1410,7 @@ fn input_target_changes_retract_a_queued_click() {
|
||||
"ribbon tab" => h.state_mut().ui.tab = "Insert".into(),
|
||||
"collapse" => h.state_mut().ui.ribbon_collapsed = true,
|
||||
"scroll" => {
|
||||
let before = crate::ribbon::scroll_position(&ctx);
|
||||
let before = crate::ribbon::scroll_position(h.state(), &ctx);
|
||||
let at = h.get_by_label("Scroll right").rect().center();
|
||||
h.input_mut().events.push(egui::Event::PointerMoved(at));
|
||||
for pressed in [true, false] {
|
||||
@@ -1422,7 +1422,7 @@ fn input_target_changes_retract_a_queued_click() {
|
||||
});
|
||||
}
|
||||
h.run_steps(1);
|
||||
assert_ne!(crate::ribbon::scroll_position(&ctx), before, "the real ribbon arrow scrolls its row");
|
||||
assert_ne!(crate::ribbon::scroll_position(h.state(), &ctx), before, "the real ribbon arrow scrolls its row");
|
||||
}
|
||||
"document" | "document return" => {
|
||||
h.state_mut().run("file.new", json!({})).unwrap();
|
||||
|
||||
Reference in new issue
Block a user