diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 02:03:38 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 02:03:38 +0000 |
| commit | 0d5bb885dee83f041830dc950d3be6f21a37f08b (patch) | |
| tree | 88a0ae7a15ed496ddad1f83f43547783b88843ac /src/ui/tools/tool-base.cpp | |
| parent | Bug fixes (diff) | |
| parent | Add Mac CI build config (diff) | |
| download | inkscape-0d5bb885dee83f041830dc950d3be6f21a37f08b.tar.gz inkscape-0d5bb885dee83f041830dc950d3be6f21a37f08b.zip | |
update to trunk
Diffstat (limited to 'src/ui/tools/tool-base.cpp')
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 3d755eadc..0467b984e 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -23,6 +23,7 @@ #include "shortcuts.h" #include "file.h" +#include "ui/contextmenu.h" #include "ui/interface.h" #include "ui/event-debug.h" #include "ui/tool/control-point.h" @@ -85,7 +86,7 @@ SPDesktop const& ToolBase::getDesktop() const { return *desktop; } -ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, bool uses_snap) +ToolBase::ToolBase(gchar const *const *cursor_shape, bool uses_snap) : pref_observer(NULL) , cursor(NULL) , xp(0) @@ -103,8 +104,6 @@ ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y, boo , desktop(NULL) , _uses_snap(uses_snap) , cursor_shape(cursor_shape) - , hot_x(hot_x) - , hot_y(hot_y) { } @@ -153,44 +152,24 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) { void ToolBase::sp_event_context_update_cursor() { GtkWidget *w = GTK_WIDGET(this->desktop->getCanvas()); if (gtk_widget_get_window (w)) { - GtkStyle *style = gtk_widget_get_style(w); - /* fixme: */ if (this->cursor_shape) { - GdkDisplay *display = gdk_display_get_default(); - if (gdk_display_supports_cursor_alpha(display) && gdk_display_supports_cursor_color(display)) { - bool fillHasColor=false, strokeHasColor=false; - guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor); - guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor); - double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0; - double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0; - - GdkPixbuf *pixbuf = sp_cursor_pixbuf_from_xpm( - this->cursor_shape, - style->black, 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 (this->cursor) { - g_object_unref(this->cursor); - } - this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); - g_object_unref(pixbuf); - } - } else { - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)this->cursor_shape); - - if (pixbuf) { - if (this->cursor) { - g_object_unref(this->cursor); - } - this->cursor = gdk_cursor_new_from_pixbuf(display, - pixbuf, this->hot_x, this->hot_y); - g_object_unref(pixbuf); - } + if(this->cursor) { + g_object_unref(this->cursor); } + + bool fillHasColor=false, strokeHasColor=false; + guint32 fillColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), true, &fillHasColor); + guint32 strokeColor = sp_desktop_get_color_tool(this->desktop, this->getPrefsPath(), false, &strokeHasColor); + double fillOpacity = fillHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), true) : 0; + double strokeOpacity = strokeHasColor ? sp_desktop_get_opacity_tool(this->desktop, this->getPrefsPath(), false) : 0; + + this->cursor = sp_cursor_from_xpm( + this->cursor_shape, &style->black, &style->white, + SP_RGBA32_C_COMPOSE(fillColor, fillOpacity), + SP_RGBA32_C_COMPOSE(strokeColor, strokeOpacity) + ); } gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor); gdk_flush(); @@ -207,8 +186,7 @@ void ToolBase::sp_event_context_update_cursor() { void ToolBase::setup() { this->pref_observer = new ToolPrefObserver(this->getPrefsPath(), this); Inkscape::Preferences::get()->addObserver(*(this->pref_observer)); - - this->sp_event_context_update_cursor(); + this->sp_event_context_update_cursor(); } /** |
