diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2008-02-21 06:54:33 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2008-02-21 06:54:33 +0000 |
| commit | ef72f4b81da42a06b872afe03ef33174a494acab (patch) | |
| tree | b1e71bfb493ee6ba2606b939576b6f120d1a8afc /src/ui | |
| parent | Warning cleanup (diff) | |
| download | inkscape-ef72f4b81da42a06b872afe03ef33174a494acab.tar.gz inkscape-ef72f4b81da42a06b872afe03ef33174a494acab.zip | |
Initial implementation of non-square swatches
(bzr r4800)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/previewable.h | 2 | ||||
| -rw-r--r-- | src/ui/previewfillable.h | 3 | ||||
| -rw-r--r-- | src/ui/previewholder.cpp | 18 | ||||
| -rw-r--r-- | src/ui/previewholder.h | 4 | ||||
| -rw-r--r-- | src/ui/widget/panel.cpp | 68 |
5 files changed, 67 insertions, 28 deletions
diff --git a/src/ui/previewable.h b/src/ui/previewable.h index f0c642082..c517e4f28 100644 --- a/src/ui/previewable.h +++ b/src/ui/previewable.h @@ -40,7 +40,7 @@ class Previewable public: // TODO need to add some nice parameters virtual ~Previewable() {} - virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size ) = 0; + virtual Gtk::Widget* getPreview( PreviewStyle style, ViewType view, ::PreviewSize size, guint ratio ) = 0; }; diff --git a/src/ui/previewfillable.h b/src/ui/previewfillable.h index d12771c90..6f02b60a8 100644 --- a/src/ui/previewfillable.h +++ b/src/ui/previewfillable.h @@ -27,10 +27,11 @@ public: virtual void addPreview( Previewable* preview ) = 0; virtual void freezeUpdates() = 0; virtual void thawUpdates() = 0; - virtual void setStyle( ::PreviewSize size, ViewType type) = 0; + virtual void setStyle( ::PreviewSize size, ViewType type, guint ratio) = 0; virtual void setOrientation( Gtk::AnchorType how ) = 0; virtual ::PreviewSize getPreviewSize() const = 0; virtual ViewType getPreviewType() const = 0; + virtual guint getPreviewRatio() const = 0; virtual void setWrap( bool b ) = 0; virtual bool getWrap() const = 0; }; diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 764890395..da991e1df 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -36,6 +36,7 @@ PreviewHolder::PreviewHolder() : _updatesFrozen(false), _anchor(Gtk::ANCHOR_CENTER), _baseSize(PREVIEW_SIZE_SMALL), + _ratio(100), _view(VIEW_TYPE_LIST), _wrap(false) { @@ -72,13 +73,13 @@ void PreviewHolder::addPreview( Previewable* preview ) int i = items.size() - 1; if ( _view == VIEW_TYPE_LIST ) { - Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize)); - Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize)); + Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio)); + Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio)); _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); } else { - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize)); + Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio)); int width = 1; int height = 1; @@ -124,11 +125,12 @@ void PreviewHolder::thawUpdates() rebuildUI(); } -void PreviewHolder::setStyle( ::PreviewSize size, ViewType view ) +void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio ) { - if ( size != _baseSize || view != _view ) { + if ( size != _baseSize || view != _view || ratio != _ratio ) { _baseSize = size; _view = view; + _ratio = ratio; rebuildUI(); } } @@ -259,10 +261,10 @@ void PreviewHolder::rebuildUI() _insides->set_col_spacings( 8 ); for ( unsigned int i = 0; i < items.size(); i++ ) { - Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize)); + Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio)); //label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize)); + Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio)); _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); @@ -275,7 +277,7 @@ void PreviewHolder::rebuildUI() int height = 1; for ( unsigned int i = 0; i < items.size(); i++ ) { - Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize)); + Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio)); if ( !_insides ) { calcGridSize( thing, items.size(), width, height ); diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index e3515c987..812d4b27d 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -32,12 +32,13 @@ public: virtual void addPreview( Previewable* preview ); virtual void freezeUpdates(); virtual void thawUpdates(); - virtual void setStyle( ::PreviewSize size, ViewType view ); + virtual void setStyle( ::PreviewSize size, ViewType view, guint ratio ); virtual void setOrientation( Gtk::AnchorType how ); virtual int getColumnPref() const { return _prefCols; } virtual void setColumnPref( int cols ); virtual ::PreviewSize getPreviewSize() const { return _baseSize; } virtual ViewType getPreviewType() const { return _view; } + virtual guint getPreviewRatio() const { return _ratio; } virtual void setWrap( bool b ); virtual bool getWrap() const { return _wrap; } @@ -57,6 +58,7 @@ private: bool _updatesFrozen; Gtk::AnchorType _anchor; ::PreviewSize _baseSize; + guint _ratio; ViewType _view; bool _wrap; }; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index 51b289ddf..c01cb7768 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -35,8 +35,9 @@ namespace Widget { static const int PANEL_SETTING_SIZE = 0; static const int PANEL_SETTING_MODE = 1; -static const int PANEL_SETTING_WRAP = 2; -static const int PANEL_SETTING_NEXTFREE = 3; +static const int PANEL_SETTING_SHAPE = 2; +static const int PANEL_SETTING_WRAP = 3; +static const int PANEL_SETTING_NEXTFREE = 4; void Panel::prep() { @@ -106,6 +107,11 @@ void Panel::_init() panel_wrap = prefs_get_int_attribute_limited( _prefs_path, "panel_wrap", 0, 0, 1 ); } + guint panel_ratio = 100; + if (_prefs_path) { + panel_ratio = prefs_get_int_attribute_limited( _prefs_path, "panel_ratio", 100, 0, 500 ); + } + _menu = new Gtk::Menu(); { const char *things[] = { @@ -162,6 +168,7 @@ void Panel::_init() { Glib::ustring type_label(_("Shape")); + Glib::ustring ellipsis(_("...")); Glib::ustring shape_1_label(_("Tall")); Glib::ustring shape_2_label(_("Square")); Glib::ustring shape_3_label(_("Wide")); @@ -173,15 +180,24 @@ void Panel::_init() Gtk::RadioMenuItem::Group shapeGroup; - Gtk::RadioMenuItem *shape_1 = manage(new Gtk::RadioMenuItem(shapeGroup, shape_1_label)); - Gtk::RadioMenuItem *shape_2 = manage(new Gtk::RadioMenuItem(shapeGroup, shape_2_label)); - Gtk::RadioMenuItem *shape_3 = manage(new Gtk::RadioMenuItem(shapeGroup, shape_3_label)); - type_menu->append(*shape_1); - type_menu->append(*shape_2); - type_menu->append(*shape_3); - - shape_2->set_active(true); + Glib::ustring* labels[] = {&ellipsis, &shape_1_label, &ellipsis, &shape_2_label, &ellipsis, &shape_3_label}; + guint values[] = {0, 25, 50, 100, 200, 400}; + guint hot_index = 3; + for ( guint i = 0; i < G_N_ELEMENTS(labels); ++i ) { + // Assume all values are in increasing order + if ( values[i] <= panel_ratio ) { + hot_index = i; + } + } + for ( guint i = 0; i < G_N_ELEMENTS(labels); ++i ) { + Gtk::RadioMenuItem *single = manage(new Gtk::RadioMenuItem(shapeGroup, *(labels[i]))); + type_menu->append(*single); + if ( i <= hot_index ) { + single->set_active(true); + } + single->signal_activate().connect(sigc::bind<int, int>(sigc::mem_fun(*this, &Panel::_bounceCall), PANEL_SETTING_SHAPE, values[i])); + } } sep = manage(new Gtk::SeparatorMenuItem()); @@ -228,6 +244,7 @@ void Panel::_init() _bounceCall(PANEL_SETTING_SIZE, panel_size); _bounceCall(PANEL_SETTING_MODE, panel_mode); + _bounceCall(PANEL_SETTING_SHAPE, panel_ratio); _bounceCall(PANEL_SETTING_WRAP, panel_wrap); } @@ -305,8 +322,13 @@ void Panel::restorePanelPrefs() if (_prefs_path) { panel_wrap = prefs_get_int_attribute_limited(_prefs_path, "panel_wrap", 0, 0, 1 ); } + guint panel_ratio = 100; + if (_prefs_path) { + panel_ratio = prefs_get_int_attribute_limited(_prefs_path, "panel_ratio", 000, 0, 500 ); + } _bounceCall(PANEL_SETTING_SIZE, panel_size); _bounceCall(PANEL_SETTING_MODE, panel_mode); + _bounceCall(PANEL_SETTING_SHAPE, panel_ratio); _bounceCall(PANEL_SETTING_WRAP, panel_wrap); } @@ -332,30 +354,31 @@ void Panel::_bounceCall(int i, int j) } if (_fillable) { ViewType curr_type = _fillable->getPreviewType(); + guint curr_ratio = _fillable->getPreviewRatio(); switch (j) { case 0: { - _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type); + _fillable->setStyle(::PREVIEW_SIZE_TINY, curr_type, curr_ratio); } break; case 1: { - _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type); + _fillable->setStyle(::PREVIEW_SIZE_SMALL, curr_type, curr_ratio); } break; case 2: { - _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type); + _fillable->setStyle(::PREVIEW_SIZE_MEDIUM, curr_type, curr_ratio); } break; case 3: { - _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type); + _fillable->setStyle(::PREVIEW_SIZE_BIG, curr_type, curr_ratio); } break; case 4: { - _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type); + _fillable->setStyle(::PREVIEW_SIZE_HUGE, curr_type, curr_ratio); } break; default: @@ -369,15 +392,16 @@ void Panel::_bounceCall(int i, int j) } if (_fillable) { ::PreviewSize curr_size = _fillable->getPreviewSize(); + guint curr_ratio = _fillable->getPreviewRatio(); switch (j) { case 0: { - _fillable->setStyle(curr_size, VIEW_TYPE_LIST); + _fillable->setStyle(curr_size, VIEW_TYPE_LIST, curr_ratio); } break; case 1: { - _fillable->setStyle(curr_size, VIEW_TYPE_GRID); + _fillable->setStyle(curr_size, VIEW_TYPE_GRID, curr_ratio); } break; default: @@ -385,6 +409,16 @@ void Panel::_bounceCall(int i, int j) } } break; + case PANEL_SETTING_SHAPE: + if (_prefs_path) { + prefs_set_int_attribute (_prefs_path, "panel_ratio", j); + } + if ( _fillable ) { + ViewType curr_type = _fillable->getPreviewType(); + ::PreviewSize curr_size = _fillable->getPreviewSize(); + _fillable->setStyle(curr_size, curr_type, j); + } + break; case PANEL_SETTING_WRAP: if (_prefs_path) { prefs_set_int_attribute (_prefs_path, "panel_wrap", j ? 1 : 0); |
