Code

Changed color dragging to have a color preview.
authorjoncruz <joncruz@users.sourceforge.net>
Fri, 10 Mar 2006 09:29:33 +0000 (09:29 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Fri, 10 Mar 2006 09:29:33 +0000 (09:29 +0000)
ChangeLog
src/dialogs/swatches.cpp

index 95ed6e187c3c2e23d5d78f1487002199bd1083ac..d34c6cccbec9b8a11bceaa67b5c589e5be4c1cb0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-03-10  Jon A. Cruz  <jon@joncruz.org>
+       * src/dialogs/swatches.cpp:
+
+         Changed color dragging to have a color preview.
+       
 2006-03-09  Jon A. Cruz  <jon@joncruz.org>
        * src/interface.cpp:
 
index 3063e22801072f21b48c4b646104bda4322653e8..5ed09b3e01808b8d73b5f2585a6d09a5c134b3e5 100644 (file)
@@ -18,6 +18,7 @@
 #include <gtk/gtkdnd.h>
 
 #include <glibmm/i18n.h>
+#include <gdkmm/pixbuf.h>
 #include "inkscape.h"
 #include "document.h"
 #include "desktop-handles.h"
@@ -114,6 +115,21 @@ static void dragGetColorData( GtkWidget *widget,
     }
 }
 
+static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
+{
+    ColorItem* item = reinterpret_cast<ColorItem*>(data);
+    if ( item )
+    {
+        Glib::RefPtr<Gdk::Pixbuf> thumb = Gdk::Pixbuf::create( Gdk::COLORSPACE_RGB, false, 8, 32, 24 );
+        guint32 fillWith = (0xff000000 & (item->_r << 24))
+                         | (0x00ff0000 & (item->_g << 16))
+                         | (0x0000ff00 & (item->_b <<  8));
+        thumb->fill( fillWith );
+        gtk_drag_set_icon_pixbuf( dc, thumb->gobj(), 0, 0 );
+    }
+
+}
+
 //"drag-drop"
 gboolean dragDropColorData( GtkWidget *widget,
                             GdkDragContext *drag_context,
@@ -206,6 +222,11 @@ Gtk::Widget* ColorItem::getPreview(PreviewStyle style, ViewType view, Gtk::Built
                           G_CALLBACK(dragGetColorData),
                           this);
 
+        g_signal_connect( G_OBJECT(newBlot->gobj()),
+                          "drag-begin",
+                          G_CALLBACK(dragBegin),
+                          this );
+
         g_signal_connect( G_OBJECT(newBlot->gobj()),
                           "drag-drop",
                           G_CALLBACK(dragDropColorData),