From 6a7bd5175bba266e10ff5eac5c630ec3115b2e19 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 1 Jan 2012 16:46:12 +0100 Subject: 1) Fix CanvasText alignment bugs caused by static variables, uninitialized variables, and variable border width 2) Snap tooltips no longer overlap with measure tool tooltips, and now have a background color (similar to the measure tool) (bzr r10816) --- src/display/snap-indicator.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/display/snap-indicator.cpp') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 3b9bb57e1..7864c0e53 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -6,7 +6,7 @@ * Diederik van Lierop * * Copyright (C) Johan Engelen 2009 - * Copyright (C) Diederik van Lierop 2010 + * Copyright (C) Diederik van Lierop 2010 - 2012 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -22,6 +22,7 @@ #include "knot.h" #include "preferences.h" #include +#include "tools-switch.h" namespace Inkscape { namespace Display { @@ -253,15 +254,29 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap } else { tooltip_str = g_strdup(source_name); } - Geom::Point tooltip_pos = p.getPoint() + _desktop->w2d(Geom::Point(15, -15)); + double fontsize = prefs->getInt("/tools/measure/fontsize"); + + Geom::Point tooltip_pos = p.getPoint(); + if (tools_isactive(_desktop, TOOLS_MEASURE)) { + // Make sure that the snap tooltips do not overlap the ones from the measure tool + tooltip_pos += _desktop->w2d(Geom::Point(0, -3*fontsize)); + } else { + tooltip_pos += _desktop->w2d(Geom::Point(0, -2*fontsize)); + } SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); + sp_canvastext_set_fontsize(SP_CANVASTEXT(canvas_tooltip), fontsize); + SP_CANVASTEXT(canvas_tooltip)->rgba = 0xffffffff; + SP_CANVASTEXT(canvas_tooltip)->outline = false; + SP_CANVASTEXT(canvas_tooltip)->background = true; if (pre_snap) { - SP_CANVASTEXT(canvas_tooltip)->rgba = 0x7f7f7fff; + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f40; + } else { + SP_CANVASTEXT(canvas_tooltip)->rgba_background = 0x33337f7f; } + SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; g_free(tooltip_str); - sp_canvastext_set_anchor((SPCanvasText* )canvas_tooltip, -1, 1); _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); // Display the bounding box, if we snapped to one -- cgit v1.2.3