From 7e05677238dae36ea57b290d468cafed09c48335 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Wed, 5 Mar 2008 18:57:01 +0000 Subject: [PATCH] New menu command to quickly create guides around page --- src/menus-skeleton.h | 2 ++ src/sp-guide.cpp | 19 +++++++++++++++++++ src/sp-guide.h | 1 + src/verbs.cpp | 7 +++++++ src/verbs.h | 1 + 5 files changed, 30 insertions(+) diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 208bc7994..56542e79e 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -84,6 +84,8 @@ static char const menus_skeleton[] = " \n" " \n" " \n" +" \n" +" \n" " \n" " \n" " \n" diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 81109c4fb..2f91a17cf 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -266,6 +266,25 @@ sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > pts; + + Geom::Point A(0, 0); + Geom::Point C(sp_document_width(doc), sp_document_height(doc)); + Geom::Point B(C[Geom::X], 0); + Geom::Point D(0, C[Geom::Y]); + + pts.push_back(std::make_pair(A, B)); + pts.push_back(std::make_pair(B, C)); + pts.push_back(std::make_pair(C, D)); + pts.push_back(std::make_pair(D, A)); + + sp_guide_pt_pairs_to_guides(doc, pts); + + sp_document_done (doc, SP_VERB_NONE, _("Guides around page")); +} + void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler) { SPCanvasItem *item = sp_guideline_new(group, guide->point_on_line, guide->normal_to_line.to_2geom()); diff --git a/src/sp-guide.h b/src/sp-guide.h index a9b04dfaa..502cf2c5b 100644 --- a/src/sp-guide.h +++ b/src/sp-guide.h @@ -47,6 +47,7 @@ GType sp_guide_get_type(); SPGuide *sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2); void sp_guide_pt_pairs_to_guides(SPDocument *doc, std::list > &pts); +void sp_guide_create_guides_around_page(SPDocument *doc); void sp_guide_show(SPGuide *guide, SPCanvasGroup *group, GCallback handler); void sp_guide_hide(SPGuide *guide, SPCanvas *canvas); diff --git a/src/verbs.cpp b/src/verbs.cpp index 08f1bb124..674ccdd82 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -81,6 +81,7 @@ #include "shape-editor.h" #include "draw-context.h" #include "gradient-drag.h" +#include "sp-guide.h" /** @@ -964,6 +965,10 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/) } break; + case SP_VERB_EDIT_GUIDES_AROUND_PAGE: + sp_guide_create_guides_around_page(sp_desktop_document(dt)); + break; + case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER: sp_selection_next_patheffect_param(dt); break; @@ -2231,6 +2236,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_GUIDES_AROUND_PAGE, "EditGuidesAroundPage", N_("_Guides around page"), + N_("Create four guides aligned with the page borders"), NULL), new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next Path Effect Parameter"), N_("Show next Path Effect parameter for editing"), "edit_next_parameter"), diff --git a/src/verbs.h b/src/verbs.h index 6576c9652..6924a4bfd 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -81,6 +81,7 @@ enum { SP_VERB_EDIT_SELECT_NEXT, SP_VERB_EDIT_SELECT_PREV, SP_VERB_EDIT_DESELECT, + SP_VERB_EDIT_GUIDES_AROUND_PAGE, SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, /* Selection */ SP_VERB_SELECTION_TO_FRONT, -- 2.30.2