From 732214b111f2e830a8a0b654a88b087766be9067 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 30 Mar 2013 00:46:09 +0100 Subject: Added "virtual pads" for - ColorProfile - LivePathEffectObject - Persp3D (bzr r11608.1.51) --- src/live_effects/lpeobject.cpp | 143 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 133 insertions(+), 10 deletions(-) (limited to 'src/live_effects/lpeobject.cpp') diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 052202e44..e9801fc11 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -73,6 +73,13 @@ LivePathEffectObject::livepatheffect_class_init(LivePathEffectObjectClass *klass sp_object_class->write = livepatheffect_write; } +CLivePathEffectObject::CLivePathEffectObject(LivePathEffectObject* lpeo) : CObject(lpeo) { + this->livepatheffectobject = lpeo; +} + +CLivePathEffectObject::~CLivePathEffectObject() { +} + /** * Callback to initialize livepatheffect object. */ @@ -82,6 +89,10 @@ LivePathEffectObject::livepatheffect_init(LivePathEffectObject *lpeobj) #ifdef LIVEPATHEFFECT_VERBOSE g_message("Init livepatheffectobject"); #endif + + lpeobj->clivepatheffectobject = new CLivePathEffectObject(lpeobj); + lpeobj->cobject = lpeobj->clivepatheffectobject; + lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; lpeobj->lpe = NULL; @@ -97,12 +108,30 @@ LivePathEffectObject::livepatheffect_build(SPObject *object, SPDocument *documen #ifdef LIVEPATHEFFECT_VERBOSE g_message("Build livepatheffect"); #endif +// g_assert(object != NULL); +// g_assert(SP_IS_OBJECT(object)); +// +//// if (((SPObjectClass *) livepatheffect_parent_class)->build) +//// (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); +// +// object->readAttr( "effect" ); +// +// if (repr) { +// repr->addListener (&livepatheffect_repr_events, object); +// } +// +// /* Register ourselves, is this necessary? */ +//// document->addResource("path-effect", object); + ((LivePathEffectObject*)object)->clivepatheffectobject->onBuild(document, repr); +} + +void CLivePathEffectObject::onBuild(SPDocument *document, Inkscape::XML::Node *repr) { + LivePathEffectObject* object = this->livepatheffectobject; + g_assert(object != NULL); g_assert(SP_IS_OBJECT(object)); -// if (((SPObjectClass *) livepatheffect_parent_class)->build) -// (* ((SPObjectClass *) livepatheffect_parent_class)->build)(object, document, repr); -// CPPIFY: todo + CObject::onBuild(document, repr); object->readAttr( "effect" ); @@ -124,6 +153,42 @@ LivePathEffectObject::livepatheffect_release(SPObject *object) g_print("Releasing livepatheffect"); #endif +// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); +// +// object->getRepr()->removeListenerByData(object); +// +// +///* +// if (object->document) { +// // Unregister ourselves +// sp_document_removeResource(object->document, "livepatheffect", object); +// } +// +// if (gradient->ref) { +// gradient->modified_connection.disconnect(); +// gradient->ref->detach(); +// delete gradient->ref; +// gradient->ref = NULL; +// } +// +// gradient->modified_connection.~connection(); +// +//*/ +// +// if (lpeobj->lpe) { +// delete lpeobj->lpe; +// lpeobj->lpe = NULL; +// } +// lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; +// +// if (((SPObjectClass *) livepatheffect_parent_class)->release) +// ((SPObjectClass *) livepatheffect_parent_class)->release(object); + ((LivePathEffectObject*)object)->clivepatheffectobject->onRelease(); +} + +void CLivePathEffectObject::onRelease() { + LivePathEffectObject* object = this->livepatheffectobject; + LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); object->getRepr()->removeListenerByData(object); @@ -152,8 +217,9 @@ LivePathEffectObject::livepatheffect_release(SPObject *object) } lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; - if (((SPObjectClass *) livepatheffect_parent_class)->release) - ((SPObjectClass *) livepatheffect_parent_class)->release(object); +// if (((SPObjectClass *) livepatheffect_parent_class)->release) +// ((SPObjectClass *) livepatheffect_parent_class)->release(object); + CObject::onRelease(); } /** @@ -162,6 +228,38 @@ LivePathEffectObject::livepatheffect_release(SPObject *object) void LivePathEffectObject::livepatheffect_set(SPObject *object, unsigned key, gchar const *value) { +// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); +//#ifdef LIVEPATHEFFECT_VERBOSE +// g_print("Set livepatheffect"); +//#endif +// switch (key) { +// case SP_PROP_PATH_EFFECT: +// if (lpeobj->lpe) { +// delete lpeobj->lpe; +// lpeobj->lpe = NULL; +// } +// +// if ( value && Inkscape::LivePathEffect::LPETypeConverter.is_valid_key(value) ) { +// lpeobj->effecttype = Inkscape::LivePathEffect::LPETypeConverter.get_id_from_key(value); +// lpeobj->lpe = Inkscape::LivePathEffect::Effect::New(lpeobj->effecttype, lpeobj); +// lpeobj->effecttype_set = true; +// } else { +// lpeobj->effecttype = Inkscape::LivePathEffect::INVALID_LPE; +// lpeobj->effecttype_set = false; +// } +// object->requestModified(SP_OBJECT_MODIFIED_FLAG); +// break; +// } +// +// if (((SPObjectClass *) livepatheffect_parent_class)->set) { +// ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value); +// } + ((LivePathEffectObject*)object)->clivepatheffectobject->onSet(key, value); +} + +void CLivePathEffectObject::onSet(unsigned key, gchar const *value) { + LivePathEffectObject* object = this->livepatheffectobject; + LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); #ifdef LIVEPATHEFFECT_VERBOSE g_print("Set livepatheffect"); @@ -185,9 +283,10 @@ LivePathEffectObject::livepatheffect_set(SPObject *object, unsigned key, gchar c break; } - if (((SPObjectClass *) livepatheffect_parent_class)->set) { - ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value); - } +// if (((SPObjectClass *) livepatheffect_parent_class)->set) { +// ((SPObjectClass *) livepatheffect_parent_class)->set(object, key, value); +// } + CObject::onSet(key, value); } /** @@ -200,6 +299,28 @@ LivePathEffectObject::livepatheffect_write(SPObject *object, Inkscape::XML::Docu g_print("Write livepatheffect"); #endif +// LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); +// +// if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { +// repr = xml_doc->createElement("inkscape:path-effect"); +// } +// +// if ((flags & SP_OBJECT_WRITE_ALL) || lpeobj->lpe) { +// repr->setAttribute("effect", Inkscape::LivePathEffect::LPETypeConverter.get_key(lpeobj->effecttype).c_str()); +// +// lpeobj->lpe->writeParamsToSVG(); +// } +// +// if (((SPObjectClass *) livepatheffect_parent_class)->write) +// (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags); +// +// return repr; + return ((LivePathEffectObject*)object)->clivepatheffectobject->onWrite(xml_doc, repr, flags); +} + +Inkscape::XML::Node* CLivePathEffectObject::onWrite(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + LivePathEffectObject* object = this->livepatheffectobject; + LivePathEffectObject *lpeobj = LIVEPATHEFFECT(object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { @@ -212,8 +333,10 @@ LivePathEffectObject::livepatheffect_write(SPObject *object, Inkscape::XML::Docu lpeobj->lpe->writeParamsToSVG(); } - if (((SPObjectClass *) livepatheffect_parent_class)->write) - (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags); +// if (((SPObjectClass *) livepatheffect_parent_class)->write) +// (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags); + + CObject::onWrite(xml_doc, repr, flags); return repr; } -- cgit v1.2.3