summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96fa6ba)
raw | patch | inline | side by side (parent: 96fa6ba)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 29 Nov 2007 23:31:22 +0000 (23:31 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 29 Nov 2007 23:31:22 +0000 (23:31 +0000) |
visibility already works, snap_enabled not yet.
index 654dcf903ce1ac836e14f2f8cf7bf6a72bc44ea5..55430bdaf90ecb95f622215440583e5c1dfe6ae9 100644 (file)
empspacing = atoi(value);
}
+ if ( (value = repr->attribute("visible")) ) {
+ visible = (strcmp(value,"true") == 0);
+ }
+
+ if ( (value = repr->attribute("snap_enabled")) ) {
+ snap_enabled = (strcmp(value,"true") == 0);
+ }
+
for (GSList *l = canvasitems; l != NULL; l = l->next) {
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
}
_wr.setUpdating (true);
- //_rrb_gridtype.setValue (nv->gridtype);
+ _rcb_visible.setActive(visible);
+ _rcb_snap_enabled.setActive(snap_enabled);
+
_rumg.setUnit (gridunit);
gdouble val;
index d099de492359eb8f112a7c9b349d12a8e569ba8f..2eaec9d6f2930941f21fd1e6d6c49ed018a8dc9b 100644 (file)
Inkscape::UI::Widget::RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sy, _rsu_ax, _rsu_az;
Inkscape::UI::Widget::RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
-
- Inkscape::UI::Widget::Registry _wr;
-
};
index 92e0c509634f510aafd2074fe9c933dca96fb8bc..de9afbfc1d89a01cc5e166c7c8ec0b12644cbfa1 100644 (file)
*
*/
+/* As a general comment, I am not exactly proud of how things are done.
+ * (for example the 'enable' widget and readRepr things)
+ * It does seem to work however. I intend to clean up and sort things out later, but that can take forever...
+ * Don't be shy to correct things.
+ */
+
#include "sp-canvas-util.h"
#include "display-forward.h"
{
GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item);
- sp_canvas_prepare_buffer (buf);
-
- if (gridcanvasitem->grid) gridcanvasitem->grid->Render(buf);
+ if ( gridcanvasitem->grid && gridcanvasitem->grid->isVisible() ) {
+ sp_canvas_prepare_buffer (buf);
+ gridcanvasitem->grid->Render(buf);
+ }
}
static void
@@ -151,7 +158,7 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
};
CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type)
- : namelabel("", Gtk::ALIGN_LEFT), gridtype(type)
+ : namelabel("", Gtk::ALIGN_LEFT), gridtype(type), visible(true), snap_enabled(true)
{
repr = in_repr;
doc = in_doc;
@@ -166,7 +173,17 @@ CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocume
str += getName();
str += "</b>";
namelabel.set_markup(str);
- vbox.pack_start(namelabel,true,true);
+ vbox.pack_start(namelabel, true, true);
+
+ _rcb_visible.init ( _("_Visible"),
+ _("Determines whether the grid is displayed or not. Objects are still snapped to invisible grids."),
+ "visible", _wr, false, repr, doc);
+ vbox.pack_start(*dynamic_cast<Gtk::Widget*>(_rcb_visible._button), true, true);
+
+ _rcb_snap_enabled.init ( _("_Snapping enabled"),
+ _("Determines whether to snap to this grid or not. Can be 'on' for invisible grids."),
+ "snap_enabled", _wr, false, repr, doc);
+ vbox.pack_start(*dynamic_cast<Gtk::Widget*>(_rcb_snap_enabled._button), true, true);
}
CanvasGrid::~CanvasGrid()
@@ -319,7 +336,6 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
}
-
// ##########################################################
// CanvasXYGrid
if ( (value = repr->attribute("originx")) ) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit));
-
}
+
if ( (value = repr->attribute("originy")) ) {
sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit);
origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit));
render_dotted = (strcmp(value,"true") == 0);
}
+ if ( (value = repr->attribute("visible")) ) {
+ visible = (strcmp(value,"true") == 0);
+ }
+
for (GSList *l = canvasitems; l != NULL; l = l->next) {
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
}
_wr.setUpdating (true);
+ _rcb_visible.setActive(visible);
+ _rcb_snap_enabled.setActive(snap_enabled);
+
_rumg.setUnit (gridunit);
gdouble val;
_rcp_gmcol.setRgba32 (empcolor);
_rsi.setValue (empspacing);
+ _rcb_dotted.setActive(render_dotted);
+
_wr.setUpdating (false);
return;
index f05d3b5cb0c2eb37132247aaa6911f7c74f20219..07e27cb4a4a0a390ee7da625c2c21e8a09fbf416 100644 (file)
virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0;
virtual void Render (SPCanvasBuf *buf) = 0;
- virtual void readRepr() {};
- virtual void onReprAttrChanged (Inkscape::XML::Node * /*repr*/, const gchar */*key*/, const gchar */*oldval*/, const gchar */*newval*/, bool /*is_interactive*/) {};
+ 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;
static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
+ bool isVisible() { return visible; };
+ bool isSnapEnabled() { return snap_enabled; };
+
protected:
CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type);
Gtk::VBox vbox;
Gtk::Label namelabel;
+ Inkscape::UI::Widget::Registry _wr;
+ Inkscape::UI::Widget::RegisteredCheckButton _rcb_visible;
+ bool visible;
+ Inkscape::UI::Widget::RegisteredCheckButton _rcb_snap_enabled;
+ bool snap_enabled;
+
GridType gridtype;
private:
Inkscape::UI::Widget::RegisteredSuffixedInteger _rsi;
Inkscape::UI::Widget::RegisteredCheckButton _rcb_dotted;
- Inkscape::UI::Widget::Registry _wr;
-
bool render_dotted;
};