From a661f8d7f400d6ea7bb82e8255830888423af5e4 Mon Sep 17 00:00:00 2001 From: joncruz Date: Sun, 19 Feb 2006 05:32:13 +0000 Subject: [PATCH] Fixing scrollbar size for embeded color swatches. --- ChangeLog | 10 +++++++++- src/dialogs/swatches.cpp | 6 ++++-- src/dialogs/swatches.h | 3 +-- src/ui/previewholder.cpp | 34 ++++++++++++++++++++++++++++++++-- src/ui/previewholder.h | 3 +++ src/ui/widget/panel.cpp | 8 ++++++++ src/ui/widget/panel.h | 3 +++ src/widgets/desktop-widget.cpp | 2 +- 8 files changed, 61 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5414336bb..47a240965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-02-18 Jon A. Cruz + * src/widgets/desktop-widget.cpp, src/dialogs/swatches.cpp, + src/dialogs/swatches.h, src/ui/widget/panel.cpp, + src/ui/widget/panel.h, src/ui/previewholder.cpp, + src/ui/previewholder.h: + + Adding spacer to get swatches scrollbar enough room to move. + Tuning up API for better embedding. + 2006-02-18 Jon A. Cruz * src/widgets/desktop-widget.cpp, src/dialogs/swatches.cpp, src/dialogs/swatches.h, src/ui/previewholder.cpp, @@ -5,7 +14,6 @@ Removed horizontal scroll bar from swatches when embedded. - 2006-02-15 Michael Wybrow * src/document.cpp, src/document.h, src/sp-conn-end-pair.cpp, diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index dd48fa539..c01217fe6 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -482,15 +482,17 @@ SwatchesPanel::~SwatchesPanel() { } -void SwatchesPanel::Temp() +void SwatchesPanel::setOrientation( Gtk::AnchorType how ) { + // Must call the parent class or bad things might happen + Inkscape::UI::Widget::Panel::setOrientation( how ); + if ( _holder ) { _holder->setOrientation( Gtk::ANCHOR_SOUTH ); } } - void SwatchesPanel::_handleAction( int setId, int itemId ) { switch( setId ) { diff --git a/src/dialogs/swatches.h b/src/dialogs/swatches.h index fea2b8309..37a04cfba 100644 --- a/src/dialogs/swatches.h +++ b/src/dialogs/swatches.h @@ -60,8 +60,7 @@ public: virtual ~SwatchesPanel(); static SwatchesPanel& getInstance(); - - void Temp(); + virtual void setOrientation( Gtk::AnchorType how ); protected: virtual void _handleAction( int setId, int itemId ); diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 321b7899f..961c060bb 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -14,6 +14,8 @@ #include "previewholder.h" #include +#include +#include namespace Inkscape { @@ -24,6 +26,9 @@ PreviewHolder::PreviewHolder() : VBox(), PreviewFillable(), _scroller(0), + _zee0(0), + _zee1(0), + _zee2(0), _anchor(Gtk::ANCHOR_CENTER), _baseSize(Gtk::ICON_SIZE_MENU), _view(VIEW_TYPE_LIST) @@ -32,9 +37,15 @@ PreviewHolder::PreviewHolder() : Gtk::Table* stuff = manage(new Gtk::Table( 1, 2 )); stuff->set_col_spacings( 8 ); _insides = stuff; + + // Add a container with the scroller and a spacer + Gtk::Table* spaceHolder = manage( new Gtk::Table(1, 2) ); + _zee0 = manage( new Gtk::VBox() ); _scroller->add(*stuff); + spaceHolder->attach( *_scroller, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); + spaceHolder->attach( *_zee0, 1, 2, 0, 1, Gtk::SHRINK, Gtk::FILL|Gtk::EXPAND ); - pack_start(*_scroller, Gtk::PACK_EXPAND_WIDGET); + pack_start(*spaceHolder, Gtk::PACK_EXPAND_WIDGET); } PreviewHolder::~PreviewHolder() @@ -89,12 +100,31 @@ void PreviewHolder::setOrientation( Gtk::AnchorType how ) { if ( _anchor != how ) { + _anchor = how; switch ( _anchor ) { case Gtk::ANCHOR_NORTH: case Gtk::ANCHOR_SOUTH: { - dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); + //dynamic_cast(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER ); + dynamic_cast(_scroller)->set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC ); + if ( !_zee1 ) + { + _zee1 = manage( new Gtk::VBox() ); + _zee2 = manage( new Gtk::VBox() ); + + // Trick to get the scrolled window to a minimum height larger than the scrollbar + + Gtk::VScrollbar* vs = dynamic_cast(_scroller)->get_vscrollbar(); + // TODO fix leakage + Glib::RefPtr sizer = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_VERTICAL); + sizer->add_widget( *_zee1 ); + sizer->add_widget( *_zee2 ); + sizer->add_widget( *vs ); + + _zee0->pack_start( *_zee1 ); + _zee0->pack_start( *_zee2 ); + } } break; diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index 532aa771f..58d0dba5d 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -40,6 +40,9 @@ private: std::vector items; Gtk::Bin *_scroller; Gtk::Table *_insides; + Gtk::Box *_zee0; + Gtk::Box *_zee1; + Gtk::Box *_zee2; Gtk::AnchorType _anchor; Gtk::BuiltinIconSize _baseSize; ViewType _view; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 67aca690a..b0a35614d 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -134,6 +134,14 @@ void Panel::setLabel(Glib::ustring const &label) tabTitle.set_label(this->label); } +void Panel::setOrientation( Gtk::AnchorType how ) +{ + if ( _anchor != how ) + { + _anchor = how; + } +} + void Panel::_regItem( Gtk::MenuItem* item, int group, int id ) { menu.append( *item ); diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 07225b8ce..9c53be8bb 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -38,6 +38,8 @@ public: void setLabel(Glib::ustring const &label); Glib::ustring const &getLabel() const; + virtual void setOrientation( Gtk::AnchorType how ); + const gchar *_prefs_path; void restorePanelPrefs(); @@ -47,6 +49,7 @@ protected: virtual void _handleAction( int setId, int itemId ); + Gtk::AnchorType _anchor; private: void init(); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index acd631c6a..2bf9f6b2e 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -184,7 +184,7 @@ sp_desktop_widget_init (SPDesktopWidget *dtw) using Inkscape::UI::Dialogs::SwatchesPanel; SwatchesPanel* swatches = new SwatchesPanel(); - swatches->Temp(); + swatches->setOrientation( Gtk::ANCHOR_SOUTH ); dtw->panels = GTK_WIDGET(swatches->gobj()); gtk_box_pack_end( GTK_BOX( dtw->vbox ), dtw->panels, FALSE, TRUE, 0 ); } -- 2.30.2