From 4dd33aa4d5c57706c7f64f63391174954160a308 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 6 Aug 2011 14:18:32 +0200 Subject: Rewrite NRArenaItem hierarchy into C++ (bzr r10347.1.21) --- src/desktop.cpp | 89 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 44 deletions(-) (limited to 'src/desktop.cpp') 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); -- cgit v1.2.3 From 75976ea07dba9b97186667524d0a76603de416af Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 7 Aug 2011 12:53:12 +0200 Subject: Rewrite NRArena -> Inkscape::Drawing. Call render and update methods on the Drawing rather than on the root DrawingItem. (bzr r10347.1.25) --- src/desktop.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index cceee9499..7a71862d3 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -72,7 +72,7 @@ #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/drawing.h" #include "display/snap-indicator.h" #include "display/sodipodi-ctrlrect.h" #include "display/sp-canvas-group.h" @@ -230,7 +230,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid drawing = sp_canvas_item_new (main, SP_TYPE_CANVAS_ARENA, NULL); g_signal_connect (G_OBJECT (drawing), "arena_event", G_CALLBACK (_arena_handler), this); - SP_CANVAS_ARENA (drawing)->arena->delta = prefs->getDouble("/options/cursortolerance/value", 1.0); // default is 1 px + SP_CANVAS_ARENA (drawing)->drawing.delta = prefs->getDouble("/options/cursortolerance/value", 1.0); // default is 1 px if (prefs->getBool("/options/startmode/outline")) { // Start in outline mode @@ -287,11 +287,11 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); Inkscape::DrawingItem *ai = document->getRoot()->invoke_show( - SP_CANVAS_ARENA (drawing)->arena, + SP_CANVAS_ARENA (drawing)->drawing, dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - SP_CANVAS_ARENA (drawing)->root->prependChild(ai); + SP_CANVAS_ARENA (drawing)->drawing.root()->prependChild(ai); } namedview->show(this); @@ -404,6 +404,7 @@ void SPDesktop::destroy() if (drawing) { doc()->getRoot()->invoke_hide(dkey); + g_object_unref(drawing); drawing = NULL; } @@ -455,14 +456,14 @@ SPDesktop::remove_temporary_canvasitem (Inkscape::Display::TemporaryItem * tempi } void SPDesktop::_setDisplayMode(Inkscape::RenderMode mode) { - SP_CANVAS_ARENA (drawing)->arena->rendermode = mode; + SP_CANVAS_ARENA (drawing)->drawing.setRenderMode(mode); canvas->rendermode = mode; _display_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw _widget->setTitle( sp_desktop_document(this)->getName() ); } void SPDesktop::_setDisplayColorMode(Inkscape::ColorMode mode) { - SP_CANVAS_ARENA (drawing)->arena->colormode = mode; + SP_CANVAS_ARENA (drawing)->drawing.setColorMode(mode); canvas->colorrendermode = mode; _display_color_mode = mode; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (main), _d2w); // redraw @@ -1570,11 +1571,11 @@ SPDesktop::setDocument (SPDocument *doc) number = namedview->getViewCount(); ai = doc->getRoot()->invoke_show( - SP_CANVAS_ARENA (drawing)->arena, + SP_CANVAS_ARENA (drawing)->drawing, dkey, SP_ITEM_SHOW_DISPLAY); if (ai) { - SP_CANVAS_ARENA (drawing)->root->prependChild(ai); + SP_CANVAS_ARENA (drawing)->drawing.root()->prependChild(ai); } namedview->show(this); /* Ugly hack */ @@ -1788,9 +1789,9 @@ _namedview_modified (SPObject *obj, guint flags, SPDesktop *desktop) SP_RGBA32_G_U(nv->pagecolor) + SP_RGBA32_B_U(nv->pagecolor)) >= 384) { // the background color is light or transparent, use black outline - SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff); + SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/onlight", 0xff); } else { // use white outline - SP_CANVAS_ARENA (desktop->drawing)->arena->outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff); + SP_CANVAS_ARENA (desktop->drawing)->drawing.outlinecolor = prefs->getInt("/options/wireframecolors/ondark", 0xffffffff); } } } -- cgit v1.2.3