diff options
| author | Markus Engel <markus.engel@tum.de> | 2013-08-03 01:03:43 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2013-08-03 01:03:43 +0000 |
| commit | bf4a1d2d49850170b936c30cfe2b30e798716406 (patch) | |
| tree | 2632b534325df2eb92933f428979eeb8f5c52225 /src | |
| parent | reordered SPDesktop::set_event_context2; fixed last mismatched-tags (diff) | |
| download | inkscape-bf4a1d2d49850170b936c30cfe2b30e798716406.tar.gz inkscape-bf4a1d2d49850170b936c30cfe2b30e798716406.zip | |
Cleaned up.
(bzr r11608.1.117)
Diffstat (limited to 'src')
45 files changed, 626 insertions, 771 deletions
diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 26d70ad15..1929bfed6 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -153,8 +153,10 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &pai if (!fill_pattern) { switch (fill.type) { case PAINT_SERVER: { - fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity); - } break; + //fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity); + fill_pattern = fill.server->pattern_new(ct.raw(), paintbox, fill.opacity); + + } break; case PAINT_COLOR: { SPColor const &c = fill.color; fill_pattern = cairo_pattern_create_rgba( @@ -178,8 +180,10 @@ bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &p if (!stroke_pattern) { switch (stroke.type) { case PAINT_SERVER: { - stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity); - } break; + //stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity); + stroke_pattern = stroke.server->pattern_new(ct.raw(), paintbox, stroke.opacity); + + } break; case PAINT_COLOR: { SPColor const &c = stroke.color; stroke_pattern = cairo_pattern_create_rgba( diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 9f745cdea..a7c14387f 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1484,7 +1484,7 @@ bool OdfOutput::processGradient(SPItem *item, for (SPStop *stop = grvec->getFirstStop(); stop ; stop = stop->getNextStop()) { - unsigned long rgba = sp_stop_get_rgba32(stop); + unsigned long rgba = stop->get_rgba32(); unsigned long rgb = (rgba >> 8) & 0xffffff; double opacity = (static_cast<double>(rgba & 0xff)) / 256.0; GradientStop gs(rgb, opacity); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 7dcbdf98c..40260ea66 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -648,8 +648,8 @@ SPStop *sp_vector_add_stop(SPGradient *vector, SPStop* prev_stop, SPStop* next_s SPStop *newstop = reinterpret_cast<SPStop *>(vector->document->getObjectByRepr(new_stop_repr)); newstop->offset = offset; sp_repr_set_css_double( newstop->getRepr(), "offset", (double)offset); - guint32 const c1 = sp_stop_get_rgba32(prev_stop); - guint32 const c2 = sp_stop_get_rgba32(next_stop); + guint32 const c1 = prev_stop->get_rgba32(); + guint32 const c2 = next_stop->get_rgba32(); guint32 cnew = average_color (c1, c2, (offset - prev_stop->offset) / (next_stop->offset - prev_stop->offset)); Inkscape::CSSOStringStream os; gchar c[64]; @@ -726,7 +726,7 @@ guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, { SPStop *first = vector->getFirstStop(); if (first) { - return sp_stop_get_rgba32(first); + return first->get_rgba32(); } } break; @@ -737,7 +737,7 @@ guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, { SPStop *last = sp_last_stop (vector); if (last) { - return sp_stop_get_rgba32(last); + return last->get_rgba32(); } } break; @@ -748,7 +748,7 @@ guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, { SPStop *stopi = sp_get_stop_i (vector, point_i); if (stopi) { - return sp_stop_get_rgba32(stopi); + return stopi->get_rgba32(); } } break; @@ -982,7 +982,7 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { if (SP_IS_STOP(child)) { - guint32 color = sp_stop_get_rgba32(SP_STOP(child)); + guint32 color = SP_STOP(child)->get_rgba32(); //g_message("Stop color %d", color); gchar c[64]; sp_svg_write_color (c, sizeof(c), diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 5921426cf..3456f33c3 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -410,9 +410,9 @@ sp_gradient_simplify(SPGradientContext *rc, double tolerance) if (g_slist_find(todel, stop0) || g_slist_find(todel, stop2)) continue; - guint32 const c0 = sp_stop_get_rgba32(stop0); - guint32 const c2 = sp_stop_get_rgba32(stop2); - guint32 const c1r = sp_stop_get_rgba32(stop1); + guint32 const c0 = stop0->get_rgba32(); + guint32 const c2 = stop2->get_rgba32(); + guint32 const c1r = stop1->get_rgba32(); guint32 c1 = average_color (c0, c2, (stop1->offset - stop0->offset) / (stop2->offset - stop0->offset)); diff --git a/src/select-context.cpp b/src/select-context.cpp index efedb23e2..2949c1181 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -115,9 +115,9 @@ SPSelectContext::SPSelectContext() : SPEventContext() { sp_load_handles(12, 1, handle_center_xpm); } -static gint xp = 0, yp = 0; // where drag started -static gint tolerance = 0; -static bool within_tolerance = false; +//static gint xp = 0, yp = 0; // where drag started +//static gint tolerance = 0; +//static bool within_tolerance = false; static bool is_cycling = false; static bool moved_while_cycling = false; SPEventContext *prev_event_context = NULL; @@ -190,45 +190,41 @@ void SPSelectContext::set(const Inkscape::Preferences::Entry& val) { } } -static bool -sp_select_context_abort(SPEventContext *event_context) -{ - SPDesktop *desktop = event_context->desktop; - SPSelectContext *sc = SP_SELECT_CONTEXT(event_context); - Inkscape::SelTrans *seltrans = sc->_seltrans; +bool SPSelectContext::sp_select_context_abort() { + Inkscape::SelTrans *seltrans = this->_seltrans; - if (sc->dragging) { - if (sc->moved) { // cancel dragging an object + if (this->dragging) { + if (this->moved) { // cancel dragging an object seltrans->ungrab(); - sc->moved = FALSE; - sc->dragging = FALSE; - sp_event_context_discard_delayed_snap_event(event_context); + this->moved = FALSE; + this->dragging = FALSE; + sp_event_context_discard_delayed_snap_event(this); drag_escaped = 1; - if (sc->item) { + if (this->item) { // only undo if the item is still valid - if (sc->item->document) { + if (this->item->document) { DocumentUndo::undo(sp_desktop_document(desktop)); } - sp_object_unref( sc->item, NULL); - } else if (sc->button_press_ctrl) { + sp_object_unref( this->item, NULL); + } else if (this->button_press_ctrl) { // NOTE: This is a workaround to a bug. // When the ctrl key is held, sc->item is not defined // so in this case (only), we skip the object doc check DocumentUndo::undo(sp_desktop_document(desktop)); } - sc->item = NULL; + this->item = NULL; - SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Move canceled.")); + SP_EVENT_CONTEXT(this)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Move canceled.")); return true; } } else { if (Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->stop(); rb_escaped = 1; - SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear(); - SP_EVENT_CONTEXT(sc)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled.")); + SP_EVENT_CONTEXT(this)->defaultMessageContext()->clear(); + SP_EVENT_CONTEXT(this)->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Selection canceled.")); return true; } } @@ -285,7 +281,7 @@ bool SPSelectContext::item_handler(SPItem* item, GdkEvent* event) { // make sure we still have valid objects to move around if (this->item && this->item->document == NULL) { - sp_select_context_abort(this); + this->sp_select_context_abort(); } switch (event->type) { @@ -345,7 +341,7 @@ bool SPSelectContext::item_handler(SPItem* item, GdkEvent* event) { } } else if (event->button.button == 3) { // right click; do not eat it so that right-click menu can appear, but cancel dragging & rubberband - sp_select_context_abort(this); + this->sp_select_context_abort(); } break; @@ -396,43 +392,47 @@ bool SPSelectContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } -static void -sp_select_context_cycle_through_items(SPSelectContext *sc, Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) { - if (!sc->cycling_cur_item) +void SPSelectContext::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) { + if (!this->cycling_cur_item) { return; + } Inkscape::DrawingItem *arenaitem; - SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; - SPItem *item = SP_ITEM(sc->cycling_cur_item->data); + SPItem *item = SP_ITEM(this->cycling_cur_item->data); // Deactivate current item - if (!g_list_find(sc->cycling_items_selected_before, item) && selection->includes(item)) + if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) { selection->remove(item); + } + arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(0.3); // Find next item and activate it GList *next; if (scroll_event->direction == GDK_SCROLL_UP) { - next = sc->cycling_cur_item->next; - if (next == NULL && sc->cycling_wrap) - next = sc->cycling_items; + next = this->cycling_cur_item->next; + if (next == NULL && this->cycling_wrap) + next = this->cycling_items; } else { - next = sc->cycling_cur_item->prev; - if (next == NULL && sc->cycling_wrap) - next = g_list_last(sc->cycling_items); + next = this->cycling_cur_item->prev; + if (next == NULL && this->cycling_wrap) + next = g_list_last(this->cycling_items); } + if (next) { - sc->cycling_cur_item = next; - item = SP_ITEM(sc->cycling_cur_item->data); + this->cycling_cur_item = next; + item = SP_ITEM(this->cycling_cur_item->data); } + arenaitem = item->get_arenaitem(desktop->dkey); arenaitem->setOpacity(1.0); - if (shift_pressed) + if (shift_pressed) { selection->add(item); - else + } else { selection->set(item); + } } @@ -465,7 +465,7 @@ bool SPSelectContext::root_handler(GdkEvent* event) { // make sure we still have valid objects to move around if (this->item && this->item->document == NULL) { - sp_select_context_abort(this); + this->sp_select_context_abort(); } switch (event->type) { @@ -533,7 +533,7 @@ bool SPSelectContext::root_handler(GdkEvent* event) { ret = TRUE; } else if (event->button.button == 3) { // right click; do not eat it so that right-click menu can appear, but cancel dragging & rubberband - sp_select_context_abort(this); + this->sp_select_context_abort(); } break; @@ -890,7 +890,7 @@ bool SPSelectContext::root_handler(GdkEvent* event) { this->cycling_wrap = prefs->getBool("/options/selection/cycleWrap", true); // Cycle through the items underneath the mouse pointer, one-by-one - sp_select_context_cycle_through_items(this, selection, scroll_event, shift_pressed); + this->sp_select_context_cycle_through_items(selection, scroll_event, shift_pressed); ret = TRUE; @@ -1043,7 +1043,7 @@ bool SPSelectContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if (!sp_select_context_abort(this)) { + if (!this->sp_select_context_abort()) { selection->clear(); } diff --git a/src/select-context.h b/src/select-context.h index ab60083b1..25b9997e6 100644 --- a/src/select-context.h +++ b/src/select-context.h @@ -56,6 +56,10 @@ public: virtual bool item_handler(SPItem* item, GdkEvent* event); virtual const std::string& getPrefsPath(); + +private: + bool sp_select_context_abort(); + void sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed); }; #endif diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 6a2fbfbb3..8e2e7d7a6 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -61,57 +61,50 @@ SPClipPath::~SPClipPath() { } void SPClipPath::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPClipPath* object = this; - SPObjectGroup::build(doc, repr); - object->readAttr( "style" ); - object->readAttr( "clipPathUnits" ); + this->readAttr( "style" ); + this->readAttr( "clipPathUnits" ); /* Register ourselves */ - doc->addResource("clipPath", object); + doc->addResource("clipPath", this); } void SPClipPath::release() { - SPClipPath* object = this; - - if (object->document) { + if (this->document) { // Unregister ourselves - object->document->removeResource("clipPath", object); + this->document->removeResource("clipPath", this); } - SPClipPath *cp = SP_CLIPPATH(object); - while (cp->display) { + while (this->display) { /* We simply unref and let item manage this in handler */ - cp->display = sp_clippath_view_list_remove(cp->display, cp->display); + this->display = sp_clippath_view_list_remove(this->display, this->display); } SPObjectGroup::release(); } void SPClipPath::set(unsigned int key, const gchar* value) { - SPClipPath* object = this; - - SPClipPath *cp = SP_CLIPPATH(object); - switch (key) { case SP_ATTR_CLIPPATHUNITS: - cp->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; - cp->clipPathUnits_set = FALSE; + this->clipPathUnits = SP_CONTENT_UNITS_USERSPACEONUSE; + this->clipPathUnits_set = FALSE; + if (value) { if (!strcmp(value, "userSpaceOnUse")) { - cp->clipPathUnits_set = TRUE; + this->clipPathUnits_set = TRUE; } else if (!strcmp(value, "objectBoundingBox")) { - cp->clipPathUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; - cp->clipPathUnits_set = TRUE; + this->clipPathUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; + this->clipPathUnits_set = TRUE; } } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: if (SP_ATTRIBUTE_IS_CSS(key)) { - sp_style_read_from_object(object->style, object); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + sp_style_read_from_object(this->style, this); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); } else { SPObjectGroup::set(key, value); } @@ -120,19 +113,16 @@ void SPClipPath::set(unsigned int key, const gchar* value) { } void SPClipPath::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { - SPClipPath* object = this; - /* Invoke SPObjectGroup implementation */ SPObjectGroup::child_added(child, ref); /* Show new object */ - SPObject *ochild = object->document->getObjectByRepr(child); + SPObject *ochild = this->document->getObjectByRepr(child); + if (SP_IS_ITEM(ochild)) { - SPClipPath *cp = SP_CLIPPATH(object); - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { - Inkscape::DrawingItem *ac = SP_ITEM(ochild)->invoke_show( v->arenaitem->drawing(), - v->key, - SP_ITEM_REFERENCE_FLAGS); + for (SPClipPathView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingItem *ac = SP_ITEM(ochild)->invoke_show(v->arenaitem->drawing(), v->key, SP_ITEM_REFERENCE_FLAGS); + if (ac) { v->arenaitem->prependChild(ac); } @@ -141,34 +131,35 @@ void SPClipPath::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* re } void SPClipPath::update(SPCtx* ctx, unsigned int flags) { - SPClipPath* object = this; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for ( SPObject *child = og->firstChild(); child; child = child->getNext()) { + for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { sp_object_ref(child); l = g_slist_prepend(l, child); } + l = g_slist_reverse(l); + while (l) { SPObject *child = SP_OBJECT(l->data); l = g_slist_remove(l, child); + if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } + sp_object_unref(child); } - SPClipPath *cp = SP_CLIPPATH(object); - for (SPClipPathView *v = cp->display; v != NULL; v = v->next) { + for (SPClipPathView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); - if (cp->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { + + if (this->clipPathUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { Geom::Affine t = Geom::Scale(v->bbox->dimensions()); t.setTranslation(v->bbox->min()); g->setChildTransform(t); @@ -179,27 +170,28 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) { } void SPClipPath::modified(unsigned int flags) { - SPClipPath* object = this; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for (SPObject *child = og->firstChild(); child; child = child->getNext()) { + for (SPObject *child = this->firstChild(); child; child = child->getNext()) { sp_object_ref(child); l = g_slist_prepend(l, child); } + l = g_slist_reverse(l); + while (l) { SPObject *child = SP_OBJECT(l->data); l = g_slist_remove(l, child); + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } + sp_object_unref(child); } } @@ -214,14 +206,14 @@ Inkscape::XML::Node* SPClipPath::write(Inkscape::XML::Document* xml_doc, Inkscap return repr; } -Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int key) -{ +Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int key) { Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); display = sp_clippath_view_new_prepend(display, key, ai); for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { if (SP_IS_ITEM(child)) { Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); + if (ac) { /* The order is not important in clippath */ ai->appendChild(ac); @@ -234,13 +226,13 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int t.setTranslation(display->bbox->min()); ai->setChildTransform(t); } + ai->setStyle(this->style); return ai; } -void SPClipPath::hide(unsigned int key) -{ +void SPClipPath::hide(unsigned int key) { for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM(child)) { SP_ITEM(child)->invoke_hide(key); @@ -258,8 +250,7 @@ void SPClipPath::hide(unsigned int key) g_assert_not_reached(); } -void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) -{ +void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) { for (SPClipPathView *v = display; v != NULL; v = v->next) { if (v->key == key) { v->bbox = bbox; @@ -268,15 +259,16 @@ void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) } } -Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) -{ - SPObject *i = 0; +Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) { Geom::OptRect bbox; - for (i = firstChild(); i; i = i->getNext()) { - if (!SP_IS_ITEM(i)) continue; - Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform); - bbox.unionWith(tmp); + + for (SPObject *i = firstChild(); i; i = i->getNext()) { + if (SP_IS_ITEM(i)) { + Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform); + bbox.unionWith(tmp); + } } + return bbox; } diff --git a/src/sp-clippath.h b/src/sp-clippath.h index 331c4f4cd..707213611 100644 --- a/src/sp-clippath.h +++ b/src/sp-clippath.h @@ -51,6 +51,7 @@ public: void setBBox(unsigned int key, Geom::OptRect const &bbox); Geom::OptRect geometricBounds(Geom::Affine const &transform); +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); diff --git a/src/sp-gradient.h b/src/sp-gradient.h index 27a652377..2d402092a 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -195,21 +195,21 @@ public: void setSwatch(bool swatch = true); + static void gradientRefModified(SPObject *href, guint flags, SPGradient *gradient); + static void gradientRefChanged(SPObject *old_ref, SPObject *ref, SPGradient *gr); + private: bool invalidateVector(); bool invalidateArray(); void rebuildVector(); void rebuildArray(); -public: +protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void modified(guint flags); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - static void gradientRefModified(SPObject *href, guint flags, SPGradient *gradient); - static void gradientRefChanged(SPObject *old_ref, SPObject *ref, SPGradient *gr); - virtual void child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref); virtual void remove_child(Inkscape::XML::Node *child); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9e44bda38..abff398e6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -541,7 +541,7 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (old_mask) { /* Hide mask */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_hide(SP_MASK(old_mask), v->arenaitem->key()); + SP_MASK(old_mask)->sp_mask_hide(v->arenaitem->key()); } } if (SP_IS_MASK(mask)) { @@ -550,11 +550,11 @@ void SPItem::mask_ref_changed(SPObject *old_mask, SPObject *mask, SPItem *item) if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new(3)); } - Inkscape::DrawingItem *ai = sp_mask_show(SP_MASK(mask), + Inkscape::DrawingItem *ai = SP_MASK(mask)->sp_mask_show( v->arenaitem->drawing(), v->arenaitem->key()); v->arenaitem->setMask(ai); - sp_mask_set_bbox(SP_MASK(mask), v->arenaitem->key(), bbox); + SP_MASK(mask)->sp_mask_set_bbox(v->arenaitem->key(), bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } @@ -589,7 +589,7 @@ void SPItem::update(SPCtx *ctx, guint flags) { } if (mask) { for (SPItemView *v = item->display; v != NULL; v = v->next) { - sp_mask_set_bbox(mask, v->arenaitem->key(), bbox); + mask->sp_mask_set_bbox(v->arenaitem->key(), bbox); } } } @@ -1050,11 +1050,11 @@ Inkscape::DrawingItem *SPItem::invoke_show(Inkscape::Drawing &drawing, unsigned int mask_key = display->arenaitem->key(); // Show and set mask - Inkscape::DrawingItem *ac = sp_mask_show(mask, drawing, mask_key); + Inkscape::DrawingItem *ac = mask->sp_mask_show(drawing, mask_key); ai->setMask(ac); // Update bbox, in case the mask uses bbox units - sp_mask_set_bbox(SP_MASK(mask), mask_key, item_bbox); + SP_MASK(mask)->sp_mask_set_bbox(mask_key, item_bbox); mask->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } if (style->filter.set && display) { @@ -1086,7 +1086,7 @@ void SPItem::invoke_hide(unsigned key) v->arenaitem->setClip(NULL); } if (mask_ref->getObject()) { - sp_mask_hide(mask_ref->getObject(), v->arenaitem->key()); + mask_ref->getObject()->sp_mask_hide(v->arenaitem->key()); v->arenaitem->setMask(NULL); } if (!ref) { diff --git a/src/sp-linear-gradient.cpp b/src/sp-linear-gradient.cpp index 4305d1acf..4e7a08f4b 100644 --- a/src/sp-linear-gradient.cpp +++ b/src/sp-linear-gradient.cpp @@ -96,28 +96,6 @@ Inkscape::XML::Node* SPLinearGradient::write(Inkscape::XML::Document *xml_doc, I return repr; } - -/** - * Directly set properties of linear gradient and request modified. - */ -void -sp_lineargradient_set_position(SPLinearGradient *lg, - gdouble x1, gdouble y1, - gdouble x2, gdouble y2) -{ - g_return_if_fail(lg != NULL); - g_return_if_fail(SP_IS_LINEARGRADIENT(lg)); - - /* fixme: units? (Lauris) */ - lg->x1.set(SVGLength::NONE, x1, x1); - lg->y1.set(SVGLength::NONE, y1, y1); - lg->x2.set(SVGLength::NONE, x2, x2); - lg->y2.set(SVGLength::NONE, y2, y2); - - lg->requestModified(SP_OBJECT_MODIFIED_FLAG); -} - - cairo_pattern_t* SPLinearGradient::pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) { this->ensureVector(); diff --git a/src/sp-linear-gradient.h b/src/sp-linear-gradient.h index 89065245d..69052fe81 100644 --- a/src/sp-linear-gradient.h +++ b/src/sp-linear-gradient.h @@ -22,11 +22,12 @@ public: SVGLength x2; SVGLength y2; -public: + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); + +protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void set(unsigned key, gchar const *value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; #endif /* !SP_LINEAR_GRADIENT_H */ diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 186e927f7..9707c9d8e 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -61,65 +61,60 @@ SPMask::~SPMask() { } void SPMask::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPMask* object = this; - SPObjectGroup::build(doc, repr); - object->readAttr( "maskUnits" ); - object->readAttr( "maskContentUnits" ); + this->readAttr( "maskUnits" ); + this->readAttr( "maskContentUnits" ); /* Register ourselves */ - doc->addResource("mask", object); + doc->addResource("mask", this); } void SPMask::release() { - SPMask* object = this; - - if (object->document) { + if (this->document) { // Unregister ourselves - object->document->removeResource("mask", object); + this->document->removeResource("mask", this); } - SPMask *cp = SP_MASK (object); - while (cp->display) { + while (this->display) { // We simply unref and let item manage this in handler - cp->display = sp_mask_view_list_remove (cp->display, cp->display); + this->display = sp_mask_view_list_remove(this->display, this->display); } SPObjectGroup::release(); } void SPMask::set(unsigned int key, const gchar* value) { - SPMask* object = this; - - SPMask *mask = SP_MASK (object); - switch (key) { case SP_ATTR_MASKUNITS: - mask->maskUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; - mask->maskUnits_set = FALSE; + this->maskUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; + this->maskUnits_set = FALSE; + if (value) { if (!strcmp (value, "userSpaceOnUse")) { - mask->maskUnits = SP_CONTENT_UNITS_USERSPACEONUSE; - mask->maskUnits_set = TRUE; + this->maskUnits = SP_CONTENT_UNITS_USERSPACEONUSE; + this->maskUnits_set = TRUE; } else if (!strcmp (value, "objectBoundingBox")) { - mask->maskUnits_set = TRUE; + this->maskUnits_set = TRUE; } } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_MASKCONTENTUNITS: - mask->maskContentUnits = SP_CONTENT_UNITS_USERSPACEONUSE; - mask->maskContentUnits_set = FALSE; + this->maskContentUnits = SP_CONTENT_UNITS_USERSPACEONUSE; + this->maskContentUnits_set = FALSE; + if (value) { if (!strcmp (value, "userSpaceOnUse")) { - mask->maskContentUnits_set = TRUE; + this->maskContentUnits_set = TRUE; } else if (!strcmp (value, "objectBoundingBox")) { - mask->maskContentUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; - mask->maskContentUnits_set = TRUE; + this->maskContentUnits = SP_CONTENT_UNITS_OBJECTBOUNDINGBOX; + this->maskContentUnits_set = TRUE; } } - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: SPObjectGroup::set(key, value); @@ -128,19 +123,16 @@ void SPMask::set(unsigned int key, const gchar* value) { } void SPMask::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { - SPMask* object = this; - /* Invoke SPObjectGroup implementation */ SPObjectGroup::child_added(child, ref); /* Show new object */ - SPObject *ochild = object->document->getObjectByRepr(child); + SPObject *ochild = this->document->getObjectByRepr(child); + if (SP_IS_ITEM (ochild)) { - SPMask *cp = SP_MASK (object); - for (SPMaskView *v = cp->display; v != NULL; v = v->next) { - Inkscape::DrawingItem *ac = SP_ITEM (ochild)->invoke_show ( v->arenaitem->drawing(), - v->key, - SP_ITEM_REFERENCE_FLAGS); + for (SPMaskView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingItem *ac = SP_ITEM (ochild)->invoke_show(v->arenaitem->drawing(), v->key, SP_ITEM_REFERENCE_FLAGS); + if (ac) { v->arenaitem->prependChild(ac); } @@ -150,34 +142,35 @@ void SPMask::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { void SPMask::update(SPCtx* ctx, unsigned int flags) { - SPMask* object = this; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for (SPObject *child = og->firstChild(); child; child = child->getNext()) { + for (SPObject *child = this->firstChild(); child; child = child->getNext()) { sp_object_ref(child); l = g_slist_prepend (l, child); } + l = g_slist_reverse (l); + while (l) { SPObject *child = SP_OBJECT(l->data); l = g_slist_remove(l, child); + if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } + sp_object_unref(child); } - SPMask *mask = SP_MASK(object); - for (SPMaskView *v = mask->display; v != NULL; v = v->next) { + for (SPMaskView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { + + if (this->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && v->bbox) { Geom::Affine t = Geom::Scale(v->bbox->dimensions()); t.setTranslation(v->bbox->min()); g->setChildTransform(t); @@ -188,27 +181,28 @@ void SPMask::update(SPCtx* ctx, unsigned int flags) { } void SPMask::modified(unsigned int flags) { - SPMask* object = this; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - SPObjectGroup *og = SP_OBJECTGROUP(object); GSList *l = NULL; - for (SPObject *child = og->firstChild(); child; child = child->getNext()) { + for (SPObject *child = this->firstChild(); child; child = child->getNext()) { sp_object_ref(child); l = g_slist_prepend(l, child); } + l = g_slist_reverse(l); + while (l) { SPObject *child = SP_OBJECT(l->data); l = g_slist_remove(l, child); + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); } + sp_object_unref(child); } } @@ -255,47 +249,46 @@ sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTr return mask_id; } -Inkscape::DrawingItem *sp_mask_show(SPMask *mask, Inkscape::Drawing &drawing, unsigned int key) -{ - g_return_val_if_fail (mask != NULL, NULL); - g_return_val_if_fail (SP_IS_MASK (mask), NULL); +Inkscape::DrawingItem *SPMask::sp_mask_show(Inkscape::Drawing &drawing, unsigned int key) { + g_return_val_if_fail (this != NULL, NULL); + g_return_val_if_fail (SP_IS_MASK (this), NULL); Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); - mask->display = sp_mask_view_new_prepend (mask->display, key, ai); + this->display = sp_mask_view_new_prepend (this->display, key, ai); - for ( SPObject *child = mask->firstChild() ; child; child = child->getNext() ) { + for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { if (SP_IS_ITEM (child)) { Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); + if (ac) { ai->prependChild(ac); } } } - if (mask->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && mask->display->bbox) { - Geom::Affine t = Geom::Scale(mask->display->bbox->dimensions()); - t.setTranslation(mask->display->bbox->min()); + if (this->maskContentUnits == SP_CONTENT_UNITS_OBJECTBOUNDINGBOX && this->display->bbox) { + Geom::Affine t = Geom::Scale(this->display->bbox->dimensions()); + t.setTranslation(this->display->bbox->min()); ai->setChildTransform(t); } return ai; } -void sp_mask_hide(SPMask *cp, unsigned int key) -{ - g_return_if_fail (cp != NULL); - g_return_if_fail (SP_IS_MASK (cp)); +void SPMask::sp_mask_hide(unsigned int key) { + g_return_if_fail (this != NULL); + g_return_if_fail (SP_IS_MASK (this)); - for ( SPObject *child = cp->firstChild(); child; child = child->getNext()) { + for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide (key); } } - for (SPMaskView *v = cp->display; v != NULL; v = v->next) { + for (SPMaskView *v = this->display; v != NULL; v = v->next) { if (v->key == key) { /* We simply unref and let item to manage this in handler */ - cp->display = sp_mask_view_list_remove (cp->display, v); + this->display = sp_mask_view_list_remove (this->display, v); return; } } @@ -303,10 +296,8 @@ void sp_mask_hide(SPMask *cp, unsigned int key) g_assert_not_reached (); } -void -sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox) -{ - for (SPMaskView *v = mask->display; v != NULL; v = v->next) { +void SPMask::sp_mask_set_bbox(unsigned int key, Geom::OptRect const &bbox) { + for (SPMaskView *v = this->display; v != NULL; v = v->next) { if (v->key == key) { v->bbox = bbox; break; diff --git a/src/sp-mask.h b/src/sp-mask.h index fe029ab56..a2e97d671 100644 --- a/src/sp-mask.h +++ b/src/sp-mask.h @@ -44,6 +44,12 @@ public: SPMaskView *display; + Inkscape::DrawingItem *sp_mask_show(Inkscape::Drawing &drawing, unsigned int key); + void sp_mask_hide(unsigned int key); + + void sp_mask_set_bbox(unsigned int key, Geom::OptRect const &bbox); + +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); @@ -102,11 +108,6 @@ protected: } }; -Inkscape::DrawingItem *sp_mask_show (SPMask *mask, Inkscape::Drawing &drawing, unsigned int key); -void sp_mask_hide (SPMask *mask, unsigned int key); - -void sp_mask_set_bbox (SPMask *mask, unsigned int key, Geom::OptRect const &bbox); - const gchar *sp_mask_create (GSList *reprs, SPDocument *document, Geom::Affine const* applyTransform); #endif // SEEN_SP_MASK_H diff --git a/src/sp-mesh-gradient.cpp b/src/sp-mesh-gradient.cpp index 2e12a2d32..3fd277f52 100644 --- a/src/sp-mesh-gradient.cpp +++ b/src/sp-mesh-gradient.cpp @@ -86,21 +86,6 @@ Inkscape::XML::Node* SPMeshGradient::write(Inkscape::XML::Document *xml_doc, Ink return repr; } -/** - * Directly set properties of mesh gradient and request modified. - */ -void -sp_meshgradient_set_position(SPMeshGradient *mg, gdouble x, gdouble y) -{ - g_return_if_fail(mg != NULL); - g_return_if_fail(SP_IS_MESHGRADIENT(mg)); - - mg->x.set(SVGLength::NONE, x, x); - mg->y.set(SVGLength::NONE, y, y); - - mg->requestModified(SP_OBJECT_MODIFIED_FLAG); -} - void sp_meshgradient_repr_write(SPMeshGradient *mg) { diff --git a/src/sp-mesh-gradient.h b/src/sp-mesh-gradient.h index bfd1c9c06..a6ab29c09 100644 --- a/src/sp-mesh-gradient.h +++ b/src/sp-mesh-gradient.h @@ -20,10 +20,12 @@ public: SVGLength x; // Upper left corner of mesh SVGLength y; // Upper right corner of mesh + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); + +protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void set(unsigned key, gchar const *value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; #endif /* !SP_MESH_GRADIENT_H */ diff --git a/src/sp-mesh-patch.cpp b/src/sp-mesh-patch.cpp index b4d0e951b..216de8270 100644 --- a/src/sp-mesh-patch.cpp +++ b/src/sp-mesh-patch.cpp @@ -77,11 +77,9 @@ SPMeshPatch::~SPMeshPatch() { } void SPMeshPatch::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPMeshPatch* object = this; - SPObject::build(doc, repr); - object->readAttr( "tensor" ); + this->readAttr( "tensor" ); } /** @@ -89,14 +87,10 @@ void SPMeshPatch::build(SPDocument* doc, Inkscape::XML::Node* repr) { */ void SPMeshPatch::set(unsigned int key, const gchar* value) { - SPMeshPatch* object = this; - - SPMeshPatch *patch = SP_MESHPATCH(object); - switch (key) { case SP_ATTR_TENSOR: { if (value) { - patch->tensor_string = new Glib::ustring( value ); + this->tensor_string = new Glib::ustring( value ); // std::cout << "sp_meshpatch_set: Tensor string: " << patch->tensor_string->c_str() << std::endl; } break; diff --git a/src/sp-mesh-patch.h b/src/sp-mesh-patch.h index 1b8d58df1..34bbb00d8 100644 --- a/src/sp-mesh-patch.h +++ b/src/sp-mesh-patch.h @@ -32,6 +32,7 @@ public: //SVGLength tx[4]; // Tensor points //SVGLength ty[4]; // Tensor points +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); diff --git a/src/sp-mesh-row.h b/src/sp-mesh-row.h index 3d9dd6b99..4f2e8842f 100644 --- a/src/sp-mesh-row.h +++ b/src/sp-mesh-row.h @@ -14,8 +14,6 @@ #include <glib.h> #include "sp-object.h" -class SPObjectClass; - #define SP_MESHROW(obj) ((SPMeshRow*)obj) #define SP_IS_MESHROW(obj) (dynamic_cast<const SPMeshRow*>((SPObject*)obj)) @@ -28,6 +26,7 @@ public: SPMeshRow* getNextMeshRow(); SPMeshRow* getPrevMeshRow(); +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); diff --git a/src/sp-metadata.cpp b/src/sp-metadata.cpp index edb73c9b1..a093107ac 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -44,8 +44,6 @@ namespace { } SPMetadata::SPMetadata() : SPObject() { - (void)this; - debug("0x%08x",(unsigned int)this); } SPMetadata::~SPMetadata() { @@ -69,11 +67,12 @@ void strip_ids_recursively(Inkscape::XML::Node *node) { void SPMetadata::build(SPDocument* doc, Inkscape::XML::Node* repr) { using Inkscape::XML::NodeSiblingIterator; - debug("0x%08x",(unsigned int)object); + debug("0x%08x",(unsigned int)this); /* clean up our mess from earlier versions; elements under rdf:RDF should not * have id= attributes... */ - static GQuark const rdf_root_name=g_quark_from_static_string("rdf:RDF"); + static GQuark const rdf_root_name = g_quark_from_static_string("rdf:RDF"); + for ( NodeSiblingIterator iter=repr->firstChild() ; iter ; ++iter ) { if ( (GQuark)iter->code() == rdf_root_name ) { strip_ids_recursively(iter); @@ -84,7 +83,7 @@ void SPMetadata::build(SPDocument* doc, Inkscape::XML::Node* repr) { } void SPMetadata::release() { - debug("0x%08x",(unsigned int)object); + debug("0x%08x",(unsigned int)this); // handle ourself @@ -92,7 +91,7 @@ void SPMetadata::release() { } void SPMetadata::set(unsigned int key, const gchar* value) { - debug("0x%08x %s(%u): '%s'",(unsigned int)object, + debug("0x%08x %s(%u): '%s'",(unsigned int)this, sp_attribute_name(key),key,value); // see if any parents need this value @@ -100,7 +99,7 @@ void SPMetadata::set(unsigned int key, const gchar* value) { } void SPMetadata::update(SPCtx* ctx, unsigned int flags) { - debug("0x%08x",(unsigned int)object); + debug("0x%08x",(unsigned int)this); //SPMetadata *metadata = SP_METADATA(object); if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | @@ -114,16 +113,13 @@ void SPMetadata::update(SPCtx* ctx, unsigned int flags) { } Inkscape::XML::Node* SPMetadata::write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags) { - SPMetadata* object = this; - - debug("0x%08x",(unsigned int)object); - //SPMetadata *metadata = SP_METADATA(object); + debug("0x%08x",(unsigned int)this); - if ( repr != object->getRepr() ) { + if ( repr != this->getRepr() ) { if (repr) { - repr->mergeFrom(object->getRepr(), "id"); + repr->mergeFrom(this->getRepr(), "id"); } else { - repr = object->getRepr()->duplicate(doc); + repr = this->getRepr()->duplicate(doc); } } diff --git a/src/sp-metadata.h b/src/sp-metadata.h index 02193f1ed..752ced9e3 100644 --- a/src/sp-metadata.h +++ b/src/sp-metadata.h @@ -25,6 +25,7 @@ public: SPMetadata(); virtual ~SPMetadata(); +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index a3b440ab0..06b741165 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -42,15 +42,13 @@ SPMissingGlyph::~SPMissingGlyph() { } void SPMissingGlyph::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPMissingGlyph* object = this; - SPObject::build(doc, repr); - object->readAttr( "d" ); - object->readAttr( "horiz-adv-x" ); - object->readAttr( "vert-origin-x" ); - object->readAttr( "vert-origin-y" ); - object->readAttr( "vert-adv-y" ); + this->readAttr( "d" ); + this->readAttr( "horiz-adv-x" ); + this->readAttr( "vert-origin-x" ); + this->readAttr( "vert-origin-y" ); + this->readAttr( "vert-adv-y" ); } void SPMissingGlyph::release() { @@ -59,53 +57,49 @@ void SPMissingGlyph::release() { void SPMissingGlyph::set(unsigned int key, const gchar* value) { - SPMissingGlyph* object = this; - - SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); - switch (key) { case SP_ATTR_D: { - if (glyph->d) { - g_free(glyph->d); + if (this->d) { + g_free(this->d); } - glyph->d = g_strdup(value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->d = g_strdup(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } case SP_ATTR_HORIZ_ADV_X: { double number = value ? g_ascii_strtod(value, 0) : 0; - if (number != glyph->horiz_adv_x){ - glyph->horiz_adv_x = number; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + if (number != this->horiz_adv_x){ + this->horiz_adv_x = number; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; } case SP_ATTR_VERT_ORIGIN_X: { double number = value ? g_ascii_strtod(value, 0) : 0; - if (number != glyph->vert_origin_x){ - glyph->vert_origin_x = number; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + if (number != this->vert_origin_x){ + this->vert_origin_x = number; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; } case SP_ATTR_VERT_ORIGIN_Y: { double number = value ? g_ascii_strtod(value, 0) : 0; - if (number != glyph->vert_origin_y){ - glyph->vert_origin_y = number; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + if (number != this->vert_origin_y){ + this->vert_origin_y = number; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; } case SP_ATTR_VERT_ADV_Y: { double number = value ? g_ascii_strtod(value, 0) : 0; - if (number != glyph->vert_adv_y){ - glyph->vert_adv_y = number; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + if (number != this->vert_adv_y){ + this->vert_adv_y = number; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; } @@ -120,10 +114,6 @@ void SPMissingGlyph::set(unsigned int key, const gchar* value) { #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); Inkscape::XML::Node* SPMissingGlyph::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { - SPMissingGlyph* object = this; - - // SPMissingGlyph *glyph = SP_MISSING_GLYPH(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:glyph"); } @@ -135,15 +125,16 @@ Inkscape::XML::Node* SPMissingGlyph::write(Inkscape::XML::Document* xml_doc, Ink sp_repr_set_svg_double(repr, "vert-origin-y", glyph->vert_origin_y); sp_repr_set_svg_double(repr, "vert-adv-y", glyph->vert_adv_y); */ - if (repr != object->getRepr()) { + if (repr != this->getRepr()) { + // TODO // All the COPY_ATTR functions below use // XML Tree directly while they shouldn't. - COPY_ATTR(repr, object->getRepr(), "d"); - COPY_ATTR(repr, object->getRepr(), "horiz-adv-x"); - COPY_ATTR(repr, object->getRepr(), "vert-origin-x"); - COPY_ATTR(repr, object->getRepr(), "vert-origin-y"); - COPY_ATTR(repr, object->getRepr(), "vert-adv-y"); + COPY_ATTR(repr, this->getRepr(), "d"); + COPY_ATTR(repr, this->getRepr(), "horiz-adv-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-x"); + COPY_ATTR(repr, this->getRepr(), "vert-origin-y"); + COPY_ATTR(repr, this->getRepr(), "vert-adv-y"); } SPObject::write(xml_doc, repr, flags); diff --git a/src/sp-missing-glyph.h b/src/sp-missing-glyph.h index a9d94b311..368f25943 100644 --- a/src/sp-missing-glyph.h +++ b/src/sp-missing-glyph.h @@ -26,16 +26,19 @@ public: SPMissingGlyph(); virtual ~SPMissingGlyph(); - char* d; - double horiz_adv_x; - double vert_origin_x; - double vert_origin_y; - double vert_adv_y; + char* d; +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); + +private: + double horiz_adv_x; + double vert_origin_x; + double vert_origin_y; + double vert_adv_y; }; #endif //#ifndef __SP_MISSING_GLYPH_H__ diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 576de312f..14cc7669d 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -97,8 +97,6 @@ SPNamedView::SPNamedView() : SPObjectGroup(), snap_manager(this) { this->default_layer_id = 0; this->connector_spacing = defaultConnSpacing; - - //new (&this->snap_manager) SnapManager(this); } SPNamedView::~SPNamedView() { @@ -193,366 +191,352 @@ static void sp_namedview_generate_old_grid(SPNamedView * /*nv*/, SPDocument *doc } void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { - SPNamedView* object = this; - - SPNamedView *nv = (SPNamedView *) object; - SPObjectGroup *og = (SPObjectGroup *) object; - SPObjectGroup::build(document, repr); - object->readAttr( "inkscape:document-units" ); - object->readAttr( "units" ); - object->readAttr( "viewonly" ); - object->readAttr( "showguides" ); - object->readAttr( "showgrid" ); - object->readAttr( "gridtolerance" ); - object->readAttr( "guidetolerance" ); - object->readAttr( "objecttolerance" ); - object->readAttr( "guidecolor" ); - object->readAttr( "guideopacity" ); - object->readAttr( "guidehicolor" ); - object->readAttr( "guidehiopacity" ); - object->readAttr( "showborder" ); - object->readAttr( "inkscape:showpageshadow" ); - object->readAttr( "borderlayer" ); - object->readAttr( "bordercolor" ); - object->readAttr( "borderopacity" ); - object->readAttr( "pagecolor" ); - object->readAttr( "inkscape:pageopacity" ); - object->readAttr( "inkscape:pageshadow" ); - object->readAttr( "inkscape:zoom" ); - object->readAttr( "inkscape:cx" ); - object->readAttr( "inkscape:cy" ); - object->readAttr( "inkscape:window-width" ); - object->readAttr( "inkscape:window-height" ); - object->readAttr( "inkscape:window-x" ); - object->readAttr( "inkscape:window-y" ); - object->readAttr( "inkscape:window-maximized" ); - object->readAttr( "inkscape:snap-global" ); - object->readAttr( "inkscape:snap-bbox" ); - object->readAttr( "inkscape:snap-nodes" ); - object->readAttr( "inkscape:snap-others" ); - object->readAttr( "inkscape:snap-from-guide" ); - object->readAttr( "inkscape:snap-center" ); - object->readAttr( "inkscape:snap-smooth-nodes" ); - object->readAttr( "inkscape:snap-midpoints" ); - object->readAttr( "inkscape:snap-object-midpoints" ); - object->readAttr( "inkscape:snap-text-baseline" ); - object->readAttr( "inkscape:snap-bbox-edge-midpoints" ); - object->readAttr( "inkscape:snap-bbox-midpoints" ); - object->readAttr( "inkscape:snap-to-guides" ); - object->readAttr( "inkscape:snap-grids" ); - object->readAttr( "inkscape:snap-intersection-paths" ); - object->readAttr( "inkscape:object-paths" ); - object->readAttr( "inkscape:snap-perpendicular" ); - object->readAttr( "inkscape:snap-tangential" ); - object->readAttr( "inkscape:snap-path-clip" ); - object->readAttr( "inkscape:snap-path-mask" ); - object->readAttr( "inkscape:object-nodes" ); - object->readAttr( "inkscape:bbox-paths" ); - object->readAttr( "inkscape:bbox-nodes" ); - object->readAttr( "inkscape:snap-page" ); - object->readAttr( "inkscape:current-layer" ); - object->readAttr( "inkscape:connector-spacing" ); + this->readAttr( "inkscape:document-units" ); + this->readAttr( "units" ); + this->readAttr( "viewonly" ); + this->readAttr( "showguides" ); + this->readAttr( "showgrid" ); + this->readAttr( "gridtolerance" ); + this->readAttr( "guidetolerance" ); + this->readAttr( "objecttolerance" ); + this->readAttr( "guidecolor" ); + this->readAttr( "guideopacity" ); + this->readAttr( "guidehicolor" ); + this->readAttr( "guidehiopacity" ); + this->readAttr( "showborder" ); + this->readAttr( "inkscape:showpageshadow" ); + this->readAttr( "borderlayer" ); + this->readAttr( "bordercolor" ); + this->readAttr( "borderopacity" ); + this->readAttr( "pagecolor" ); + this->readAttr( "inkscape:pageopacity" ); + this->readAttr( "inkscape:pageshadow" ); + this->readAttr( "inkscape:zoom" ); + this->readAttr( "inkscape:cx" ); + this->readAttr( "inkscape:cy" ); + this->readAttr( "inkscape:window-width" ); + this->readAttr( "inkscape:window-height" ); + this->readAttr( "inkscape:window-x" ); + this->readAttr( "inkscape:window-y" ); + this->readAttr( "inkscape:window-maximized" ); + this->readAttr( "inkscape:snap-global" ); + this->readAttr( "inkscape:snap-bbox" ); + this->readAttr( "inkscape:snap-nodes" ); + this->readAttr( "inkscape:snap-others" ); + this->readAttr( "inkscape:snap-from-guide" ); + this->readAttr( "inkscape:snap-center" ); + this->readAttr( "inkscape:snap-smooth-nodes" ); + this->readAttr( "inkscape:snap-midpoints" ); + this->readAttr( "inkscape:snap-object-midpoints" ); + this->readAttr( "inkscape:snap-text-baseline" ); + this->readAttr( "inkscape:snap-bbox-edge-midpoints" ); + this->readAttr( "inkscape:snap-bbox-midpoints" ); + this->readAttr( "inkscape:snap-to-guides" ); + this->readAttr( "inkscape:snap-grids" ); + this->readAttr( "inkscape:snap-intersection-paths" ); + this->readAttr( "inkscape:object-paths" ); + this->readAttr( "inkscape:snap-perpendicular" ); + this->readAttr( "inkscape:snap-tangential" ); + this->readAttr( "inkscape:snap-path-clip" ); + this->readAttr( "inkscape:snap-path-mask" ); + this->readAttr( "inkscape:object-nodes" ); + this->readAttr( "inkscape:bbox-paths" ); + this->readAttr( "inkscape:bbox-nodes" ); + this->readAttr( "inkscape:snap-page" ); + this->readAttr( "inkscape:current-layer" ); + this->readAttr( "inkscape:connector-spacing" ); /* Construct guideline list */ - for (SPObject *o = og->firstChild() ; o; o = o->getNext() ) { + for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { if (SP_IS_GUIDE(o)) { SPGuide * g = SP_GUIDE(o); - nv->guides = g_slist_prepend(nv->guides, g); + this->guides = g_slist_prepend(this->guides, g); //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); - g->setColor(nv->guidecolor); - g->setHiColor(nv->guidehicolor); + g->setColor(this->guidecolor); + g->setHiColor(this->guidehicolor); } } // backwards compatibility with grid settings (pre 0.46) - sp_namedview_generate_old_grid(nv, document, repr); + sp_namedview_generate_old_grid(this, document, repr); } void SPNamedView::release() { - SPNamedView* object = this; - SPNamedView *namedview = (SPNamedView *) object; - - if (namedview->guides) { - g_slist_free(namedview->guides); - namedview->guides = NULL; + if (this->guides) { + g_slist_free(this->guides); + this->guides = NULL; } // delete grids: - while ( namedview->grids ) { - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; // get first entry + while ( this->grids ) { + Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)this->grids->data; // get first entry delete gr; - namedview->grids = g_slist_remove_link(namedview->grids, namedview->grids); // deletes first entry + this->grids = g_slist_remove_link(this->grids, this->grids); // deletes first entry } SPObjectGroup::release(); - - //namedview->snap_manager.~SnapManager(); } void SPNamedView::set(unsigned int key, const gchar* value) { - SPNamedView* object = this; - - SPNamedView *nv = SP_NAMEDVIEW(object); - switch (key) { case SP_ATTR_VIEWONLY: - nv->editable = (!value); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->editable = (!value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWGUIDES: if (!value) { // show guides if not specified, for backwards compatibility - nv->showguides = TRUE; + this->showguides = TRUE; } else { - nv->showguides = sp_str_to_bool(value); + this->showguides = sp_str_to_bool(value); } - sp_namedview_setup_guides(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + sp_namedview_setup_guides(this); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWGRIDS: if (!value) { // don't show grids if not specified, for backwards compatibility - nv->grids_visible = false; + this->grids_visible = false; } else { - nv->grids_visible = sp_str_to_bool(value); + this->grids_visible = sp_str_to_bool(value); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GRIDTOLERANCE: - nv->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setGridTolerance(value ? g_ascii_strtod(value, NULL) : 10000); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDETOLERANCE: - nv->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setGuideTolerance(value ? g_ascii_strtod(value, NULL) : 20); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_OBJECTTOLERANCE: - nv->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setObjectTolerance(value ? g_ascii_strtod(value, NULL) : 20); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDECOLOR: - nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); + this->guidecolor = (this->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); if (value) { - nv->guidecolor = (nv->guidecolor & 0xff) | sp_svg_read_color(value, nv->guidecolor); + this->guidecolor = (this->guidecolor & 0xff) | sp_svg_read_color(value, this->guidecolor); } - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(nv->guidecolor); + SP_GUIDE(l->data)->setColor(this->guidecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEOPACITY: - nv->guidecolor = (nv->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); - sp_nv_read_opacity(value, &nv->guidecolor); + this->guidecolor = (this->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); + sp_nv_read_opacity(value, &this->guidecolor); - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(nv->guidecolor); + SP_GUIDE(l->data)->setColor(this->guidecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEHICOLOR: - nv->guidehicolor = (nv->guidehicolor & 0xff) | (DEFAULTGUIDEHICOLOR & 0xffffff00); + this->guidehicolor = (this->guidehicolor & 0xff) | (DEFAULTGUIDEHICOLOR & 0xffffff00); if (value) { - nv->guidehicolor = (nv->guidehicolor & 0xff) | sp_svg_read_color(value, nv->guidehicolor); + this->guidehicolor = (this->guidehicolor & 0xff) | sp_svg_read_color(value, this->guidehicolor); } - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); - SP_GUIDE(l->data)->setHiColor(nv->guidehicolor); + SP_GUIDE(l->data)->setHiColor(this->guidehicolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_GUIDEHIOPACITY: - nv->guidehicolor = (nv->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); - sp_nv_read_opacity(value, &nv->guidehicolor); + this->guidehicolor = (this->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); + sp_nv_read_opacity(value, &this->guidehicolor); - for (GSList *l = nv->guides; l != NULL; l = l->next) { + for (GSList *l = this->guides; l != NULL; l = l->next) { //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); - SP_GUIDE(l->data)->setHiColor(nv->guidehicolor); + SP_GUIDE(l->data)->setHiColor(this->guidehicolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWBORDER: - nv->showborder = (value) ? sp_str_to_bool (value) : TRUE; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->showborder = (value) ? sp_str_to_bool (value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDERLAYER: - nv->borderlayer = SP_BORDER_LAYER_BOTTOM; - if (value && !strcasecmp(value, "true")) nv->borderlayer = SP_BORDER_LAYER_TOP; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->borderlayer = SP_BORDER_LAYER_BOTTOM; + if (value && !strcasecmp(value, "true")) this->borderlayer = SP_BORDER_LAYER_TOP; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDERCOLOR: - nv->bordercolor = (nv->bordercolor & 0xff) | (DEFAULTBORDERCOLOR & 0xffffff00); + this->bordercolor = (this->bordercolor & 0xff) | (DEFAULTBORDERCOLOR & 0xffffff00); if (value) { - nv->bordercolor = (nv->bordercolor & 0xff) | sp_svg_read_color (value, nv->bordercolor); + this->bordercolor = (this->bordercolor & 0xff) | sp_svg_read_color (value, this->bordercolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_BORDEROPACITY: - nv->bordercolor = (nv->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff); - sp_nv_read_opacity(value, &nv->bordercolor); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->bordercolor = (this->bordercolor & 0xffffff00) | (DEFAULTBORDERCOLOR & 0xff); + sp_nv_read_opacity(value, &this->bordercolor); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_PAGECOLOR: - nv->pagecolor = (nv->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00); + this->pagecolor = (this->pagecolor & 0xff) | (DEFAULTPAGECOLOR & 0xffffff00); if (value) { - nv->pagecolor = (nv->pagecolor & 0xff) | sp_svg_read_color(value, nv->pagecolor); + this->pagecolor = (this->pagecolor & 0xff) | sp_svg_read_color(value, this->pagecolor); } - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_PAGEOPACITY: - nv->pagecolor = (nv->pagecolor & 0xffffff00) | (DEFAULTPAGECOLOR & 0xff); - sp_nv_read_opacity(value, &nv->pagecolor); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->pagecolor = (this->pagecolor & 0xffffff00) | (DEFAULTPAGECOLOR & 0xff); + sp_nv_read_opacity(value, &this->pagecolor); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_PAGESHADOW: - nv->pageshadow = value? atoi(value) : 2; // 2 is the default - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->pageshadow = value? atoi(value) : 2; // 2 is the default + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SHOWPAGESHADOW: - nv->showpageshadow = (value) ? sp_str_to_bool(value) : TRUE; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->showpageshadow = (value) ? sp_str_to_bool(value) : TRUE; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_ZOOM: - nv->zoom = value ? g_ascii_strtod(value, NULL) : 0; // zero means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->zoom = value ? g_ascii_strtod(value, NULL) : 0; // zero means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CX: - nv->cx = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->cx = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CY: - nv->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->cy = value ? g_ascii_strtod(value, NULL) : HUGE_VAL; // HUGE_VAL means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_WIDTH: - nv->window_width = value? atoi(value) : -1; // -1 means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_width = value? atoi(value) : -1; // -1 means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_HEIGHT: - nv->window_height = value ? atoi(value) : -1; // -1 means not set - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_height = value ? atoi(value) : -1; // -1 means not set + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_X: - nv->window_x = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_x = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_Y: - nv->window_y = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_y = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_WINDOW_MAXIMIZED: - nv->window_maximized = value ? atoi(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->window_maximized = value ? atoi(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GLOBAL: - nv->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapEnabledGlobally(value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GRID: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GRID, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_GUIDE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_GUIDE, value ? sp_str_to_bool(value) : TRUE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE_SMOOTH: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_SMOOTH, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_LINE_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_LINE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OBJECT_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OBJECT_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TEXT_BASELINE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_TEXT_BASELINE, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_MIDPOINT: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_MIDPOINT, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_INTERSECTION: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_INTERSECTION, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PERP: - nv->snap_manager.snapprefs.setSnapPerp(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapPerp(value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_TANG: - nv->snap_manager.snapprefs.setSnapTang(value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setSnapTang(value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_CLIP: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_CLIP, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PATH_MASK: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PATH_MASK, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE_CUSP: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CUSP, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_EDGE, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_CORNER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CORNER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_PAGE_BORDER: - nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_PAGE_BORDER, value ? sp_str_to_bool(value) : FALSE); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CURRENT_LAYER: - nv->default_layer_id = value ? g_quark_from_string(value) : 0; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->default_layer_id = value ? g_quark_from_string(value) : 0; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_CONNECTOR_SPACING: - nv->connector_spacing = value ? g_ascii_strtod(value, NULL) : + this->connector_spacing = value ? g_ascii_strtod(value, NULL) : defaultConnSpacing; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_DOCUMENT_UNITS: { /* The default unit if the document doesn't override this: e.g. for files saved as @@ -591,8 +575,8 @@ void SPNamedView::set(unsigned int key, const gchar* value) { /* fixme: Don't use g_log (see above). */ } } - nv->doc_units = new_unit; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->doc_units = new_unit; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } case SP_ATTR_UNITS: { @@ -615,8 +599,8 @@ void SPNamedView::set(unsigned int key, const gchar* value) { /* fixme: Don't use g_log (see above). */ } } - nv->units = new_unit; - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->units = new_unit; + this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } default: @@ -667,34 +651,33 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des } void SPNamedView::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPNamedView* object = this; - - SPNamedView *nv = (SPNamedView *) object; - SPObjectGroup::child_added(child, ref); if (!strcmp(child->name(), "inkscape:grid")) { - sp_namedview_add_grid(nv, child, NULL); + sp_namedview_add_grid(this, child, NULL); } else { - SPObject *no = object->document->getObjectByRepr(child); - if ( !SP_IS_OBJECT(no) ) + SPObject *no = this->document->getObjectByRepr(child); + if ( !SP_IS_OBJECT(no) ) { return; + } if (SP_IS_GUIDE(no)) { SPGuide *g = (SPGuide *) no; - nv->guides = g_slist_prepend(nv->guides, g); + this->guides = g_slist_prepend(this->guides, g); - //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); - g->setColor(nv->guidecolor); - g->setHiColor(nv->guidehicolor); + //g_object_set(G_OBJECT(g), "color", this->guidecolor, "hicolor", this->guidehicolor, NULL); + g->setColor(this->guidecolor); + g->setHiColor(this->guidehicolor); - if (nv->editable) { - for (GSList *l = nv->views; l != NULL; l = l->next) { + if (this->editable) { + for (GSList *l = this->views; l != NULL; l = l->next) { g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event); - if (static_cast<SPDesktop*>(l->data)->guides_active) - g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)), - TRUE); - sp_namedview_show_single_guide(SP_GUIDE(g), nv->showguides); + + if (static_cast<SPDesktop*>(l->data)->guides_active) { + g->sensitize(sp_desktop_canvas(static_cast<SPDesktop*> (l->data)), TRUE); + } + + sp_namedview_show_single_guide(SP_GUIDE(g), this->showguides); } } } @@ -702,27 +685,27 @@ void SPNamedView::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *r } void SPNamedView::remove_child(Inkscape::XML::Node *child) { - SPNamedView* object = this; - SPNamedView *nv = (SPNamedView *) object; - if (!strcmp(child->name(), "inkscape:grid")) { - for ( GSList *iter = nv->grids ; iter ; iter = iter->next ) { + for ( GSList *iter = this->grids ; iter ; iter = iter->next ) { Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)iter->data; + if ( gr->repr == child ) { delete gr; - nv->grids = g_slist_remove_link(nv->grids, iter); + this->grids = g_slist_remove_link(this->grids, iter); break; } } } else { - GSList **ref = &nv->guides; - for ( GSList *iter = nv->guides ; iter ; iter = iter->next ) { + GSList **ref = &this->guides; + for ( GSList *iter = this->guides ; iter ; iter = iter->next ) { + if ( reinterpret_cast<SPObject *>(iter->data)->getRepr() == child ) { *ref = iter->next; iter->next = NULL; g_slist_free_1(iter); break; } + ref = &iter->next; } } @@ -731,15 +714,13 @@ void SPNamedView::remove_child(Inkscape::XML::Node *child) { } Inkscape::XML::Node* SPNamedView::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPNamedView* object = this; - if ( ( flags & SP_OBJECT_WRITE_EXT ) && - repr != object->getRepr() ) + repr != this->getRepr() ) { if (repr) { - repr->mergeFrom(object->getRepr(), "id"); + repr->mergeFrom(this->getRepr(), "id"); } else { - repr = object->getRepr()->duplicate(xml_doc); + repr = this->getRepr()->duplicate(xml_doc); } } diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 50ff57278..bf3aa33d3 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -96,7 +96,7 @@ private: double getMarginLength(gchar const * const key,SPUnit const * const margin_units,SPUnit const * const return_units,double const width,double const height,bool const use_width); friend class SPDocument; -public: +protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, gchar const* value); diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index 19b813236..c3967461e 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -23,53 +23,48 @@ SPObjectGroup::~SPObjectGroup() { } void SPObjectGroup::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { - SPObjectGroup* object = this; - SPObject::child_added(child, ref); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } void SPObjectGroup::remove_child(Inkscape::XML::Node *child) { - SPObjectGroup* object = this; - SPObject::remove_child(child); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } void SPObjectGroup::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { - SPObjectGroup* object = this; - SPObject::order_changed(child, old_ref, new_ref); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { - SPObjectGroup* object = this; - if (flags & SP_OBJECT_WRITE_BUILD) { if (!repr) { repr = xml_doc->createElement("svg:g"); } + GSList *l = 0; - for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { + for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + if (crepr) { l = g_slist_prepend(l, crepr); } } + while (l) { repr->addChild(static_cast<Inkscape::XML::Node *>(l->data), NULL); Inkscape::GC::release(static_cast<Inkscape::XML::Node *>(l->data)); l = g_slist_remove(l, l->data); } } else { - for ( SPObject *child = object->firstChild() ; child ; child = child->getNext() ) { + for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { child->updateRepr(flags); } } diff --git a/src/sp-object-group.h b/src/sp-object-group.h index 06249e4ae..a34ef0721 100644 --- a/src/sp-object-group.h +++ b/src/sp-object-group.h @@ -24,6 +24,7 @@ public: SPObjectGroup(); virtual ~SPObjectGroup(); +protected: virtual void child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref); virtual void remove_child(Inkscape::XML::Node* child); diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index 54b39a981..1f32086f7 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -38,43 +38,15 @@ SPPaintServer::SPPaintServer() : SPObject() { SPPaintServer::~SPPaintServer() { } -cairo_pattern_t *sp_paint_server_invoke_create_pattern(SPPaintServer *ps, - cairo_t *ct, - Geom::OptRect const &bbox, - double opacity) -{ - g_return_val_if_fail(ps != NULL, NULL); - g_return_val_if_fail(SP_IS_PAINT_SERVER(ps), NULL); - - cairo_pattern_t *cp = NULL; - - cp = ps->pattern_new(ct, bbox, opacity); - - return cp; -} - -// CPPIFY: make pure virtual -cairo_pattern_t* SPPaintServer::pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) { - //throw; - - // dummy_pattern - cairo_pattern_t *cp = cairo_pattern_create_rgb(1.0, 0.0, 1.0); - return cp; -} - -cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, - cairo_t *ct, - Geom::OptRect const &bbox, - double opacity) -{ - return sp_paint_server_invoke_create_pattern(ps, ct, bbox, opacity); -} - bool SPPaintServer::isSwatch() const { return swatch; } + +// TODO: So a solid brush is a gradient with a swatch and zero stops? +// Should we derive a new class for that? Or at least make this method +// virtual and move it out of the way? bool SPPaintServer::isSolid() const { bool solid = false; diff --git a/src/sp-paint-server.h b/src/sp-paint-server.h index 79d8929c2..9bde0883f 100644 --- a/src/sp-paint-server.h +++ b/src/sp-paint-server.h @@ -28,19 +28,14 @@ public: SPPaintServer(); virtual ~SPPaintServer(); -protected: - bool swatch; -public: - bool isSwatch() const; bool isSolid() const; - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); -}; - - -cairo_pattern_t *sp_paint_server_create_pattern(SPPaintServer *ps, cairo_t *ct, Geom::OptRect const &bbox, double opacity); + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) = 0; +protected: + bool swatch; +}; #endif // SEEN_SP_PAINT_SERVER_H /* diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 1aec904ae..408a57195 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -74,8 +74,6 @@ SPPattern::SPPattern() : SPPaintServer() { this->height.unset(); this->viewBox_set = FALSE; - - //new (&this->modified_connection) sigc::connection(); } SPPattern::~SPPattern() { @@ -111,8 +109,6 @@ void SPPattern::release() { this->ref = NULL; } - //this->modified_connection.~connection(); - SPPaintServer::release(); } diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 78bd1549a..3e33528f8 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -58,12 +58,14 @@ public: sigc::connection modified_connection; + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); + +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); virtual void update(SPCtx* ctx, unsigned int flags); virtual void modified(unsigned int flags); - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; diff --git a/src/sp-radial-gradient.cpp b/src/sp-radial-gradient.cpp index 14f95b060..c8bf5db81 100644 --- a/src/sp-radial-gradient.cpp +++ b/src/sp-radial-gradient.cpp @@ -136,27 +136,6 @@ Inkscape::XML::Node* SPRadialGradient::write(Inkscape::XML::Document *xml_doc, I return repr; } -/** - * Directly set properties of radial gradient and request modified. - */ -void -sp_radialgradient_set_position(SPRadialGradient *rg, - gdouble cx, gdouble cy, gdouble fx, gdouble fy, gdouble r) -{ - g_return_if_fail(rg != NULL); - g_return_if_fail(SP_IS_RADIALGRADIENT(rg)); - - /* fixme: units? (Lauris) */ - rg->cx.set(SVGLength::NONE, cx, cx); - rg->cy.set(SVGLength::NONE, cy, cy); - rg->fx.set(SVGLength::NONE, fx, fx); - rg->fy.set(SVGLength::NONE, fy, fy); - rg->r.set(SVGLength::NONE, r, r); - - rg->requestModified(SP_OBJECT_MODIFIED_FLAG); -} - - cairo_pattern_t* SPRadialGradient::pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) { this->ensureVector(); diff --git a/src/sp-radial-gradient.h b/src/sp-radial-gradient.h index f3daac0a1..7514af2dc 100644 --- a/src/sp-radial-gradient.h +++ b/src/sp-radial-gradient.h @@ -24,10 +24,12 @@ public: SVGLength fx; SVGLength fy; + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); + +protected: virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void set(unsigned key, gchar const *value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); }; #endif /* !SP_RADIAL_GRADIENT_H */ diff --git a/src/sp-script.cpp b/src/sp-script.cpp index 99b57d8e9..158796e51 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -34,14 +34,12 @@ SPScript::~SPScript() { } void SPScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPScript* object = this; - SPObject::build(doc, repr); //Read values of key attributes from XML nodes into object. - object->readAttr( "xlink:href" ); + this->readAttr( "xlink:href" ); - doc->addResource("script", object); + doc->addResource("script", this); } /** @@ -51,11 +49,9 @@ void SPScript::build(SPDocument* doc, Inkscape::XML::Node* repr) { */ void SPScript::release() { - SPScript* object = this; - - if (object->document) { + if (this->document) { // Unregister ourselves - object->document->removeResource("script", object); + this->document->removeResource("script", this); } SPObject::release(); @@ -70,15 +66,14 @@ void SPScript::modified(unsigned int flags) { void SPScript::set(unsigned int key, const gchar* value) { - SPScript* object = this; - - SPScript *scr = SP_SCRIPT(object); - switch (key) { case SP_ATTR_XLINK_HREF: - if (scr->xlinkhref) g_free(scr->xlinkhref); - scr->xlinkhref = g_strdup(value); - object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + if (this->xlinkhref) { + g_free(this->xlinkhref); + } + + this->xlinkhref = g_strdup(value); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; default: SPObject::set(key, value); diff --git a/src/sp-script.h b/src/sp-script.h index 7355cd124..62d6eba7a 100644 --- a/src/sp-script.h +++ b/src/sp-script.h @@ -25,6 +25,7 @@ public: gchar *xlinkhref; +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void release(); virtual void set(unsigned int key, const gchar* value); diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp index a8d81818b..d644a9b4b 100644 --- a/src/sp-stop.cpp +++ b/src/sp-stop.cpp @@ -47,15 +47,13 @@ SPStop::~SPStop() { } void SPStop::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPStop* object = this; - SPObject::build(doc, repr); - object->readAttr( "offset" ); - object->readAttr( "stop-color" ); - object->readAttr( "stop-opacity" ); - object->readAttr( "style" ); - object->readAttr( "path" ); // For mesh + this->readAttr( "offset" ); + this->readAttr( "stop-color" ); + this->readAttr( "stop-opacity" ); + this->readAttr( "style" ); + this->readAttr( "path" ); // For mesh } /** @@ -63,10 +61,6 @@ void SPStop::build(SPDocument* doc, Inkscape::XML::Node* repr) { */ void SPStop::set(unsigned int key, const gchar* value) { - SPStop* object = this; - - SPStop *stop = SP_STOP(object); - switch (key) { case SP_ATTR_STYLE: { /** \todo @@ -80,51 +74,51 @@ void SPStop::set(unsigned int key, const gchar* value) { * stop-color and stop-opacity properties. */ { - gchar const *p = object->getStyleProperty( "stop-color", "black"); + gchar const *p = this->getStyleProperty( "stop-color", "black"); if (streq(p, "currentColor")) { - stop->currentColor = true; + this->currentColor = true; } else { - stop->specified_color = SPStop::readStopColor( p ); + this->specified_color = SPStop::readStopColor( p ); } } { - gchar const *p = object->getStyleProperty( "stop-opacity", "1"); - gdouble opacity = sp_svg_read_percentage(p, stop->opacity); - stop->opacity = opacity; + gchar const *p = this->getStyleProperty( "stop-opacity", "1"); + gdouble opacity = sp_svg_read_percentage(p, this->opacity); + this->opacity = opacity; } - object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; } case SP_PROP_STOP_COLOR: { { - gchar const *p = object->getStyleProperty( "stop-color", "black"); + gchar const *p = this->getStyleProperty( "stop-color", "black"); if (streq(p, "currentColor")) { - stop->currentColor = true; + this->currentColor = true; } else { - stop->currentColor = false; - stop->specified_color = SPStop::readStopColor( p ); + this->currentColor = false; + this->specified_color = SPStop::readStopColor( p ); } } - object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; } case SP_PROP_STOP_OPACITY: { { - gchar const *p = object->getStyleProperty( "stop-opacity", "1"); - gdouble opacity = sp_svg_read_percentage(p, stop->opacity); - stop->opacity = opacity; + gchar const *p = this->getStyleProperty( "stop-opacity", "1"); + gdouble opacity = sp_svg_read_percentage(p, this->opacity); + this->opacity = opacity; } - object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; } case SP_ATTR_OFFSET: { - stop->offset = sp_svg_read_percentage(value, 0.0); - object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + this->offset = sp_svg_read_percentage(value, 0.0); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); break; } case SP_PROP_STOP_PATH: { if (value) { - stop->path_string = new Glib::ustring( value ); + this->path_string = new Glib::ustring( value ); //Geom::PathVector pv = sp_svg_read_pathv(value); //SPCurve *curve = new SPCurve(pv); //if( curve ) { @@ -146,16 +140,12 @@ void SPStop::set(unsigned int key, const gchar* value) { */ Inkscape::XML::Node* SPStop::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { - SPStop* object = this; - - SPStop *stop = SP_STOP(object); - if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:stop"); } - Glib::ustring colorStr = stop->specified_color.toString(); - gfloat opacity = stop->opacity; + Glib::ustring colorStr = this->specified_color.toString(); + gfloat opacity = this->opacity; SPObject::write(xml_doc, repr, flags); @@ -165,7 +155,7 @@ Inkscape::XML::Node* SPStop::write(Inkscape::XML::Document* xml_doc, Inkscape::X Inkscape::CSSOStringStream os; os << "stop-color:"; - if (stop->currentColor) { + if (this->currentColor) { os << "currentColor"; } else { os << colorStr; @@ -174,7 +164,7 @@ Inkscape::XML::Node* SPStop::write(Inkscape::XML::Document* xml_doc, Inkscape::X repr->setAttribute("style", os.str().c_str()); repr->setAttribute("stop-color", NULL); repr->setAttribute("stop-opacity", NULL); - sp_repr_set_css_double(repr, "offset", stop->offset); + sp_repr_set_css_double(repr, "offset", this->offset); /* strictly speaking, offset an SVG <number> rather than a CSS one, but exponents make no sense * for offset proportions. */ @@ -186,8 +176,7 @@ Inkscape::XML::Node* SPStop::write(Inkscape::XML::Document* xml_doc, Inkscape::X */ // A stop might have some non-stop siblings -SPStop* SPStop::getNextStop() -{ +SPStop* SPStop::getNextStop() { SPStop *result = 0; for (SPObject* obj = getNext(); obj && !result; obj = obj->getNext()) { @@ -199,8 +188,7 @@ SPStop* SPStop::getNextStop() return result; } -SPStop* SPStop::getPrevStop() -{ +SPStop* SPStop::getPrevStop() { SPStop *result = 0; for (SPObject* obj = getPrev(); obj; obj = obj->getPrev()) { @@ -220,22 +208,24 @@ SPStop* SPStop::getPrevStop() return result; } -SPColor SPStop::readStopColor( Glib::ustring const &styleStr, guint32 dfl ) -{ +SPColor SPStop::readStopColor(Glib::ustring const &styleStr, guint32 dfl) { SPColor color(dfl); SPStyle* style = sp_style_new(0); SPIPaint paint; paint.read( styleStr.c_str(), *style ); + if ( paint.isColor() ) { color = paint.value.color; } + sp_style_unref(style); + return color; } -SPColor SPStop::getEffectiveColor() const -{ +SPColor SPStop::getEffectiveColor() const { SPColor ret; + if (currentColor) { char const *str = getStyleProperty("color", NULL); /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial @@ -245,30 +235,33 @@ SPColor SPStop::getEffectiveColor() const } else { ret = specified_color; } + return ret; } /** * Return stop's color as 32bit value. */ -guint32 -sp_stop_get_rgba32(SPStop const *const stop) -{ +guint32 SPStop::get_rgba32() const { guint32 rgb0 = 0; + /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial * value depends on user agent, and don't give any further restrictions that I can * see.) */ - if (stop->currentColor) { - char const *str = stop->getStyleProperty( "color", NULL); + if (this->currentColor) { + char const *str = this->getStyleProperty("color", NULL); + if (str) { rgb0 = sp_svg_read_color(str, rgb0); } - unsigned const alpha = static_cast<unsigned>(stop->opacity * 0xff + 0.5); - g_return_val_if_fail((alpha & ~0xff) == 0, - rgb0 | 0xff); + + unsigned const alpha = static_cast<unsigned>(this->opacity * 0xff + 0.5); + + g_return_val_if_fail((alpha & ~0xff) == 0, rgb0 | 0xff); + return rgb0 | alpha; } else { - return stop->specified_color.toRGBA32( stop->opacity ); + return this->specified_color.toRGBA32(this->opacity); } } diff --git a/src/sp-stop.h b/src/sp-stop.h index 3b09b4c7d..17b156e31 100644 --- a/src/sp-stop.h +++ b/src/sp-stop.h @@ -49,15 +49,15 @@ public: SPColor getEffectiveColor() const; + guint32 get_rgba32() const; + +protected: virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); virtual void set(unsigned int key, const gchar* value); virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags); }; -guint32 sp_stop_get_rgba32(SPStop const *); - - #endif /* !SEEN_SP_STOP_H */ /* diff --git a/src/spray-context.cpp b/src/spray-context.cpp index 8256d6861..51fdab6ff 100644 --- a/src/spray-context.cpp +++ b/src/spray-context.cpp @@ -178,13 +178,10 @@ static bool is_transform_modes(gint mode) mode == SPRAY_OPTION); } -static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) -{ - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - SPDesktop *desktop = event_context->desktop; - +void SPSprayContext::update_cursor(bool /*with_shift*/) { guint num = 0; gchar *sel_message = NULL; + if (!desktop->selection->isEmpty()) { num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList())); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); @@ -192,22 +189,22 @@ static void sp_spray_update_cursor(SPSprayContext *tc, bool /*with_shift*/) sel_message = g_strdup_printf(_("<b>Nothing</b> selected")); } + switch (this->mode) { + case SPRAY_MODE_COPY: + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>copies</b> of the initial selection."), sel_message); + break; + case SPRAY_MODE_CLONE: + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>clones</b> of the initial selection."), sel_message); + break; + case SPRAY_MODE_SINGLE_PATH: + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a <b>single path</b> of the initial selection."), sel_message); + break; + default: + break; + } - switch (tc->mode) { - case SPRAY_MODE_COPY: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>copies</b> of the initial selection."), sel_message); - break; - case SPRAY_MODE_CLONE: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>clones</b> of the initial selection."), sel_message); - break; - case SPRAY_MODE_SINGLE_PATH: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a <b>single path</b> of the initial selection."), sel_message); - break; - default: - break; - } - event_context->sp_event_context_update_cursor(); - g_free(sel_message); + this->sp_event_context_update_cursor(); + g_free(sel_message); } void SPSprayContext::setup() { @@ -260,7 +257,7 @@ void SPSprayContext::set(const Inkscape::Preferences::Entry& val) { if (path == "mode") { this->mode = val.getInt(); - sp_spray_update_cursor(this, false); + this->update_cursor(false); } else if (path == "width") { this->width = 0.01 * CLAMP(val.getInt(10), 1, 100); } else if (path == "usepressure") { @@ -585,7 +582,7 @@ static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift) SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); // need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; - sp_spray_update_cursor(tc, with_shift); + tc->update_cursor(with_shift); } bool SPSprayContext::root_handler(GdkEvent* event) { @@ -824,7 +821,7 @@ bool SPSprayContext::root_handler(GdkEvent* event) { break; case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_spray_update_cursor(this, true); + this->update_cursor(true); break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: @@ -845,7 +842,7 @@ bool SPSprayContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_spray_update_cursor(this, false); + this->update_cursor(false); break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: diff --git a/src/spray-context.h b/src/spray-context.h index a3bcb93de..796f094cd 100644 --- a/src/spray-context.h +++ b/src/spray-context.h @@ -93,6 +93,9 @@ public: virtual bool root_handler(GdkEvent* event); virtual const std::string& getPrefsPath(); + + + void update_cursor(bool /*with_shift*/); }; #endif diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 3afdc177c..2171ecbe4 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -160,14 +160,10 @@ static bool is_color_mode (gint mode) return (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER || mode == TWEAK_MODE_BLUR); } -static void -sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) -{ - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - SPDesktop *desktop = event_context->desktop; - +void SPTweakContext::update_cursor (bool with_shift) { guint num = 0; gchar *sel_message = NULL; + if (!desktop->selection->isEmpty()) { num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList())); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); @@ -175,85 +171,86 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) sel_message = g_strdup_printf(_("<b>Nothing</b> selected")); } - switch (tc->mode) { + switch (this->mode) { case TWEAK_MODE_MOVE: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); + this->cursor_shape = cursor_tweak_move_xpm; break; case TWEAK_MODE_MOVE_IN_OUT: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_move_out_xpm; + this->cursor_shape = cursor_tweak_move_out_xpm; } else { - event_context->cursor_shape = cursor_tweak_move_in_xpm; + this->cursor_shape = cursor_tweak_move_in_xpm; } break; case TWEAK_MODE_MOVE_JITTER: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_jitter_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); + this->cursor_shape = cursor_tweak_move_jitter_xpm; break; case TWEAK_MODE_SCALE: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_scale_up_xpm; + this->cursor_shape = cursor_tweak_scale_up_xpm; } else { - event_context->cursor_shape = cursor_tweak_scale_down_xpm; + this->cursor_shape = cursor_tweak_scale_down_xpm; } break; case TWEAK_MODE_ROTATE: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; + this->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; } else { - event_context->cursor_shape = cursor_tweak_rotate_clockwise_xpm; + this->cursor_shape = cursor_tweak_rotate_clockwise_xpm; } break; case TWEAK_MODE_MORELESS: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_less_xpm; + this->cursor_shape = cursor_tweak_less_xpm; } else { - event_context->cursor_shape = cursor_tweak_more_xpm; + this->cursor_shape = cursor_tweak_more_xpm; } break; case TWEAK_MODE_PUSH: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); - event_context->cursor_shape = cursor_push_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); + this->cursor_shape = cursor_push_xpm; break; case TWEAK_MODE_SHRINK_GROW: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_thicken_xpm; + this->cursor_shape = cursor_thicken_xpm; } else { - event_context->cursor_shape = cursor_thin_xpm; + this->cursor_shape = cursor_thin_xpm; } break; case TWEAK_MODE_ATTRACT_REPEL: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_repel_xpm; + this->cursor_shape = cursor_repel_xpm; } else { - event_context->cursor_shape = cursor_attract_xpm; + this->cursor_shape = cursor_attract_xpm; } break; case TWEAK_MODE_ROUGHEN: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); - event_context->cursor_shape = cursor_roughen_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); + this->cursor_shape = cursor_roughen_xpm; break; case TWEAK_MODE_COLORPAINT: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); + this->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_COLORJITTER: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); + this->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_BLUR: - tc->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); + this->cursor_shape = cursor_color_xpm; break; } - event_context->sp_event_context_update_cursor(); + + this->sp_event_context_update_cursor(); g_free(sel_message); } @@ -322,7 +319,7 @@ void SPTweakContext::set(const Inkscape::Preferences::Entry& val) { this->width = CLAMP(val.getDouble(0.1), -1000.0, 1000.0); } else if (path == "mode") { this->mode = val.getInt(); - sp_tweak_update_cursor(this, false); + this->update_cursor(false); } else if (path == "fidelity") { this->fidelity = CLAMP(val.getDouble(), 0.0, 1.0); } else if (path == "force") { @@ -1130,7 +1127,7 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift) SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode); // need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; - sp_tweak_update_cursor (tc, with_shift); + tc->update_cursor(with_shift); } static void @@ -1144,7 +1141,7 @@ sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift prefs->setInt("/tools/tweak/mode", now_mode); // changing prefs changed tc->mode, restore back :) tc->mode = mode; - sp_tweak_update_cursor (tc, with_shift); + tc->update_cursor(with_shift); } bool SPTweakContext::root_handler(GdkEvent* event) { @@ -1463,7 +1460,7 @@ bool SPTweakContext::root_handler(GdkEvent* event) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_tweak_update_cursor(this, true); + this->update_cursor(true); break; case GDK_KEY_Control_L: @@ -1486,7 +1483,7 @@ bool SPTweakContext::root_handler(GdkEvent* event) { switch (get_group0_keyval(&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_tweak_update_cursor(this, false); + this->update_cursor(false); break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: diff --git a/src/tweak-context.h b/src/tweak-context.h index ac046a875..da1a50a79 100644 --- a/src/tweak-context.h +++ b/src/tweak-context.h @@ -78,6 +78,8 @@ public: virtual const std::string& getPrefsPath(); + void update_cursor(bool with_shift); + private: bool set_style(const SPCSSAttr* css); }; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index ecb9df4c4..4249591f0 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -800,7 +800,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S if (SP_IS_STOP(sl->data)){ SPStop *stop = SP_STOP(sl->data); Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr(); - Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop))); + Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); GdkPixbuf *pb = cpv->toPixbuf(32, 16); Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25); diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 118d8a68a..e9fc426f6 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -369,7 +369,7 @@ static void sp_gvs_rebuild_gui_full(SPGradientVectorSelector *gvs) unsigned long sp_gradient_to_hhssll(SPGradient *gr) { SPStop *stop = gr->getFirstStop(); - unsigned long rgba = sp_stop_get_rgba32(stop); + unsigned long rgba = stop->get_rgba32(); float hsl[3]; sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_B_F(rgba)); @@ -635,7 +635,7 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s if (SP_IS_STOP(sl->data)){ SPStop *stop = SP_STOP(sl->data); Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr(); - Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop))); + Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); GdkPixbuf *pb = cpv->toPixbuf(64, 16); gtk_list_store_append (store, &iter); @@ -791,8 +791,8 @@ static void sp_grd_ed_add_stop(GtkWidget */*widget*/, GtkWidget *vb) newstop->offset = (stop->offset + next->offset) * 0.5 ; - guint32 const c1 = sp_stop_get_rgba32(stop); - guint32 const c2 = sp_stop_get_rgba32(next); + guint32 const c1 = stop->get_rgba32(); + guint32 const c2 = next->get_rgba32(); guint32 cnew = sp_average_color(c1, c2); Inkscape::CSSOStringStream os; @@ -1315,7 +1315,7 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GObject *obj if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX(combo_box), &iter)) { GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combo_box))); - Inkscape::UI::Widget::ColorPreview *cp = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop))); + Inkscape::UI::Widget::ColorPreview *cp = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); GdkPixbuf *pb = cp->toPixbuf(64, 16); gtk_list_store_set (store, &iter, 0, pb, /*1, repr->attribute("id"),*/ 2, stop, -1); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 0a5b3781b..fc3477471 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -762,7 +762,7 @@ StrokeStyle::getItemColorForMarker(SPItem *item, Inkscape::PaintTarget fill_or_s stop = sp_last_stop(vector); } if (stop) { - guint32 const c1 = sp_stop_get_rgba32(stop); + guint32 const c1 = stop->get_rgba32(); gchar c[64]; sp_svg_write_color(c, sizeof(c), c1); color = g_strdup(c); diff --git a/src/widgets/swatch-selector.cpp b/src/widgets/swatch-selector.cpp index ad59e0dc3..7178ad072 100644 --- a/src/widgets/swatch-selector.cpp +++ b/src/widgets/swatch-selector.cpp @@ -172,7 +172,7 @@ void SwatchSelector::setVector(SPDocument */*doc*/, SPGradient *vector) if ( vector && vector->isSolid() ) { SPStop* stop = vector->getFirstStop(); - guint32 const colorVal = sp_stop_get_rgba32(stop); + guint32 const colorVal = stop->get_rgba32(); _csel->base->setAlpha(SP_RGBA32_A_F(colorVal)); SPColor color( SP_RGBA32_R_F(colorVal), SP_RGBA32_G_F(colorVal), SP_RGBA32_B_F(colorVal) ); // set its color, from the stored array |
