From: buliabyak Date: Wed, 24 Oct 2007 19:39:25 +0000 (+0000) Subject: change cursor for color gestures X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d72622ce1f87f61aff54d734c9c18f1691153536;p=inkscape.git change cursor for color gestures --- diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 8710162fd..613fa977d 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -43,6 +43,10 @@ #include "verbs.h" #include "color.h" #include +#include "pixmaps/cursor-adj-h.xpm" +#include "pixmaps/cursor-adj-s.xpm" +#include "pixmaps/cursor-adj-l.xpm" +#include "sp-cursor.h" static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -1147,6 +1151,8 @@ RotateableSwatch::RotateableSwatch(guint mode) { fillstroke = mode; startcolor_set = false; undokey = "ssrot1"; + cr = NULL; + cr_set = false; } RotateableSwatch::~RotateableSwatch() { @@ -1212,6 +1218,30 @@ RotateableSwatch::do_motion(double by, guint modifier) { if (parent->_mode[fillstroke] != SS_COLOR) return; + if (!cr_set) { + GtkWidget *w = GTK_WIDGET(gobj()); + + GdkBitmap *bitmap = NULL; + GdkBitmap *mask = NULL; + if (modifier == 2) { // saturation + sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_s_xpm); + } else if (modifier == 1) { // lightness + sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_l_xpm); + } else { // hue + sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_h_xpm); + } + if ((bitmap != NULL) && (mask != NULL)) { + cr = gdk_cursor_new_from_pixmap(bitmap, mask, + &w->style->black, + &w->style->white, + 16, 16); + g_object_unref (bitmap); + g_object_unref (mask); + gdk_window_set_cursor(w->window, cr); + cr_set = true; + } + } + guint32 cc; if (!startcolor_set) { cc = startcolor = parent->_thisselected[fillstroke]; @@ -1251,6 +1281,16 @@ RotateableSwatch::do_release(double by, guint modifier) { float hsl[3]; color_adjust(hsl, by, startcolor, modifier); + if (cr_set) { + GtkWidget *w = GTK_WIDGET(gobj()); + gdk_window_set_cursor(w->window, NULL); + if (cr) { + gdk_cursor_unref (cr); + cr = NULL; + } + cr_set = false; + } + if (modifier == 2) { // saturation sp_document_maybe_done (sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation")); diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 299e78617..cd67abfc5 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -63,11 +63,17 @@ public: ~RotateableSwatch(); guint fillstroke; + SelectedStyle *parent; + guint32 startcolor; bool startcolor_set; + gchar *undokey; + GdkCursor *cr; + bool cr_set; + double color_adjust (float *hsl, double by, guint32 cc, guint state); virtual void do_motion (double by, guint state); virtual void do_release (double by, guint state);