mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-05 13:32:45 -05:00
Merge pull request #10893 from dotCooCoo/fix/libraries-panel-scroll
Libraries: a library taller than the panel scrolls
This commit is contained in:
2 files changed
+33
-4
No files matched your search
@@ -20,7 +20,7 @@ use craft::keymap::CommandRef;
|
||||
use craft::theme::variant::Tone;
|
||||
use craft::ui::choice::Segmented;
|
||||
use craft::ui::contract::{
|
||||
ActivateOn, Bind, BodyCx, CollectionEvent, DropAt, DropKind, DropPlace, Entry, ListDrag, Props as _, ReorderRule, SelectMode, Show as _,
|
||||
ActivateOn, Bind, BodyCx, CollectionEvent, DropAt, DropKind, DropPlace, Entry, ListDrag, Props as _, ReorderRule, Scroll, SelectMode, Show as _,
|
||||
ShowCollection as _, ShowContainer as _, Sizing, Trigger,
|
||||
};
|
||||
use craft::ui::display::{Divider, Shade, Text};
|
||||
@@ -349,13 +349,14 @@ impl<'a> View<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The list: the ungrouped items, then the groups as sections. A drop anywhere on it away from
|
||||
/// the items and groups takes an item out of its group, or adds art or a swatch ungrouped.
|
||||
/// The list: the ungrouped items, then the groups as sections, scrolling under the header when
|
||||
/// they are taller than the panel. A drop anywhere on it away from the items and groups takes an
|
||||
/// item out of its group, or adds art or a swatch ungrouped.
|
||||
fn show(&self, ui: &mut Ui, closed: &mut HashSet<(String, String)>, acts: &RefCell<Vec<Act>>) {
|
||||
let membership = Arc::clone(&self.membership);
|
||||
let list = DropAction::new(move |drag: &PanelDrag| membership.landing(drag, None).is_some())
|
||||
.sizing(Sizing::Fill)
|
||||
.show(ui, |ui, _| Stack::new().fill().show(ui, |ui, cx| self.contents(ui, cx, closed, acts)));
|
||||
.show(ui, |ui, _| Stack::new().fill().scroll(Scroll::vertical()).show(ui, |ui, cx| self.contents(ui, cx, closed, acts)));
|
||||
if let Some(drag) = &list.output.dropped
|
||||
&& let Some(act) = self.membership.landing(drag, None)
|
||||
{
|
||||
|
||||
@@ -679,6 +679,34 @@ fn a_shrunk_thumbnail_keeps_its_color_beside_clear_pixels() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A library longer than the panel scrolls: the wheel over the items brings the last one into view, in the list view
|
||||
/// and in the thumbnail view, while the footer's New Group stays in view.
|
||||
#[test]
|
||||
fn a_long_library_scrolls_with_the_wheel() {
|
||||
for list in [false, true] {
|
||||
let mut app = app();
|
||||
app.run("library.create", json!({"name": "Brand"})).unwrap();
|
||||
for i in 0..400 {
|
||||
app.run("library.add", json!({"kind": "fillColor", "color": format!("#{:06x}", i * 0x9731), "name": format!("Swatch {i}")})).unwrap();
|
||||
}
|
||||
app.ui.libraries_list_view = list;
|
||||
let mut panel = Harness::new(app, show);
|
||||
panel.room(egui::vec2(300.0, 400.0));
|
||||
panel.frame();
|
||||
panel.frame();
|
||||
assert!(panel.in_view("Swatch 0"), "the first item shows (list view {list})");
|
||||
assert!(!panel.in_view("Swatch 399"), "the last item starts out of view (list view {list})");
|
||||
let at = panel.rect("Swatch 0").center();
|
||||
for _ in 0..40 {
|
||||
panel.scroll_at(at, -400.0);
|
||||
}
|
||||
panel.frame();
|
||||
assert!(panel.in_view("Swatch 399"), "the wheel scrolls the last item into view (list view {list})");
|
||||
assert!(!panel.in_view("Swatch 0"), "the first item scrolls out of view (list view {list})");
|
||||
assert!(panel.in_view("New Group"), "the footer stays in view (list view {list})");
|
||||
}
|
||||
}
|
||||
|
||||
/// Graphic thumbnails decoded while the panel draws one frame.
|
||||
fn decoded(panel: &mut Harness) -> usize {
|
||||
super::counters::DECODED.with(|c| c.set(0));
|
||||
|
||||
Reference in new issue
Block a user