summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2007-08-14 09:00:10 +0000
committernicholasbishop <nicholasbishop@users.sourceforge.net>2007-08-14 09:00:10 +0000
commit19a700e402aec60d4d2d41919aed750f5b0413ad (patch)
treea6fb0280267db3e039127aef73cc0988c0009990 /src
parentRolled back a couple of nasties from a bad patch...oops! Added author of the (diff)
downloadinkscape-19a700e402aec60d4d2d41919aed750f5b0413ad.tar.gz
inkscape-19a700e402aec60d4d2d41919aed750f5b0413ad.zip
Filter effects dialog:
* Added autoscrolling during connection drag/drop. If a connection is dragged towards the top or bottom of the primitives treeview, the view will scroll with it. (bzr r3466)
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/filter-effects-dialog.cpp47
-rw-r--r--src/ui/dialog/filter-effects-dialog.h3
2 files changed, 50 insertions, 0 deletions
diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp
index 315b73d99..6cc5d0fa8 100644
--- a/src/ui/dialog/filter-effects-dialog.cpp
+++ b/src/ui/dialog/filter-effects-dialog.cpp
@@ -1502,6 +1502,8 @@ bool FilterEffectsDialog::PrimitiveList::on_button_press_event(GdkEventButton* e
}
if(_in_drag) {
+ _scroll_connection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &PrimitiveList::on_scroll_timeout), 150);
+ _autoscroll = 0;
get_selection()->select(path);
return true;
}
@@ -1511,6 +1513,28 @@ bool FilterEffectsDialog::PrimitiveList::on_button_press_event(GdkEventButton* e
bool FilterEffectsDialog::PrimitiveList::on_motion_notify_event(GdkEventMotion* e)
{
+ const int speed = 10;
+ const int limit = 15;
+
+ Gdk::Rectangle vis;
+ get_visible_rect(vis);
+ int vis_x, vis_y;
+ tree_to_widget_coords(vis.get_x(), vis.get_y(), vis_x, vis_y);
+ const int top = vis_y + vis.get_height();
+
+ // When autoscrolling during a connection drag, set the speed based on
+ // where the mouse is in relation to the edges.
+ if(e->y < vis_y)
+ _autoscroll = -(int)(speed + (vis_y - e->y) / 5);
+ else if(e->y < vis_y + limit)
+ _autoscroll = -speed;
+ else if(e->y > top)
+ _autoscroll = (int)(speed + (e->y - top) / 5);
+ else if(e->y > top - limit)
+ _autoscroll = speed;
+ else
+ _autoscroll = 0;
+
queue_draw();
return Gtk::TreeView::on_motion_notify_event(e);
@@ -1520,6 +1544,8 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton*
{
SPFilterPrimitive *prim = get_selected(), *target;
+ _scroll_connection.disconnect();
+
if(_in_drag && prim) {
Gtk::TreePath path;
Gtk::TreeViewColumn* col;
@@ -1692,6 +1718,27 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra
sp_document_done(filter->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Reorder filter primitive"));
}
+// If a connection is dragged towards the top or bottom of the list, the list should scroll to follow.
+bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout()
+{
+ if(_autoscroll) {
+ Gtk::Adjustment& a = *dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment();
+ double v;
+
+ v = a.get_value() + _autoscroll;
+ if(v < 0)
+ v = 0;
+ if(v > a.get_upper() - a.get_page_size())
+ v = a.get_upper() - a.get_page_size();
+
+ a.set_value(v);
+
+ queue_draw();
+ }
+
+ return true;
+}
+
int FilterEffectsDialog::PrimitiveList::primitive_count() const
{
return _model->children().size();
diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h
index 95dafaff2..ace6e68bd 100644
--- a/src/ui/dialog/filter-effects-dialog.h
+++ b/src/ui/dialog/filter-effects-dialog.h
@@ -197,6 +197,7 @@ private:
const int x1, const int y1, const int row_count);
void sanitize_connections(const Gtk::TreeIter& prim_iter);
void on_primitive_selection_changed();
+ bool on_scroll_timeout();
FilterEffectsDialog& _dialog;
Glib::RefPtr<Gtk::ListStore> _model;
@@ -207,6 +208,8 @@ private:
int _in_drag;
SPFilterPrimitive* _drag_prim;
sigc::signal<void> _signal_primitive_changed;
+ sigc::connection _scroll_connection;
+ int _autoscroll;
std::auto_ptr<SignalObserver> _observer;
};