diff options
| author | gustav_b <gustav_b@users.sourceforge.net> | 2007-09-20 08:17:58 +0000 |
|---|---|---|
| committer | gustav_b <gustav_b@users.sourceforge.net> | 2007-09-20 08:17:58 +0000 |
| commit | 2253fd51aece1dd179464456822ee8897f9661f8 (patch) | |
| tree | a1d609e950d363a17f1f7181e72635bb90f507d8 /src/ui/widget | |
| parent | fix typo in 2geom Makefile_insert (diff) | |
| download | inkscape-2253fd51aece1dd179464456822ee8897f9661f8.tar.gz inkscape-2253fd51aece1dd179464456822ee8897f9661f8.zip | |
Add scrolling of dock on DockItem::present.
(bzr r3777)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/dock-item.cpp | 8 | ||||
| -rw-r--r-- | src/ui/widget/dock.cpp | 18 | ||||
| -rw-r--r-- | src/ui/widget/dock.h | 3 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 372fe5d9d..2187c33e9 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -269,7 +269,7 @@ DockItem::show_all() void DockItem::present() { - // iconified or unattached + if (isIconified() || !isAttached()) { show(); } @@ -280,11 +280,13 @@ DockItem::present() GTK_WIDGET (_gdl_dock_item)); if (i >= 0) gtk_notebook_set_current_page (GTK_NOTEBOOK (_gdl_dock_item->parent), i); - return; - } + } // always grab focus, even if we're already present grab_focus(); + + if (!isFloating() && getWidget().is_realized()) + _dock.scrollToItem(*this); } diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index 0f92f7217..f282449dd 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -15,6 +15,8 @@ #include "dock.h" +#include <gtkmm/adjustment.h> + namespace Inkscape { namespace UI { namespace Widget { @@ -196,6 +198,22 @@ Dock::toggleDockable(int width, int height) } +void +Dock::scrollToItem(DockItem& item) +{ + int item_x, item_y; + item.getWidget().translate_coordinates(getWidget(), 0, 0, item_x, item_y); + + int dock_height = getWidget().get_height(), item_height = item.getWidget().get_height(); + double vadjustment = _scrolled_window->get_vadjustment()->get_value(); + + if (item_y < 0) + _scrolled_window->get_vadjustment()->set_value(vadjustment + item_y); + else if (item_y + item_height > dock_height) + _scrolled_window->get_vadjustment()->set_value( + vadjustment + ((item_y + item_height) - dock_height)); +} + Glib::SignalProxy0<void> Dock::signal_layout_changed() { diff --git a/src/ui/widget/dock.h b/src/ui/widget/dock.h index 3b2cb8d77..3cd29c01f 100644 --- a/src/ui/widget/dock.h +++ b/src/ui/widget/dock.h @@ -51,6 +51,9 @@ public: /** Toggle size of dock between the previous dimensions and the ones sent as parameters */ void toggleDockable(int width=0, int height=0); + /** Scrolls the scrolled window container to make the provided dock item visible, if needed */ + void scrollToItem(DockItem& item); + protected: std::list<const DockItem *> _dock_items; //< added dock items |
