index 851fc3a3bf9780828aceef86cafe852a00bcd538..d4bc26c5d08a68879f9d9ae2a555ecced6bb3384 100644 (file)
GSList *clipboard = NULL;
GSList *defs_clipboard = NULL;
SPCSSAttr *style_clipboard = NULL;
+NR::Rect size_clipboard(NR::Point(0,0), NR::Point(0,0));
static void sp_copy_stuff_used_by_item(GSList **defs_clip, SPItem *item, const GSList *items);
g_return_if_fail(SP_IS_GROUP(dt->currentLayer()));
- bool inlayer = prefs_get_int_attribute ("options.kbselection", "inlayer", 1);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
exclude = selection->itemList();
}
- if (inlayer && !force_all_layers) {
+ if (force_all_layers)
+ inlayer = PREFS_SELECTION_ALL;
+ switch (inlayer) {
+ case PREFS_SELECTION_LAYER: {
if ( (onlysensitive && SP_ITEM(dt->currentLayer())->isLocked()) ||
(onlyvisible && dt->itemIsHidden(SP_ITEM(dt->currentLayer()))) )
return;
}
g_slist_free (all_items);
-
- } else {
+ break;
+ }
+ case PREFS_SELECTION_LAYER_RECURSIVE: {
+ items = get_all_items (NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, exclude);
+ break;
+ }
+ default: {
items = get_all_items (NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, exclude);
+ break;
+ }
}
selection->setList (items);
g_free (query);
}
+ size_clipboard = selection->bounds();
+
g_slist_free ((GSList *) items);
}
sp_document_done(SP_DT_DOCUMENT (desktop));
}
+void sp_selection_paste_size (bool apply_x, bool apply_y)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop == NULL) return;
+
+ Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+
+ // check if something is in the clipboard
+ if (size_clipboard.extent(NR::X) < 1e-6 || size_clipboard.extent(NR::Y) < 1e-6) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ // check if something is selected
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to paste size to."));
+ return;
+ }
+
+ NR::Rect current = selection->bounds();
+ if (current.extent(NR::X) < 1e-6 || current.extent(NR::Y) < 1e-6) {
+ return;
+ }
+
+ double scale_x = size_clipboard.extent(NR::X) / current.extent(NR::X);
+ double scale_y = size_clipboard.extent(NR::Y) / current.extent(NR::Y);
+
+ sp_selection_scale_relative (selection, current.midpoint(),
+ NR::scale(
+ apply_x? scale_x : (desktop->isToolboxButtonActive ("lock")? scale_y : 1.0),
+ apply_y? scale_y : (desktop->isToolboxButtonActive ("lock")? scale_x : 1.0)));
+
+ sp_document_done(SP_DT_DOCUMENT (desktop));
+}
+
+void sp_selection_paste_size_separately (bool apply_x, bool apply_y)
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop == NULL) return;
+
+ Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+
+ // check if something is in the clipboard
+ if (size_clipboard.extent(NR::X) < 1e-6 || size_clipboard.extent(NR::Y) < 1e-6) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ // check if something is selected
+ if (selection->isEmpty()) {
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to paste size to."));
+ return;
+ }
+
+ for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
+ SPItem *item = SP_ITEM(l->data);
+
+ NR::Rect current = sp_item_bbox_desktop(item);
+ if (current.extent(NR::X) < 1e-6 || current.extent(NR::Y) < 1e-6) {
+ continue;
+ }
+
+ double scale_x = size_clipboard.extent(NR::X) / current.extent(NR::X);
+ double scale_y = size_clipboard.extent(NR::Y) / current.extent(NR::Y);
+
+ sp_item_scale_rel (item,
+ NR::scale(
+ apply_x? scale_x : (desktop->isToolboxButtonActive ("lock")? scale_y : 1.0),
+ apply_y? scale_y : (desktop->isToolboxButtonActive ("lock")? scale_x : 1.0)));
+
+ }
+
+ sp_document_done(SP_DT_DOCUMENT (desktop));
+}
+
void sp_selection_to_next_layer ()
{
SPDesktop *dt = SP_ACTIVE_DESKTOP;
template <typename D>
SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
- bool only_in_viewport, bool inlayer, bool onlyvisible, bool onlysensitive);
+ bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive);
template <typename D>
SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *root,
- bool only_in_viewport, bool inlayer, bool onlyvisible, bool onlysensitive);
+ bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive);
struct Forward {
typedef SPObject *Iterator;
g_return_if_fail(desktop != NULL);
Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
- bool inlayer = prefs_get_int_attribute ("options.kbselection", "inlayer", 1);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
SPObject *root;
- if (inlayer) {
- root = desktop->currentLayer();
+ if (PREFS_SELECTION_ALL != inlayer) {
+ root = selection->activeContext();
} else {
root = desktop->currentRoot();
}
SPItem *item=next_item_from_list<Forward>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
- selection->set(item);
+ selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
scroll_to_show_item(desktop, item);
}
g_return_if_fail(desktop != NULL);
Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
- bool inlayer = prefs_get_int_attribute ("options.kbselection", "inlayer", 1);
+ PrefsSelectionContext inlayer = (PrefsSelectionContext)prefs_get_int_attribute ("options.kbselection", "inlayer", PREFS_SELECTION_LAYER);
bool onlyvisible = prefs_get_int_attribute ("options.kbselection", "onlyvisible", 1);
bool onlysensitive = prefs_get_int_attribute ("options.kbselection", "onlysensitive", 1);
SPObject *root;
- if (inlayer) {
- root = desktop->currentLayer();
+ if (PREFS_SELECTION_ALL != inlayer) {
+ root = selection->activeContext();
} else {
root = desktop->currentRoot();
}
SPItem *item=next_item_from_list<Reverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive);
if (item) {
- selection->set(item);
+ selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer);
if ( SP_CYCLING == SP_CYCLE_FOCUS ) {
scroll_to_show_item(desktop, item);
}
template <typename D>
SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items,
- SPObject *root, bool only_in_viewport, bool inlayer, bool onlyvisible, bool onlysensitive)
+ SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
{
SPObject *current=root;
while (items) {
template <typename D>
SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
- bool only_in_viewport, bool inlayer, bool onlyvisible, bool onlysensitive)
+ bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
{
typename D::Iterator children;
typename D::Iterator iter;
while ( iter && !found ) {
SPObject *object=D::object(iter);
if (desktop->isLayer(object)) {
- if (!inlayer) { // recurse into sublayers
+ if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers
found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
}
} else if ( SP_IS_ITEM(object) &&
sp_repr_set_attr(clone, "x", "0");
sp_repr_set_attr(clone, "y", "0");
sp_repr_set_attr(clone, "xlink:href", g_strdup_printf("#%s", sel_repr->attribute("id")));
+
+ sp_repr_set_attr(clone, "inkscape:transform-center-x", sel_repr->attribute("inkscape:transform-center-x"));
+ sp_repr_set_attr(clone, "inkscape:transform-center-y", sel_repr->attribute("inkscape:transform-center-y"));
// add the new clone to the top of the original's parent
parent->appendChild(clone);