summaryrefslogtreecommitdiffstats
path: root/src/desktop.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-06 12:18:32 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-08-06 12:18:32 +0000
commit4dd33aa4d5c57706c7f64f63391174954160a308 (patch)
treeb9d4ea1278348836a718c5e6aaeaff9f82c790bf /src/desktop.cpp
parentPer-item render cache. (diff)
downloadinkscape-4dd33aa4d5c57706c7f64f63391174954160a308.tar.gz
inkscape-4dd33aa4d5c57706c7f64f63391174954160a308.zip
Rewrite NRArenaItem hierarchy into C++
(bzr r10347.1.21)
Diffstat (limited to 'src/desktop.cpp')
-rw-r--r--src/desktop.cpp89
1 files changed, 45 insertions, 44 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 5e968b08b..cceee9499 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -59,55 +59,56 @@
#include <2geom/transforms.h>
#include <2geom/rect.h>
-#include "macros.h"
-#include "inkscape-private.h"
-#include "desktop.h"
+
+#include "box3d-context.h"
+#include "color.h"
#include "desktop-events.h"
+#include "desktop.h"
#include "desktop-handles.h"
-#include "document.h"
-#include "message-stack.h"
-#include "selection.h"
-#include "select-context.h"
-#include "sp-namedview.h"
-#include "color.h"
-#include "sp-item-group.h"
-#include "preferences.h"
-#include "object-hierarchy.h"
-#include "helper/units.h"
+#include "desktop-style.h"
+#include "device-manager.h"
#include "display/canvas-arena.h"
-#include "display/nr-arena.h"
-#include "display/gnome-canvas-acetate.h"
-#include "display/sodipodi-ctrlrect.h"
-#include "display/sp-canvas-util.h"
+#include "display/canvas-grid.h"
#include "display/canvas-temporary-item-list.h"
+#include "display/drawing-group.h"
+#include "display/gnome-canvas-acetate.h"
+#include "display/nr-arena.h"
#include "display/snap-indicator.h"
+#include "display/sodipodi-ctrlrect.h"
#include "display/sp-canvas-group.h"
-#include "ui/dialog/dialog-manager.h"
-#include "xml/repr.h"
-#include "message-context.h"
-#include "device-manager.h"
+#include "display/sp-canvas.h"
+#include "display/sp-canvas-util.h"
+#include "document.h"
+#include "event-log.h"
+#include "helper/units.h"
+#include "inkscape-private.h"
#include "layer-fns.h"
#include "layer-manager.h"
+#include "macros.h"
+#include "message-context.h"
+#include "message-stack.h"
+#include "object-hierarchy.h"
+#include "preferences.h"
#include "resource-manager.h"
-#include "event-log.h"
-#include "display/canvas-grid.h"
-#include "widgets/desktop-widget.h"
-#include "box3d-context.h"
-#include "desktop-style.h"
+#include "select-context.h"
+#include "selection.h"
#include "sp-item-group.h"
+#include "sp-item-group.h"
+#include "sp-namedview.h"
#include "sp-root.h"
+#include "ui/dialog/dialog-manager.h"
+#include "widgets/desktop-widget.h"
+#include "xml/repr.h"
// TODO those includes are only for node tool quick zoom. Remove them after fixing it.
#include "ui/tool/node-tool.h"
#include "ui/tool/control-point-selection.h"
-#include "display/sp-canvas.h"
-
namespace Inkscape { namespace XML { class Node; }}
// Callback declarations
static void _onSelectionChanged (Inkscape::Selection *selection, SPDesktop *desktop);
-static gint _arena_handler (SPCanvasArena *arena, NRArenaItem *ai, GdkEvent *event, SPDesktop *desktop);
+static gint _arena_handler (SPCanvasArena *arena, Inkscape::DrawingItem *ai, GdkEvent *event, SPDesktop *desktop);
static void _layer_activated(SPObject *layer, SPDesktop *desktop);
static void _layer_deactivated(SPObject *layer, SPDesktop *desktop);
static void _layer_hierarchy_changed(SPObject *top, SPObject *bottom, SPDesktop *desktop);
@@ -158,7 +159,7 @@ SPDesktop::SPDesktop() :
_layer_hierarchy( 0 ),
_reconstruction_old_layer_id( 0 ),
_display_mode(Inkscape::RENDERMODE_NORMAL),
- _display_color_mode(Inkscape::COLORRENDERMODE_NORMAL),
+ _display_color_mode(Inkscape::COLORMODE_NORMAL),
_widget( 0 ),
_inkscape( 0 ),
_guides_message_context( 0 ),
@@ -285,12 +286,12 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
_modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
- NRArenaItem *ai = document->getRoot()->invoke_show(
+ Inkscape::DrawingItem *ai = document->getRoot()->invoke_show(
SP_CANVAS_ARENA (drawing)->arena,
dkey,
SP_ITEM_SHOW_DISPLAY);
if (ai) {
- nr_arena_item_add_child (SP_CANVAS_ARENA (drawing)->root, ai, NULL);
+ SP_CANVAS_ARENA (drawing)->root->prependChild(ai);
}
namedview->show(this);
@@ -460,8 +461,8 @@ void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) {
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw
_widget->setTitle( sp_desktop_document(this)->getName() );
}
-void SPDesktop::_setDisplayColorMode(Inkscape::ColorRenderMode mode) {
- SP_CANVAS_ARENA (drawing)->arena->colorrendermode = mode;
+void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) {
+ SP_CANVAS_ARENA (drawing)->arena->colormode = mode;
canvas->colorrendermode = mode;
_display_color_mode = mode;
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw
@@ -485,15 +486,15 @@ void SPDesktop::displayModeToggle() {
}
void SPDesktop::displayColorModeToggle() {
switch (_display_color_mode) {
- case Inkscape::COLORRENDERMODE_NORMAL:
- _setDisplayColorMode(Inkscape::COLORRENDERMODE_GRAYSCALE);
+ case Inkscape::COLORMODE_NORMAL:
+ _setDisplayColorMode(Inkscape::COLORMODE_GRAYSCALE);
break;
- case Inkscape::COLORRENDERMODE_GRAYSCALE:
- _setDisplayColorMode(Inkscape::COLORRENDERMODE_NORMAL);
+ case Inkscape::COLORMODE_GRAYSCALE:
+ _setDisplayColorMode(Inkscape::COLORMODE_NORMAL);
break;
-// case Inkscape::COLORRENDERMODE_PRINT_COLORS_PREVIEW:
+// case Inkscape::COLORMODE_PRINT_COLORS_PREVIEW:
default:
- _setDisplayColorMode(Inkscape::COLORRENDERMODE_NORMAL);
+ _setDisplayColorMode(Inkscape::COLORMODE_NORMAL);
}
}
@@ -1562,7 +1563,7 @@ SPDesktop::setDocument (SPDocument *doc)
/// are surely more safe methods to accomplish this.
// TODO since the comment had reversed logic, check the intent of this block of code:
if (drawing) {
- NRArenaItem *ai = 0;
+ Inkscape::DrawingItem *ai = 0;
namedview = sp_document_namedview (doc, NULL);
_modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this));
@@ -1573,7 +1574,7 @@ SPDesktop::setDocument (SPDocument *doc)
dkey,
SP_ITEM_SHOW_DISPLAY);
if (ai) {
- nr_arena_item_add_child (SP_CANVAS_ARENA (drawing)->root, ai, NULL);
+ SP_CANVAS_ARENA (drawing)->root->prependChild(ai);
}
namedview->show(this);
/* Ugly hack */
@@ -1662,10 +1663,10 @@ _onSelectionChanged
* \todo fixme
*/
static gint
-_arena_handler (SPCanvasArena */*arena*/, NRArenaItem *ai, GdkEvent *event, SPDesktop *desktop)
+_arena_handler (SPCanvasArena */*arena*/, Inkscape::DrawingItem *ai, GdkEvent *event, SPDesktop *desktop)
{
if (ai) {
- SPItem *spi = (SPItem*)NR_ARENA_ITEM_GET_DATA (ai);
+ SPItem *spi = (SPItem*) ai->data();
return sp_event_context_item_handler (desktop->event_context, spi, event);
} else {
return sp_event_context_root_handler (desktop->event_context, event);