From 58928f3ed2adc05902c3fb2daf15b27a100c14f3 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Wed, 28 Jun 2017 00:04:40 +0200 Subject: Partial fix for menu items and split contextmenu into separate file --- src/ui/tools/tool-base.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/tools/tool-base.cpp') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 3d755eadc..9231db7c8 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" -- cgit v1.2.3 From f55448431e934bf29bb9a983711d204614db7cc7 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 30 Jun 2017 05:58:14 +0200 Subject: Hackfest: Refactor cursors so the hot spot is inside the xpm --- src/ui/tools/tool-base.cpp | 55 ++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 39 deletions(-) (limited to 'src/ui/tools/tool-base.cpp') diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 9231db7c8..0467b984e 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -86,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) @@ -104,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) { } @@ -154,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(); @@ -208,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(); } /** -- cgit v1.2.3