Skip to content

Commit

Permalink
Drag 'n drop UX working as expected.
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualritz committed Aug 12, 2023
1 parent f810b21 commit 0d058fe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ inherits = "release"

[patch.crates-io]
egui = { git = "https://github.com/emilk/egui", branch = "master" } # rev = "4bd4eca2e4b440ca585d8844740afd8144ba7dbc" } # branch = "master" }
egui_dnd = { git = "https://github.com/lucasmerlin/egui_dnd", branch = "main" }
eframe = { git = "https://github.com/emilk/egui", branch = "master" } # rev = "4bd4eca2e4b440ca585d8844740afd8144ba7dbc" } # branch = "master" }
unicode_skeleton = { git = "https://github.com/virtualritz/unicode_skeleton.git", branch = "master" }
#decancer = { git = "https://github.com/null8626/decancer.git", branch = "main" }
Expand Down
23 changes: 16 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use ahash::AHashSet as HashSet;
use enum_dispatch::enum_dispatch;
//use log::info;
use egui_dnd::{utils::shift_vec, DragDropItem, DragDropUi};
use egui_dnd::{dnd, DragDropItem, DragDropUi};
use serde::{Deserialize, Serialize};
use std::{hash::{Hasher, Hash}, collections::{BTreeMap, VecDeque}};
use unicode_blocks as ub;
Expand Down Expand Up @@ -586,21 +586,30 @@ impl eframe::App for GlyphanaApp {
//ui.end_row();
}*/

let response = self
dnd(ui, "dnd_example").show_vec(&mut self.categories, |ui, item, handle, state| {
handle
.show_drag_cursor_on_hover(false)
.ui(ui, |ui| {ui.selectable_value(&mut self.selected_category, item.id(), &item.name); });
});


/*let response = self
.categories_ui
.ui::<Category>(ui, self.categories.iter_mut(), |item, ui, handle| {
ui.horizontal(|ui| {
.ui::<Category>(ui, self.categories.iter(), |item, ui, handle, _pressure| {
/*ui.horizontal(|ui| {
// Anything in the handle can be used to drag the item
handle.ui(ui, item, |ui| {
ui.label("☰");
});
ui.selectable_value(&mut self.selected_category, item.id(), &item.name);
});
});*/
ui.selectable_value(&mut self.selected_category, item.id(), &item.name);
});
//response.update_vec(&mut self.categories);
if let Some(response) = response.completed {
shift_vec(response.from, response.to, &mut self.categories);
}
}*/
//});
});
});
Expand Down

0 comments on commit 0d058fe

Please sign in to comment.