diff options
| author | Jon A. Cruz <jon@joncruz.org> | 2009-03-05 08:11:54 +0000 |
|---|---|---|
| committer | joncruz <joncruz@users.sourceforge.net> | 2009-03-05 08:11:54 +0000 |
| commit | 31c5e23a0b6c91c2765b9e111c29c6debf86004a (patch) | |
| tree | 912bfd7c32a1556fca7f6f73cb1bff747b96a994 /src/ui | |
| parent | Control when shift affects moving of handles. Applies patch from bug #245698. (diff) | |
| download | inkscape-31c5e23a0b6c91c2765b9e111c29c6debf86004a.tar.gz inkscape-31c5e23a0b6c91c2765b9e111c29c6debf86004a.zip | |
Adding clear-color swatch to complement no-color.
(bzr r7422)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/dialog/swatches.cpp | 38 | ||||
| -rw-r--r-- | src/ui/dialog/swatches.h | 3 |
2 files changed, 30 insertions, 11 deletions
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 1a5ef8521..5cd357673 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -41,9 +41,8 @@ namespace Inkscape { namespace UI { namespace Dialogs { -// create a None color swatch -ColorItem::ColorItem() : - def(), +ColorItem::ColorItem(eek::ColorDef::ColorType type) : + def(type), _isLive(false), _linkIsTone(false), _linkPercent(0), @@ -106,6 +105,7 @@ typedef enum { APP_X_INKY_COLOR = 0, APP_X_COLOR, APP_X_NOCOLOR, + APP_X_XCOLOR, TEXT_DATA } colorFlavorType; @@ -130,6 +130,12 @@ static const GtkTargetEntry sourceNoColorEntries[] = { {"text/plain", 0, TEXT_DATA}, }; +static const GtkTargetEntry sourceClearColorEntries[] = { + {"application/x-inkscape-xcolor", 0, APP_X_XCOLOR}, + {"application/x-color", 0, APP_X_COLOR}, + {"text/plain", 0, TEXT_DATA}, +}; + void ColorItem::_dragGetColorData( GtkWidget */*widget*/, GdkDragContext */*drag_context*/, GtkSelectionData *data, @@ -196,7 +202,7 @@ void ColorItem::_dragGetColorData( GtkWidget */*widget*/, reinterpret_cast<const guchar*>(tmp), itemCount * 2); delete[] tmp; - } else if ( info == APP_X_NOCOLOR ) { + } else if ( (info == APP_X_NOCOLOR) || (info == APP_X_XCOLOR) ) { Glib::ustring paletteName; // Find where this thing came from @@ -445,6 +451,7 @@ void ColorItem::_dropDataIn( GtkWidget */*widget*/, break; } case APP_X_NOCOLOR: + case APP_X_XCOLOR: { // g_message("APP_X_NOCOLOR dropping through to x-color"); } @@ -695,9 +702,10 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, ::PreviewS gtk_drag_source_set( GTK_WIDGET(newBlot->gobj()), GDK_BUTTON1_MASK, - (def.getType() != eek::ColorDef::RGB) ? sourceNoColorEntries : - sourceColorEntries, - (def.getType() != eek::ColorDef::RGB) ? G_N_ELEMENTS(sourceNoColorEntries) : + (def.getType() == eek::ColorDef::CLEAR) ? sourceClearColorEntries : + (def.getType() == eek::ColorDef::NONE) ? sourceNoColorEntries : sourceColorEntries, + (def.getType() == eek::ColorDef::CLEAR) ? G_N_ELEMENTS(sourceClearColorEntries) : + (def.getType() == eek::ColorDef::NONE) ? G_N_ELEMENTS(sourceNoColorEntries) : G_N_ELEMENTS(sourceColorEntries), GdkDragAction(GDK_ACTION_MOVE | GDK_ACTION_COPY) ); @@ -1154,7 +1162,8 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : { Gtk::RadioMenuItem* hotItem = 0; _holder = new PreviewHolder(); - _remove = new ColorItem(); + _clear = new ColorItem( eek::ColorDef::CLEAR ); + _remove = new ColorItem( eek::ColorDef::NONE ); loadEmUp(); if ( !possible.empty() ) { JustForNow* first = 0; @@ -1180,6 +1189,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : _holder->setColumnPref( first->_prefWidth ); } _holder->freezeUpdates(); + // TODO restore once 'clear' works _holder->addPreview(_clear); _holder->addPreview(_remove); for ( std::vector<ColorItem*>::iterator it = first->_colors.begin(); it != first->_colors.end(); it++ ) { _holder->addPreview(*it); @@ -1214,8 +1224,15 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : SwatchesPanel::~SwatchesPanel() { - if (_remove) delete _remove; - if (_holder) delete _holder; + if ( _clear ) { + delete _clear; + } + if ( _remove ) { + delete _remove; + } + if ( _holder ) { + delete _holder; + } } void SwatchesPanel::setOrientation( Gtk::AnchorType how ) @@ -1247,6 +1264,7 @@ void SwatchesPanel::_handleAction( int setId, int itemId ) _holder->setColumnPref( curr->_prefWidth ); } _holder->freezeUpdates(); + _holder->addPreview(_clear); _holder->addPreview(_remove); for ( std::vector<ColorItem*>::iterator it = curr->_colors.begin(); it != curr->_colors.end(); it++ ) { _holder->addPreview(*it); diff --git a/src/ui/dialog/swatches.h b/src/ui/dialog/swatches.h index 17081733d..560719ed2 100644 --- a/src/ui/dialog/swatches.h +++ b/src/ui/dialog/swatches.h @@ -31,7 +31,7 @@ class ColorItem : public Inkscape::UI::Previewable { friend void _loadPaletteFile( gchar const *filename ); public: - ColorItem(); + ColorItem( eek::ColorDef::ColorType type ); ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ); virtual ~ColorItem(); @@ -101,6 +101,7 @@ private: static SwatchesPanel* instance; PreviewHolder* _holder; + ColorItem* _clear; ColorItem* _remove; }; |
