summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/livepatheffect-editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog/livepatheffect-editor.cpp')
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp127
1 files changed, 67 insertions, 60 deletions
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 9a569725c..eb3857ee7 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -295,9 +295,8 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
if ( item ) {
- if ( SP_IS_LPE_ITEM(item) ) {
- SPLPEItem *lpeitem = SP_LPE_ITEM(item);
-
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
effect_list_reload(lpeitem);
current_lpeitem = lpeitem;
@@ -318,25 +317,28 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
button_up.set_sensitive(false);
button_down.set_sensitive(false);
}
- } else if ( SP_IS_USE(item) ) {
- // test whether linked object is supported by the CLONE_ORIGINAL LPE
- SPItem *orig = SP_USE(item)->get_original();
- if ( SP_IS_SHAPE(orig) ||
- SP_IS_TEXT(orig) )
- {
- // Note that an SP_USE cannot have an LPE applied, so we only need to worry about the "add effect" case.
- set_sensitize_all(true);
- showText(_("Click add button to convert clone"));
- button_remove.set_sensitive(false);
- button_up.set_sensitive(false);
- button_down.set_sensitive(false);
+ } else {
+ SPUse *use = dynamic_cast<SPUse *>(item);
+ if ( use ) {
+ // test whether linked object is supported by the CLONE_ORIGINAL LPE
+ SPItem *orig = use->get_original();
+ if ( dynamic_cast<SPShape *>(orig) ||
+ dynamic_cast<SPText *>(orig) )
+ {
+ // Note that an SP_USE cannot have an LPE applied, so we only need to worry about the "add effect" case.
+ set_sensitize_all(true);
+ showText(_("Click add button to convert clone"));
+ button_remove.set_sensitive(false);
+ button_up.set_sensitive(false);
+ button_down.set_sensitive(false);
+ } else {
+ showText(_("Select a path or shape"));
+ set_sensitize_all(false);
+ }
} else {
showText(_("Select a path or shape"));
set_sensitize_all(false);
}
- } else {
- showText(_("Select a path or shape"));
- set_sensitize_all(false);
}
} else {
showText(_("Only one item can be selected"));
@@ -423,7 +425,7 @@ LivePathEffectEditor::onAdd()
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
if (item) {
- if ( SP_IS_LPE_ITEM(item) ) {
+ if ( dynamic_cast<SPLPEItem *>(item) ) {
// show effectlist dialog
using Inkscape::UI::Dialog::LivePathEffectAdd;
LivePathEffectAdd::show(current_desktop);
@@ -439,7 +441,7 @@ LivePathEffectEditor::onAdd()
}
// If item is a SPRect, convert it to path first:
- if ( SP_IS_RECT(item) ) {
+ if ( dynamic_cast<SPRect *>(item) ) {
sp_selected_path_to_curves(sel, current_desktop, false);
item = sel->singleItem(); // get new item
}
@@ -451,41 +453,43 @@ LivePathEffectEditor::onAdd()
lpe_list_locked = false;
onSelectionChanged(sel);
- }
- else if ( SP_IS_USE(item) ) {
- // item is a clone. do not show effectlist dialog.
- // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path
-
- // test whether linked object is supported by the CLONE_ORIGINAL LPE
- SPItem *orig = SP_USE(item)->get_original();
- if ( SP_IS_SHAPE(orig) ||
- SP_IS_TEXT(orig) )
- {
- // select original
- sel->set(orig);
-
- // delete clone but remember its id and transform
- gchar *id = g_strdup(item->getRepr()->attribute("id"));
- gchar *transform = g_strdup(item->getRepr()->attribute("transform"));
- item->deleteObject(false);
- item = NULL;
-
- // run sp_selection_clone_original_path_lpe
- sp_selection_clone_original_path_lpe(current_desktop);
- SPItem *new_item = sel->singleItem();
- new_item->getRepr()->setAttribute("id", id);
- new_item->getRepr()->setAttribute("transform", transform);
- g_free(id);
- g_free(transform);
-
- /// \todo Add the LPE stack of the original path?
-
- SPDocument *doc = current_desktop->doc();
- DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
- _("Create and apply Clone original path effect"));
-
- lpe_list_locked = false;
- onSelectionChanged(sel);
+ } else {
+ SPUse *use = dynamic_cast<SPUse *>(item);
+ if ( use ) {
+ // item is a clone. do not show effectlist dialog.
+ // convert to path, apply CLONE_ORIGINAL LPE, link it to the cloned path
+
+ // test whether linked object is supported by the CLONE_ORIGINAL LPE
+ SPItem *orig = use->get_original();
+ if ( dynamic_cast<SPShape *>(orig) ||
+ dynamic_cast<SPText *>(orig) )
+ {
+ // select original
+ sel->set(orig);
+
+ // delete clone but remember its id and transform
+ gchar *id = g_strdup(item->getRepr()->attribute("id"));
+ gchar *transform = g_strdup(item->getRepr()->attribute("transform"));
+ item->deleteObject(false);
+ item = NULL;
+
+ // run sp_selection_clone_original_path_lpe
+ sp_selection_clone_original_path_lpe(current_desktop);
+ SPItem *new_item = sel->singleItem();
+ new_item->getRepr()->setAttribute("id", id);
+ new_item->getRepr()->setAttribute("transform", transform);
+ g_free(id);
+ g_free(transform);
+
+ /// \todo Add the LPE stack of the original path?
+
+ SPDocument *doc = current_desktop->doc();
+ DocumentUndo::done(doc, SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Create and apply Clone original path effect"));
+
+ lpe_list_locked = false;
+ onSelectionChanged(sel);
+ }
}
}
}
@@ -498,13 +502,14 @@ LivePathEffectEditor::onRemove()
Inkscape::Selection *sel = _getSelection();
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
- if ( item && SP_IS_LPE_ITEM(item) ) {
- SP_LPE_ITEM(item)->removeCurrentPathEffect(false);
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
+ lpeitem->removeCurrentPathEffect(false);
DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Remove path effect") );
- effect_list_reload(SP_LPE_ITEM(item));
+ effect_list_reload(lpeitem);
}
}
@@ -515,7 +520,8 @@ void LivePathEffectEditor::onUp()
Inkscape::Selection *sel = _getSelection();
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
- if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) {
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
lpeitem->upCurrentPathEffect();
DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
@@ -531,7 +537,8 @@ void LivePathEffectEditor::onDown()
Inkscape::Selection *sel = _getSelection();
if ( sel && !sel->isEmpty() ) {
SPItem *item = sel->singleItem();
- if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) {
+ SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
+ if ( lpeitem ) {
lpeitem->downCurrentPathEffect();
DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT,