summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-11-06 20:11:34 +0000
committerjabiertxof <info@marker.es>2016-11-06 20:11:34 +0000
commitf947dd4e24cd82b3c4013eddb14fb1ac8f71f184 (patch)
treec038e5125f9cf77ddb0dbd13d5fda103397689b5 /src
parentFix a bug that allow to enter rotate mode with right click (diff)
parentFix some bugs on pen/cil dropdown shapes (diff)
downloadinkscape-f947dd4e24cd82b3c4013eddb14fb1ac8f71f184.tar.gz
inkscape-f947dd4e24cd82b3c4013eddb14fb1ac8f71f184.zip
Update to trunk
(bzr r15142.1.34)
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp10
-rw-r--r--src/object-set.h1
-rw-r--r--src/selection-chemistry.cpp34
-rw-r--r--src/selection-chemistry.h2
-rw-r--r--src/ui/tools/freehand-base.cpp84
-rw-r--r--src/verbs.cpp2
6 files changed, 59 insertions, 74 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 0d5f35797..95764aea9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -119,6 +119,7 @@
#include "verbs.h"
#include "path-chemistry.h"
+#include "object-set.h"
#include "sp-text.h"
#include "sp-flowtext.h"
#include "text-editing.h"
@@ -1161,16 +1162,13 @@ static int sp_process_file_list(GSList *fl)
// "crop" the document to the specified object, cleaning as we go.
SPObject *obj = doc->getObjectById(sp_export_id);
- Geom::OptRect const bbox(SP_ITEM(obj)->visualBounds());
-
- if (bbox) {
- doc->fitToRect(*bbox, false);
- }
-
if (sp_export_id_only) {
// If -j then remove all other objects to complete the "crop"
doc->getRoot()->cropToObject(obj);
}
+ Inkscape::ObjectSet s(doc);
+ s.set(obj);
+ s.fitCanvas(false);
}
Inkscape::Extension::save(Inkscape::Extension::db.get("org.inkscape.output.svg.plain"), doc, sp_export_svg, false,
diff --git a/src/object-set.h b/src/object-set.h
index a70730ef1..47a2efb9d 100644
--- a/src/object-set.h
+++ b/src/object-set.h
@@ -402,6 +402,7 @@ public:
// various
void getExportHints(Glib::ustring &filename, float *xdpi, float *ydpi);
+ bool fitCanvas(bool with_margins, bool skip_undo = false);
protected:
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 2db059afe..cd61ffba3 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -4094,39 +4094,27 @@ void ObjectSet::unsetMask(bool apply_clip_path) {
* "fit-margin-..." attributes. See SPDocument::fitToRect.
* \return true if an undoable change should be recorded.
*/
-bool
-fit_canvas_to_selection(SPDesktop *desktop, bool with_margins)
+bool ObjectSet::fitCanvas(bool with_margins, bool skip_undo)
{
- g_return_val_if_fail(desktop != NULL, false);
- SPDocument *doc = desktop->getDocument();
-
- g_return_val_if_fail(doc != NULL, false);
- g_return_val_if_fail(desktop->selection != NULL, false);
+ g_return_val_if_fail(document() != NULL, false);
- if (desktop->selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
return false;
}
- Geom::OptRect const bbox(desktop->selection->visualBounds());
+ Geom::OptRect const bbox(visualBounds());
if (bbox) {
- doc->fitToRect(*bbox, with_margins);
+ document()->fitToRect(*bbox, with_margins);
+ if(!skip_undo)
+ DocumentUndo::done(document(), SP_VERB_FIT_CANVAS_TO_SELECTION,
+ _("Fit Page to Selection"));
return true;
} else {
return false;
}
}
-/**
- * Fit canvas to the bounding box of the selection, as an undoable action.
- */
-void
-verb_fit_canvas_to_selection(SPDesktop *const desktop)
-{
- if (fit_canvas_to_selection(desktop)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION,
- _("Fit Page to Selection"));
- }
-}
/**
* \param with_margins margins defined in the xml under <sodipodi:namedview>
@@ -4171,7 +4159,7 @@ void fit_canvas_to_selection_or_drawing(SPDesktop *desktop) {
bool const changed = ( desktop->selection->isEmpty()
? fit_canvas_to_drawing(doc, true)
- : fit_canvas_to_selection(desktop, true) );
+ : desktop->selection->fitCanvas(true,true));
if (changed) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_FIT_CANVAS_TO_SELECTION_OR_DRAWING,
_("Fit Page to Selection or Drawing"));
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 969a6e35a..c82c5a4a5 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -96,8 +96,6 @@ void sp_redo (SPDesktop *desktop, SPDocument *doc);
void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi);
-bool fit_canvas_to_selection(SPDesktop *, bool with_margins = false);
-void verb_fit_canvas_to_selection(SPDesktop *);
bool fit_canvas_to_drawing(SPDocument *, bool with_margins = false);
void verb_fit_canvas_to_drawing(SPDesktop *);
void fit_canvas_to_selection_or_drawing(SPDesktop *);
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index deb89b874..056c723ee 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -273,12 +273,42 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem
enum shapeType { NONE, TRIANGLE_IN, TRIANGLE_OUT, ELLIPSE, CLIPBOARD, BEND_CLIPBOARD, LAST_APPLIED };
static shapeType previous_shape_type = NONE;
-static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
+static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve, bool is_bend)
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (item && SP_IS_LPE_ITEM(item)) {
+ //Store the clipboard path to apply in the future without the use of clipboard
+ static Geom::PathVector previous_shape_pathv;
+ static SPItem *bend_item;
+ shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
+ if (previous_shape_type == NONE) {
+ previous_shape_type = shape;
+ }
+ if(shape == LAST_APPLIED){
+
+ shape = previous_shape_type;
+ if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
+ shape = LAST_APPLIED;
+ }
+ }
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ if (is_bend &&
+ (shape == BEND_CLIPBOARD || (shape == LAST_APPLIED && previous_shape_type != CLIPBOARD)) &&
+ cm->paste(SP_ACTIVE_DESKTOP,true))
+ {
+ bend_item = dc->selection->singleItem();
+ if(!bend_item || (!SP_IS_SHAPE(bend_item) && !SP_IS_GROUP(bend_item))){
+ previous_shape_type = NONE;
+ return;
+ }
+ } else if(is_bend) {
+ return;
+ }
+ if (!is_bend && previous_shape_type == BEND_CLIPBOARD && shape == BEND_CLIPBOARD) {
+ return;
+ }
bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0);
if(simplify){
double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0);
@@ -300,29 +330,16 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
curve = sp_shape->getCurve();
}
- //Store the clipboard path to apply in the future without the use of clipboard
- static Geom::PathVector previous_shape_pathv;
-
- shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
bool shape_applied = false;
SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS);
const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
const char *stroke_width = sp_repr_css_property(css_item, "stroke-width", "0");
double swidth;
sp_svg_number_read_d(stroke_width, &swidth);
- static SPItem *bend_item;
#define SHAPE_LENGTH 10
#define SHAPE_HEIGHT 10
- if(shape == LAST_APPLIED){
-
- shape = previous_shape_type;
- if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
- shape = LAST_APPLIED;
- }
- }
-
switch (shape) {
case NONE:
// don't apply any shape
@@ -400,21 +417,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
}
case BEND_CLIPBOARD:
{
- Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if(cm->paste(SP_ACTIVE_DESKTOP,true)){
- gchar const *svgd = item->getRepr()->attribute("d");
- bend_item = dc->selection->singleItem();
- if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
- bend_item->moveTo(item,false);
- bend_item->transform.setTranslation(Geom::Point());
- spdc_apply_bend_shape(svgd, dc, bend_item);
- dc->selection->add(SP_OBJECT(bend_item));
-
- shape = BEND_CLIPBOARD;
- } else {
- bend_item = NULL;
- shape = NONE;
- }
+ gchar const *svgd = item->getRepr()->attribute("d");
+ if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
+ bend_item->moveTo(item,false);
+ bend_item->transform.setTranslation(Geom::Point());
+ spdc_apply_bend_shape(svgd, dc, bend_item);
+ dc->selection->add(SP_OBJECT(bend_item));
+
+ shape = BEND_CLIPBOARD;
} else {
bend_item = NULL;
shape = NONE;
@@ -790,25 +800,15 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
if (!dc->white_item) {
// Attach repr
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- shapeType shape_selected = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
//Bend needs the transforms applied after, Other effects best before
- if((previous_shape_type == BEND_CLIPBOARD && shape_selected == LAST_APPLIED) ||
- shape_selected == BEND_CLIPBOARD)
- {
- spdc_check_for_and_apply_waiting_LPE(dc, item, c);
- previous_shape_type = BEND_CLIPBOARD;
- }
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c, true);
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
- if((previous_shape_type != BEND_CLIPBOARD || shape_selected != LAST_APPLIED) &&
- shape_selected != BEND_CLIPBOARD)
- {
- spdc_check_for_and_apply_waiting_LPE(dc, item, c);
- dc->selection->set(repr);
- }
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c, false);
+ dc->selection->set(repr);
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}
diff --git a/src/verbs.cpp b/src/verbs.cpp
index dc92545e2..c2167f67c 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -2359,7 +2359,7 @@ void FitCanvasVerb::perform(SPAction *action, void *data)
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_FIT_CANVAS_TO_SELECTION:
- verb_fit_canvas_to_selection(dt);
+ dt->selection->fitCanvas(true);
break;
case SP_VERB_FIT_CANVAS_TO_DRAWING:
verb_fit_canvas_to_drawing(dt);