X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fdisplay%2Fcanvas-grid.h;h=b8f313948e222fc3931c69f79cc3f01eeb69063d;hb=0dc33d4ce43e0bb49c63aa53b826ec4a1ff68e28;hp=b8ed8174c617d22200b416c6e563f36353a7609a;hpb=84e5676034b77e63dbc43746cec0a8b48fd06f7c;p=inkscape.git diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index b8ed8174c..b8f313948 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -1,36 +1,32 @@ -#ifndef INKSCAPE_CANVAS_GRID_H -#define INKSCAPE_CANVAS_GRID_H - -/* - * Inkscape::CXYGrid - * - * Generic (and quite unintelligent) grid item for gnome canvas - * - * Copyright (C) Johan Engelen 2006-2007 +/** @file + * @brief Cartesian grid item for the Inkscape canvas + */ +/* Copyright (C) Johan Engelen 2006-2007 * Copyright (C) Lauris Kaplinski 2000 - * */ -#include -#include "xml/repr.h" -#include +#ifndef INKSCAPE_CANVAS_GRID_H +#define INKSCAPE_CANVAS_GRID_H +#include +#include +#include #include + +#include "sp-canvas-item.h" +#include "xml/repr.h" #include "ui/widget/color-picker.h" #include "ui/widget/scalar-unit.h" - #include "ui/widget/registered-widget.h" #include "ui/widget/registry.h" -#include "ui/widget/tolerance-slider.h" - #include "xml/node-event-vector.h" - #include "snapper.h" #include "line-snapper.h" struct SPDesktop; struct SPNamedView; +struct SPCanvasBuf; class SPDocument; namespace Inkscape { @@ -83,13 +79,20 @@ public: GridCanvasItem * createCanvasItem(SPDesktop * desktop); - virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0; + virtual void Update (Geom::Matrix const &affine, unsigned int flags) = 0; virtual void Render (SPCanvasBuf *buf) = 0; virtual void readRepr() = 0; virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, const gchar */*key*/, const gchar */*oldval*/, const gchar */*newval*/, bool /*is_interactive*/) = 0; - virtual Gtk::Widget & getWidget() = 0; + Gtk::Widget * newWidget(); + + Geom::Point origin; /**< Origin of the grid */ + guint32 color; /**< Color for normal lines */ + guint32 empcolor; /**< Color for emphasis lines */ + gint empspacing; /**< Spacing between emphasis lines */ + + SPUnit const* gridunit; Inkscape::XML::Node * repr; SPDocument *doc; @@ -104,18 +107,15 @@ public: protected: CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type); + virtual Gtk::Widget * newSpecificWidget() = 0; + GSList * canvasitems; // list of created canvasitems SPNamedView * namedview; - Gtk::VBox vbox; - Gtk::Label namelabel; - Inkscape::UI::Widget::Registry _wr; - Inkscape::UI::Widget::RegisteredCheckButton _rcb_visible; bool visible; - Inkscape::UI::Widget::RegisteredCheckButton _rcb_enabled; - + GridType gridtype; private: @@ -129,40 +129,28 @@ public: CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); virtual ~CanvasXYGrid(); - void Update (NR::Matrix const &affine, unsigned int flags); + void Update (Geom::Matrix const &affine, unsigned int flags); void Render (SPCanvasBuf *buf); void readRepr(); void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive); - Gtk::Widget & getWidget(); - - NR::Point origin; - guint32 color; - guint32 empcolor; - gint empspacing; - SPUnit const* gridunit; - - NR::Point spacing; /**< Spacing between elements of the grid */ + Geom::Point spacing; /**< Spacing between elements of the grid */ bool scaled[2]; /**< Whether the grid is in scaled mode, which can - be different in the X or Y direction, hense two + be different in the X or Y direction, hence two variables */ - NR::Point ow; /**< Transformed origin by the affine for the zoom */ - NR::Point sw; /**< Transformed spacing by the affine for the zoom */ + Geom::Point ow; /**< Transformed origin by the affine for the zoom */ + Geom::Point sw; /**< Transformed spacing by the affine for the zoom */ + +protected: + virtual Gtk::Widget * newSpecificWidget(); + private: CanvasXYGrid(const CanvasXYGrid&); CanvasXYGrid& operator=(const CanvasXYGrid&); void updateWidgets(); - Gtk::Table table; - - Inkscape::UI::Widget::RegisteredUnitMenu _rumg, _rums; - Inkscape::UI::Widget::RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sx, _rsu_sy; - Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol; - Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi; - Inkscape::UI::Widget::RegisteredCheckButton _rcb_dotted; - bool render_dotted; }; @@ -171,12 +159,16 @@ private: class CanvasXYGridSnapper : public LineSnapper { public: - CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d); + CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager *sm, Geom::Coord const d); bool ThisSnapperMightSnap() const; + Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom) + bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance + private: - LineList _getSnapLines(NR::Point const &p) const; - void _addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, const NR::Point point_on_line) const; + LineList _getSnapLines(Geom::Point const &p) const; + void _addSnappedLine(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const; + void _addSnappedPoint(SnappedConstraints &sc, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; CanvasXYGrid *grid; };