summaryrefslogtreecommitdiffstats
path: root/src/ui/previewholder.cpp
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-09-27 02:58:05 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-09-27 02:58:05 +0000
commitc58c848684c4d1d58e59ca0d8112530bc451175c (patch)
treea8e9eceb6396958f8d2806ad9cb1ad5d1c3d6950 /src/ui/previewholder.cpp
parentFix for 169001 : Long layer names mess with the UI (diff)
downloadinkscape-c58c848684c4d1d58e59ca0d8112530bc451175c.tar.gz
inkscape-c58c848684c4d1d58e59ca0d8112530bc451175c.zip
Fix for 171177 : Border in palette swatches
(bzr r11706)
Diffstat (limited to 'src/ui/previewholder.cpp')
-rw-r--r--src/ui/previewholder.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp
index e1c2c718a..0dac18665 100644
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
@@ -12,6 +12,7 @@
#include "previewholder.h"
+#include "preferences.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
@@ -38,7 +39,8 @@ PreviewHolder::PreviewHolder() :
_baseSize(PREVIEW_SIZE_SMALL),
_ratio(100),
_view(VIEW_TYPE_LIST),
- _wrap(false)
+ _wrap(false),
+ _border(BORDER_NONE)
{
_scroller = manage(new Gtk::ScrolledWindow());
_insides = manage(new Gtk::Table( 1, 2 ));
@@ -77,13 +79,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, _ratio));
- Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio));
+ Gtk::Widget* label = manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
+ Gtk::Widget* thing = manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border));
_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, _ratio));
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize, _ratio, _border));
int width = 1;
int height = 1;
@@ -129,12 +131,13 @@ void PreviewHolder::thawUpdates()
rebuildUI();
}
-void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio )
+void PreviewHolder::setStyle( ::PreviewSize size, ViewType view, guint ratio, ::BorderStyle border )
{
- if ( size != _baseSize || view != _view || ratio != _ratio ) {
+ if ( size != _baseSize || view != _view || ratio != _ratio || border != _border ) {
_baseSize = size;
_view = view;
_ratio = ratio;
+ _border = border;
// Kludge to restore scrollbars
if ( !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) {
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER );
@@ -304,12 +307,15 @@ void PreviewHolder::rebuildUI()
if ( _view == VIEW_TYPE_LIST ) {
_insides = manage(new Gtk::Table( 1, 2 ));
_insides->set_col_spacings( 8 );
+ if (_border == BORDER_WIDE) {
+ _insides->set_row_spacings( 1 );
+ }
for ( unsigned int i = 0; i < items.size(); i++ ) {
- Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio));
+ Gtk::Widget* label = manage(items[i]->getPreview(PREVIEW_STYLE_BLURB, _view, _baseSize, _ratio, _border));
//label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
- Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio));
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border));
_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 );
@@ -322,11 +328,18 @@ 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, _ratio));
+
+ // If this is the last row, flag so the previews can draw a bottom
+ ::BorderStyle border = ((row == height -1) && (_border == BORDER_SOLID)) ? BORDER_SOLID_LAST_ROW : _border;
+ Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, border));
if ( !_insides ) {
calcGridSize( thing, items.size(), width, height );
_insides = manage(new Gtk::Table( height, width ));
+ if (_border == BORDER_WIDE) {
+ _insides->set_col_spacings( 1 );
+ _insides->set_row_spacings( 1 );
+ }
}
_insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );