* claim: #5850 * Find in Timeline scrolls both timeline layouts to the found feature (#5850) Find in Timeline selected the feature but neither the bottom History strip nor the history on the left scrolled to it. The handler now leaves a one-shot reveal request (TreeState::timeline_reveal); whichever layout draws its items next scrolls the found item into the middle of its scroll area and drops it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0343960bd6
commit
992c93fe5b
4 files changed
+46
No files matched your search
@@ -122,6 +122,9 @@ pub struct TreeState {
|
||||
pub picked_timeline_groups: Vec<u64>,
|
||||
/// Last feature-history item clicked, for Shift ranges (`f:<id>` or `g:<id>`).
|
||||
pub timeline_anchor: Option<String>,
|
||||
/// Find in Timeline: the feature the history scrolls to the next time it draws its items, in
|
||||
/// the bottom strip or in the history on the left (#5850).
|
||||
pub timeline_reveal: Option<u64>,
|
||||
/// The Edit Canvas / Calibrate panel.
|
||||
pub canvas_panel: Option<CanvasPanel>,
|
||||
/// A Section Analysis hidden with its eye in the Analysis folder: its plane (origin,
|
||||
|
||||
@@ -1190,6 +1190,7 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {
|
||||
crate::browser::reveal_feature(app, f, body);
|
||||
}
|
||||
let _ = app.run("select.set", json!({"items": [{"type": "feature", "id": f}]}));
|
||||
app.tree.timeline_reveal = Some(f);
|
||||
}
|
||||
}
|
||||
"ui.tangentChain" => tangent_chain(app),
|
||||
|
||||
@@ -419,6 +419,8 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
|
||||
.map(|f| (f.id, f.name.clone(), icon_of(&f.kind), f.suppressed, f.kind.type_name(), TimelineKind::of(&f.kind)))
|
||||
.collect();
|
||||
let order: Vec<u64> = feats.iter().map(|f| f.0).collect();
|
||||
// Find in Timeline: scroll the found feature into the strip on this frame (#5850).
|
||||
let reveal = app.tree.timeline_reveal.take();
|
||||
// The feature whose body is under the cursor in the viewport.
|
||||
let st = app.session.world_state();
|
||||
let from_view = match &app.viewport.hover {
|
||||
@@ -441,6 +443,9 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
|
||||
}
|
||||
xs.push(x);
|
||||
let br = Rect::from_min_size(pos2(x, r.top() + 6.0), vec2(28.0, 28.0));
|
||||
if reveal == Some(*id) {
|
||||
ui.scroll_to_rect(br, Some(egui::Align::Center));
|
||||
}
|
||||
crate::scenario::publish_handle(&format!("timeline:{name}"), br.center());
|
||||
let resp = ui.interact(br, ui.id().with(("feat", *id)), Sense::click_and_drag());
|
||||
let res = app.session.model.result(*id);
|
||||
@@ -769,6 +774,38 @@ mod tests {
|
||||
assert_eq!(moved.y, first.y);
|
||||
}
|
||||
|
||||
/// Find in Timeline on the last body of a history longer than the timeline scrolls its
|
||||
/// feature into view, in the bottom strip and in the history on the left (#5850).
|
||||
#[test]
|
||||
fn find_in_timeline_scrolls_both_timelines_to_the_found_feature() {
|
||||
for left in [false, true] {
|
||||
let mut h = Harness::new();
|
||||
h.app.preferences.timeline_left = left;
|
||||
for i in 0..80 {
|
||||
h.app.run("sketch.create", json!({"plane": "XY", "name": format!("S{i}")})).unwrap();
|
||||
h.app.run("sketch.finish", json!({})).unwrap();
|
||||
}
|
||||
h.app.run("solid.box", json!({"length": 10, "width": 10, "height": 10, "name": "Last", "body_name": "Plate"})).unwrap();
|
||||
h.app.run("select.clear", json!({})).unwrap();
|
||||
h.frames(4);
|
||||
let shown = |h: &Harness| {
|
||||
let history = h.app.shell.history.unwrap();
|
||||
let found = crate::scenario::handle_at("timeline:Last").unwrap();
|
||||
history.contains(found)
|
||||
};
|
||||
assert!(!shown(&h), "left={left}: the last feature starts outside the timeline");
|
||||
|
||||
let target = crate::context_menu::Target::Body { name: "Plate".into() };
|
||||
let item = crate::context_menu::items(&h.app, &target).into_iter().find(|item| item.id == "ui.findTimeline").unwrap();
|
||||
crate::context_menu::run_item(&mut h.app, &item, egui::pos2(0.0, 0.0));
|
||||
h.frames(30);
|
||||
let last = h.app.session.doc.find_feature("Last").unwrap().id;
|
||||
assert_eq!(h.app.session.selection, [solidcraft_engine::Sel::Feature { id: last }], "left={left}");
|
||||
assert!(shown(&h), "left={left}: Find in Timeline scrolled the found feature into the timeline");
|
||||
assert!(h.app.tree.timeline_reveal.is_none(), "left={left}: the request is done once drawn");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_feature_menu_edits_its_profile_sketch_in_both_timelines() {
|
||||
for left in [false, true] {
|
||||
|
||||
@@ -935,6 +935,8 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {
|
||||
.collect();
|
||||
let groups = app.session.doc.timeline_groups.clone();
|
||||
let order = visible_order(app, &features, &groups);
|
||||
// Find in Timeline: scroll the found feature into the history on this frame (#5850).
|
||||
let reveal = app.tree.timeline_reveal.take();
|
||||
let first_indices: std::collections::BTreeMap<u64, Option<usize>> =
|
||||
groups.iter().map(|group| (group.id, group_first_feature(&groups, &features, group.id))).collect();
|
||||
let end_indices: std::collections::BTreeMap<u64, usize> = groups
|
||||
@@ -1014,6 +1016,9 @@ fn vertical_features(app: &mut SolveApp, ui: &mut egui::Ui, names: bool) {
|
||||
row
|
||||
};
|
||||
crate::scenario::publish_rect(&format!("history:feature:{name}"), rect);
|
||||
if reveal == Some(*id) {
|
||||
ui.scroll_to_rect(rect, Some(egui::Align::Center));
|
||||
}
|
||||
let fold_rect = Rect::from_min_size(rect.left_top() + vec2(indent, 0.0), vec2(16.0, rect.height()));
|
||||
let on_fold = has_patterns && response.interact_pointer_pos().is_some_and(|p| fold_rect.contains(p));
|
||||
crate::scenario::publish_handle(&format!("timeline:{name}"), rect.center());
|
||||
|
||||
Reference in new issue
Block a user