diff options
| author | Markus Engel <markus.engel@tum.de> | 2014-02-26 01:08:53 +0000 |
|---|---|---|
| committer | Markus Engel <markus.engel@tum.de> | 2014-02-26 01:08:53 +0000 |
| commit | 7e85379f54292595afe296e5f0be240f6c8f7835 (patch) | |
| tree | a40874339b162e49b76008b81e0d046d05443ac6 /src | |
| parent | Allow 'transform' on flowRoot, flowPara, and flowSpan. (diff) | |
| download | inkscape-7e85379f54292595afe296e5f0be240f6c8f7835.tar.gz inkscape-7e85379f54292595afe296e5f0be240f6c8f7835.zip | |
Made constructors of tools use initializer lists.
(bzr r13060)
Diffstat (limited to 'src')
33 files changed, 402 insertions, 514 deletions
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index bb7dfa21c..435f4aa4b 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -69,18 +69,10 @@ const std::string& ArcTool::getPrefsPath() { const std::string ArcTool::prefsPath = "/tools/shapes/arc"; -ArcTool::ArcTool() : ToolBase() { - this->cursor_shape = cursor_ellipse_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - //this->tool_url = "/tools/shapes/arc"; - - this->arc = NULL; +ArcTool::ArcTool() + : ToolBase(cursor_ellipse_xpm, 4, 4) + , arc(NULL) +{ } void ArcTool::finish() { @@ -142,13 +134,10 @@ void ArcTool::setup() { } bool ArcTool::item_handler(SPItem* item, GdkEvent* event) { - gint ret = FALSE; - switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { Inkscape::setup_for_drag_start(desktop, this, event); - ret = TRUE; } break; // motion and release are always on root (why?) @@ -156,13 +145,7 @@ bool ArcTool::item_handler(SPItem* item, GdkEvent* event) { break; } -// if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler) { -// ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler(event_context, item, event); -// } - // CPPIFY: ret is overwritten... - ret = ToolBase::item_handler(item, event); - - return ret; + return ToolBase::item_handler(item, event); } bool ArcTool::root_handler(GdkEvent* event) { @@ -173,7 +156,7 @@ bool ArcTool::root_handler(GdkEvent* event) { this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - gint ret = FALSE; + bool handled = false; switch (event->type) { case GDK_BUTTON_PRESS: @@ -191,7 +174,7 @@ bool ArcTool::root_handler(GdkEvent* event) { GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, NULL, event->button.time); - ret = TRUE; + handled = true; m.unSetup(); } break; @@ -214,7 +197,7 @@ bool ArcTool::root_handler(GdkEvent* event) { gobble_motion_events(GDK_BUTTON1_MASK); - ret = TRUE; + handled = true; } else if (!sp_event_context_knot_mouseover(this)){ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); @@ -249,7 +232,7 @@ bool ArcTool::root_handler(GdkEvent* event) { this->xp = 0; this->yp = 0; this->item_to_select = NULL; - ret = TRUE; + handled = true; } sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); break; @@ -278,14 +261,14 @@ bool ArcTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY(event)) - ret = TRUE; + handled = true; break; case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-arc"); - ret = TRUE; + handled = true; } break; @@ -295,7 +278,7 @@ bool ArcTool::root_handler(GdkEvent* event) { sp_event_context_discard_delayed_snap_event(this); // if drawing, cancel, otherwise pass it up for deselecting this->cancel(); - ret = TRUE; + handled = true; } break; @@ -316,7 +299,7 @@ bool ArcTool::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); + handled = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: @@ -346,11 +329,11 @@ bool ArcTool::root_handler(GdkEvent* event) { break; } - if (!ret) { - ret = ToolBase::root_handler(event); + if (!handled) { + handled = ToolBase::root_handler(event); } - return ret; + return handled; } void ArcTool::drag(Geom::Point pt, guint state) { diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 2e345fef1..f0381a4a5 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -72,22 +72,13 @@ const std::string& Box3dTool::getPrefsPath() { const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox"; -Box3dTool::Box3dTool() : ToolBase() { - this->cursor_shape = cursor_3dbox_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->box3d = NULL; - - this->ctrl_dragged = false; - this->extruded = false; - - this->_vpdrag = NULL; +Box3dTool::Box3dTool() + : ToolBase(cursor_3dbox_xpm, 4, 4) + , _vpdrag(NULL) + , box3d(NULL) + , ctrl_dragged(false) + , extruded(false) +{ } void Box3dTool::finish() { diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 2c5e6561c..64097e834 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -105,30 +105,24 @@ const std::string& CalligraphicTool::getPrefsPath() { const std::string CalligraphicTool::prefsPath = "/tools/calligraphic"; -CalligraphicTool::CalligraphicTool() : DynamicBase() { - this->cursor_shape = cursor_calligraphy_xpm; - this->hot_x = 4; - this->hot_y = 4; - +CalligraphicTool::CalligraphicTool() + : DynamicBase(cursor_calligraphy_xpm, 4, 4) + , keep_selected(true) + , hatch_spacing(0) + , hatch_spacing_step(0) + , hatch_item(NULL) + , hatch_livarot_path(NULL) + , hatch_last_nearest(Geom::Point(0,0)) + , hatch_last_pointer(Geom::Point(0,0)) + , hatch_escaped(false) + , hatch_area(NULL) + , just_started_drawing(false) + , trace_bg(false) +{ this->vel_thin = 0.1; this->flatness = 0.9; this->cap_rounding = 0.0; - this->abs_width = false; - this->keep_selected = true; - - this->hatch_spacing = 0; - this->hatch_spacing_step = 0; - - this->hatch_last_nearest = Geom::Point(0,0); - this->hatch_last_pointer = Geom::Point(0,0); - this->hatch_escaped = false; - this->hatch_area = NULL; - this->hatch_item = NULL; - this->hatch_livarot_path = NULL; - - this->trace_bg = false; - this->just_started_drawing = false; } CalligraphicTool::~CalligraphicTool() { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 50cb00360..391bae2e5 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -182,54 +182,39 @@ const std::string& ConnectorTool::getPrefsPath() { const std::string ConnectorTool::prefsPath = "/tools/connector"; -ConnectorTool::ConnectorTool() : ToolBase() { - this->red_curve = 0; - this->isOrthogonal = false; - this->c1 = 0; - this->red_bpath = 0; - this->green_curve = 0; - this->selection = 0; - this->cl0 = 0; - this->cl1 = 0; - this->c0 = 0; - - this->cursor_shape = cursor_connector_xpm; - this->hot_x = 1; - this->hot_y = 1; - this->xp = 0; - this->yp = 0; - - this->red_color = 0xff00007f; - - this->newconn = NULL; - this->newConnRef = NULL; - this->curvature = 0.0; - - this->sel_changed_connection = sigc::connection(); - - this->active_shape = NULL; - this->active_shape_repr = NULL; - this->active_shape_layer_repr = NULL; - - this->active_conn = NULL; - this->active_conn_repr = NULL; - - this->active_handle = NULL; - - this->selected_handle = NULL; - - this->clickeditem = NULL; - this->clickedhandle = NULL; - +ConnectorTool::ConnectorTool() + : ToolBase(cursor_connector_xpm, 1, 1) + , selection(NULL) + , npoints(0) + , state(SP_CONNECTOR_CONTEXT_IDLE) + , red_bpath(NULL) + , red_curve(NULL) + , red_color(0xff00007f) + , green_curve(NULL) + , newconn(NULL) + , newConnRef(NULL) + , curvature(0.0) + , isOrthogonal(false) + , active_shape(NULL) + , active_shape_repr(NULL) + , active_shape_layer_repr(NULL) + , active_conn(NULL) + , active_conn_repr(NULL) + , active_handle(NULL) + , selected_handle(NULL) + , clickeditem(NULL) + , clickedhandle(NULL) + , shref(NULL) + , ehref(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) +{ for (int i = 0; i < 2; ++i) { this->endpt_handle[i] = NULL; this->endpt_handler_id[i] = 0; } - - this->shref = NULL; - this->ehref = NULL; - this->npoints = 0; - this->state = SP_CONNECTOR_CONTEXT_IDLE; } ConnectorTool::~ConnectorTool() { diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 88ed342df..e9e2d6c39 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -72,21 +72,17 @@ const std::string& DropperTool::getPrefsPath() { const std::string DropperTool::prefsPath = "/tools/dropper"; -DropperTool::DropperTool() : ToolBase() { - this->R = 0; - this->G = 0; - this->B = 0; - this->alpha = 0; - this->dragging = false; - - this->grabbed = 0; - this->area = 0; - this->centre = Geom::Point(0, 0); - - this->cursor_shape = cursor_dropper_f_xpm; - this->hot_x = 7; - this->hot_y = 7; - +DropperTool::DropperTool() + : ToolBase(cursor_dropper_f_xpm, 7, 7) + , R(0) + , G(0) + , B(0) + , alpha(0) + , dragging(false) + , grabbed(NULL) + , area(NULL) + , centre(0, 0) +{ cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7); cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7); } diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index cec58dce9..21b4b0532 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -23,40 +23,41 @@ namespace Inkscape { namespace UI { namespace Tools { -DynamicBase::DynamicBase() : - ToolBase(), - accumulated(NULL), - segments(NULL), - currentshape(NULL), - currentcurve(NULL), - cal1(NULL), - cal2(NULL), - point1(), - point2(), - repr(NULL), - cur(0,0), - vel(0,0), - vel_max(0), - acc(0,0), - ang(0,0), - last(0,0), - del(0,0), - pressure(DEFAULT_PRESSURE), - xtilt(0), - ytilt(0), - dragging(FALSE), - usepressure(FALSE), - usetilt(FALSE), - mass(0.3), - drag(DRAG_DEFAULT), - angle(30.0), - width(0.2), - vel_thin(0.1), - flatness(0.9), - tremor(0), - cap_rounding(0), - is_drawing(false), - abs_width(false) +DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : ToolBase(cursor_shape, hot_x, hot_y) + , accumulated(NULL) + , segments(NULL) + , currentshape(NULL) + , currentcurve(NULL) + , cal1(NULL) + , cal2(NULL) + , point1() + , point2() + , npoints(0) + , repr(NULL) + , cur(0, 0) + , vel(0, 0) + , vel_max(0) + , acc(0, 0) + , ang(0, 0) + , last(0, 0) + , del(0, 0) + , pressure(DEFAULT_PRESSURE) + , xtilt(0) + , ytilt(0) + , dragging(false) + , usepressure(false) + , usetilt(false) + , mass(0.3) + , drag(DRAG_DEFAULT) + , angle(30.0) + , width(0.2) + , vel_thin(0.1) + , flatness(0.9) + , tremor(0) + , cap_rounding(0) + , is_drawing(false) + , abs_width(false) { } diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h index 9218eabd3..76fcd0f02 100644 --- a/src/ui/tools/dynamic-base.h +++ b/src/ui/tools/dynamic-base.h @@ -31,7 +31,7 @@ namespace Tools { class DynamicBase : public ToolBase { public: - DynamicBase(); + DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~DynamicBase(); virtual void set(const Inkscape::Preferences::Entry& val); @@ -81,9 +81,9 @@ protected: gdouble ytilt; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; double mass, drag; double angle; double width; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 270987d27..011d28663 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -103,10 +103,9 @@ const std::string& EraserTool::getPrefsPath() { const std::string EraserTool::prefsPath = "/tools/eraser"; -EraserTool::EraserTool() : DynamicBase() { - this->cursor_shape = cursor_eraser_xpm; - this->hot_x = 4; - this->hot_y = 4; +EraserTool::EraserTool() + : DynamicBase(cursor_eraser_xpm, 4, 4) +{ } EraserTool::~EraserTool() { diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 4e29b8856..d74848dc6 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -94,17 +94,12 @@ const std::string& FloodTool::getPrefsPath() { const std::string FloodTool::prefsPath = "/tools/paintbucket"; -FloodTool::FloodTool() : ToolBase() { - this->cursor_shape = cursor_paintbucket_xpm; - this->hot_x = 11; - this->hot_y = 30; - this->xp = 0; - this->yp = 0; +FloodTool::FloodTool() + : ToolBase(cursor_paintbucket_xpm, 11, 30) + , item(NULL) +{ + // TODO: Why does the flood tool use a hardcoded tolerance instead of a pref? this->tolerance = 4; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->item = NULL; } FloodTool::~FloodTool() { diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 1e0e6b3b6..2fb4a3481 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -70,37 +70,31 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc); static void spdc_reset_white(FreehandBase *dc); static void spdc_free_colors(FreehandBase *dc); -FreehandBase::FreehandBase() : ToolBase() { - this->selection = 0; - this->grab = 0; - this->anchor_statusbar = false; - - this->attach = FALSE; - - this->red_color = 0xff00007f; - this->blue_color = 0x0000ff7f; - this->green_color = 0x00ff007f; - this->red_curve_is_valid = false; - - this->red_bpath = NULL; - this->red_curve = NULL; - - this->blue_bpath = NULL; - this->blue_curve = NULL; - - this->green_bpaths = NULL; - this->green_curve = NULL; - this->green_anchor = NULL; - this->green_closed = false; - - this->white_item = NULL; - this->white_curves = NULL; - this->white_anchors = NULL; - - this->sa = NULL; - this->ea = NULL; - - this->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE; +FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : ToolBase(cursor_shape, hot_x, hot_y) + , selection(NULL) + , grab(NULL) + , attach(false) + , red_color(0xff00007f) + , blue_color(0x0000ff7f) + , green_color(0x00ff007f) + , red_bpath(NULL) + , red_curve(NULL) + , blue_bpath(NULL) + , blue_curve(NULL) + , green_bpaths(NULL) + , green_curve(NULL) + , green_anchor(NULL) + , green_closed(false) + , white_item(NULL) + , white_curves(NULL) + , white_anchors(NULL) + , sa(NULL) + , ea(NULL) + , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE) + , red_curve_is_valid(false) + , anchor_statusbar(false) +{ } FreehandBase::~FreehandBase() { diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 7e53684e3..c8da9faed 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -37,13 +37,13 @@ namespace Tools { class FreehandBase : public ToolBase { public: - FreehandBase(); + FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~FreehandBase(); Inkscape::Selection *selection; SPCanvasItem *grab; - guint attach : 1; + bool attach; guint32 red_color; guint32 blue_color; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 10f78a8a8..a0bbfbaf1 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -74,20 +74,16 @@ const std::string& GradientTool::getPrefsPath() { const std::string GradientTool::prefsPath = "/tools/gradient"; -GradientTool::GradientTool() : ToolBase() { - this->node_added = false; - this->subselcon = 0; - this->selcon = 0; - - this->cursor_addnode = false; - this->cursor_shape = cursor_gradient_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; +GradientTool::GradientTool() + : ToolBase(cursor_gradient_xpm, 4, 4) + , cursor_addnode(false) + , node_added(false) +// TODO: Why are these connections stored as pointers? + , selcon(NULL) + , subselcon(NULL) +{ + // TODO: This value is overwritten in the root handler this->tolerance = 6; - this->within_tolerance = false; - this->item_to_select = NULL; } GradientTool::~GradientTool() { diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index a5406f1c5..6c41bb160 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -81,16 +81,14 @@ const std::string& LpeTool::getPrefsPath() { const std::string LpeTool::prefsPath = "/tools/lpetool"; -LpeTool::LpeTool() : PenTool() { - this->mode = Inkscape::LivePathEffect::BEND_PATH; - this->shape_editor = 0; - - this->cursor_shape = cursor_crosshairs_xpm; - this->hot_x = 7; - this->hot_y = 7; - - this->canvas_bbox = NULL; - this->measuring_items = new std::map<SPPath *, SPCanvasItem*>; +LpeTool::LpeTool() + : PenTool(cursor_crosshairs_xpm, 7, 7) + , shape_editor(NULL) + , canvas_bbox(NULL) + , mode(Inkscape::LivePathEffect::BEND_PATH) +// TODO: pointer? + , measuring_items(new std::map<SPPath *, SPCanvasItem*>) +{ } LpeTool::~LpeTool() { diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 4d7f1e074..380aa79e3 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -236,12 +236,10 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const ¢er, Geom } // namespace -MeasureTool::MeasureTool() : ToolBase() { - this->grabbed = 0; - - this->cursor_shape = cursor_measure_xpm; - this->hot_x = 4; - this->hot_y = 4; +MeasureTool::MeasureTool() + : ToolBase(cursor_measure_xpm, 4, 4) + , grabbed(NULL) +{ } MeasureTool::~MeasureTool() { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 4e7617f44..7d6d3bc23 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -75,20 +75,18 @@ const std::string& MeshTool::getPrefsPath() { const std::string MeshTool::prefsPath = "/tools/mesh"; -MeshTool::MeshTool() : ToolBase() { - this->selcon = 0; - this->node_added = false; - this->subselcon = 0; - - this->cursor_addnode = false; - this->cursor_shape = cursor_gradient_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; +// TODO: The gradient tool class looks like a 1:1 copy. + +MeshTool::MeshTool() + : ToolBase(cursor_gradient_xpm, 4, 4) + , cursor_addnode(false) + , node_added(false) +// TODO: Why are these connections stored as pointers? + , selcon(NULL) + , subselcon(NULL) +{ + // TODO: This value is overwritten in the root handler this->tolerance = 6; - this->within_tolerance = false; - this->item_to_select = NULL; } MeshTool::~MeshTool() { diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 7e33b1a4c..b1e11bd66 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -126,30 +126,27 @@ const std::string NodeTool::prefsPath = "/tools/nodes"; SPCanvasGroup *create_control_group(SPDesktop *d); -NodeTool::NodeTool() : ToolBase() { - this->show_handles = false; - this->single_node_transform_handles = false; - this->show_transform_handles = false; - this->cursor_drag = false; - this->live_objects = false; - this->edit_clipping_paths = false; - this->live_outline = false; - this->flashed_item = 0; - this->_transform_handle_group = 0; - this->show_path_direction = false; - this->_last_over = 0; - this->edit_masks = false; - this->show_outline = false; - this->flash_tempitem = 0; - - this->cursor_shape = cursor_node_xpm; - this->hot_x = 1; - this->hot_y = 1; - - this->_selected_nodes = 0; - this->_multipath = 0; - this->_selector = 0; - this->_path_data = 0; +NodeTool::NodeTool() + : ToolBase(cursor_node_xpm, 1, 1) + , _selected_nodes(NULL) + , _multipath(NULL) + , edit_clipping_paths(false) + , edit_masks(false) + , flashed_item(NULL) + , flash_tempitem(NULL) + , _selector(NULL) + , _path_data(NULL) + , _transform_handle_group(NULL) + , _last_over(NULL) + , cursor_drag(false) + , show_handles(false) + , show_outline(false) + , live_outline(false) + , live_objects(false) + , show_path_direction(false) + , show_transform_handles(false) + , single_node_transform_handles(false) +{ } SPCanvasGroup *create_control_group(SPDesktop *d) diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index dc5e801c0..39b69f576 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -89,29 +89,44 @@ const std::string& PenTool::getPrefsPath() { const std::string PenTool::prefsPath = "/tools/freehand/pen"; -PenTool::PenTool() : FreehandBase() { - this->polylines_only = false; - this->polylines_paraxial = false; - this->expecting_clicks_for_LPE = 0; - - this->cursor_shape = cursor_pen_xpm; - this->hot_x = 4; - this->hot_y = 4; - - this->npoints = 0; - this->mode = MODE_CLICK; - this->state = POINT; - - this->c0 = NULL; - this->c1 = NULL; - this->cl0 = NULL; - this->cl1 = NULL; - - this->events_disabled = 0; +PenTool::PenTool() + : FreehandBase(cursor_pen_xpm, 4, 4) + , p() + , npoints(0) + , mode(MODE_CLICK) + , state(POINT) + , polylines_only(false) + , polylines_paraxial(false) + , num_clicks(0) + , expecting_clicks_for_LPE(0) + , waiting_LPE(NULL) + , waiting_item(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) + , events_disabled(false) +{ +} - this->num_clicks = 0; - this->waiting_LPE = NULL; - this->waiting_item = NULL; +PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : FreehandBase(cursor_shape, hot_x, hot_y) + , p() + , npoints(0) + , mode(MODE_CLICK) + , state(POINT) + , polylines_only(false) + , polylines_paraxial(false) + , num_clicks(0) + , expecting_clicks_for_LPE(0) + , waiting_LPE(NULL) + , waiting_item(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) + , events_disabled(false) +{ } PenTool::~PenTool() { @@ -1305,13 +1320,13 @@ static void spdc_pen_finish(PenTool *const pc, gboolean const closed) } static void pen_disable_events(PenTool *const pc) { - pc->events_disabled++; + pc->events_disabled = true; } static void pen_enable_events(PenTool *const pc) { - g_return_if_fail(pc->events_disabled != 0); + g_return_if_fail(pc->events_disabled != 0); - pc->events_disabled--; + pc->events_disabled = false; } void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type, diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 4452dbd68..f2b1ee04a 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -23,6 +23,7 @@ namespace Tools { class PenTool : public FreehandBase { public: PenTool(); + PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~PenTool(); enum Mode { @@ -60,7 +61,7 @@ public: SPCtrlLine *cl0; SPCtrlLine *cl1; - unsigned int events_disabled : 1; + bool events_disabled; static const std::string prefsPath; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 52779d551..4fbaa50f3 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -83,20 +83,15 @@ const std::string& PencilTool::getPrefsPath() { const std::string PencilTool::prefsPath = "/tools/freehand/pencil"; -PencilTool::PencilTool() : - FreehandBase(), - p(), - npoints(0), - state(SP_PENCIL_CONTEXT_IDLE), - req_tangent(0,0), - is_drawing(false), - ps(), - sketch_interpolation(Geom::Piecewise<Geom::D2<Geom::SBasis> >())// since PencilTool is not properly constructed... +PencilTool::PencilTool() + : FreehandBase(cursor_pencil_xpm, 4, 4) + , p() + , npoints(0) + , state(SP_PENCIL_CONTEXT_IDLE) + , req_tangent(0, 0) + , is_drawing(false) + , sketch_n(0) { - this->cursor_shape = cursor_pencil_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->sketch_n = 0; } void PencilTool::setup() { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 263fdea84..f5153e8ce 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -66,20 +66,12 @@ const std::string& RectTool::getPrefsPath() { const std::string RectTool::prefsPath = "/tools/shapes/rect"; -RectTool::RectTool() : ToolBase() { - this->cursor_shape = cursor_rect_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->rect = NULL; - - this->rx = 0.0; - this->ry = 0.0; +RectTool::RectTool() + : ToolBase(cursor_rect_xpm, 4, 4) + , rect(NULL) + , rx(0) + , ry(0) +{ } void RectTool::finish() { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 498882417..85bc3fd4a 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -90,24 +90,24 @@ sp_load_handles(int start, int count, char const **xpm) { } } -SelectTool::SelectTool() : ToolBase() { - this->grabbed = 0; - this->item = 0; - - this->dragging = FALSE; - this->moved = FALSE; - this->button_press_shift = false; - this->button_press_ctrl = false; - this->button_press_alt = false; - this->cycling_items = NULL; - this->cycling_items_cmp = NULL; - this->cycling_items_selected_before = NULL; - this->cycling_cur_item = NULL; - this->cycling_wrap = true; - this->_seltrans = NULL; - this->_describer = NULL; - - +SelectTool::SelectTool() + // Don't load a default cursor + : ToolBase(NULL, 0, 0) + , dragging(false) + , moved(false) + , button_press_shift(false) + , button_press_ctrl(false) + , button_press_alt(false) + , cycling_items(NULL) + , cycling_items_cmp(NULL) + , cycling_items_selected_before(NULL) + , cycling_cur_item(NULL) + , cycling_wrap(true) + , item(NULL) + , grabbed(NULL) + , _seltrans(NULL) + , _describer(NULL) +{ // cursors in select context CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1); CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1); diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index b26fc03bc..81763e8b1 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -35,8 +35,8 @@ public: SelectTool(); virtual ~SelectTool(); - guint dragging : 1; - guint moved : 1; + bool dragging; + bool moved; bool button_press_shift; bool button_press_ctrl; bool button_press_alt; diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 005b2d239..7d33b0f67 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -65,21 +65,13 @@ const std::string& SpiralTool::getPrefsPath() { const std::string SpiralTool::prefsPath = "/tools/shapes/spiral"; -SpiralTool::SpiralTool() : ToolBase() { - this->cursor_shape = cursor_spiral_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->spiral = NULL; - - this->revo = 3.0; - this->exp = 1.0; - this->t0 = 0.0; +SpiralTool::SpiralTool() + : ToolBase(cursor_spiral_xpm, 4, 4) + , spiral(NULL) + , revo(3) + , exp(1) + , t0(0) +{ } void SpiralTool::finish() { diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 14a3acd9a..2fc3f1c91 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -134,35 +134,30 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it item->doWriteTransform(item->getRepr(), item->transform); } -SprayTool::SprayTool() : ToolBase() { - this->usetilt = 0; - this->dilate_area = 0; - this->usetext = false; - this->population = 0; - this->is_drawing = false; - this->mode = 0; - this->usepressure = 0; - - this->cursor_shape = cursor_spray_xpm; - this->hot_x = 4; - this->hot_y = 4; - - /* attributes */ - this->dragging = FALSE; - this->distrib = 1; - this->width = 0.2; - this->force = 0.2; - this->ratio = 0; - this->tilt = 0; - this->mean = 0.2; - this->rotation_variation = 0; - this->standard_deviation = 0.2; - this->scale = 1; - this->scale_variation = 1; - this->pressure = TC_DEFAULT_PRESSURE; - - this->is_dilating = false; - this->has_dilated = false; +SprayTool::SprayTool() + : ToolBase(cursor_spray_xpm, 4, 4) + , pressure(TC_DEFAULT_PRESSURE) + , dragging(false) + , usepressure(0) + , usetilt(0) + , usetext(false) + , width(0.2) + , ratio(0) + , tilt(0) + , rotation_variation(0) + , force(0.2) + , population(0) + , scale_variation(1) + , scale(1) + , mean(0.2) + , standard_deviation(0.2) + , distrib(1) + , mode(0) + , is_drawing(false) + , is_dilating(false) + , has_dilated(false) + , dilate_area(NULL) +{ } SprayTool::~SprayTool() { diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index e7362fd50..1a8f98006 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -61,10 +61,10 @@ public: gdouble pressure; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; - bool usetext ; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; + bool usetext; double width; double ratio; diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index b5d8c4418..42010788f 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -69,25 +69,15 @@ const std::string& StarTool::getPrefsPath() { const std::string StarTool::prefsPath = "/tools/shapes/star"; -StarTool::StarTool() : ToolBase() { - this->randomized = 0; - this->rounded = 0; - - this->cursor_shape = cursor_star_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - //this->tool_url = "/tools/shapes/star"; - - this->star = NULL; - - this->magnitude = 5; - this->proportion = 0.5; - this->isflatsided = false; +StarTool::StarTool() + : ToolBase(cursor_star_xpm, 4, 4) + , star(NULL) + , magnitude(5) + , proportion(0.5) + , isflatsided(false) + , rounded(0) + , randomized(0) +{ } void StarTool::finish() { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index ba68c7829..00f6a853c 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -91,37 +91,26 @@ const std::string& TextTool::getPrefsPath() { const std::string TextTool::prefsPath = "/tools/text"; -TextTool::TextTool() : ToolBase() { - this->preedit_string = 0; - this->unipos = 0; - - this->cursor_shape = cursor_text_xpm; - this->hot_x = 7; - this->hot_y = 7; - - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - - this->imc = NULL; - - this->text = NULL; - this->pdoc = Geom::Point(0, 0); - - this->unimode = false; - - this->cursor = NULL; - this->indicator = NULL; - this->frame = NULL; - this->grabbed = NULL; - this->timeout = 0; - this->show = FALSE; - this->phase = 0; - this->nascent_object = 0; - this->over_text = 0; - this->dragging = 0; - this->creating = 0; +TextTool::TextTool() + : ToolBase(cursor_text_xpm, 7, 7) + , imc(NULL) + , text(NULL) + , pdoc(0, 0) + , unimode(false) + , unipos(0) + , cursor(NULL) + , indicator(NULL) + , frame(NULL) + , timeout(0) + , show(false) + , phase(false) + , nascent_object(false) + , over_text(false) + , dragging(0) + , creating(false) + , grabbed(NULL) + , preedit_string(NULL) +{ } TextTool::~TextTool() { diff --git a/src/ui/tools/text-tool.h b/src/ui/tools/text-tool.h index ef8a67984..c5336d378 100644 --- a/src/ui/tools/text-tool.h +++ b/src/ui/tools/text-tool.h @@ -61,15 +61,15 @@ public: SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes std::vector<SPCanvasItem*> text_selection_quads; gint timeout; - guint show : 1; - guint phase : 1; - guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL + bool show; + bool phase; + bool nascent_object; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL - guint over_text : 1; // true if cursor is over a text object + bool over_text; // true if cursor is over a text object guint dragging : 2; // dragging selection over text - guint creating : 1; // dragging rubberband to create flowtext + bool creating; // dragging rubberband to create flowtext SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window Geom::Point p0; // initial point if the flowtext rect diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index cc028724a..dc10e9388 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -90,28 +90,26 @@ SPDesktop const& ToolBase::getDesktop() const { return *desktop; } -ToolBase::ToolBase() { - this->hot_y = 0; - this->xp = 0; - this->cursor_shape = 0; - this->pref_observer = 0; - this->hot_x = 0; - this->yp = 0; - this->within_tolerance = false; - this->tolerance = 0; - //this->key = 0; - this->item_to_select = 0; - - this->desktop = NULL; - this->cursor = NULL; - this->message_context = NULL; - this->_selcue = NULL; - this->_grdrag = NULL; - this->space_panning = false; - this->shape_editor = NULL; - this->_delayed_snap_event = NULL; - this->_dse_callback_in_process = false; - //this->tool_url = NULL; +ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : pref_observer(NULL) + , cursor(NULL) + , xp(0) + , yp(0) + , tolerance(0) + , within_tolerance(false) + , item_to_select(NULL) + , message_context(NULL) + , _selcue(NULL) + , _grdrag(NULL) + , shape_editor(NULL) + , space_panning(false) + , _delayed_snap_event(NULL) + , _dse_callback_in_process(false) + , desktop(NULL) + , cursor_shape(cursor_shape) + , hot_x(hot_x) + , hot_y(hot_y) +{ } ToolBase::~ToolBase() { diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 43edc4bd7..a4a27a06c 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -110,7 +110,8 @@ public: void enableGrDrag (bool enable=true); bool deleteSelectedDrag(bool just_one); - ToolBase(); + ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + virtual ~ToolBase(); Inkscape::Preferences::Observer *pref_observer; @@ -179,8 +180,11 @@ public: SPDesktop *desktop; protected: + /// An xpm containing the shape of the tool's cursor. gchar const *const *cursor_shape; - gint hot_x, hot_y; ///< indicates the cursor's hot spot + + /// The cursor's hot spot + gint hot_x, hot_y; private: ToolBase(const ToolBase&); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 0791eff5a..75650d3af 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -111,32 +111,25 @@ const std::string& TweakTool::getPrefsPath() { const std::string TweakTool::prefsPath = "/tools/tweak"; -TweakTool::TweakTool() : ToolBase() { - this->mode = 0; - this->dilate_area = 0; - this->usetilt = 0; - this->usepressure = 0; - this->is_drawing = false; - this->fidelity = 0; - - this->cursor_shape = cursor_push_xpm; - this->hot_x = 4; - this->hot_y = 4; - - /* attributes */ - this->dragging = FALSE; - - this->width = 0.2; - this->force = 0.2; - this->pressure = TC_DEFAULT_PRESSURE; - - this->is_dilating = false; - this->has_dilated = false; - - this->do_h = true; - this->do_s = true; - this->do_l = true; - this->do_o = false; +TweakTool::TweakTool() + : ToolBase(cursor_push_xpm, 4, 4) + , pressure(TC_DEFAULT_PRESSURE) + , dragging(false) + , usepressure(false) + , usetilt(false) + , width(0.2) + , force(0.2) + , fidelity(0) + , mode(0) + , is_drawing(false) + , is_dilating(false) + , has_dilated(false) + , dilate_area(NULL) + , do_h(true) + , do_s(true) + , do_l(true) + , do_o(false) +{ } TweakTool::~TweakTool() { diff --git a/src/ui/tools/tweak-tool.h b/src/ui/tools/tweak-tool.h index 6cbb9aded..7fe4b1856 100644 --- a/src/ui/tools/tweak-tool.h +++ b/src/ui/tools/tweak-tool.h @@ -50,9 +50,9 @@ public: gdouble pressure; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; double width; double force; diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 0996e6cf4..9f99cfe2e 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -45,12 +45,11 @@ const std::string& ZoomTool::getPrefsPath() { const std::string ZoomTool::prefsPath = "/tools/zoom"; -ZoomTool::ZoomTool() : ToolBase() { - this->grabbed = 0; - this->cursor_shape = cursor_zoom_xpm; - this->hot_x = 6; - this->hot_y = 6; - this->escaped = false; +ZoomTool::ZoomTool() + : ToolBase(cursor_zoom_xpm, 6, 6) + , grabbed(NULL) + , escaped(false) +{ } ZoomTool::~ZoomTool() { |
