mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-28 09:21:55 +01:00
Merge pull request #9621 from dotCooCoo/fix/panel-artwork-drop-file-revert
Reject panel artwork drags started before File Revert
This commit is contained in:
19 files changed
+241
-70
No files matched your search
@@ -388,6 +388,7 @@ impl VectorcraftApp {
|
||||
}
|
||||
font_menu::end_previews(self, &out.ended_previews);
|
||||
edits::end_removed(self, &out.removed_gestures);
|
||||
dialogs::three_d::sync_graphics_source(self);
|
||||
let lang = self.ui_language();
|
||||
if self.host.lang() != lang {
|
||||
self.host = Arc::new(self.host.with_lang(lang));
|
||||
|
||||
@@ -279,8 +279,9 @@ pub(crate) fn released_on_pane(app: &VectorcraftApp, art: CarriedArt, at: Pos2,
|
||||
/// to the drag session. Moves of anchors or segments stay reshapes. `covered`: another window is over the canvas at the
|
||||
/// pointer. → whether a carry runs.
|
||||
pub(crate) fn carry_out(app: &mut VectorcraftApp, cx: &mut ToolContext<'_>, pointer: &ToolPointer, covered: bool) -> bool {
|
||||
let Some(reverts) = app.session.active().map(|st| st.reverts) else { return false };
|
||||
let Some(art) = carried(app, cx, pointer, covered) else { return false };
|
||||
let panel = PanelDrag::Art { document: art.document, ids: art.ids.clone() };
|
||||
let panel = PanelDrag::Art { document: art.document, reverts, ids: art.ids.clone() };
|
||||
cx.start_drag_also(art, Arc::new(panel), DragPreview::None);
|
||||
true
|
||||
}
|
||||
|
||||
@@ -445,6 +445,74 @@ fn button(pos: Pos2, pressed: bool) -> Event {
|
||||
Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Default::default() }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_canvas_art_drag_cannot_make_a_graphic_style_after_file_revert() {
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use craft::ui::runtime::drag;
|
||||
|
||||
struct SavedFile(std::path::PathBuf);
|
||||
impl Drop for SavedFile {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_file(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn canvas_and_styles(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
egui::Panel::top("audit-styles").exact_size(220.0).show(ui, |ui| crate::panels::graphic_styles::show(app, ui));
|
||||
canvas::show(app, ui);
|
||||
}
|
||||
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string())));
|
||||
app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string())));
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
let id = NodeId(app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap());
|
||||
app.run("paint.setFill", json!({"color": "#ff0000", "ids": [id.0]})).unwrap();
|
||||
app.run("graphicStyle.new", json!({"name": "Drop Target"})).unwrap();
|
||||
let path = SavedFile(std::env::temp_dir().join(format!("vc-ui-artwork-drop-revert-{}.vectorcraft", std::process::id())));
|
||||
app.run("file.saveAs", json!({"path": path.0})).unwrap();
|
||||
assert!(path.0.is_file());
|
||||
app.run("paint.setFill", json!({"color": "#00ff00", "ids": [id.0]})).unwrap();
|
||||
app.run("select.none", json!({})).unwrap();
|
||||
app.select_tool("selection");
|
||||
let mut panel = Panel::new(app, canvas_and_styles);
|
||||
let carry_to_style = |panel: &mut Panel| {
|
||||
let at = panel.app().canvas_view().unwrap().to_screen(Point::new(100.0, 100.0));
|
||||
let target = panel.rect("Drop Target").center();
|
||||
panel.frame_with(vec![Event::PointerMoved(at), button(at, true)]);
|
||||
panel.frame_with(vec![Event::PointerMoved(at + egui::vec2(20.0, 0.0))]);
|
||||
assert!(panel.app().session.active().unwrap().interaction.is_some(), "the Selection tool starts a move");
|
||||
panel.frame_with(vec![Event::PointerMoved(target)]);
|
||||
panel.frame();
|
||||
let carried = drag::active::<PanelDrag>(panel.ctx());
|
||||
assert!(matches!(carried.as_deref(), Some(PanelDrag::Art { ids, .. }) if ids == &[id]), "the canvas starts the panel payload");
|
||||
assert!(drag::mark(panel.ctx()).is_some(), "Graphic Styles accepts artwork dragged from the current contents");
|
||||
};
|
||||
carry_to_style(&mut panel);
|
||||
|
||||
let (uid, reverts) = {
|
||||
let app = panel.app();
|
||||
let state = app.session.active().unwrap();
|
||||
(state.uid, state.reverts)
|
||||
};
|
||||
panel.app().run("file.revert", json!({"confirmed": true})).unwrap();
|
||||
let styles = |app: &VectorcraftApp| app.session.active().unwrap().doc.graphic_styles.len();
|
||||
let count = {
|
||||
let app = panel.app();
|
||||
let state = app.session.active().unwrap();
|
||||
assert_eq!((state.uid, state.reverts), (uid, reverts + 1));
|
||||
assert!(state.doc.node(id).is_some(), "the restored object keeps the same ID");
|
||||
styles(&app)
|
||||
};
|
||||
panel.frame();
|
||||
assert!(drag::mark(panel.ctx()).is_none());
|
||||
panel.release();
|
||||
assert_eq!(styles(&panel.app()), count, "a drag from discarded art cannot create a style from restored art");
|
||||
carry_to_style(&mut panel);
|
||||
panel.release();
|
||||
assert_eq!(styles(&panel.app()), count + 1, "a fresh drag can still create a style from the restored artwork");
|
||||
}
|
||||
|
||||
/// A Selection, Direct Selection or Group Selection move that leaves the canvas hands the art to the drag session
|
||||
/// with the ids the move started with, and the move waits where it was last.
|
||||
#[test]
|
||||
|
||||
@@ -63,8 +63,8 @@ pub(crate) struct Data {
|
||||
pub bevels_file: bool,
|
||||
/// The active document, for the symbol pictures.
|
||||
pub doc: Option<Arc<Document>>,
|
||||
/// The document that owns the object IDs accepted by the Graphics drop target.
|
||||
pub document_uid: Option<u64>,
|
||||
/// The opening document generation while it can still supply artwork to the Graphics drop target.
|
||||
pub document: Option<(u64, u64)>,
|
||||
/// The active document's version.
|
||||
pub revision: u64,
|
||||
/// Whether the active document has a selection.
|
||||
@@ -87,7 +87,7 @@ pub(crate) fn data(app: &VectorcraftApp, effect: Option<&str>, params: &Map<Stri
|
||||
bevels: effect.map(|e| revolve::bevel_options(app, params, e).0).unwrap_or_default(),
|
||||
bevels_file: app.session.bevels.path().is_some(),
|
||||
doc: st.map(|s| s.doc.clone()),
|
||||
document_uid: st.map(|s| s.uid),
|
||||
document: st.map(|s| (s.uid, s.reverts)),
|
||||
revision: st.map_or(0, |s| s.revision),
|
||||
selected: st.is_some_and(|s| !s.selection.objects.is_empty()),
|
||||
surfaces: None,
|
||||
@@ -352,6 +352,13 @@ fn surfaces(app: &mut VectorcraftApp, s: &Session, fields: &DialogFields, params
|
||||
Some(listed)
|
||||
}
|
||||
|
||||
/// Refresh drop eligibility before the dialog can receive a release in this frame.
|
||||
pub(crate) fn sync_graphics_source(app: &VectorcraftApp) {
|
||||
let Some(open) = &app.three_d_dialog else { return };
|
||||
let source = open.source.filter(|&(uid, reverts)| app.session.documents().iter().any(|d| (d.uid, d.reverts) == (uid, reverts)));
|
||||
open.data.write().unwrap_or_else(PoisonError::into_inner).document = source;
|
||||
}
|
||||
|
||||
/// Once per frame: refreshes the rows' data, runs the preview, and, with Preview off, tries the values so the dialog
|
||||
/// still says why OK would fail. `refuse` is called only from a result this pump produced: an idle pump leaves a
|
||||
/// refusal standing until the values change.
|
||||
@@ -467,16 +474,17 @@ mod drawing_tests {
|
||||
fn three_d_ownership_preview_resumes_only_in_the_opening_drawing() {
|
||||
let (mut app, original) = drawing();
|
||||
open_effect(&mut app, true);
|
||||
let first = app.session.active().unwrap().uid;
|
||||
frame(&mut app);
|
||||
assert_eq!(applied(&app, original), [EXTRUDE]);
|
||||
let opening_document = read(&app.three_d_dialog.as_ref().unwrap().data).doc.clone().unwrap();
|
||||
let other = second_drawing(&mut app);
|
||||
frame(&mut app);
|
||||
assert!(applied(&app, other).is_empty(), "3D preview reached the other drawing");
|
||||
assert!(!app.session.in_interaction());
|
||||
assert!(!gizmo_shown(&app));
|
||||
assert!(!crate::canvas::revolve_editing(&app));
|
||||
assert_eq!(read(&app.three_d_dialog.as_ref().unwrap().data).document_uid, Some(first));
|
||||
let drawn_document = read(&app.three_d_dialog.as_ref().unwrap().data).doc.clone().unwrap();
|
||||
assert!(Arc::ptr_eq(&drawn_document, &opening_document), "Map Art keeps the opening document");
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
frame(&mut app);
|
||||
assert_eq!(applied(&app, original), [EXTRUDE]);
|
||||
|
||||
@@ -174,11 +174,12 @@ fn body(ui: &mut Ui, fields: &mut DialogFields, cx: &mut CustomContext, data: &D
|
||||
fn library(ui: &mut Ui, data: &Data, apply: bool) -> Option<Action> {
|
||||
Text::new(tl!("Graphics")).show(ui);
|
||||
let mut action = None;
|
||||
let (Some(doc), Some(uid)) = (data.doc.clone(), data.document_uid) else { return action };
|
||||
let Some(doc) = data.doc.clone() else { return action };
|
||||
let source_drawing = data.document;
|
||||
let names: Vec<String> = doc.symbols.iter().map(|s| s.name.clone()).collect();
|
||||
let keys = crate::panels::symbols::document_symbols(&doc, data.revision);
|
||||
let source = keyed(&names[..], |name: &String| name.clone()).with_text(|name| Cow::Borrowed(name.as_str()));
|
||||
let drop_art = DropAction::<PanelDrag>::new(move |drag| matches!(drag, PanelDrag::Art { document, .. } if *document == uid));
|
||||
let drop_art = DropAction::<PanelDrag>::new(move |drag| source_drawing.is_some_and(|(uid, reverts)| drag.artwork_for(uid, reverts).is_some()));
|
||||
let mut dropped = drop_art.show(ui, |ui, _| {
|
||||
TileGrid::new(tl!("Graphics")).activate(ActivateOn::Click).show_items(ui, &source, &mut |name, _| {
|
||||
let tip = if apply { name.clone() } else { format!("{name}: {}", tl!("Select a 3D object to map the graphic onto it.")) };
|
||||
@@ -199,7 +200,9 @@ fn library(ui: &mut Ui, data: &Data, apply: bool) -> Option<Action> {
|
||||
action = Some(Action::Map(name));
|
||||
}
|
||||
}
|
||||
if let Some(PanelDrag::Art { ids, .. }) = dropped.output.dropped {
|
||||
if let Some((uid, reverts)) = source_drawing
|
||||
&& let Some(ids) = dropped.output.dropped.as_ref().and_then(|drag| drag.artwork_for(uid, reverts))
|
||||
{
|
||||
action = Some(Action::Add(Some(ids.iter().map(|id| id.0).collect())));
|
||||
}
|
||||
if clicked(&Button::new(tl!("Add as Single Graphic")).enabled(data.selected).show(ui)) {
|
||||
@@ -207,3 +210,73 @@ fn library(ui: &mut Ui, data: &Data, apply: bool) -> Option<Action> {
|
||||
}
|
||||
action
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::VectorcraftApp;
|
||||
use crate::tests::panel_harness::Panel;
|
||||
use craft::ui::contract::{ListDrag, Role};
|
||||
use craft::ui::list::{List, ListRow};
|
||||
use craft::ui::runtime::drag;
|
||||
|
||||
fn draw_graphics(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let st = app.session.active().unwrap();
|
||||
let payload = PanelDrag::Art { document: st.uid, reverts: st.reverts, ids: st.selection.objects.clone() };
|
||||
ui.allocate_ui(egui::vec2(ui.available_width(), 80.0), |ui| {
|
||||
let keys = keyed(&[0_usize], |key: &usize| *key);
|
||||
List::<usize>::new("Artwork")
|
||||
.drag_payload(move |_: &ListDrag<usize>| Some(payload.clone()))
|
||||
.show_items(ui, &keys, &mut |_, _| ListRow::new("Dragged artwork"));
|
||||
});
|
||||
if let Some(open) = &app.three_d_dialog {
|
||||
let data = open.data.read().unwrap();
|
||||
let _ = library(ui, &data, true);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn held_graphics_drag_is_refused_after_the_opening_drawing_reverts() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
let dir = vectorcraft_testkit::TempDir::new("three-d-graphics-revert");
|
||||
app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string())));
|
||||
app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string())));
|
||||
app.run("file.new", json!({"width": 400, "height": 400})).unwrap();
|
||||
let shape = app.run("shape.rectangle", json!({"x": 20, "y": 20, "width": 50, "height": 50})).unwrap()["id"].clone();
|
||||
app.run("threeD.addGraphic", json!({"name": "Opening Graphic"})).unwrap();
|
||||
app.run("file.saveAs", json!({"path": dir.join("Art.vectorcraft")})).unwrap();
|
||||
app.run("shape.rectangle", json!({"x": 120, "y": 90, "width": 45, "height": 40})).unwrap();
|
||||
app.run("file.new", json!({"width": 400, "height": 400})).unwrap();
|
||||
assert!(app.session.set_active(0));
|
||||
app.run("select.set", json!({"ids": [shape]})).unwrap();
|
||||
|
||||
let mut panel = Panel::new(app, draw_graphics);
|
||||
panel.room(egui::vec2(800.0, 820.0));
|
||||
super::super::three_d::open(&mut panel.app(), &json!({"effect": INFLATE})).unwrap();
|
||||
panel.frame();
|
||||
let from = panel.rect("Dragged artwork").center();
|
||||
let to = panel.rect("Opening Graphic").center();
|
||||
panel.drag_hold_role("Dragged artwork", Role::LIST_ITEM, to - from);
|
||||
assert!(drag::mark(panel.ctx()).is_some(), "the opening drawing's drag is accepted");
|
||||
assert!(panel.app().session.set_active(1));
|
||||
panel.frame();
|
||||
assert!(drag::mark(panel.ctx()).is_some(), "switching drawings retains the opening drawing's drag");
|
||||
|
||||
{
|
||||
let mut app = panel.app();
|
||||
assert!(app.session.set_active(0));
|
||||
let source = app.session.active().unwrap();
|
||||
let (uid, generation) = (source.uid, source.reverts);
|
||||
app.run("file.revert", json!({"confirmed": true})).unwrap();
|
||||
let restored = app.session.active().unwrap();
|
||||
assert_eq!(restored.uid, uid);
|
||||
assert_ne!(restored.reverts, generation);
|
||||
assert!(app.session.set_active(1));
|
||||
}
|
||||
panel.frame();
|
||||
assert!(drag::active::<PanelDrag>(panel.ctx()).is_some(), "the same drag is still in progress");
|
||||
assert!(drag::mark(panel.ctx()).is_none(), "the drop stops accepting artwork from the reverted generation");
|
||||
let _ = panel.rect("Opening Graphic");
|
||||
panel.release();
|
||||
}
|
||||
}
|
||||
@@ -26,8 +26,8 @@ pub enum PanelDrag {
|
||||
/// (`graphicStyle.new`), or with Alt held replaces the style it is dropped on with that
|
||||
/// object's look (`graphicStyle.redefine`), the Symbols panel a symbol of it all
|
||||
/// (`symbol.new`), the Swatches panel a pattern swatch of a copy (`object.pattern.make`) and
|
||||
/// the Brushes panel an Art brush (`brush.new`).
|
||||
Art { document: u64, ids: Vec<vectorcraft_doc::NodeId> },
|
||||
/// the Brushes panel an Art brush (`brush.new`). `reverts` identifies the contents it came from.
|
||||
Art { document: u64, reverts: u64, ids: Vec<vectorcraft_doc::NodeId> },
|
||||
/// A Libraries panel graphic (`item`: its id in `library`): the canvas places a copy centred
|
||||
/// where it is dropped (`library.use`); the panel moves it to where it is dropped.
|
||||
LibraryGraphic { library: String, item: String },
|
||||
@@ -53,6 +53,14 @@ pub struct SwatchRows {
|
||||
}
|
||||
|
||||
impl PanelDrag {
|
||||
/// The artwork IDs while the destination still shows the contents the drag came from.
|
||||
pub(crate) fn artwork_for(&self, uid: u64, reload_count: u64) -> Option<&[vectorcraft_doc::NodeId]> {
|
||||
match self {
|
||||
Self::Art { document, reverts, ids } if (*document, *reverts) == (uid, reload_count) => Some(ids),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// `paint` dragged from a Fill/Stroke proxy, a Recent Colors chip, a Color Guide color or the
|
||||
/// Gradient panel's thumbnail. A gradient carries no placement: it fits the art it lands on
|
||||
/// (freeform points are placed afresh there, coloured like the dragged ones).
|
||||
|
||||
@@ -509,6 +509,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
return;
|
||||
};
|
||||
let uid = st.uid;
|
||||
let reverts = st.reverts;
|
||||
let model = app.ui.asset_export_panel.docs.entry(uid).or_default();
|
||||
model.selection.items.retain(|id| st.doc.asset(*id).is_some());
|
||||
let grid_id = ui.scope_id().with(("asset-export-grid", uid));
|
||||
@@ -553,7 +554,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
footer = Some(bar);
|
||||
});
|
||||
let zone = footed.show(ui, |ui, _| {
|
||||
let drop_art = DropAction::<PanelDrag>::new(move |p| matches!(p, PanelDrag::Art { document, .. } if *document == uid));
|
||||
let drop_art = DropAction::<PanelDrag>::new(move |p| p.artwork_for(uid, reverts).is_some());
|
||||
drop_art.sizing(Sizing::Fill).show(ui, |ui, _| {
|
||||
if st.doc.assets.is_empty() {
|
||||
Notice::new(Tone::Neutral, tl!("Drag art here, or select it and click +. Hold Alt for one asset of several objects."))
|
||||
@@ -571,8 +572,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
})
|
||||
});
|
||||
if let Some(PanelDrag::Art { ids, .. }) = zone.inner.and_then(|zone| zone.output.dropped) {
|
||||
seen.dropped = Some((ids.into_iter().map(|id| id.0).collect(), alt));
|
||||
if let Some(payload) = zone.inner.and_then(|zone| zone.output.dropped)
|
||||
&& let Some(ids) = payload.artwork_for(uid, reverts)
|
||||
{
|
||||
seen.dropped = Some((ids.iter().map(|id| id.0).collect(), alt));
|
||||
}
|
||||
for event in events {
|
||||
match event {
|
||||
|
||||
@@ -380,12 +380,9 @@ fn takes_art(ty: &str) -> bool {
|
||||
matches!(ty, "scatter" | "art" | "pattern")
|
||||
}
|
||||
|
||||
/// The ids of art dragged off the canvas of the document `doc` (its uid).
|
||||
fn art_of(payload: &PanelDrag, doc: u64) -> Option<Vec<u64>> {
|
||||
match payload {
|
||||
PanelDrag::Art { document, ids, .. } if *document == doc => Some(ids.iter().map(|id| id.0).collect()),
|
||||
_ => None,
|
||||
}
|
||||
/// The ids of art dragged from the displayed drawing.
|
||||
fn art_of(payload: &PanelDrag, uid: u64, reverts: u64) -> Option<Vec<u64>> {
|
||||
payload.artwork_for(uid, reverts).map(|ids| ids.iter().map(|id| id.0).collect())
|
||||
}
|
||||
|
||||
/// The library and name of a brush dragged out of a brush library panel; a folder or another kind's item is none.
|
||||
@@ -547,7 +544,7 @@ fn keys_of(sel: &Selection<String>, doc: u64) -> Selection<BrushKey> {
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let (list, current) = brushes(app);
|
||||
let doc = app.session.active().map(|st| st.doc.clone());
|
||||
let (uid, revision) = app.session.active().map_or((0, 0), |st| (st.uid, st.revision));
|
||||
let (uid, revision, reverts) = app.session.active().map_or((0, 0, 0), |st| (st.uid, st.revision, st.reverts));
|
||||
let memo = app.session.active().map(document_brushes).unwrap_or_default();
|
||||
let first = by_name(&memo);
|
||||
let multi = picked(app, &list, current.as_deref());
|
||||
@@ -584,7 +581,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
// the pass that drops and the held ones in a rerun pass, which takes no drop.
|
||||
let art_onto = PresetDrop::new::<PanelDrag>(DropPlace::Onto, move |payload: &PanelDrag, at: &DropAt<BrushKey>| {
|
||||
let DropAt::Onto(key) = at else { return false };
|
||||
art_of(payload, uid).is_some()
|
||||
payload.artwork_for(uid, reverts).is_some()
|
||||
&& !key.group
|
||||
&& type_of(first, key).is_some_and(takes_art)
|
||||
&& craft::ui::runtime::pointer::frame(&ctx).pick_mods.alt
|
||||
@@ -607,7 +604,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let mut footed = None;
|
||||
let shown = Stack::new().label(tl!("Brushes")).fill().footer(|ui, _| footed = Some(footer(app, ui, on))).show(ui, |ui, _| {
|
||||
let library = DropAction::<ListDrag<LibraryKey>>::new(|drag| library_brush(drag).is_some()).sizing(Sizing::Fill).show(ui, |ui, _| {
|
||||
let art = DropAction::<PanelDrag>::new(move |payload| art_of(payload, uid).is_some()).sizing(Sizing::Fill).show(ui, |ui, _| browser(ui));
|
||||
let art = DropAction::<PanelDrag>::new(move |payload| payload.artwork_for(uid, reverts).is_some())
|
||||
.sizing(Sizing::Fill)
|
||||
.show(ui, |ui, _| browser(ui));
|
||||
(art.output.dropped, art.inner.unwrap_or_default())
|
||||
});
|
||||
(library.output.dropped, library.inner.unwrap_or_default())
|
||||
@@ -642,7 +641,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
PresetEvent::Menu { target, command, .. } => item_command(app, &target, &command, multi.as_ref()),
|
||||
PresetEvent::Reorder(edit) => move_brush(app, &rows(uid, &memo, &hidden), first, &edit),
|
||||
PresetEvent::Dropped { at, payload, .. } => {
|
||||
if let (DropAt::Onto(key), Some(ids)) = (&at, payload.get::<PanelDrag>().and_then(|p| art_of(p, uid))) {
|
||||
if let (DropAt::Onto(key), Some(ids)) = (&at, payload.get::<PanelDrag>().and_then(|p| art_of(p, uid, reverts))) {
|
||||
crate::dialogs::brush_replace_art::replace(app, &key.name, &ids);
|
||||
}
|
||||
}
|
||||
@@ -650,7 +649,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
// Art dropped on the list opens New Brush for that art, as the New Brush button opens it for the selection.
|
||||
if let Some(ids) = art_drop.as_ref().and_then(|p| art_of(p, uid))
|
||||
if let Some(ids) = art_drop.as_ref().and_then(|p| art_of(p, uid, reverts))
|
||||
&& let Err(e) = app.run("ui.newBrush", json!({ "ids": ids }))
|
||||
{
|
||||
app.status(e);
|
||||
|
||||
@@ -258,8 +258,8 @@ fn drops_on_the_panel_run_their_commands() {
|
||||
let star = t.run("shape.star", json!({"cx": 50, "cy": 50, "radius1": 20, "radius2": 9, "points": 5}))["id"].as_u64().unwrap();
|
||||
// Nothing selected: what New Brush makes comes from the dropped art.
|
||||
t.run("select.none", json!({}));
|
||||
let document = t.app().session.active().unwrap().uid;
|
||||
t.drags(PanelDrag::Art { document, ids: vec![NodeId(star)] });
|
||||
let (document, reverts) = t.app().session.active().map(|st| (st.uid, st.reverts)).unwrap();
|
||||
t.drags(PanelDrag::Art { document, reverts, ids: vec![NodeId(star)] });
|
||||
let (lib, before) = (t.run("brush.list", json!({})), brushes(&t.app()).0);
|
||||
let at = t.target(on).center();
|
||||
t.drop_at(at, modifiers);
|
||||
@@ -275,8 +275,8 @@ fn drops_on_the_panel_run_their_commands() {
|
||||
for (name, part) in [("Dots", "art"), ("Arrow", "art"), ("Chain", "side")] {
|
||||
let mut t = Trial::new();
|
||||
let id = t.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 30, "height": 12}))["id"].as_u64().unwrap();
|
||||
let document = t.app().session.active().unwrap().uid;
|
||||
t.drags(PanelDrag::Art { document, ids: vec![NodeId(id)] });
|
||||
let (document, reverts) = t.app().session.active().map(|st| (st.uid, st.reverts)).unwrap();
|
||||
t.drags(PanelDrag::Art { document, reverts, ids: vec![NodeId(id)] });
|
||||
let steps = undo_count(&t.app());
|
||||
let at = t.target(name).center();
|
||||
t.drop_at(at, Modifiers::ALT);
|
||||
|
||||
@@ -467,7 +467,7 @@ const AT_START: usize = 2;
|
||||
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
// The document is shared (an `Arc`): holding it while drawing copies nothing.
|
||||
let Some((uid, doc)) = app.session.active().map(|d| (d.uid, d.doc.clone())) else {
|
||||
let Some((uid, reverts, doc)) = app.session.active().map(|d| (d.uid, d.reverts, d.doc.clone())) else {
|
||||
super::empty_state(ui, "dc-graphic-styles", tl!("No document"), tl!("Open a document to see its graphic styles."));
|
||||
return;
|
||||
};
|
||||
@@ -484,7 +484,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
// The browser's own state (an open rename field, the scroll position) is kept per document.
|
||||
let browser_id = ui.make_persistent_id(("graphic-styles-browser", uid));
|
||||
let list = PresetBrowser::<StyleKey>::list_id(browser_id);
|
||||
let takes_object = move |drag: &PanelDrag, _: &DropAt<StyleKey>| dropped_object(drag, uid).is_some();
|
||||
let takes_object = move |drag: &PanelDrag, _: &DropAt<StyleKey>| dropped_object(drag, uid, reverts).is_some();
|
||||
// A style dragged from this panel's list.
|
||||
let ours = move |drag: &ListDrag<StyleKey>| drag.list == list;
|
||||
let svg = |name: &'static str| IconSpec::svg(IconId::new(name));
|
||||
@@ -610,9 +610,9 @@ fn reorder(app: &mut VectorcraftApp, edit: EditEvent<ReorderMove<StyleKey>>) {
|
||||
|
||||
/// The object whose look a dropped payload carries: the first of the art dragged from this document, or the
|
||||
/// Appearance panel's object.
|
||||
fn dropped_object(drag: &PanelDrag, uid: u64) -> Option<NodeId> {
|
||||
fn dropped_object(drag: &PanelDrag, uid: u64, reverts: u64) -> Option<NodeId> {
|
||||
match drag {
|
||||
PanelDrag::Art { document, ids } if *document == uid => ids.first().copied(),
|
||||
PanelDrag::Art { .. } => drag.artwork_for(uid, reverts)?.first().copied(),
|
||||
PanelDrag::Appearance(id) => Some(*id),
|
||||
_ => None,
|
||||
}
|
||||
@@ -624,7 +624,7 @@ fn dropped(app: &mut VectorcraftApp, at: &DropAt<StyleKey>, payload: &DropPayloa
|
||||
DropAt::Onto(name) => Some(name.as_str()),
|
||||
_ => None,
|
||||
};
|
||||
let object = app.session.active().and_then(|st| dropped_object(payload.get::<PanelDrag>()?, st.uid));
|
||||
let object = app.session.active().and_then(|st| dropped_object(payload.get::<PanelDrag>()?, st.uid, st.reverts));
|
||||
let style = payload.get::<ListDrag<StyleKey>>().map(|drag| drag.grabbed.as_str());
|
||||
drop_on(app, onto, object, style, alt);
|
||||
}
|
||||
@@ -1427,9 +1427,10 @@ mod tests {
|
||||
app.run("paint.setFill", json!({"color": "#00ff00", "ids": [oval.0]})).unwrap();
|
||||
let (red, green) = (doc(&app).graphic_style("Red").unwrap().appearance.fill_paint(), doc(&app).node(oval).unwrap().appearance.fill_paint());
|
||||
let n = names(&app);
|
||||
let document = app.session.active().unwrap().uid;
|
||||
for payload in [PanelDrag::Art { document, ids: vec![oval] }, PanelDrag::Appearance(oval)] {
|
||||
drop_on(&mut app, Some("Red"), dropped_object(&payload, document), None, true);
|
||||
let st = app.session.active().unwrap();
|
||||
let (document, reverts) = (st.uid, st.reverts);
|
||||
for payload in [PanelDrag::Art { document, reverts, ids: vec![oval] }, PanelDrag::Appearance(oval)] {
|
||||
drop_on(&mut app, Some("Red"), dropped_object(&payload, document, reverts), None, true);
|
||||
let d = doc(&app);
|
||||
assert_eq!(d.graphic_style("Red").unwrap().appearance.fill_paint(), green);
|
||||
assert_eq!(d.node(oval).unwrap().extras().graphic_style, d.graphic_style("Red").map(|g| g.id));
|
||||
@@ -1455,7 +1456,7 @@ mod tests {
|
||||
|
||||
fn with_artwork(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let st = app.session.active().unwrap();
|
||||
let payload = PanelDrag::Art { document: st.uid, ids: st.selection.objects.clone() };
|
||||
let payload = PanelDrag::Art { document: st.uid, reverts: st.reverts, ids: st.selection.objects.clone() };
|
||||
ui.allocate_ui(egui::vec2(ui.available_width(), 80.0), |ui| {
|
||||
let keys = craft::behavior::keyed(&[0_usize], |key: &usize| *key);
|
||||
List::<usize>::new("Artwork")
|
||||
|
||||
@@ -190,7 +190,7 @@ fn swatch_add(drag: &PanelDrag, library: &str) -> Option<(ItemKind, Value)> {
|
||||
/// which keep their test, can read it: what a drop into a group, or out of every group, does.
|
||||
struct Membership {
|
||||
library: String,
|
||||
active_document: Option<u64>,
|
||||
active_document: Option<(u64, u64)>,
|
||||
/// The group of each grouped item, by its index in the library's groups.
|
||||
index: HashMap<(ItemKind, String), usize>,
|
||||
/// The groups' names, in the library's order.
|
||||
@@ -198,7 +198,7 @@ struct Membership {
|
||||
}
|
||||
|
||||
impl Membership {
|
||||
fn of(library: &str, lib: &Library, active_document: Option<u64>) -> Self {
|
||||
fn of(library: &str, lib: &Library, active_document: Option<(u64, u64)>) -> Self {
|
||||
let index = lib.group_index().into_iter().map(|((kind, item), group)| ((kind, item.to_string()), group)).collect();
|
||||
Membership { library: library.to_string(), active_document, index, names: lib.groups.iter().map(|g| g.name.clone()).collect() }
|
||||
}
|
||||
@@ -210,8 +210,9 @@ impl Membership {
|
||||
PanelDrag::Paint { library: Some((l, item)), .. } if l == library => Some(Grab::Item(ItemKind::Color, item.clone())),
|
||||
PanelDrag::LibraryGraphic { library: l, item } if l == library => Some(Grab::Item(ItemKind::Graphic, item.clone())),
|
||||
PanelDrag::LibraryItem { library: l, kind, item } if l == library => Some(Grab::Item(*kind, item.clone())),
|
||||
PanelDrag::Art { document, ids } if Some(*document) == self.active_document => {
|
||||
let ids: Vec<u64> = ids.iter().map(|id| id.0).collect();
|
||||
PanelDrag::Art { .. } => {
|
||||
let (uid, reverts) = self.active_document?;
|
||||
let ids: Vec<u64> = drag.artwork_for(uid, reverts)?.iter().map(|id| id.0).collect();
|
||||
Some(Grab::New(ItemKind::Graphic, json!({ "kind": "graphic", "ids": ids })))
|
||||
}
|
||||
PanelDrag::Paint { .. } => swatch_add(drag, library).map(|(kind, add)| Grab::New(kind, add)),
|
||||
@@ -305,7 +306,15 @@ struct View<'a> {
|
||||
}
|
||||
|
||||
impl<'a> View<'a> {
|
||||
fn new(library: &'a str, lib: &'a Library, query: &str, list: bool, fill_active: bool, active_document: Option<u64>, can_apply: bool) -> Self {
|
||||
fn new(
|
||||
library: &'a str,
|
||||
lib: &'a Library,
|
||||
query: &str,
|
||||
list: bool,
|
||||
fill_active: bool,
|
||||
active_document: Option<(u64, u64)>,
|
||||
can_apply: bool,
|
||||
) -> Self {
|
||||
let membership = Membership::of(library, lib, active_document);
|
||||
let query = query.trim().to_lowercase();
|
||||
let searching = !query.is_empty();
|
||||
@@ -776,7 +785,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
return;
|
||||
};
|
||||
let acts = RefCell::new(Vec::new());
|
||||
let active_document = app.session.active().map(|st| st.uid);
|
||||
let active_document = app.session.active().map(|st| (st.uid, st.reverts));
|
||||
let has_doc = active_document.is_some();
|
||||
{
|
||||
// PLAN: assumed `UiState::{libraries_list_view: bool, library_search: String, library_groups_closed: HashSet<(String, String)>}` (ap.AS17, hub-w1).
|
||||
|
||||
@@ -71,7 +71,8 @@ fn art(app: &mut VectorcraftApp, x: f64, name: Option<&str>) -> Vec<vectorcraft_
|
||||
/// New art at `x`, as the canvas drags it.
|
||||
fn art_drag(app: &mut VectorcraftApp, x: f64) -> PanelDrag {
|
||||
let ids = art(app, x, None);
|
||||
PanelDrag::Art { document: app.session.active().unwrap().uid, ids }
|
||||
let state = app.session.active().unwrap();
|
||||
PanelDrag::Art { document: state.uid, reverts: state.reverts, ids }
|
||||
}
|
||||
|
||||
fn graphics(app: &mut VectorcraftApp) -> Vec<String> {
|
||||
|
||||
@@ -408,6 +408,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
};
|
||||
let dragged_doc = Arc::clone(&thumbs.doc);
|
||||
let document = st.uid;
|
||||
let reverts = st.reverts;
|
||||
let shown_app: &VectorcraftApp = app;
|
||||
let browser = SwatchesPanel::new(&data, Bind::bound(&mut model.state), Srgba::rgb(0.0, 0.0, 0.0))
|
||||
.drag_payload(move |drag: &ListDrag<SwatchKey>| Some(dnd::drag_of(&dragged_doc, document, &drag.grabbed, dragged_rows(drag))))
|
||||
@@ -417,8 +418,8 @@ fn body(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
_ => vec![],
|
||||
})
|
||||
.row_items(|key| row_items(shown_app, key))
|
||||
.takes_drop::<PanelDrag>(DropPlace::Between, |drag, _| dnd::accepts(drag, document))
|
||||
.takes_drop::<PanelDrag>(DropPlace::Onto, |drag, _| dnd::accepts(drag, document))
|
||||
.takes_drop::<PanelDrag>(DropPlace::Between, |drag, _| dnd::accepts(drag, document, reverts))
|
||||
.takes_drop::<PanelDrag>(DropPlace::Onto, |drag, _| dnd::accepts(drag, document, reverts))
|
||||
.select(SelectMode::Multi)
|
||||
.search(model.show_find)
|
||||
.reveal(focus.map(SwatchKey::Swatch))
|
||||
|
||||
@@ -5,12 +5,11 @@ use craft::keymap::Mods;
|
||||
use craft::ui::contract::{DropAt, ReorderMove};
|
||||
|
||||
/// Swatches take paints, and take swatch rows or canvas art from the current document.
|
||||
pub(super) fn accepts(drag: &PanelDrag, document: u64) -> bool {
|
||||
pub(super) fn accepts(drag: &PanelDrag, document: u64, reverts: u64) -> bool {
|
||||
match drag {
|
||||
PanelDrag::Paint { rows: Some(rows), .. } => rows.document == document,
|
||||
PanelDrag::Paint { .. } => true,
|
||||
PanelDrag::Art { document: source, .. } => *source == document,
|
||||
_ => false,
|
||||
_ => drag.artwork_for(document, reverts).is_some(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +44,6 @@ impl Drop {
|
||||
Some(Drop::Move { names: r.names.clone(), target, after, with })
|
||||
}
|
||||
PanelDrag::Paint { paint, .. } => Some(Drop::New { paint: paint.clone(), target, replace: mods.alt, spot: mods.cmd }),
|
||||
// PLAN: assumed `Art { document: u64, ids: Vec<NodeId> }` (widgets-w13).
|
||||
PanelDrag::Art { ids, .. } => Some(Drop::Pattern { ids: ids.iter().map(|id| id.0).collect(), target, replace: mods.alt }),
|
||||
_ => None,
|
||||
}
|
||||
@@ -88,7 +86,7 @@ fn place(shown: &[SwatchKey], at: &DropAt<SwatchKey>) -> (Option<String>, bool)
|
||||
/// `drag` dropped onto a swatch or between rows of the `shown` list (ap.AP2 `Dropped`); a gap with no
|
||||
/// row under the pointer is the end of the list.
|
||||
pub(super) fn on_dropped(app: &mut VectorcraftApp, shown: &[SwatchKey], at: &DropAt<SwatchKey>, drag: &PanelDrag, mods: Mods) {
|
||||
if !app.session.active().is_some_and(|st| accepts(drag, st.uid)) {
|
||||
if !app.session.active().is_some_and(|st| accepts(drag, st.uid, st.reverts)) {
|
||||
return;
|
||||
}
|
||||
let (target, after) = place(shown, at);
|
||||
|
||||
@@ -163,7 +163,8 @@ fn a_foreign_swatch_row_payload_cannot_move_or_replace_local_swatches() {
|
||||
let drag = rows_drag(&app, "Red", &["Red"]);
|
||||
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
|
||||
let before = doc(&app);
|
||||
assert!(!dnd::accepts(&drag, app.session.active().unwrap().uid));
|
||||
let state = app.session.active().unwrap();
|
||||
assert!(!dnd::accepts(&drag, state.uid, state.reverts));
|
||||
dropped_below(&mut app, drag.clone(), none());
|
||||
dropped(&mut app, drag, "Green", alt());
|
||||
assert_eq!(doc(&app).swatches, before.swatches);
|
||||
@@ -171,7 +172,8 @@ fn a_foreign_swatch_row_payload_cannot_move_or_replace_local_swatches() {
|
||||
|
||||
/// Art `ids` dragged off the canvas.
|
||||
fn art_drag(app: &VectorcraftApp, ids: Vec<vectorcraft_doc::NodeId>) -> PanelDrag {
|
||||
PanelDrag::Art { document: app.session.active().map(|st| st.uid).unwrap_or_default(), ids }
|
||||
let (document, reverts) = app.session.active().map_or((0, 0), |st| (st.uid, st.reverts));
|
||||
PanelDrag::Art { document, reverts, ids }
|
||||
}
|
||||
|
||||
/// The browser's reorder committing `names` before row `before` (a colour group: into it).
|
||||
|
||||
@@ -530,7 +530,9 @@ const AT_START: usize = 4;
|
||||
/// list becomes a symbol (Shift at the release keeps the art as ordinary art); dropped on a symbol
|
||||
/// with Alt it redefines that symbol in one undo step.
|
||||
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let Some((doc, revision, uid, has_sel)) = app.session.active().map(|st| (st.doc.clone(), st.revision, st.uid, !st.selection.is_empty())) else {
|
||||
let Some((doc, revision, uid, reverts, has_sel)) =
|
||||
app.session.active().map(|st| (st.doc.clone(), st.revision, st.uid, st.reverts, !st.selection.is_empty()))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let keys = document_symbols(&doc, revision);
|
||||
@@ -575,7 +577,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
.show(ui, |ui, _| {
|
||||
// Art dropped anywhere on the list becomes a symbol; dropped on a symbol, the browser's
|
||||
// own target takes it.
|
||||
DropAction::<PanelDrag>::new(move |drag| art_of(drag, uid).is_some()).show(ui, |ui, _| {
|
||||
DropAction::<PanelDrag>::new(move |drag| art_of(drag, uid, reverts).is_some()).show(ui, |ui, _| {
|
||||
let mut state = PresetState::new();
|
||||
state.zoom = zoom;
|
||||
PresetBrowser::new(tl!("Symbols"), Bind::bound(&mut state), &source)
|
||||
@@ -587,7 +589,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
.row_menu(PresetRowMenu::Host)
|
||||
.row_items(|key: &SymbolKey| item_rows(&linked, &key.name))
|
||||
.takes_drop(PresetDrop::new::<PanelDrag>(DropPlace::Onto, move |drag: &PanelDrag, _: &DropAt<SymbolKey>| {
|
||||
art_of(drag, uid).is_some()
|
||||
art_of(drag, uid, reverts).is_some()
|
||||
}))
|
||||
.empty(tl!("No symbols in this document"))
|
||||
.show(ui)
|
||||
@@ -605,7 +607,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
if let Some((dropped, events)) = taken {
|
||||
if let Some((drag, mods)) = dropped
|
||||
&& let Some(ids) = art_of(&drag, uid)
|
||||
&& let Some(ids) = art_of(&drag, uid, reverts)
|
||||
{
|
||||
new_symbol(app, ids, mods.shift);
|
||||
}
|
||||
@@ -630,7 +632,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
PresetEvent::Dropped { at, payload, mods, .. } => {
|
||||
let Some(ids) = payload.get::<PanelDrag>().and_then(|drag| art_of(drag, uid)) else { continue };
|
||||
let Some(ids) = payload.get::<PanelDrag>().and_then(|drag| art_of(drag, uid, reverts)) else { continue };
|
||||
if !mods.alt {
|
||||
new_symbol(app, ids, mods.shift);
|
||||
} else if let Some(target) = at.key()
|
||||
@@ -683,13 +685,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The ids of art dragged off the canvas of document `uid`; `None` for another drag or art of
|
||||
/// another document.
|
||||
fn art_of(drag: &PanelDrag, uid: u64) -> Option<&[NodeId]> {
|
||||
match drag {
|
||||
PanelDrag::Art { document, ids, .. } if *document == uid && !ids.is_empty() => Some(ids),
|
||||
_ => None,
|
||||
}
|
||||
/// The ids of the nonempty artwork dragged from the displayed drawing.
|
||||
fn art_of(drag: &PanelDrag, uid: u64, reverts: u64) -> Option<&[NodeId]> {
|
||||
drag.artwork_for(uid, reverts).filter(|ids| !ids.is_empty())
|
||||
}
|
||||
|
||||
/// Whether the art `ids` can redefine a symbol of `doc`: every object is still there and none is a
|
||||
|
||||
@@ -92,7 +92,7 @@ fn panel(app: VectorcraftApp) -> Panel {
|
||||
fn art_and_symbols(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
use craft::ui::contract::{ListDrag, ShowCollection as _};
|
||||
if let Some(st) = app.session.active() {
|
||||
let document = st.uid;
|
||||
let (document, reverts) = (st.uid, st.reverts);
|
||||
let mut named = Vec::new();
|
||||
st.doc.walk(|n| {
|
||||
if let Some(name) = &n.name {
|
||||
@@ -104,7 +104,7 @@ fn art_and_symbols(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let ids: Vec<NodeId> = named.iter().map(|(_, id)| *id).collect();
|
||||
ui.allocate_ui(vec2(ui.available_width(), 200.0), |ui| {
|
||||
let _ = craft::ui::list::List::<usize>::new("Art off the canvas")
|
||||
.drag_payload(move |drag: &ListDrag<usize>| ids.get(drag.grabbed).map(|id| PanelDrag::Art { document, ids: vec![*id] }))
|
||||
.drag_payload(move |drag: &ListDrag<usize>| ids.get(drag.grabbed).map(|id| PanelDrag::Art { document, reverts, ids: vec![*id] }))
|
||||
.show_items(ui, &rows, &mut |key, _| craft::ui::list::ListRow::new(named[*key].0.clone()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ fn art_and_assets(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
use craft::ui::list::{List, ListRow};
|
||||
|
||||
let st = app.session.active().unwrap();
|
||||
let payload = crate::panel_drag::PanelDrag::Art { document: st.uid, ids: st.selection.objects.clone() };
|
||||
let payload = crate::panel_drag::PanelDrag::Art { document: st.uid, reverts: st.reverts, ids: st.selection.objects.clone() };
|
||||
ui.allocate_ui(egui::vec2(ui.available_width(), 80.0), |ui| {
|
||||
let keys = craft::behavior::keyed(&[0_usize], |key: &usize| *key);
|
||||
List::<usize>::new("Artwork")
|
||||
|
||||
@@ -696,7 +696,7 @@ fn three_d_graphics_accepts_artwork_only_from_its_document() {
|
||||
|
||||
fn with_artwork(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
let st = app.session.active().unwrap();
|
||||
let payload = PanelDrag::Art { document: st.uid, ids: st.selection.objects.clone() };
|
||||
let payload = PanelDrag::Art { document: st.uid, reverts: st.reverts, ids: st.selection.objects.clone() };
|
||||
ui.allocate_ui(egui::vec2(ui.available_width(), 80.0), |ui| {
|
||||
let keys = craft::behavior::keyed(&[0_usize], |key: &usize| *key);
|
||||
List::<usize>::new("Artwork")
|
||||
|
||||
Reference in new issue
Block a user