From 55f1ee16880c7a22402fa9ad7df84c70ee4c2fc5 Mon Sep 17 00:00:00 2001 From: joncruz Date: Tue, 28 Mar 2006 17:14:27 +0000 Subject: [PATCH] Changed objects to only get linked to "linkable" colors. --- ChangeLog | 8 ++++++++ src/dialogs/eek-preview.cpp | 35 ++++++++++++++++++++++++------- src/dialogs/eek-preview.h | 3 ++- src/dialogs/swatches.cpp | 41 ++++++++++++++++++++++--------------- src/dialogs/swatches.h | 8 ++++++++ src/interface.cpp | 12 ++++++----- 6 files changed, 78 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f85a016e..b17a68f4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-03-28 Jon A. Cruz + + * src/interface.cpp, src/dialogs/eek-color-def.h, + src/dialogs/eek-preview.h, src/dialogs/eek-preview.cpp, + src/dialogs/swatches.h, src/dialogs/swatches.cpp: + + Changed objects to only get liked to "linkable" colors. + 2006-03-28 Jon A. Cruz * src/interface.cpp, src/dialogs/swatches.cpp: diff --git a/src/dialogs/eek-preview.cpp b/src/dialogs/eek-preview.cpp index d2ac8db5d..0108d4777 100644 --- a/src/dialogs/eek-preview.cpp +++ b/src/dialogs/eek-preview.cpp @@ -210,11 +210,12 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) ); } - if ( area.height < possible.height ) { - area.y = possible.y + (possible.height - area.height); - } - if ( preview->_linked & PREVIEW_LINK_OUT ) { + GdkRectangle otherArea = {area.x, area.y, area.width, area.height}; + if ( otherArea.height < possible.height ) { + otherArea.y = possible.y + (possible.height - otherArea.height); + } + gtk_paint_arrow( style, widget->window, (GtkStateType)widget->state, @@ -224,8 +225,28 @@ gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event ) NULL, /* detail */ GTK_ARROW_UP, FALSE, - area.x, area.y, - area.width, area.height + otherArea.x, otherArea.y, + otherArea.width, otherArea.height + ); + } + + if ( preview->_linked & PREVIEW_LINK_OTHER ) { + GdkRectangle otherArea = {insetX, area.y, area.width, area.height}; + if ( otherArea.height < possible.height ) { + otherArea.y = possible.y + (possible.height - otherArea.height) / 2; + } + + gtk_paint_arrow( style, + widget->window, + (GtkStateType)widget->state, + GTK_SHADOW_ETCHED_OUT, + NULL, /* clip area. &area, */ + widget, /* may be NULL */ + NULL, /* detail */ + GTK_ARROW_LEFT, + FALSE, + otherArea.x, otherArea.y, + otherArea.width, otherArea.height ); } } @@ -485,7 +506,7 @@ static void eek_preview_class_init( EekPreviewClass *klass ) void eek_preview_set_linked( EekPreview* splat, LinkType link ) { - link = (LinkType)(link & PREVIEW_LINK_BOTH); + link = (LinkType)(link & PREVIEW_LINK_ALL); if ( link != (LinkType)splat->_linked ) { splat->_linked = link; diff --git a/src/dialogs/eek-preview.h b/src/dialogs/eek-preview.h index 736d71058..114be8742 100644 --- a/src/dialogs/eek-preview.h +++ b/src/dialogs/eek-preview.h @@ -71,7 +71,8 @@ typedef enum { PREVIEW_LINK_NONE = 0, PREVIEW_LINK_IN = 1, PREVIEW_LINK_OUT = 2, - PREVIEW_LINK_BOTH = 3 + PREVIEW_LINK_OTHER = 4, + PREVIEW_LINK_ALL = 7 } LinkType; typedef struct _EekPreview EekPreview; diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index 1d429603d..8d81c3b99 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -42,6 +42,7 @@ SwatchesPanel* SwatchesPanel::instance = 0; ColorItem::ColorItem( unsigned int r, unsigned int g, unsigned int b, Glib::ustring& name ) : def( r, g, b, name ), + _isLive(false), _linkIsTone(false), _linkPercent(0), _linkGray(0), @@ -102,12 +103,12 @@ static const GtkTargetEntry sourceColorEntries[] = { {"text/plain", 0, TEXT_DATA}, }; -static void dragGetColorData( GtkWidget *widget, - GdkDragContext *drag_context, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) +void ColorItem::_dragGetColorData( GtkWidget *widget, + GdkDragContext *drag_context, + GtkSelectionData *data, + guint info, + guint time, + gpointer user_data) { static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE); static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE); @@ -148,19 +149,19 @@ static void dragGetColorData( GtkWidget *widget, // } else { // g_message("Unable to find the color"); // } - int itemCount = 4 + 1 + 1 + paletteName.length(); + int itemCount = 4 + 2 + 1 + paletteName.length(); - guint16* tmp = new guint16[itemCount] -; + guint16* tmp = new guint16[itemCount]; tmp[0] = (item->def.getR() << 8) | item->def.getR(); tmp[1] = (item->def.getG() << 8) | item->def.getG(); tmp[2] = (item->def.getB() << 8) | item->def.getB(); tmp[3] = 0xffff; + tmp[4] = (item->_isLive || !item->_listeners.empty() || (item->_linkSrc != 0) ) ? 1 : 0; - tmp[4] = index; - tmp[5] = paletteName.length(); + tmp[5] = index; + tmp[6] = paletteName.length(); for ( unsigned int i = 0; i < paletteName.length(); i++ ) { - tmp[6 + i] = paletteName[i]; + tmp[7 + i] = paletteName[i]; } gtk_selection_data_set( data, typeXColor, @@ -351,7 +352,9 @@ void ColorItem::_colorDefChanged(void* data) (item->def.getG() << 8) | item->def.getG(), (item->def.getB() << 8) | item->def.getB() ); - eek_preview_set_linked( preview, (LinkType)((item->_linkSrc ? PREVIEW_LINK_IN:0) | (item->_listeners.empty() ? 0:PREVIEW_LINK_OUT)) ); + eek_preview_set_linked( preview, (LinkType)((item->_linkSrc ? PREVIEW_LINK_IN:0) + | (item->_listeners.empty() ? 0:PREVIEW_LINK_OUT) + | (item->_isLive ? PREVIEW_LINK_OTHER:0)) ); widget->queue_draw(); } @@ -439,7 +442,9 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built eek_preview_set_color( preview, (def.getR() << 8) | def.getR(), (def.getG() << 8) | def.getG(), (def.getB() << 8) | def.getB()); eek_preview_set_details( preview, (::PreviewStyle)style, (::ViewType)view, (::GtkIconSize)size ); - eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0) | (_listeners.empty() ? 0:PREVIEW_LINK_OUT)) ); + eek_preview_set_linked( preview, (LinkType)((_linkSrc ? PREVIEW_LINK_IN:0) + | (_listeners.empty() ? 0:PREVIEW_LINK_OUT) + | (_isLive ? PREVIEW_LINK_OTHER:0)) ); def.addCallback( _colorDefChanged, this ); @@ -485,7 +490,7 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built g_signal_connect( G_OBJECT(newBlot->gobj()), "drag-data-get", - G_CALLBACK(dragGetColorData), + G_CALLBACK(ColorItem::_dragGetColorData), this); g_signal_connect( G_OBJECT(newBlot->gobj()), @@ -645,10 +650,14 @@ void ColorItem::_wireMagicColors( void* p ) if ( subby.find('E') != std::string::npos ) { - //g_message(" HOT!"); (*it)->def.setEditable( true ); } + if ( subby.find('L') != std::string::npos ) + { + (*it)->_isLive = true; + } + std::string part; // Tint. index + 1 more val. if ( getBlock( part, 'T', subby ) ) { diff --git a/src/dialogs/swatches.h b/src/dialogs/swatches.h index b6f28f182..965c32240 100644 --- a/src/dialogs/swatches.h +++ b/src/dialogs/swatches.h @@ -57,6 +57,13 @@ private: guint event_time, gpointer user_data); + static void _dragGetColorData( GtkWidget *widget, + GdkDragContext *drag_context, + GtkSelectionData *data, + guint info, + guint time, + gpointer user_data); + static void _wireMagicColors( void* p ); static void _colorDefChanged(void* data); @@ -66,6 +73,7 @@ private: Gtk::Tooltips tips; std::vector _previews; + bool _isLive; bool _linkIsTone; int _linkPercent; int _linkGray; diff --git a/src/interface.cpp b/src/interface.cpp index 5de76aff1..c913d1122 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1005,16 +1005,18 @@ sp_ui_drag_data_received(GtkWidget *widget, sp_desktop_apply_css_recursive( item, css, true ); item->updateRepr(); - if ( data->length > 12 ) { + if ( data->length > 14 ) { + int flags = dataVals[4]; + // piggie-backed palette entry info - int index = dataVals[4]; + int index = dataVals[5]; Glib::ustring palName; - for ( int i = 0; i < dataVals[5]; i++ ) { - palName += (gunichar)dataVals[6+i]; + for ( int i = 0; i < dataVals[6]; i++ ) { + palName += (gunichar)dataVals[7+i]; } // Now hook in a magic tag of some sort. - if ( !palName.empty() ) { + if ( !palName.empty() && (flags & 1) ) { gchar* str = g_strdup_printf("%d|", index); palName.insert( 0, str ); g_free(str); -- 2.30.2