fix the darn scrolling reset when opening up trips for a person
@@ -42,6 +42,8 @@ pub struct InfoPanel {
cached_actions: Vec<Key>,
}
+// TODO We need a separate, weaker form of PartialEq for this to detect when we're on the "current"
+// tab.
#[derive(Clone, PartialEq)]
pub enum Tab {
// What trips are open? For finished trips, show the timeline in the current simulation if
@@ -341,8 +343,17 @@ impl InfoPanel {
match self.composite.event(ctx) {
Some(Outcome::Clicked(action)) => {
if let Some(new_tab) = self.hyperlinks.get(&action).cloned() {
- // TODO restore if the tab was the same?
- *self = InfoPanel::new(ctx, app, new_tab, ctx_actions);
+ let mut new = InfoPanel::new(ctx, app, new_tab, ctx_actions);
+ // TODO Most cases use changed_settings, but one doesn't. Detect that
+ // "sameness" here.
+ if let (Tab::PersonTrips(p1, _), Tab::PersonTrips(p2, _)) =
+ (&self.tab, &new.tab)
+ {
+ if p1 == p2 {
+ new.composite.restore(ctx, &self.composite);
+ }
+ }
+ *self = new;
return (false, None);
} else if action == "close info" {
(true, None)
