summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/freehand-base.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-11-13 00:00:04 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-11-13 00:00:04 +0000
commit152a0caf7e216e7ceafeed20822500c385e3e2df (patch)
treea3b5d60e08f3bd8221ba2e50eea80b087e5d541a /src/ui/tools/freehand-base.cpp
parentUpdate to trunk (diff)
parentfix C++11 compilation. There A LOT of const_casts in this file... :-( (diff)
downloadinkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.tar.gz
inkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.zip
Update to trunk
(bzr r12588.1.26)
Diffstat (limited to '')
-rw-r--r--src/ui/tools/freehand-base.cpp (renamed from src/draw-context.cpp)91
1 files changed, 52 insertions, 39 deletions
diff --git a/src/draw-context.cpp b/src/ui/tools/freehand-base.cpp
index a73d4b715..6e3a04b59 100644
--- a/src/draw-context.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -34,8 +34,8 @@
#include "draw-anchor.h"
#include "macros.h"
#include "message-stack.h"
-#include "pen-context.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/lpe-tool.h"
#include "preferences.h"
#include "selection.h"
#include "selection-chemistry.h"
@@ -45,16 +45,21 @@
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
-#include "draw-context.h"
#include "ui/clipboard.h"
+#include "ui/tools/freehand-base.h"
+
#include <gdk/gdkkeysyms.h>
using Inkscape::DocumentUndo;
-static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc);
-static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, SPDrawContext *dc);
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc);
+static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, FreehandBase *dc);
-static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel);
+static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection *sel);
/**
* Flushes white curve(s) and additional curve into object.
@@ -62,12 +67,12 @@ static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel);
* No cleaning of colored curves - this has to be done by caller
* No rereading of white data, so if you cannot rely on ::modified, do it in caller
*/
-static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc);
+static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
-static void spdc_reset_white(SPDrawContext *dc);
-static void spdc_free_colors(SPDrawContext *dc);
+static void spdc_reset_white(FreehandBase *dc);
+static void spdc_free_colors(FreehandBase *dc);
-SPDrawContext::SPDrawContext() : SPEventContext() {
+FreehandBase::FreehandBase() : ToolBase() {
this->selection = 0;
this->grab = 0;
this->anchor_statusbar = false;
@@ -100,7 +105,7 @@ SPDrawContext::SPDrawContext() : SPEventContext() {
this->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE;
}
-SPDrawContext::~SPDrawContext() {
+FreehandBase::~FreehandBase() {
if (this->grab) {
sp_canvas_item_ungrab(this->grab, GDK_CURRENT_TIME);
this->grab = NULL;
@@ -113,8 +118,8 @@ SPDrawContext::~SPDrawContext() {
spdc_free_colors(this);
}
-void SPDrawContext::setup() {
- SPEventContext::setup();
+void FreehandBase::setup() {
+ ToolBase::setup();
this->selection = sp_desktop_selection(desktop);
@@ -151,7 +156,7 @@ void SPDrawContext::setup() {
spdc_attach_selection(this, this->selection);
}
-void SPDrawContext::finish() {
+void FreehandBase::finish() {
this->sel_changed_connection.disconnect();
this->sel_modified_connection.disconnect();
@@ -166,10 +171,10 @@ void SPDrawContext::finish() {
spdc_free_colors(this);
}
-void SPDrawContext::set(const Inkscape::Preferences::Entry& /*value*/) {
+void FreehandBase::set(const Inkscape::Preferences::Entry& /*value*/) {
}
-bool SPDrawContext::root_handler(GdkEvent* event) {
+bool FreehandBase::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -193,20 +198,20 @@ bool SPDrawContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-static Glib::ustring const tool_name(SPDrawContext *dc)
+static Glib::ustring const tool_name(FreehandBase *dc)
{
return ( SP_IS_PEN_CONTEXT(dc)
? "/tools/freehand/pen"
: "/tools/freehand/pencil" );
}
-static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem *item)
+static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, FreehandBase *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -218,7 +223,7 @@ static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *
static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd);
}
-static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, SPDrawContext *dc, SPItem *item)
+static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -235,6 +240,7 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points
lpe->getRepr()->setAttribute("interpolator_beta", "0.2");
}
+<<<<<<< TREE
static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -251,6 +257,9 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *
static bool bend;
static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve)
+=======
+static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
+>>>>>>> MERGE-SOURCE
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -472,7 +481,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item
* Selection handlers
*/
-static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
+static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc)
{
if (dc->attach) {
spdc_attach_selection(dc, sel);
@@ -481,14 +490,14 @@ static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
/* fixme: We have to ensure this is not delayed (Lauris) */
-static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, SPDrawContext *dc)
+static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, FreehandBase *dc)
{
if (dc->attach) {
spdc_attach_selection(dc, sel);
}
}
-static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/)
+static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/)
{
// We reset white and forget white/start/end anchors
spdc_reset_white(dc);
@@ -530,14 +539,14 @@ static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*
}
-void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o,
+void spdc_endpoint_snap_rotation(ToolBase const *const ec, Geom::Point &p, Geom::Point const &o,
guint state)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
- SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
- m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
+ SnapManager &m = ec->desktop->namedview->snap_manager;
+ m.setup(ec->desktop);
bool snap_enabled = m.snapprefs.getSnapEnabledGlobally();
if (state & GDK_SHIFT_MASK) {
@@ -559,9 +568,9 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
}
-void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
+void spdc_endpoint_snap_free(ToolBase const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
{
- SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec);
+ SPDesktop *dt = ec->desktop;
SnapManager &m = dt->namedview->snap_manager;
Inkscape::Selection *selection = sp_desktop_selection (dt);
@@ -587,7 +596,7 @@ static SPCurve *reverse_then_unref(SPCurve *orig)
return ret;
}
-void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
+void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
{
// Concat RBG
SPCurve *c = dc->green_curve;
@@ -619,7 +628,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
// Step A - test, whether we ended on green anchor
if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) {
// We hit green anchor, closing Green-Blue-Red
- SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
+ dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
c->closepath_current();
// Closed path, just flush
spdc_flush_white(dc, c);
@@ -634,7 +643,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
|| dc->sa->curve->is_closed() ) )
{
// We hit bot start and end of single curve, closing paths
- SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
+ dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
c = reverse_then_unref(c);
}
@@ -671,7 +680,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
c->unref();
}
-static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
+static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
{
SPCurve *c;
@@ -693,9 +702,9 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
// Now we have to go back to item coordinates at last
c->transform( dc->white_item
? (dc->white_item)->dt2i_affine()
- : SP_EVENT_CONTEXT_DESKTOP(dc)->dt2doc() );
+ : dc->desktop->dt2doc() );
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
+ SPDesktop *desktop = dc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
@@ -752,7 +761,7 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
doc->ensureUpToDate();
}
-SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p)
+SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
{
SPDrawAnchor *active = NULL;
@@ -771,7 +780,7 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p)
return active;
}
-static void spdc_reset_white(SPDrawContext *dc)
+static void spdc_reset_white(FreehandBase *dc)
{
if (dc->white_item) {
// We do not hold refcount
@@ -787,7 +796,7 @@ static void spdc_reset_white(SPDrawContext *dc)
}
}
-static void spdc_free_colors(SPDrawContext *dc)
+static void spdc_free_colors(FreehandBase *dc)
{
// Red
if (dc->red_bpath) {
@@ -834,11 +843,11 @@ static void spdc_free_colors(SPDrawContext *dc)
}
}
-void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state) {
+void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) {
g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil"));
Glib::ustring tool_path = tool;
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
+ SPDesktop *desktop = ec->desktop;
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "arc");
@@ -897,6 +906,10 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
}
+}
+}
+}
+
/*
Local Variables:
mode:c++