summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-12-07 20:47:44 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-12-07 20:47:44 +0000
commit075a88fc7edbec8682bcd672de325ec1bedf129f (patch)
tree33d64f8ddc366a96e2c480b672224d44fc0e6355 /src/ui
parentUpdate to trunk (diff)
parentFix bug 1733422 - Bezier and pencil tool don't work form: from clipboard (diff)
downloadinkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.tar.gz
inkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.zip
Mege trunk into powerpencilII
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/guides.cpp2
-rw-r--r--src/ui/tools/freehand-base.cpp76
-rw-r--r--src/ui/tools/freehand-base.h7
-rw-r--r--src/ui/tools/pen-tool.cpp145
-rw-r--r--src/ui/tools/pencil-tool.cpp61
-rw-r--r--src/ui/widget/registered-widget.cpp24
-rw-r--r--src/ui/widget/registered-widget.h11
-rw-r--r--src/ui/widget/scalar.cpp6
-rw-r--r--src/ui/widget/scalar.h5
9 files changed, 159 insertions, 178 deletions
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index f0de5ad0d..5dc64bb24 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -96,7 +96,7 @@ void GuidelinePropertiesDialog::_onOK()
normal = Geom::rot90(Geom::Point::polar(rad_angle, 1.0));
}
//To allow reposition from dialog
- _guide->set_locked(false, true);
+ _guide->set_locked(false, false);
_guide->set_normal(normal, true);
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 89d9074ba..b72eb84db 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -36,6 +36,7 @@
#include "ui/tools/lpe-tool.h"
#include "selection-chemistry.h"
#include "sp-item-group.h"
+#include "sp-rect.h"
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
@@ -85,7 +86,7 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape)
, green_anchor(NULL)
, green_closed(false)
, white_item(NULL)
- , overwrite_curve(NULL)
+ , sa_overwrited(NULL)
, sa(NULL)
, ea(NULL)
, waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE)
@@ -144,7 +145,7 @@ void FreehandBase::setup() {
this->green_closed = FALSE;
// Create start anchor alternative curve
- this->overwrite_curve = new SPCurve();
+ this->sa_overwrited = new SPCurve();
this->attach = TRUE;
spdc_attach_selection(this, this->selection);
@@ -464,6 +465,8 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
if(cm->paste(SP_ACTIVE_DESKTOP,true)){
SPItem * pasted_clipboard = dc->selection->singleItem();
+ dc->selection->toCurves();
+ pasted_clipboard = dc->selection->singleItem();
if(pasted_clipboard){
Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr();
Inkscape::XML::Node *path = sp_repr_lookup_name(pasted_clipboard_root, "svg:path", -1); // unlimited search depth
@@ -492,6 +495,19 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
{
gchar const *svgd = item->getRepr()->attribute("d");
if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){
+ // If item is a SPRect, convert it to path first:
+ if ( dynamic_cast<SPRect *>(bend_item) ) {
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ if (desktop) {
+ Inkscape::Selection *sel = desktop->getSelection();
+ if ( sel && !sel->isEmpty() ) {
+ sel->clear();
+ sel->add(bend_item);
+ sel->toCurves();
+ bend_item = sel->singleItem();
+ }
+ }
+ }
bend_item->moveTo(item,false);
bend_item->transform.setTranslation(Geom::Point());
spdc_apply_bend_shape(svgd, dc, bend_item);
@@ -597,6 +613,9 @@ static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, F
static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/)
{
+ if (SP_IS_PENCIL_CONTEXT(dc) && dc->sa && dc->input_has_pressure) {
+ return;
+ }
// We reset white and forget white/start/end anchors
spdc_reset_white(dc);
dc->sa = NULL;
@@ -742,38 +761,21 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
{
// We hit bot start and end of single curve, closing paths
dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
- if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
- c = reverse_then_unref(c);
- }
- if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
- prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
- dc->overwrite_curve->append_continuous(c, 0.0625);
- c->unref();
- dc->overwrite_curve->closepath_current();
- if(dc->sa){
- dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve));
- dc->white_curves.push_back(dc->overwrite_curve);
- }
- }else{
- dc->sa->curve->append_continuous(c, 0.0625);
- c->unref();
- dc->sa->curve->closepath_current();
+ dc->sa_overwrited->append_continuous(c, 0.0625);
+ c->unref();
+ dc->sa_overwrited->closepath_current();
+ if(dc->sa){
+ dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve));
+ dc->white_curves.push_back(dc->sa_overwrited);
}
+
spdc_flush_white(dc, NULL);
return;
}
-
// Step C - test start
if (dc->sa) {
- SPCurve *s = dc->sa->curve;
- dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), s));
- if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
- prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
- s = dc->overwrite_curve;
- }
- if (dc->sa->start) {
- s = reverse_then_unref(s);
- }
+ dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve));
+ SPCurve *s = dc->sa_overwrited;
s->append_continuous(c, 0.0625);
c->unref();
c = s;
@@ -805,7 +807,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
c->append_continuous(e, 0.0625);
e->unref();
}
-
if (forceclosed)
{
dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
@@ -880,8 +881,17 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}
+ } else if (SP_IS_PENCIL_CONTEXT(dc)) {
+ if (dc->input_has_pressure) {
+ spdc_check_for_and_apply_waiting_LPE(dc, dc->white_item, c, false);
+// Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+// shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
+// if (shape == NONE) {
+// std::vector<Geom::Point> points;
+// spdc_apply_powerstroke_shape(points, dc, dc->white_item);
+// }
+ }
}
-
DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL,
_("Draw path"));
@@ -950,7 +960,11 @@ static void spdc_free_colors(FreehandBase *dc)
if (dc->blue_curve) {
dc->blue_curve = dc->blue_curve->unref();
}
-
+
+ // Overwrite start anchor curve
+ if (dc->sa_overwrited) {
+ dc->sa_overwrited = dc->sa_overwrited->unref();
+ }
// Green
for (auto i : dc->green_bpaths)
sp_canvas_item_destroy(i);
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 02d0a9982..4a14cf8d3 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -76,11 +76,8 @@ public:
std::list<SPCurve *> white_curves;
std::vector<SPDrawAnchor*> white_anchors;
- // Alternative curve to use on continuing the exisiting curve in case of
- // bspline or spirolive, because using anchor curves gives random memory
- // bugs as reported by su_v when running this code on macOS (as well as
- // making the code hard to understand).
- SPCurve *overwrite_curve;
+ // Temporary modiffied curve when start anchor
+ SPCurve *sa_overwrited;
// Start anchor
SPDrawAnchor *sa;
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 16cdf63b5..a42a3a07a 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -423,7 +423,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
// This is allowed, if we just canceled curve
case PenTool::POINT:
if (this->npoints == 0) {
- this->_bsplineSpiroColor();
+ this->setPolylineMode();
Geom::Point p;
if ((bevent.state & GDK_CONTROL_MASK) && (this->polylines_only || this->polylines_paraxial)) {
p = event_dt;
@@ -444,7 +444,13 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
// Set start anchor
this->sa = anchor;
- if(anchor){
+ if (anchor) {
+ //Put the start overwrite curve always on the same direction
+ if (anchor->start) {
+ this->sa_overwrited = this->sa->curve->create_reverse();
+ } else {
+ this->sa_overwrited = this->sa->curve->copy();
+ }
this->_bsplineSpiroStartAnchor(bevent.state & GDK_SHIFT_MASK);
}
if (anchor && (!this->hasWaitingLPE()|| this->bspline || this->spiro)) {
@@ -473,7 +479,6 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
}
this->_setInitialPoint(p);
} else {
-
// Set end anchor
this->ea = anchor;
Geom::Point p;
@@ -497,6 +502,7 @@ bool PenTool::_handleButtonPress(GdkEventButton const &bevent) {
this->_setSubsequentPoint(p, true);
}
}
+ this->_bsplineSpiroColor();
// avoid the creation of a control point so a node is created in the release event
this->state = (this->spiro || this->bspline || this->polylines_only) ? PenTool::POINT : PenTool::CONTROL;
ret = true;
@@ -734,26 +740,9 @@ bool PenTool::_handleButtonRelease(GdkEventButton const &revent) {
case PenTool::MODE_CLICK:
switch (this->state) {
case PenTool::POINT:
- if ( this->npoints == 0 ) {
- // Start new thread only with button release
- this->_bsplineSpiroColor();
- if (anchor) {
- p = anchor->dp;
- }
- this->sa = anchor;
- // continue the existing curve
- if (anchor) {
- if(this->bspline || this->spiro){
- this->_bsplineSpiroStartAnchor(revent.state & GDK_SHIFT_MASK);;
- }
- }
- this->_setInitialPoint(p);
- } else {
- // Set end anchor here
- this->ea = anchor;
- if (anchor) {
- p = anchor->dp;
- }
+ this->ea = anchor;
+ if (anchor) {
+ p = anchor->dp;
}
this->state = PenTool::CONTROL;
break;
@@ -1264,6 +1253,8 @@ void PenTool::_resetColors() {
}
this->sa = NULL;
this->ea = NULL;
+ this->sa_overwrited->reset();
+
this->npoints = 0;
this->red_curve_is_valid = false;
}
@@ -1415,11 +1406,7 @@ void PenTool::_bsplineSpiroStartAnchor(bool shift)
this->spiro = false;
}
if(!this->spiro && !this->bspline){
- SPCurve *tmp_curve = this->sa->curve->copy();
- if (this->sa->start) {
- tmp_curve = tmp_curve ->create_reverse();
- }
- this->overwrite_curve = tmp_curve ;
+ _bsplineSpiroColor();
return;
}
if(shift){
@@ -1433,14 +1420,10 @@ void PenTool::_bsplineSpiroStartAnchorOn()
{
using Geom::X;
using Geom::Y;
- SPCurve *tmp_curve = this->sa->curve->copy();
- if (this->sa->start) {
- tmp_curve = tmp_curve ->create_reverse();
- }
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*this->sa_overwrited ->last_segment());
SPCurve *last_segment = new SPCurve();
- Geom::Point point_a = tmp_curve->last_segment()->initialPoint();
- Geom::Point point_d = *tmp_curve->last_point();
+ Geom::Point point_a = this->sa_overwrited->last_segment()->initialPoint();
+ Geom::Point point_d = *this->sa_overwrited->last_point();
Geom::Point point_c = point_d + (1./3)*(point_a - point_d);
point_c = Geom::Point(point_c[X] + HANDLE_CUBIC_GAP, point_c[Y] + HANDLE_CUBIC_GAP);
if(cubic){
@@ -1450,43 +1433,34 @@ void PenTool::_bsplineSpiroStartAnchorOn()
last_segment->moveto(point_a);
last_segment->curveto(point_a,point_c,point_d);
}
- if( tmp_curve ->get_segment_count() == 1){
- tmp_curve = last_segment;
+ if( this->sa_overwrited->get_segment_count() == 1){
+ this->sa_overwrited = last_segment->copy();
}else{
//we eliminate the last segment
- tmp_curve ->backspace();
+ this->sa_overwrited->backspace();
//and we add it again with the recreation
- tmp_curve ->append_continuous(last_segment, 0.0625);
+ this->sa_overwrited->append_continuous(last_segment, 0.0625);
}
- if (this->sa->start) {
- tmp_curve = tmp_curve ->create_reverse();
- }
- this->overwrite_curve = tmp_curve ;
+ last_segment->unref();
}
void PenTool::_bsplineSpiroStartAnchorOff()
{
- SPCurve *tmp_curve = this->sa->curve->copy();
- if(this->sa->start)
- tmp_curve = tmp_curve ->create_reverse();
- Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
+ Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*this->sa_overwrited->last_segment());
if(cubic){
SPCurve *last_segment = new SPCurve();
last_segment->moveto((*cubic)[0]);
last_segment->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
- if( tmp_curve ->get_segment_count() == 1){
- tmp_curve = last_segment;
+ if( this->sa_overwrited->get_segment_count() == 1){
+ this->sa_overwrited = last_segment->copy();
}else{
//we eliminate the last segment
- tmp_curve ->backspace();
+ this->sa_overwrited->backspace();
//and we add it again with the recreation
- tmp_curve ->append_continuous(last_segment, 0.0625);
+ this->sa_overwrited->append_continuous(last_segment, 0.0625);
}
+ last_segment->unref();
}
- if (this->sa->start) {
- tmp_curve = tmp_curve ->create_reverse();
- }
- this->overwrite_curve = tmp_curve;
}
void PenTool::_bsplineSpiroMotion(guint const state){
@@ -1503,17 +1477,14 @@ void PenTool::_bsplineSpiroMotion(guint const state){
this->p[2] = Geom::Point(this->p[2][X] + HANDLE_CUBIC_GAP,this->p[2][Y] + HANDLE_CUBIC_GAP);
if (this->green_curve->is_unset() && !this->sa) {
this->p[1] = this->p[0] + (1./3)*(this->p[3] - this->p[0]);
- this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP,this->p[1][Y] + HANDLE_CUBIC_GAP);
+ this->p[1] = Geom::Point(this->p[1][X] + HANDLE_CUBIC_GAP, this->p[1][Y] + HANDLE_CUBIC_GAP);
if(shift){
this->p[2] = this->p[3];
}
} else if (!this->green_curve->is_unset()){
tmp_curve = this->green_curve->copy();
} else {
- tmp_curve = this->overwrite_curve->copy();
- if(this->sa->start) {
- tmp_curve = tmp_curve ->create_reverse();
- }
+ tmp_curve = this->sa_overwrited->copy();
}
if ((state & GDK_MOD1_MASK ) && previous != Geom::Point(0,0)) { //ALT drag
this->p[0] = this->p[0] + (this->p[3] - previous);
@@ -1550,11 +1521,7 @@ void PenTool::_bsplineSpiroMotion(guint const state){
}
cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmp_curve ->last_segment());
if (this->sa && this->green_curve->is_unset()) {
- if(this->sa->start) {
- this->overwrite_curve = tmp_curve->copy()->create_reverse();
- } else {
- this->overwrite_curve = tmp_curve->copy();
- }
+ this->sa_overwrited = tmp_curve->copy();
}
if (!this->green_bpaths.empty()) {
this->green_curve = tmp_curve->copy();
@@ -1588,6 +1555,9 @@ void PenTool::_bsplineSpiroMotion(guint const state){
if (shift) {
this->p[2] = this->p[3];
}
+ if(Geom::are_near((*cubic)[3], (*cubic)[2])) {
+ this->p[1] = this->p[0];
+ }
} else {
this->p[1] = (*cubic)[3] + ((*cubic)[3] - (*cubic)[2] );
}
@@ -1627,19 +1597,13 @@ void PenTool::_bsplineSpiroEndAnchorOn()
SPCurve *tmp_curve;
SPCurve *last_segment = new SPCurve();
Geom::Point point_c(0,0);
- bool reverse = false;
if( this->green_anchor && this->green_anchor->active ){
tmp_curve = this->green_curve->create_reverse();
if(this->green_curve->get_segment_count()==0){
return;
}
- reverse = true;
} else if(this->sa){
- tmp_curve = this->overwrite_curve->copy();
- if(!this->sa->start){
- tmp_curve = tmp_curve ->create_reverse();
- reverse = true;
- }
+ tmp_curve = this->sa_overwrited->copy()->create_reverse();
}else{
return;
}
@@ -1665,17 +1629,16 @@ void PenTool::_bsplineSpiroEndAnchorOn()
//and we add it again with the recreation
tmp_curve ->append_continuous(last_segment, 0.0625);
}
- if (reverse) {
- tmp_curve = tmp_curve ->create_reverse();
- }
+ tmp_curve = tmp_curve ->create_reverse();
if( this->green_anchor && this->green_anchor->active )
{
this->green_curve->reset();
- this->green_curve = tmp_curve ;
+ this->green_curve = tmp_curve->copy();
}else{
- this->overwrite_curve->reset();
- this->overwrite_curve = tmp_curve ;
+ this->sa_overwrited->reset();
+ this->sa_overwrited = tmp_curve->copy();
}
+ tmp_curve->unref();
}
void PenTool::_bsplineSpiroEndAnchorOff()
@@ -1683,20 +1646,14 @@ void PenTool::_bsplineSpiroEndAnchorOff()
SPCurve *tmp_curve;
SPCurve *last_segment = new SPCurve();
- bool reverse = false;
this->p[2] = this->p[3];
if( this->green_anchor && this->green_anchor->active ){
tmp_curve = this->green_curve->create_reverse();
if(this->green_curve->get_segment_count()==0){
return;
}
- reverse = true;
} else if(this->sa){
- tmp_curve = this->overwrite_curve->copy();
- if(!this->sa->start){
- tmp_curve = tmp_curve ->create_reverse();
- reverse = true;
- }
+ tmp_curve = this->sa_overwrited->copy()->create_reverse();
}else{
return;
}
@@ -1716,17 +1673,17 @@ void PenTool::_bsplineSpiroEndAnchorOff()
//and we add it again with the recreation
tmp_curve ->append_continuous(last_segment, 0.0625);
}
- if (reverse) {
- tmp_curve = tmp_curve ->create_reverse();
- }
+ tmp_curve = tmp_curve ->create_reverse();
+
if( this->green_anchor && this->green_anchor->active )
{
this->green_curve->reset();
- this->green_curve = tmp_curve ;
+ this->green_curve = tmp_curve->copy();
}else{
- this->overwrite_curve->reset();
- this->overwrite_curve = tmp_curve ;
+ this->sa_overwrited->reset();
+ this->sa_overwrited = tmp_curve->copy();
}
+ tmp_curve->unref();
}
//prepares the curves for its transformation into BSpline curve.
@@ -1740,10 +1697,7 @@ void PenTool::_bsplineSpiroBuild()
SPCurve *curve = new SPCurve();
//If we continuate the existing curve we add it at the start
if(this->sa && !this->sa->curve->is_unset()){
- curve = this->overwrite_curve->copy();
- if (this->sa->start) {
- curve = curve->create_reverse();
- }
+ curve = this->sa_overwrited->copy();
}
if (!this->green_curve->is_unset()){
@@ -2038,7 +1992,6 @@ void PenTool::_finish(gboolean const closed) {
// cancelate line without a created segment
this->red_curve->reset();
spdc_concat_colors_and_flush(this, closed);
- this->overwrite_curve = NULL;
this->sa = NULL;
this->ea = NULL;
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 13d69b063..db1b975ef 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -211,7 +211,12 @@ bool PencilTool::_handleButtonPress(GdkEventButton const &bevent) {
}
if (anchor) {
p = anchor->dp;
- this->overwrite_curve = anchor->curve;
+ //Put the start overwrite curve always on the same direction
+ if (anchor->start) {
+ this->sa_overwrited = anchor->curve->create_reverse();
+ } else {
+ this->sa_overwrited = anchor->curve->copy();
+ }
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
} else {
m.setup(desktop, true);
@@ -277,6 +282,25 @@ bool PencilTool::_handleMotionNotify(GdkEventMotion const &mevent) {
return false; // Do not drag if we're within tolerance from origin.
}
}
+ // motion notify coordinates as given (no snapping back to origin)
+ if (input_has_pressure && pencil_within_tolerance) {
+ anchor = spdc_test_inside(this, pencil_drag_origin_w);
+ if (anchor) {
+ this->sa = anchor;
+ //Put the start overwrite curve always on the same direction
+ if (anchor->start) {
+ this->sa_overwrited = this->sa->curve->create_reverse();
+ } else {
+ this->sa_overwrited = this->sa->curve->copy();
+ }
+ p = anchor->dp;
+ this->_setStartpoint(p);
+ desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
+ }
+ }
+ if (input_has_pressure) {
+ this->state = SP_PENCIL_CONTEXT_FREEHAND;
+ }
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
@@ -760,7 +784,7 @@ PencilTool::addPowerStrokePencil(SPCurve * c)
min = max;
}
bool live = false;
- SPCurve * curve;
+ SPCurve * curve = new SPCurve();
if (sa) {
Effect* lpe = SP_LPE_ITEM(white_item)->getCurrentLPE();
LPEPowerStroke* ps = static_cast<LPEPowerStroke*>(lpe);
@@ -786,40 +810,27 @@ PencilTool::addPowerStrokePencil(SPCurve * c)
stroreps.clear();
strorewps.clear();
prefs->setDouble("/tools/freehand/pencil/tolerance", tol);
- if (sa) {
- curve = sa->curve;
- if(prefs->getInt("/tools/freehand/pencil/freehand-mode", 0) == 1 ||
- prefs->getInt("/tools/freehand/pencil/freehand-mode", 0) == 2)
- {
- curve = overwrite_curve;
- }
- if (sa->start) {
- SPCurve *ret = curve->create_reverse();
- curve->unref();
- curve = ret->copy();
- ret->unref();
- }
- if (!green_curve->is_empty()) {
- if (curve->is_empty()) {
- curve = green_curve->copy();
- } else {
- green_curve->move_endpoints(curve->first_path()->finalPoint(), green_curve->first_path()->finalPoint());
- curve->append_continuous( green_curve, 0.0625);
- }
- if (!red_curve->is_empty()) {
+ if (sa && sa->curve) {
+ curve = sa_overwrited->copy();
+ if (!green_curve->is_unset()) {
+ curve->append_continuous( green_curve, 0.0625);
+ if (!red_curve->is_unset()) {
curve->append_continuous( red_curve, 0.0625);
}
}
} else {
- if (!green_curve->is_empty()) {
+ if (!green_curve->is_unset()) {
curve = green_curve->copy();
- if (!red_curve->is_empty()) {
+ if (!red_curve->is_unset()) {
curve->append_continuous( red_curve, 0.0625);
}
} else {
curve = NULL;
}
}
+ if (curve->is_empty()) {
+ curve = NULL;
+ }
red_curve = previous_red->copy();
green_curve = previous_green->copy();
previous_red->unref();
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index a88413347..a3b87f89b 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -279,7 +279,6 @@ RegisteredScalar::RegisteredScalar ( const Glib::ustring& label, const Glib::ust
init_parent(key, wr, repr_in, doc_in);
setProgrammatically = false;
-
setRange (-1e6, 1e6);
setDigits (2);
setIncrements(0.1, 1.0);
@@ -299,12 +298,14 @@ RegisteredScalar::on_value_changed()
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
- os << getValue();
-
- set_sensitive(false);
+ //Force exact 0 if decimals over to 6
+ double val = getValue() < 1e-6 && getValue() > -1e-6?0.0:getValue();
+ os << val;
+ //TODO: Test is ok remove this sensitives
+ //also removed in registed text and in registered random
+ //set_sensitive(false);
write_to_xml(os.str().c_str());
- set_sensitive(true);
-
+ //set_sensitive(true);
_wr->setUpdating (false);
}
@@ -342,11 +343,9 @@ RegisteredText::on_activate()
}
_wr->setUpdating (true);
Glib::ustring str(getText());
- set_sensitive(false);
Inkscape::SVGOStringStream os;
os << str;
write_to_xml(os.str().c_str());
- set_sensitive(true);
_wr->setUpdating (false);
}
@@ -757,7 +756,6 @@ RegisteredRandom::RegisteredRandom ( const Glib::ustring& label, const Glib::ust
init_parent(key, wr, repr_in, doc_in);
setProgrammatically = false;
-
setRange (-1e6, 1e6);
setDigits (2);
setIncrements(0.1, 1.0);
@@ -786,12 +784,10 @@ RegisteredRandom::on_value_changed()
_wr->setUpdating (true);
Inkscape::SVGOStringStream os;
- os << getValue() << ';' << getStartSeed();
-
- set_sensitive(false);
+ //Force exact 0 if decimals over to 6
+ double val = getValue() < 1e-6 && getValue() > -1e-6?0.0:getValue();
+ os << val << ';' << getStartSeed();
write_to_xml(os.str().c_str());
- set_sensitive(true);
-
_wr->setUpdating (false);
}
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index f66d5cbf2..765fa77b6 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -12,11 +12,11 @@
#ifndef INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
#define INKSCAPE_UI_WIDGET_REGISTERED_WIDGET__H_
-#include "ui/widget/scalar.h"
#include <2geom/affine.h>
#include "xml/node.h"
#include "registry.h"
+#include "ui/widget/scalar.h"
#include "ui/widget/scalar-unit.h"
#include "ui/widget/point.h"
#include "ui/widget/text.h"
@@ -108,12 +108,14 @@ protected:
bool saved = DocumentUndo::getUndoSensitive(local_doc);
DocumentUndo::setUndoSensitive(local_doc, false);
+ const char * svgstr_old = local_repr->attribute(_key.c_str());
if (!write_undo) {
local_repr->setAttribute(_key.c_str(), svgstr);
}
DocumentUndo::setUndoSensitive(local_doc, saved);
-
- local_doc->setModifiedSinceSave();
+ if (svgstr_old && svgstr && strcmp(svgstr_old,svgstr)) {
+ local_doc->setModifiedSinceSave();
+ }
if (write_undo) {
local_repr->setAttribute(_key.c_str(), svgstr);
@@ -244,9 +246,8 @@ public:
Registry& wr,
Inkscape::XML::Node* repr_in = NULL,
SPDocument *doc_in = NULL );
-
protected:
- sigc::connection _value_changed_connection;
+ sigc::connection _value_changed_connection;
void on_value_changed();
};
diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp
index f8543a371..937bea697 100644
--- a/src/ui/widget/scalar.cpp
+++ b/src/ui/widget/scalar.cpp
@@ -14,7 +14,6 @@
# include <config.h>
#endif
-
#include "scalar.h"
#include "spinbutton.h"
#include <gtkmm/scale.h>
@@ -149,6 +148,11 @@ Glib::SignalProxy0<void> Scalar::signal_value_changed()
return static_cast<SpinButton*>(_widget)->signal_value_changed();
}
+Glib::SignalProxy1<bool, GdkEventButton*> Scalar::signal_button_release_event()
+{
+ return static_cast<SpinButton*>(_widget)->signal_button_release_event();
+}
+
} // namespace Widget
} // namespace UI
diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h
index f186f46ac..b2c923953 100644
--- a/src/ui/widget/scalar.h
+++ b/src/ui/widget/scalar.h
@@ -153,6 +153,11 @@ public:
Glib::SignalProxy0<void> signal_value_changed();
/**
+ * Signal raised when the spin button's pressed.
+ */
+ Glib::SignalProxy1<bool, GdkEventButton*> signal_button_release_event();
+
+ /**
* true if the value was set by setValue, not changed by the user;
* if a callback checks it, it must reset it back to false.
*/