diff options
| author | Jasper van de Gronde <jasper.vandegronde@gmail.com> | 2010-09-06 09:16:22 +0000 |
|---|---|---|
| committer | Jasper van de Gronde <th.v.d.gronde@hccnet.nl> | 2010-09-06 09:16:22 +0000 |
| commit | 17fbfe1ce12dd215eb9a8984ff8da0ea4e2416ad (patch) | |
| tree | 7974c6e7493642ab70ff589bed0bcc71c09d75dc /src/event-context.cpp | |
| parent | make hpgl document height compatible with dxf (Bug 487052) (diff) | |
| download | inkscape-17fbfe1ce12dd215eb9a8984ff8da0ea4e2416ad.tar.gz inkscape-17fbfe1ce12dd215eb9a8984ff8da0ea4e2416ad.zip | |
Color preview in cursor
(bzr r9743)
Diffstat (limited to 'src/event-context.cpp')
| -rw-r--r-- | src/event-context.cpp | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/event-context.cpp b/src/event-context.cpp index 5d60379c8..56f875844 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -44,6 +44,7 @@ #include "desktop.h" #include "desktop-handles.h" #include "desktop-events.h" +#include "desktop-style.h" #include "widgets/desktop-widget.h" #include "sp-namedview.h" #include "selection.h" @@ -62,6 +63,7 @@ #include "ui/tool/control-point.h" #include "shape-editor.h" #include "sp-guide.h" +#include "color.h" static void sp_event_context_class_init(SPEventContextClass *klass); static void sp_event_context_init(SPEventContext *event_context); @@ -141,6 +143,7 @@ static void sp_event_context_init(SPEventContext *event_context) { event_context->shape_editor = NULL; event_context->_delayed_snap_event = NULL; event_context->_dse_callback_in_process = false; + event_context->tool_url = NULL; } /** @@ -183,17 +186,38 @@ void sp_event_context_update_cursor(SPEventContext *ec) { if (w->window) { /* fixme: */ if (ec->cursor_shape) { - GdkBitmap *bitmap = NULL; - GdkBitmap *mask = NULL; - sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape); - if ((bitmap != NULL) && (mask != NULL)) { - if (ec->cursor) - gdk_cursor_unref(ec->cursor); - ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask, - &w->style->black, &w->style->white, ec->hot_x, - ec->hot_y); - g_object_unref(bitmap); - g_object_unref(mask); + GdkDisplay *display = gdk_display_get_default(); + if (ec->tool_url && gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) { + bool fillHasColor=false, strokeHasColor=false; + guint32 fillColor = sp_desktop_get_color_tool(ec->desktop, ec->tool_url, true, &fillHasColor); + guint32 strokeColor = sp_desktop_get_color_tool(ec->desktop, ec->tool_url, false, &strokeHasColor); + double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(ec->desktop, ec->tool_url, true) : 0; + double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(ec->desktop, ec->tool_url, false) : 0; + GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm( + ec->cursor_shape, + w->style->black, w->style->white, + SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(fillColor),SP_RGBA32_G_U(fillColor),SP_RGBA32_B_U(fillColor),SP_COLOR_F_TO_U(fillOpacity)), + SP_RGBA32_U_COMPOSE(SP_RGBA32_R_U(strokeColor),SP_RGBA32_G_U(strokeColor),SP_RGBA32_B_U(strokeColor),SP_COLOR_F_TO_U(strokeOpacity)) + ); + if (pixbuf != NULL) { + if (ec->cursor) + gdk_cursor_unref(ec->cursor); + ec->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, ec->hot_x, ec->hot_y); + g_object_unref(pixbuf); + } + } else { + GdkBitmap *bitmap = NULL; + GdkBitmap *mask = NULL; + sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, ec->cursor_shape); + if ((bitmap != NULL) && (mask != NULL)) { + if (ec->cursor) + gdk_cursor_unref(ec->cursor); + ec->cursor = gdk_cursor_new_from_pixmap(bitmap, mask, + &w->style->black, &w->style->white, ec->hot_x, + ec->hot_y); + g_object_unref(bitmap); + g_object_unref(mask); + } } } gdk_window_set_cursor(w->window, ec->cursor); |
