From: johanengelen Date: Wed, 24 Oct 2007 23:19:48 +0000 (+0000) Subject: Fix bug [ 1818794 ] Showing grid on opening svg X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b217fa4b3fb2d35e4b65f89e476f6808191c18a1;p=inkscape.git Fix bug [ 1818794 ] Showing grid on opening svg + some bits of code to do on-canvas path parameter editing LPE. --- diff --git a/src/attributes-test.h b/src/attributes-test.h index 1030f9e46..57eb03eb5 100644 --- a/src/attributes-test.h +++ b/src/attributes-test.h @@ -404,12 +404,12 @@ struct {char const *attr; bool supported;} const all_attrs[] = { /* SPNamedView */ {"viewonly", true}, {"showgrid", true}, - {"gridtype", true}, +// {"gridtype", true}, {"showguides", true}, {"gridtolerance", true}, {"guidetolerance", true}, {"objecttolerance", true}, - {"gridoriginx", true}, +/* {"gridoriginx", true}, {"gridoriginy", true}, {"gridspacingx", true}, {"gridspacingy", true}, @@ -419,7 +419,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = { {"gridopacity", true}, {"gridempcolor", true}, {"gridempopacity", true}, - {"gridempspacing", true}, + {"gridempspacing", true}, */ {"guidecolor", true}, {"guideopacity", true}, {"guidehicolor", true}, diff --git a/src/attributes.cpp b/src/attributes.cpp index 977ab3483..5fb4a87a0 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -61,6 +61,7 @@ static SPStyleProp const props[] = { /* SPNamedView */ {SP_ATTR_VIEWONLY, "viewonly"}, {SP_ATTR_SHOWGUIDES, "showguides"}, + {SP_ATTR_SHOWGRIDS, "showgrid"}, {SP_ATTR_GRIDTOLERANCE, "gridtolerance"}, {SP_ATTR_GUIDETOLERANCE, "guidetolerance"}, {SP_ATTR_OBJECTTOLERANCE, "objecttolerance"}, diff --git a/src/attributes.h b/src/attributes.h index 4a2970830..6d05361f2 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -62,6 +62,7 @@ enum SPAttributeEnum { /* SPNamedView */ SP_ATTR_VIEWONLY, SP_ATTR_SHOWGUIDES, + SP_ATTR_SHOWGRIDS, SP_ATTR_GRIDTOLERANCE, SP_ATTR_GUIDETOLERANCE, SP_ATTR_OBJECTTOLERANCE, diff --git a/src/desktop.cpp b/src/desktop.cpp index 4b4d1fe5b..4d2cd2fcb 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -146,7 +146,7 @@ SPDesktop::SPDesktop() : _w2d(), _d2w(), _doc2dt( NR::Matrix(NR::scale(1, -1)) ), - grids_visible( true ) + grids_visible( false ) { _d2w.set_identity(); _w2d.set_identity(); @@ -308,7 +308,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) // (Setting up after the connections are all in place, as it may use some of them) layer_manager = new Inkscape::LayerManager( this ); - grids_visible = true; + showGrids(namedview->grids_visible); } @@ -1176,23 +1176,29 @@ void SPDesktop::clearWaitingCursor() sp_event_context_update_cursor(sp_desktop_event_context(this)); } -void SPDesktop::toggleGrid() +void SPDesktop::toggleGrids() { if (namedview->grids) { if(gridgroup) { - grids_visible = !grids_visible; - if (grids_visible) { - sp_canvas_item_show(SP_CANVAS_ITEM(gridgroup)); - } else { - sp_canvas_item_hide(SP_CANVAS_ITEM(gridgroup)); - } + showGrids(!grids_visible); } } else { //there is no grid present at the moment. add a rectangular grid and make it visible Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); Inkscape::CanvasGrid::writeNewGridToRepr(repr, sp_desktop_document(this), Inkscape::GRID_RECTANGULAR); - grids_visible = true; + showGrids(true); + } +} + +void SPDesktop::showGrids(bool show) +{ + grids_visible = show; + g_message(show?"show":"hide"); + sp_namedview_show_grids(namedview, grids_visible); + if (show) { sp_canvas_item_show(SP_CANVAS_ITEM(gridgroup)); + } else { + sp_canvas_item_hide(SP_CANVAS_ITEM(gridgroup)); } } diff --git a/src/desktop.h b/src/desktop.h index bc80336de..2a811a723 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -260,9 +260,10 @@ struct SPDesktop : public Inkscape::UI::View::View void setWaitingCursor(); void clearWaitingCursor(); - void toggleGrid(); + void toggleGrids(); bool gridsEnabled() { return grids_visible; } - + void showGrids(bool show); + bool is_iconified(); bool is_maximized(); bool is_fullscreen(); @@ -286,8 +287,8 @@ struct SPDesktop : public Inkscape::UI::View::View virtual void mouseover() {} virtual void mouseout() {} - virtual bool onDeleteUI (GdkEventAny*); - virtual bool onWindowStateEvent (GdkEventWindowState* event); + virtual bool onDeleteUI (GdkEventAny*); + virtual bool onWindowStateEvent (GdkEventWindowState* event); private: Inkscape::UI::View::EditWidgetInterface *_widget; @@ -297,9 +298,10 @@ private: NR::Matrix _w2d; NR::Matrix _d2w; NR::Matrix _doc2dt; - - bool grids_visible; - + + bool grids_visible; /* don't set this variable directly, use the method below */ + void set_grids_visible(bool visible); + void push_current_zoom (GList**); sigc::signal _document_replaced_signal; @@ -307,7 +309,7 @@ private: sigc::signal _deactivate_signal; sigc::signal _event_context_changed_signal; sigc::signal _tool_subselection_changed; - + sigc::connection _activate_connection; sigc::connection _deactivate_connection; sigc::connection _sel_modified_connection; @@ -316,7 +318,7 @@ private: sigc::connection _reconstruction_finish_connection; sigc::connection _commit_connection; sigc::connection _modified_connection; - + virtual void onPositionSet (double, double); virtual void onResized (double, double); virtual void onRedrawRequested(); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index b6086db27..846d3699a 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -265,7 +265,8 @@ GridCanvasItem * CanvasGrid::createCanvasItem(SPDesktop * desktop) { if (!desktop) return NULL; - //Johan: I think for multiple desktops it is best if each has their own canvasitem, but share the same CanvasGrid object; that is what this function is for. +// Johan: I think for multiple desktops it is best if each has their own canvasitem, +// but share the same CanvasGrid object; that is what this function is for. // check if there is already a canvasitem on this desktop linking to this grid for (GSList *l = canvasitems; l != NULL; l = l->next) { diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 15ba663be..db1064511 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -25,7 +25,7 @@ #include "verbs.h" #include "document.h" -#define LPEPATHPARAM_DEBUG +// needed for on-canvas editting: #include "tools-switch.h" #include "shape-editor.h" #include "node-context.h" @@ -110,9 +110,6 @@ PathParam::param_getWidget() static_cast(_widget)->pack_start(*pButton, true, true); _tooltips->set_tip(*pButton, _("Edit on-canvas")); edit_button = pButton; -#ifndef LPEPATHPARAM_DEBUG - edit_button->set_sensitive(false); -#endif pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); pButton = Gtk::manage(new Gtk::Button()); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index fa41060c2..c019910cb 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -127,10 +127,11 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: if (((SPObjectClass *) (parent_class))->build) { (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); } - +g_message("tijdens laden %d", nv->viewcount); sp_object_read_attr(object, "inkscape:document-units"); sp_object_read_attr(object, "viewonly"); sp_object_read_attr(object, "showguides"); + sp_object_read_attr(object, "showgrid"); sp_object_read_attr(object, "gridtolerance"); sp_object_read_attr(object, "guidetolerance"); sp_object_read_attr(object, "objecttolerance"); @@ -206,7 +207,7 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->editable = (!value); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_SHOWGUIDES: + case SP_ATTR_SHOWGUIDES: if (!value) { // show guides if not specified, for backwards compatibility nv->showguides = TRUE; } else { @@ -215,7 +216,17 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va sp_namedview_setup_guides(nv); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_GRIDTOLERANCE: + case SP_ATTR_SHOWGRIDS: + if (!value) { // show grids if not specified, for backwards compatibility + nv->grids_visible = false; + } else { + nv->grids_visible = sp_str_to_bool(value); + g_message("set attr : %s", value); + } + g_message("set attr %s", nv->grids_visible ? "true":"false"); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + case SP_ATTR_GRIDTOLERANCE: nv->gridtoleranceunit = &px; nv->gridtolerance = DEFAULTTOLERANCE; if (value) { @@ -441,7 +452,7 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des break; } } - + if (!grid) { //create grid object Inkscape::GridType gridtype = Inkscape::CanvasGrid::getGridTypeFromSVGName(repr->attribute("type")); @@ -590,6 +601,8 @@ void SPNamedView::show(SPDesktop *desktop) } } } + + desktop->showGrids(grids_visible); } #define MIN_ONSCREEN_DISTANCE 50 @@ -761,6 +774,22 @@ void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) sp_document_set_undo_sensitive(doc, saved); } +void sp_namedview_show_grids(SPNamedView * namedview, bool show) +{ + namedview->grids_visible = show; + + SPDocument *doc = SP_OBJECT_DOCUMENT (namedview); + Inkscape::XML::Node *repr = SP_OBJECT_REPR(namedview); + + bool saved = sp_document_get_undo_sensitive(doc); + sp_document_set_undo_sensitive(doc, false); + + sp_repr_set_boolean(repr, "showgrid", namedview->grids_visible); + + doc->rroot->setAttribute("sodipodi:modified", "true"); + sp_document_set_undo_sensitive(doc, saved); +} + gchar const *SPNamedView::getName() const { SPException ex; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 7eefdfae5..8b6dbcc92 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -51,6 +51,7 @@ struct SPNamedView : public SPObjectGroup { SnapManager snap_manager; GSList * grids; + bool grids_visible; SPUnit const *doc_units; @@ -75,7 +76,7 @@ struct SPNamedView : public SPObjectGroup { GSList *guides; GSList *views; - + gint viewcount; void show(SPDesktop *desktop); @@ -100,6 +101,7 @@ void sp_namedview_document_from_window(SPDesktop *desktop); void sp_namedview_update_layers_from_document (SPDesktop *desktop); void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr); +void sp_namedview_show_grids(SPNamedView *namedview, bool show); #endif /* !INKSCAPE_SP_NAMEDVIEW_H */ diff --git a/src/verbs.cpp b/src/verbs.cpp index abf834c47..32e0c46af 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -999,6 +999,19 @@ EditVerb::perform(SPAction *action, void *data, void *pdata) sp_desktop_selection(dt)->clear(); } break; + + case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER: + //FACTOR OUT THIS CODE TO SOMEWHERE ELSE! + // if(selection has LPE) { + // If not already in nodecontext, goto it! + // if (!tools_isactive(dt, TOOLS_NODES)) { + // tools_switch_current(TOOLS_NODES); + // } + // add goto next code here: + //} else { + // statusbar message: selection has no path effect applied. + //} + break; default: break; } @@ -1646,7 +1659,7 @@ ZoomVerb::perform(SPAction *action, void *data, void *pdata) sp_namedview_toggle_guides(doc, repr); break; case SP_VERB_TOGGLE_GRID: - dt->toggleGrid(); + dt->toggleGrids(); break; #ifdef HAVE_GTK_WINDOW_FULLSCREEN case SP_VERB_FULLSCREEN: @@ -2246,6 +2259,8 @@ Verb *Verb::_base_verbs[] = { N_("Select previous object or node"), NULL), new EditVerb(SP_VERB_EDIT_DESELECT, "EditDeselect", N_("D_eselect"), N_("Deselect any selected objects or nodes"), "selection_deselect"), + new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next Path Effect Parameter"), + N_("Show next Path Effect parameter for editting"), NULL), /* Selection */ new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"), diff --git a/src/verbs.h b/src/verbs.h index 34a633b2f..ccb63dadd 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -78,6 +78,7 @@ enum { SP_VERB_EDIT_SELECT_NEXT, SP_VERB_EDIT_SELECT_PREV, SP_VERB_EDIT_DESELECT, + SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, /* Selection */ SP_VERB_SELECTION_TO_FRONT, SP_VERB_SELECTION_TO_BACK,