From 454a66aa12442146b02bda954fee3ff1077fc238 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 22 Mar 2008 18:29:40 +0000 Subject: Line-end fixups (bzr r5161) --- src/display/canvas-temporary-item-list.cpp | 166 ++++++++++++++--------------- src/display/canvas-temporary-item-list.h | 116 ++++++++++---------- src/display/canvas-temporary-item.cpp | 146 ++++++++++++------------- src/display/canvas-temporary-item.h | 112 +++++++++---------- src/display/snap-indicator.cpp | 156 +++++++++++++-------------- src/display/snap-indicator.h | 106 +++++++++--------- 6 files changed, 401 insertions(+), 401 deletions(-) (limited to 'src/display') diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp index 54e81a1f0..c324a5ddf 100644 --- a/src/display/canvas-temporary-item-list.cpp +++ b/src/display/canvas-temporary-item-list.cpp @@ -1,83 +1,83 @@ -/** \file - * Provides a class that can contain active TemporaryItem's on a desktop - * Code inspired by message-stack.cpp - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/canvas-temporary-item-list.h" - -#include "display/canvas-temporary-item.h" - -namespace Inkscape { -namespace Display { - -TemporaryItemList::TemporaryItemList(SPDesktop *desktop) - : desktop(desktop) -{ - -} - -TemporaryItemList::~TemporaryItemList() -{ - // delete all items in list so the timeouts are removed - for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - TemporaryItem * tempitem = *it; - delete tempitem; - } - itemlist.clear(); -} - -/* Note that TemporaryItem or TemporaryItemList is responsible for deletion and such, so this return pointer can safely be ignored. */ -TemporaryItem * -TemporaryItemList::add_item(SPCanvasItem *item, guint lifetime) -{ - // beware of strange things happening due to very short timeouts - TemporaryItem * tempitem = new TemporaryItem(item, lifetime); - itemlist.push_back(tempitem); - tempitem->signal_timeout.connect( sigc::mem_fun(*this, &TemporaryItemList::_item_timeout) ); - return tempitem; -} - -void -TemporaryItemList::delete_item( TemporaryItem * tempitem ) -{ - // check if the item is in the list, if so, delete it. (in other words, don't wait for the item to delete itself) - bool in_list = false; - for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { - if ( *it == tempitem ) { - in_list = true; - break; - } - } - if (in_list) { - itemlist.remove(tempitem); - delete tempitem; - } -} - -void -TemporaryItemList::_item_timeout(TemporaryItem * tempitem) -{ - itemlist.remove(tempitem); - // no need to delete the item, it does that itself after signal_timeout.emit() completes -} - -} //namespace Display -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +/** \file + * Provides a class that can contain active TemporaryItem's on a desktop + * Code inspired by message-stack.cpp + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/canvas-temporary-item-list.h" + +#include "display/canvas-temporary-item.h" + +namespace Inkscape { +namespace Display { + +TemporaryItemList::TemporaryItemList(SPDesktop *desktop) + : desktop(desktop) +{ + +} + +TemporaryItemList::~TemporaryItemList() +{ + // delete all items in list so the timeouts are removed + for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { + TemporaryItem * tempitem = *it; + delete tempitem; + } + itemlist.clear(); +} + +/* Note that TemporaryItem or TemporaryItemList is responsible for deletion and such, so this return pointer can safely be ignored. */ +TemporaryItem * +TemporaryItemList::add_item(SPCanvasItem *item, guint lifetime) +{ + // beware of strange things happening due to very short timeouts + TemporaryItem * tempitem = new TemporaryItem(item, lifetime); + itemlist.push_back(tempitem); + tempitem->signal_timeout.connect( sigc::mem_fun(*this, &TemporaryItemList::_item_timeout) ); + return tempitem; +} + +void +TemporaryItemList::delete_item( TemporaryItem * tempitem ) +{ + // check if the item is in the list, if so, delete it. (in other words, don't wait for the item to delete itself) + bool in_list = false; + for ( std::list::iterator it = itemlist.begin(); it != itemlist.end(); ++it ) { + if ( *it == tempitem ) { + in_list = true; + break; + } + } + if (in_list) { + itemlist.remove(tempitem); + delete tempitem; + } +} + +void +TemporaryItemList::_item_timeout(TemporaryItem * tempitem) +{ + itemlist.remove(tempitem); + // no need to delete the item, it does that itself after signal_timeout.emit() completes +} + +} //namespace Display +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/canvas-temporary-item-list.h b/src/display/canvas-temporary-item-list.h index cd4bcfe99..4d712e216 100644 --- a/src/display/canvas-temporary-item-list.h +++ b/src/display/canvas-temporary-item-list.h @@ -1,58 +1,58 @@ -#ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H -#define INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H - -/** \file - * Provides a class that can contain active TemporaryItem's on a desktop - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "forward.h" -#include "display/display-forward.h" -#include - -namespace Inkscape { -namespace Display { - -class TemporaryItem; - -class TemporaryItemList { -public: - TemporaryItemList(SPDesktop *desktop); - virtual ~TemporaryItemList(); - - TemporaryItem* add_item (SPCanvasItem *item, guint lifetime); - void delete_item (TemporaryItem * tempitem); - -protected: - SPDesktop *desktop; /** Desktop we are on. */ - - std::list itemlist; /** list of temp items */ - - void _item_timeout (TemporaryItem * tempitem); - -private: - TemporaryItemList(const TemporaryItemList&); - TemporaryItemList& operator=(const TemporaryItemList&); -}; - -} //namespace Display -} //namespace Inkscape - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +#ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H +#define INKSCAPE_CANVAS_TEMPORARY_ITEM_LIST_H + +/** \file + * Provides a class that can contain active TemporaryItem's on a desktop + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "forward.h" +#include "display/display-forward.h" +#include + +namespace Inkscape { +namespace Display { + +class TemporaryItem; + +class TemporaryItemList { +public: + TemporaryItemList(SPDesktop *desktop); + virtual ~TemporaryItemList(); + + TemporaryItem* add_item (SPCanvasItem *item, guint lifetime); + void delete_item (TemporaryItem * tempitem); + +protected: + SPDesktop *desktop; /** Desktop we are on. */ + + std::list itemlist; /** list of temp items */ + + void _item_timeout (TemporaryItem * tempitem); + +private: + TemporaryItemList(const TemporaryItemList&); + TemporaryItemList& operator=(const TemporaryItemList&); +}; + +} //namespace Display +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/canvas-temporary-item.cpp b/src/display/canvas-temporary-item.cpp index 7d7f8087c..d31323b72 100644 --- a/src/display/canvas-temporary-item.cpp +++ b/src/display/canvas-temporary-item.cpp @@ -1,73 +1,73 @@ -/** \file - * Provides a class that can contain active TemporaryItem's on a desktop - * When the object is deleted, it also deletes the canvasitem it contains! - * This object should be created/managed by a TemporaryItemList. - * After its lifetime, it fires the timeout signal, afterwards *it deletes itself*. - * - * (part of code inspired by message-stack.cpp) - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/canvas-temporary-item.h" - -#include - -namespace Inkscape { -namespace Display { - -/** lifetime is measured in milliseconds - */ -TemporaryItem::TemporaryItem(SPCanvasItem *item, guint lifetime) - : canvasitem(item), - timeout_id(0) -{ - // zero lifetime means stay forever, so do not add timeout event. - if (lifetime > 0) { - timeout_id = g_timeout_add(lifetime, &TemporaryItem::_timeout, this); - } -} - -TemporaryItem::~TemporaryItem() -{ - // when it has not expired yet... - if (timeout_id) { - g_source_remove(timeout_id); - timeout_id = 0; - } - - if (canvasitem) { - // destroying the item automatically hides it - gtk_object_destroy (GTK_OBJECT (canvasitem)); - canvasitem = NULL; - } -} - -/* static method*/ -gboolean TemporaryItem::_timeout(gpointer data) { - TemporaryItem *tempitem = reinterpret_cast(data); - tempitem->timeout_id = 0; - tempitem->signal_timeout.emit(tempitem); - delete tempitem; - return FALSE; -} - - -} //namespace Display -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +/** \file + * Provides a class that can contain active TemporaryItem's on a desktop + * When the object is deleted, it also deletes the canvasitem it contains! + * This object should be created/managed by a TemporaryItemList. + * After its lifetime, it fires the timeout signal, afterwards *it deletes itself*. + * + * (part of code inspired by message-stack.cpp) + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/canvas-temporary-item.h" + +#include + +namespace Inkscape { +namespace Display { + +/** lifetime is measured in milliseconds + */ +TemporaryItem::TemporaryItem(SPCanvasItem *item, guint lifetime) + : canvasitem(item), + timeout_id(0) +{ + // zero lifetime means stay forever, so do not add timeout event. + if (lifetime > 0) { + timeout_id = g_timeout_add(lifetime, &TemporaryItem::_timeout, this); + } +} + +TemporaryItem::~TemporaryItem() +{ + // when it has not expired yet... + if (timeout_id) { + g_source_remove(timeout_id); + timeout_id = 0; + } + + if (canvasitem) { + // destroying the item automatically hides it + gtk_object_destroy (GTK_OBJECT (canvasitem)); + canvasitem = NULL; + } +} + +/* static method*/ +gboolean TemporaryItem::_timeout(gpointer data) { + TemporaryItem *tempitem = reinterpret_cast(data); + tempitem->timeout_id = 0; + tempitem->signal_timeout.emit(tempitem); + delete tempitem; + return FALSE; +} + + +} //namespace Display +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/canvas-temporary-item.h b/src/display/canvas-temporary-item.h index 0caa0d943..ec1e3b999 100644 --- a/src/display/canvas-temporary-item.h +++ b/src/display/canvas-temporary-item.h @@ -1,56 +1,56 @@ -#ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_H -#define INKSCAPE_CANVAS_TEMPORARY_ITEM_H - -/** \file - * Provides a class to put a canvasitem temporarily on-canvas. - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/display-forward.h" - -#include - -namespace Inkscape { -namespace Display { - -class TemporaryItem { -public: - TemporaryItem(SPCanvasItem *item, guint lifetime); - virtual ~TemporaryItem(); - - sigc::signal signal_timeout; - -protected: - friend class TemporaryItemList; - - SPCanvasItem * canvasitem; /** The item we are holding on to */ - guint timeout_id; /** ID by which glib knows the timeout event */ - - static gboolean _timeout(gpointer data); ///< callback for when lifetime expired - -private: - TemporaryItem(const TemporaryItem&); - TemporaryItem& operator=(const TemporaryItem&); -}; - -} //namespace Display -} //namespace Inkscape - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +#ifndef INKSCAPE_CANVAS_TEMPORARY_ITEM_H +#define INKSCAPE_CANVAS_TEMPORARY_ITEM_H + +/** \file + * Provides a class to put a canvasitem temporarily on-canvas. + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/display-forward.h" + +#include + +namespace Inkscape { +namespace Display { + +class TemporaryItem { +public: + TemporaryItem(SPCanvasItem *item, guint lifetime); + virtual ~TemporaryItem(); + + sigc::signal signal_timeout; + +protected: + friend class TemporaryItemList; + + SPCanvasItem * canvasitem; /** The item we are holding on to */ + guint timeout_id; /** ID by which glib knows the timeout event */ + + static gboolean _timeout(gpointer data); ///< callback for when lifetime expired + +private: + TemporaryItem(const TemporaryItem&); + TemporaryItem& operator=(const TemporaryItem&); +}; + +} //namespace Display +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index b6046e88c..f5e754d90 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -1,78 +1,78 @@ -/** \file - * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "display/snap-indicator.h" - -#include "desktop.h" -#include "desktop-handles.h" -#include "display/sodipodi-ctrl.h" -#include "knot.h" - -namespace Inkscape { -namespace Display { - -SnapIndicator::SnapIndicator(SPDesktop * desktop) - : tempitem(NULL), - desktop(desktop) -{ -} - -SnapIndicator::~SnapIndicator() -{ - // remove item that might be present - remove_snappoint(); -} - -void -SnapIndicator::set_new_snappoint(Geom::Point p) -{ - remove_snappoint(); - - bool enabled = false; // TODO add preference for snap indicator. - if (enabled) { - // TODO add many different kinds of snap indicator :-) - SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop), - SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, - "size", 10.0, - "stroked", TRUE, - "stroke_color", 0xf000f0ff, - "mode", SP_KNOT_MODE_XOR, - "shape", SP_KNOT_SHAPE_CROSS, - NULL ); - SP_CTRL(canvasitem)->moveto ( p ); - tempitem = desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout - } -} - -void -SnapIndicator::remove_snappoint() -{ - if (tempitem) { - desktop->remove_temporary_canvasitem(tempitem); - tempitem = NULL; - } -} - - -} //namespace Display -} /* namespace Inkscape */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +/** \file + * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "display/snap-indicator.h" + +#include "desktop.h" +#include "desktop-handles.h" +#include "display/sodipodi-ctrl.h" +#include "knot.h" + +namespace Inkscape { +namespace Display { + +SnapIndicator::SnapIndicator(SPDesktop * desktop) + : tempitem(NULL), + desktop(desktop) +{ +} + +SnapIndicator::~SnapIndicator() +{ + // remove item that might be present + remove_snappoint(); +} + +void +SnapIndicator::set_new_snappoint(Geom::Point p) +{ + remove_snappoint(); + + bool enabled = false; // TODO add preference for snap indicator. + if (enabled) { + // TODO add many different kinds of snap indicator :-) + SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop), + SP_TYPE_CTRL, + "anchor", GTK_ANCHOR_CENTER, + "size", 10.0, + "stroked", TRUE, + "stroke_color", 0xf000f0ff, + "mode", SP_KNOT_MODE_XOR, + "shape", SP_KNOT_SHAPE_CROSS, + NULL ); + SP_CTRL(canvasitem)->moveto ( p ); + tempitem = desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout + } +} + +void +SnapIndicator::remove_snappoint() +{ + if (tempitem) { + desktop->remove_temporary_canvasitem(tempitem); + tempitem = NULL; + } +} + + +} //namespace Display +} /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index bedeb492b..0395d4000 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -1,53 +1,53 @@ -#ifndef INKSCAPE_DISPLAY_SNAP_INDICATOR_H -#define INKSCAPE_DISPLAY_SNAP_INDICATOR_H - -/** \file - * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap - * - * Authors: - * Johan Engelen - * - * Copyright (C) Johan Engelen 2008 - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "forward.h" -#include "display/display-forward.h" -#include <2geom/point.h> - -namespace Inkscape { -namespace Display { - -class SnapIndicator { -public: - SnapIndicator(SPDesktop *desktop); - virtual ~SnapIndicator(); - - void set_new_snappoint(Geom::Point p); - void remove_snappoint(); - -protected: - TemporaryItem * tempitem; - SPDesktop *desktop; - -private: - SnapIndicator(const SnapIndicator&); - SnapIndicator& operator=(const SnapIndicator&); -}; - -} //namespace Display -} //namespace Inkscape - -#endif - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : +#ifndef INKSCAPE_DISPLAY_SNAP_INDICATOR_H +#define INKSCAPE_DISPLAY_SNAP_INDICATOR_H + +/** \file + * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap + * + * Authors: + * Johan Engelen + * + * Copyright (C) Johan Engelen 2008 + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "forward.h" +#include "display/display-forward.h" +#include <2geom/point.h> + +namespace Inkscape { +namespace Display { + +class SnapIndicator { +public: + SnapIndicator(SPDesktop *desktop); + virtual ~SnapIndicator(); + + void set_new_snappoint(Geom::Point p); + void remove_snappoint(); + +protected: + TemporaryItem * tempitem; + SPDesktop *desktop; + +private: + SnapIndicator(const SnapIndicator&); + SnapIndicator& operator=(const SnapIndicator&); +}; + +} //namespace Display +} //namespace Inkscape + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3