summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e898b1a)
raw | patch | inline | side by side (parent: e898b1a)
author | joncruz <joncruz@users.sourceforge.net> | |
Tue, 28 Feb 2006 07:47:09 +0000 (07:47 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Tue, 28 Feb 2006 07:47:09 +0000 (07:47 +0000) |
diff --git a/ChangeLog b/ChangeLog
index fd15483e77698e702282531ea93a6a2bc8724904..13dd31e7b5fbab7bd0d2cbc1bd647a7fbbed99a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-02-27 Jon A. Cruz <jon@joncruz.org>
+ * src/dialogs/swatches.cpp, src/ui/previewfillable.h,
+ src/ui/previewholder.h, src/ui/previewholder.cpp:
+
+ Finished cleanup of embedded swatches when switching palettes.
+
2006-02-26 Jon A. Cruz <jon@joncruz.org>
* src/dialogs/swatches.cpp, src/ui/previewholder.h,
src/ui/previewholder.cpp:
index e6d1ac2b57107159b8e6eff731f01a712260f46b..7da1b5694fa0bd1927674e3e68a1f3faf4ecc2d7 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
if ( first->_prefWidth > 0 ) {
_holder->setColumnPref( first->_prefWidth );
}
+ _holder->freezeUpdates();
for ( std::vector<ColorItem*>::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) {
_holder->addPreview(*it);
}
+ _holder->thawUpdates();
Gtk::RadioMenuItem::Group groupOne;
int i = 0;
if ( curr->_prefWidth > 0 ) {
_holder->setColumnPref( curr->_prefWidth );
}
+ _holder->freezeUpdates();
for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) {
_holder->addPreview(*it);
}
+ _holder->thawUpdates();
}
}
break;
index b62ab6b99fd7fbca9d70e4e2ab9e84fcf158beba..f4a67887ee6632c7ff243a532408696ca31883b1 100644 (file)
--- a/src/ui/previewfillable.h
+++ b/src/ui/previewfillable.h
virtual ~PreviewFillable() {}
virtual void clear() = 0;
virtual void addPreview( Previewable* preview ) = 0;
+ virtual void freezeUpdates() = 0;
+ virtual void thawUpdates() = 0;
virtual void setStyle(Gtk::BuiltinIconSize size, ViewType type) = 0;
virtual void setOrientation( Gtk::AnchorType how ) = 0;
virtual Gtk::BuiltinIconSize getPreviewSize() const = 0;
index cc2339c9cf3f7dba860d7867a9125d413a34b7bc..c2bc133270f5e5e20664f4ac096a096a5a34eb62 100644 (file)
--- a/src/ui/previewholder.cpp
+++ b/src/ui/previewholder.cpp
VBox(),
PreviewFillable(),
_scroller(0),
+ _insides(0),
+ _prefCols(0),
+ _updatesFrozen(false),
_anchor(Gtk::ANCHOR_CENTER),
_baseSize(Gtk::ICON_SIZE_MENU),
_view(VIEW_TYPE_LIST)
void PreviewHolder::addPreview( Previewable* preview )
{
items.push_back(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));
-
- _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));
+ if ( !_updatesFrozen )
+ {
+ int i = items.size() - 1;
- int width = 1;
- int height = 1;
- calcGridSize( thing, items.size(), width, height );
- int col = i % width;
- int row = i / width;
+ 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));
- if ( i < 10 ) {
- g_message( "i:%d width:%d height:%d prop cols:%d", i, width, height, (int)_insides->property_n_columns() );
+ _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));
+
+ int width = 1;
+ int height = 1;
+ calcGridSize( thing, items.size(), width, height );
+ int col = i % width;
+ int row = i / width;
+
+ if ( _insides && width > (int)_insides->property_n_columns() ) {
+ std::vector<Gtk::Widget*>kids = _insides->get_children();
+ int oldWidth = (int)_insides->property_n_columns();
+ int childCount = (int)kids.size();
+// g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
+ _insides->resize( height, width );
+
+ for ( int j = oldWidth; j < childCount; j++ ) {
+ Gtk::Widget* target = kids[childCount - (j + 1)];
+ int col2 = j % width;
+ int row2 = j / width;
+ Glib::RefPtr<Gtk::Widget> handle(target);
+ _insides->remove( *target );
+ _insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
+ }
+ } else if ( col == 0 ) {
+ // we just started a new row
+ _insides->resize( row + 1, width );
+ }
+ _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
}
- if ( col == 0 ) {
- // we just started a new row
- _insides->resize( row + 1, width );
- } else if ( _insides && width > (int)_insides->property_n_columns() ) {
- _insides->resize( height, width );
- }
- _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
+ _scroller->show_all_children();
+ _scroller->queue_draw();
}
+}
- _scroller->show_all_children();
- _scroller->queue_draw();
+void PreviewHolder::freezeUpdates()
+{
+ _updatesFrozen = true;
+}
+
+void PreviewHolder::thawUpdates()
+{
+ _updatesFrozen = false;
+ rebuildUI();
}
void PreviewHolder::setStyle(Gtk::BuiltinIconSize size, ViewType view)
diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h
index d165e5bf93b3f3dd4531bfc845902f6a2ecfb176..53ffd5f054dc7ea3899e6480a57b2e5ac330b004 100644 (file)
--- a/src/ui/previewholder.h
+++ b/src/ui/previewholder.h
virtual void clear();
virtual void addPreview( Previewable* preview );
+ virtual void freezeUpdates();
+ virtual void thawUpdates();
virtual void setStyle(Gtk::BuiltinIconSize size, ViewType view);
virtual void setOrientation( Gtk::AnchorType how );
virtual int getColumnPref() const { return _prefCols; }
Gtk::Bin *_scroller;
Gtk::Table *_insides;
int _prefCols;
+ bool _updatesFrozen;
Gtk::AnchorType _anchor;
Gtk::BuiltinIconSize _baseSize;
ViewType _view;