From 8867de5daf309e4cdd3fce177b408618490be4f3 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Tue, 29 Jun 2010 23:35:42 +0530 Subject: This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp-item and marks the onset of document c++ification as well. Users can check performace increase with [/usr/bin/time -v inkscape_binary_with_commandline_options]. (bzr r9546.1.1) --- src/desktop.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index 52f172577..204807e98 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -190,7 +190,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid /* Setup Dialog Manager */ _dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance(); - dkey = sp_item_display_key_new (1); + dkey = SPItem::display_key_new (1); /* Connect document */ setDocument (document); @@ -277,7 +277,7 @@ 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 = sp_item_invoke_show (SP_ITEM (sp_document_root (document)), + NRArenaItem *ai = SP_ITEM (sp_document_root (document))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); @@ -394,7 +394,7 @@ void SPDesktop::destroy() } if (drawing) { - sp_item_invoke_hide (SP_ITEM (sp_document_root (doc())), dkey); + SP_ITEM (sp_document_root (doc()))->invoke_hide (dkey); drawing = NULL; } @@ -552,7 +552,7 @@ bool SPDesktop::isLayer(SPObject *object) const { bool SPDesktop::isWithinViewport (SPItem *item) const { Geom::Rect const viewport = get_display_area(); - Geom::OptRect const bbox = sp_item_bbox_desktop(item); + Geom::OptRect const bbox = item->getBboxDesktop(); if (bbox) { return viewport.contains(*bbox); } else { @@ -1075,7 +1075,7 @@ SPDesktop::zoom_drawing() SPItem *docitem = SP_ITEM (sp_document_root (doc())); g_return_if_fail (docitem != NULL); - Geom::OptRect d = sp_item_bbox_desktop(docitem); + Geom::OptRect d = docitem->getBboxDesktop(); /* Note that the second condition here indicates that ** there are no items in the drawing. @@ -1474,7 +1474,7 @@ SPDesktop::setDocument (SPDocument *doc) { if (this->doc() && doc) { namedview->hide(this); - sp_item_invoke_hide (SP_ITEM (sp_document_root (this->doc())), dkey); + SP_ITEM (sp_document_root (this->doc()))->invoke_hide (dkey); } if (_layer_hierarchy) { @@ -1505,7 +1505,7 @@ SPDesktop::setDocument (SPDocument *doc) _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); number = namedview->getViewCount(); - ai = sp_item_invoke_show (SP_ITEM (sp_document_root (doc)), + ai = SP_ITEM (sp_document_root (doc))->invoke_show ( SP_CANVAS_ARENA (drawing)->arena, dkey, SP_ITEM_SHOW_DISPLAY); -- cgit v1.2.3 From 121815791be2d24cb745663520b111ee914fbc09 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Thu, 1 Jul 2010 15:36:56 +0530 Subject: C++fied SPDocument added (bzr r9546.1.2) --- src/desktop.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index 204807e98..d5e7974ea 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -185,7 +185,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid SPDocument *document = SP_OBJECT_DOCUMENT (namedview); /* Kill flicker */ - sp_document_ensure_up_to_date (document); + document->ensure_up_to_date (); /* Setup Dialog Manager */ _dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance(); @@ -255,7 +255,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid // display rect and zoom are now handled in sp_desktop_widget_realize() Geom::Rect const d(Geom::Point(0.0, 0.0), - Geom::Point(sp_document_width(document), sp_document_height(document))); + Geom::Point(document->getWidth(), document->getHeight())); SP_CTRLRECT(page)->setRectangle(d); SP_CTRLRECT(page_border)->setRectangle(d); @@ -272,7 +272,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid /* Connect event for page resize */ - _doc2dt[5] = sp_document_height (document); + _doc2dt[5] = document->getHeight (); sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt); _modified_connection = namedview->connectModified(sigc::bind<2>(sigc::ptr_fun(&_namedview_modified), this)); @@ -684,7 +684,7 @@ SPItem * SPDesktop::item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); + return SPDocument::item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); } /** @@ -694,7 +694,7 @@ SPItem * SPDesktop::item_at_point (Geom::Point const p, bool into_groups, SPItem *upto) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_item_at_point (doc(), dkey, p, into_groups, upto); + return doc()->item_at_point ( dkey, p, into_groups, upto); } /** @@ -704,7 +704,7 @@ SPItem * SPDesktop::group_at_point (Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); - return sp_document_group_at_point (doc(), dkey, p); + return doc()->group_at_point (dkey, p); } /** @@ -1014,7 +1014,7 @@ void SPDesktop::zoom_page() { Geom::Rect d(Geom::Point(0, 0), - Geom::Point(sp_document_width(doc()), sp_document_height(doc()))); + Geom::Point(doc()->getWidth(), doc()->getHeight())); if (d.minExtent() < 1.0) { return; @@ -1031,12 +1031,12 @@ SPDesktop::zoom_page_width() { Geom::Rect const a = get_display_area(); - if (sp_document_width(doc()) < 1.0) { + if (doc()->getWidth() < 1.0) { return; } Geom::Rect d(Geom::Point(0, a.midpoint()[Geom::Y]), - Geom::Point(sp_document_width(doc()), a.midpoint()[Geom::Y])); + Geom::Point(doc()->getWidth(), a.midpoint()[Geom::Y])); set_display_area(d, 10); } -- cgit v1.2.3 From 150ac8ed3274e060e3349b5c0901ec8c7c7e3d4e Mon Sep 17 00:00:00 2001 From: Abhishek Sharma Public Date: Sat, 17 Jul 2010 12:48:31 +0530 Subject: More in XML privatisation with new create3DBox function and other supplements to efficiently hide information. (bzr r9546.1.8) --- src/desktop.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index d5e7974ea..3f9fc7806 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -90,6 +90,7 @@ #include "display/canvas-grid.h" #include "widgets/desktop-widget.h" #include "box3d-context.h" +#include "desktop-style.h" // TODO those includes are only for node tool quick zoom. Remove them after fixing it. #include "ui/tool/node-tool.h" @@ -960,6 +961,27 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py, 0.0); } +/** + * Apply the desktop's current style or the tool style to the object. + */ +void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool_path, bool with_text) +{ + SPCSSAttr *css_current = sp_desktop_get_style(this, with_text); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + if (prefs->getBool(tool_path + "/usecurrent") && css_current) { + sp_repr_css_set(obj->getRepr(), css_current, "style"); + } else { + SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); + sp_repr_css_set(obj->getRepr(), css, "style"); + sp_repr_css_attr_unref(css); + } + if (css_current) { + sp_repr_css_attr_unref(css_current); + } + +} + /** * Zoom to center with absolute zoom factor. */ -- cgit v1.2.3 From e5dec7d5f087114818646072164234aa999e6d72 Mon Sep 17 00:00:00 2001 From: Abhishek Sharma public Date: Wed, 11 Aug 2010 20:19:55 +0530 Subject: XML Privatisation Stuff after a long time (bzr r9546.1.12) --- src/desktop.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/desktop.cpp') diff --git a/src/desktop.cpp b/src/desktop.cpp index 3f9fc7806..e7ef2897e 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -970,10 +970,12 @@ void SPDesktop::applyCurrentOrToolStyle(SPObject *obj, Glib::ustring const &tool Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool(tool_path + "/usecurrent") && css_current) { - sp_repr_css_set(obj->getRepr(), css_current, "style"); + //sp_repr_css_set(obj->getRepr(), css_current, "style"); + obj->setCSS(css_current,"style"); } else { SPCSSAttr *css = prefs->getInheritedStyle(tool_path + "/style"); - sp_repr_css_set(obj->getRepr(), css, "style"); + //sp_repr_css_set(obj->getRepr(), css, "style"); + obj->setCSS(css,"style"); sp_repr_css_attr_unref(css); } if (css_current) { @@ -1432,8 +1434,9 @@ void SPDesktop::toggleGrids() } } else { //there is no grid present at the moment. add a rectangular grid and make it visible - Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); + //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); + //Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); + namedview->writeNewGrid(sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); showGrids(true); } } @@ -1451,9 +1454,11 @@ void SPDesktop::showGrids(bool show, bool dirty_document) void SPDesktop::toggleSnapGlobal() { - bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); - Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); - sp_repr_set_boolean(repr, "inkscape:snap-global", !v); + //bool v = namedview->snap_manager.snapprefs.getSnapEnabledGlobally(); + //Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); + //sp_repr_set_boolean(repr, "inkscape:snap-global", !v); + bool v=namedview->getSnapGlobal(); + namedview->setSnapGlobal(!v); } //---------------------------------------------------------------------- -- cgit v1.2.3