Scroll the History panel to keep the border between 'done' and 'undone' in the centre...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 18 Feb 2008 16:34:11 +0000 (16:34 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Mon, 18 Feb 2008 16:34:11 +0000 (16:34 +0000)
git-svn-id: http://svn.voria.com/code@1746 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/dock_history.cpp
synfig-studio/trunk/src/gtkmm/dock_history.h
synfig-studio/trunk/src/gtkmm/historytreestore.cpp
synfig-studio/trunk/src/gtkmm/historytreestore.h

index 4277f16..4887895 100644 (file)
@@ -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<studio::Instance> 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();
index aceb519..6973aa1 100644 (file)
@@ -47,6 +47,11 @@ class Dock_History : public Dock_CanvasSpecific
        Gtk::TreeView *action_tree;
 
        etl::loose_handle<studio::Instance>     selected_instance;
+
+       sigc::connection on_undo_tree_changed_connection;
+
+       void on_undo_tree_changed();
+
        void set_selected_instance_(etl::handle<studio::Instance> x);
 
 
index bc0c97a..1f0eb9c 100644 (file)
@@ -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<synfigapp::Action::Undoable> action)
        row=*insert(iter);
 
        insert_action(row,action);
+
+       signal_undo_tree_changed()();
 }
 
 void
index 3e8e6f1..69803f1 100644 (file)
@@ -93,6 +93,8 @@ public:
 private:
 
        etl::loose_handle<studio::Instance> 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<void> signal_undo_tree_changed_;
+
+       /*
+ -- ** -- S I G N A L   I N T E R F A C E S -----------------------------------
+       */
+
+public:
+
+       sigc::signal<void>& signal_undo_tree_changed() { return signal_undo_tree_changed_; }
+
+       /*
  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
        */