mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:24:24 +00:00
panels-w8: repair 1
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
use super::words::PanelWords;
|
||||
use crate::contract::{
|
||||
Bind, CollectionEvent, ColumnSpec, ListDrag, NoValue, Outcome, Pattern, Props as _, SelectMode, ShowCollection as _, ShowContainer as _, Sizing,
|
||||
Bind, CollectionEvent, ColumnSpec, ListDrag, NoValue, Outcome, Pattern, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing,
|
||||
ToggleColumn, request_rename,
|
||||
};
|
||||
use crate::layout_components::Stack;
|
||||
@@ -11,6 +11,7 @@ use crate::menu::{Menu, MenuItem};
|
||||
use crate::primitives::IconSpec;
|
||||
use crate::primitives::textures::{Priority, ThumbPaint, ThumbRequest, ThumbSource, Thumbnails};
|
||||
use crate::runtime::env::{Env, Label};
|
||||
use crate::runtime::memory::Remember as _;
|
||||
use crate::sections::{FooterAction, FooterBar};
|
||||
use craft_behavior::{ColumnKey, ColumnWidth, GesturePhase, IconId, Selection, SelectionChange, keyed};
|
||||
use craft_keymap::Mods;
|
||||
@@ -247,7 +248,7 @@ impl<'a> HistoryPanel<'a> {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
for row in rows {
|
||||
row.key.hash(&mut hasher);
|
||||
env.resolve(&row.label).as_str().hash(&mut hasher);
|
||||
row.label.as_str().hash(&mut hasher);
|
||||
row.redo.hash(&mut hasher);
|
||||
row.icon.hash(&mut hasher);
|
||||
}
|
||||
@@ -381,7 +382,7 @@ impl<'a> HistoryPanel<'a> {
|
||||
&& let HistoryKey::Snapshot(snapshot) = rename.key
|
||||
{
|
||||
let text = rename.name.trim();
|
||||
let changed = rows.iter().find(|row| row.key == rename.key).is_some_and(|row| env.resolve(&row.label).as_str() != text);
|
||||
let changed = rows.iter().find(|row| row.key == rename.key).is_some_and(|row| row.label.as_str() != text);
|
||||
if changed && !text.is_empty() {
|
||||
picked.push(HistoryEvent::Rename { snapshot, text: text.to_owned() });
|
||||
}
|
||||
|
||||
@@ -13,21 +13,17 @@ type Seen = Rc<RefCell<Vec<HistoryEvent>>>;
|
||||
fn rig(source: Option<HistoryKey>, with_source: bool) -> (Fixture, Seen) {
|
||||
let seen: Seen = Rc::new(RefCell::new(Vec::new()));
|
||||
let sink = seen.clone();
|
||||
let rows = vec![
|
||||
HistoryRow::state(1, "Open"),
|
||||
HistoryRow::state(2, "Brush"),
|
||||
HistoryRow::state(3, "Fill"),
|
||||
HistoryRow::snapshot(7, "Snapshot 1"),
|
||||
];
|
||||
let fixture = Fixture::new(move |ui| {
|
||||
let mut panel = HistoryPanel::new(&rows, Some(HistoryKey::State(2)))
|
||||
.can_delete(|key| *key != HistoryKey::State(1))
|
||||
.footer(HistoryFooter { delete: true, new_snapshot: false, new_document: false });
|
||||
if with_source {
|
||||
panel = panel.source(source);
|
||||
}
|
||||
sink.borrow_mut().extend(panel.show(ui).events);
|
||||
});
|
||||
let rows = vec![HistoryRow::state(1, "Open"), HistoryRow::state(2, "Brush"), HistoryRow::state(3, "Fill"), HistoryRow::snapshot(7, "Snapshot 1")];
|
||||
let fixture =
|
||||
Fixture::new(move |ui| {
|
||||
let mut panel = HistoryPanel::new(&rows, Some(HistoryKey::State(2)))
|
||||
.can_delete(|key| *key != HistoryKey::State(1))
|
||||
.footer(HistoryFooter { delete: true, new_snapshot: false, new_document: false });
|
||||
if with_source {
|
||||
panel = panel.source(source);
|
||||
}
|
||||
sink.borrow_mut().extend(panel.show(ui).events);
|
||||
});
|
||||
(fixture, seen)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user