snap-indicator.cpp revision 9a0751b8ddc1e4f4991cc95f18de6434d8adfd11
5053N/A/** \file
5053N/A * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap
5053N/A *
5053N/A * Authors:
5053N/A * Johan Engelen
5053N/A *
5053N/A * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
5053N/A *
5053N/A * Released under GNU GPL, read the file 'COPYING' for more information
5053N/A */
5053N/A
5053N/A#include "display/snap-indicator.h"
5053N/A
5053N/A#include "desktop.h"
5053N/A#include "desktop-handles.h"
5053N/A#include "display/sodipodi-ctrl.h"
5053N/A#include "knot.h"
5053N/A
5053N/Anamespace Inkscape {
5053N/Anamespace Display {
5053N/A
5053N/ASnapIndicator::SnapIndicator(SPDesktop * desktop)
5053N/A : tempitem(NULL),
5053N/A desktop(desktop)
5053N/A{
5053N/A}
5053N/A
5053N/ASnapIndicator::~SnapIndicator()
5053N/A{
5053N/A // remove item that might be present
5053N/A remove_snappoint();
5053N/A}
5053N/A
5053N/Avoid
5053N/ASnapIndicator::set_new_snappoint(Geom::Point p)
5053N/A{
5053N/A remove_snappoint();
5053N/A
5053N/A bool enabled = false; // TODO add preference for snap indicator.
5053N/A if (enabled) {
5053N/A // TODO add many different kinds of snap indicator :-)
5053N/A SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop),
5053N/A SP_TYPE_CTRL,
5053N/A "anchor", GTK_ANCHOR_CENTER,
5053N/A "size", 10.0,
5053N/A "stroked", TRUE,
5053N/A "stroke_color", 0xf000f0ff,
5053N/A "mode", SP_KNOT_MODE_XOR,
5053N/A "shape", SP_KNOT_SHAPE_CROSS,
5053N/A NULL );
5053N/A SP_CTRL(canvasitem)->moveto ( p );
5053N/A tempitem = desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout
5053N/A }
5053N/A}
5053N/A
5053N/Avoid
5053N/ASnapIndicator::remove_snappoint()
5053N/A{
5053N/A if (tempitem) {
5053N/A desktop->remove_temporary_canvasitem(tempitem);
5053N/A tempitem = NULL;
5053N/A }
5053N/A}
5053N/A
5053N/A
5053N/A} //namespace Display
5053N/A} /* namespace Inkscape */
5053N/A
5053N/A/*
5053N/A Local Variables:
5053N/A mode:c++
5053N/A c-file-style:"stroustrup"
5053N/A c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
5053N/A indent-tabs-mode:nil
5053N/A fill-column:99
5053N/A End:
5053N/A*/
5053N/A// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
5053N/A