From 99140178a9fac20077b8b4498a6e8e4e8d060abc Mon Sep 17 00:00:00 2001 From: dooglus Date: Mon, 18 Feb 2008 16:34:11 +0000 Subject: [PATCH] Scroll the History panel to keep the border between 'done' and 'undone' in the centre of the panel if possible. Also, select the most recently 'done' action, if any. git-svn-id: http://svn.voria.com/code@1746 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/dock_history.cpp | 34 ++++++++++++++++++++++ synfig-studio/trunk/src/gtkmm/dock_history.h | 5 ++++ synfig-studio/trunk/src/gtkmm/historytreestore.cpp | 4 +++ synfig-studio/trunk/src/gtkmm/historytreestore.h | 18 ++++++++++++ 4 files changed, 61 insertions(+) diff --git a/synfig-studio/trunk/src/gtkmm/dock_history.cpp b/synfig-studio/trunk/src/gtkmm/dock_history.cpp index 4277f16..4887895 100644 --- a/synfig-studio/trunk/src/gtkmm/dock_history.cpp +++ b/synfig-studio/trunk/src/gtkmm/dock_history.cpp @@ -289,14 +289,48 @@ Dock_History::update_undo_redo() } void +Dock_History::on_undo_tree_changed() +{ + Gtk::TreeModel::Children children(selected_instance->history_tree_store()->children()); + + if (!children.size()) + return; + + studio::HistoryTreeStore::Model model; + + Gtk::TreeModel::Children::iterator iter, prev = children.end(); + for (iter = children.begin(); iter != children.end(); prev = iter++) + if ((*iter)[model.is_redo]) + { + if (prev == children.end()) + action_tree->get_selection()->unselect_all(); + else + { + action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5); + action_tree->get_selection()->select(prev); + } + return; + } + + action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5); + action_tree->get_selection()->select(prev); +} + +void Dock_History::set_selected_instance_(etl::handle instance) { if(studio::App::shutdown_in_progress) return; + if (on_undo_tree_changed_connection) + on_undo_tree_changed_connection.disconnect(); + selected_instance=instance; if(instance) { + on_undo_tree_changed_connection = selected_instance->history_tree_store()->signal_undo_tree_changed().connect( + sigc::mem_fun(*this,&Dock_History::on_undo_tree_changed)); + action_tree->set_model(instance->history_tree_store()); action_tree->show(); update_undo_redo(); diff --git a/synfig-studio/trunk/src/gtkmm/dock_history.h b/synfig-studio/trunk/src/gtkmm/dock_history.h index aceb519..6973aa1 100644 --- a/synfig-studio/trunk/src/gtkmm/dock_history.h +++ b/synfig-studio/trunk/src/gtkmm/dock_history.h @@ -47,6 +47,11 @@ class Dock_History : public Dock_CanvasSpecific Gtk::TreeView *action_tree; etl::loose_handle selected_instance; + + sigc::connection on_undo_tree_changed_connection; + + void on_undo_tree_changed(); + void set_selected_instance_(etl::handle x); diff --git a/synfig-studio/trunk/src/gtkmm/historytreestore.cpp b/synfig-studio/trunk/src/gtkmm/historytreestore.cpp index bc0c97a..1f0eb9c 100644 --- a/synfig-studio/trunk/src/gtkmm/historytreestore.cpp +++ b/synfig-studio/trunk/src/gtkmm/historytreestore.cpp @@ -104,6 +104,8 @@ HistoryTreeStore::rebuild() { insert_action(*(append()),*iter,true,false,true); } + + signal_undo_tree_changed()(); } void @@ -199,6 +201,8 @@ HistoryTreeStore::on_new_action(etl::handle action) row=*insert(iter); insert_action(row,action); + + signal_undo_tree_changed()(); } void diff --git a/synfig-studio/trunk/src/gtkmm/historytreestore.h b/synfig-studio/trunk/src/gtkmm/historytreestore.h index 3e8e6f1..69803f1 100644 --- a/synfig-studio/trunk/src/gtkmm/historytreestore.h +++ b/synfig-studio/trunk/src/gtkmm/historytreestore.h @@ -93,6 +93,8 @@ public: private: etl::loose_handle instance_; + +public: Gtk::TreeIter curr_row; /* @@ -102,6 +104,22 @@ private: private: /* + -- ** -- P R I V A T E D A T A --------------------------------------------- + */ + +private: + + sigc::signal signal_undo_tree_changed_; + + /* + -- ** -- S I G N A L I N T E R F A C E S ----------------------------------- + */ + +public: + + sigc::signal& signal_undo_tree_changed() { return signal_undo_tree_changed_; } + + /* -- ** -- S I G N A L T E R M I N A L S ------------------------------------- */ -- 2.7.4