From 49a274f32919fa63e96bb66e76b691afafda66ff Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 16 Jul 2009 14:55:16 +0000 Subject: Implement guide behaviour as discussed on the mailing list (bzr r8293) --- src/sp-guide.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index e6983a681..f5edf7d97 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -404,35 +404,45 @@ void sp_guide_set_normal(SPGuide const &guide, Geom::Point const normal_to_line, /** * Returns a human-readable description of the guideline for use in dialog boxes and status bar. + * If verbose is false, only positioning information is included (useful for dialogs). * * The caller is responsible for freeing the string. */ -char *sp_guide_description(SPGuide const *guide) +char *sp_guide_description(SPGuide const *guide, const bool verbose) { using Geom::X; using Geom::Y; - GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); - GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); + GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], + SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); + GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], + SP_ACTIVE_DESKTOP->namedview->getDefaultMetric()); - const gchar *shortcuts = _("drag to move, Shift+drag to rotate, Ctrl+click to delete"); + gchar *shortcuts = g_strdup_printf("; %s", _("Shift+drag to rotate, Ctrl+drag to move origin, Del to delete")); + gchar *descr; if ( are_near(guide->normal_to_line, component_vectors[X]) || are_near(guide->normal_to_line, -component_vectors[X]) ) { - return g_strdup_printf(_("vertical, at %s; %s"), position_string_x->str, shortcuts); + descr = g_strdup_printf(_("vertical, at %s"), position_string_x->str); } else if ( are_near(guide->normal_to_line, component_vectors[Y]) || are_near(guide->normal_to_line, -component_vectors[Y]) ) { - return g_strdup_printf(_("horizontal, at %s; %s"), position_string_y->str, shortcuts); + descr = g_strdup_printf(_("horizontal, at %s"), position_string_y->str); } else { double const radians = guide->angle(); double const degrees = Geom::rad_to_deg(radians); int const degrees_int = (int) round(degrees); - return g_strdup_printf(_("at %d degrees, through (%s,%s); %s"), - degrees_int, position_string_x->str, position_string_y->str, shortcuts); + descr = g_strdup_printf(_("at %d degrees, through (%s,%s)"), + degrees_int, position_string_x->str, position_string_y->str); } g_string_free(position_string_x, TRUE); g_string_free(position_string_y, TRUE); + + if (verbose) { + descr = g_strconcat(descr, shortcuts, NULL); + } + g_free(shortcuts); + return descr; } void sp_guide_remove(SPGuide *guide) -- cgit v1.2.3 From 8b04d0db6c55e36935690d37defb6f9b68945796 Mon Sep 17 00:00:00 2001 From: johnce Date: Wed, 5 Aug 2009 05:40:36 +0000 Subject: SPDocument->Document (bzr r8404) --- src/sp-guide.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f5edf7d97..170dfa375 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -54,7 +54,7 @@ static void sp_guide_init(SPGuide *guide); static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); +static void sp_guide_build(SPObject *object, Document *document, Inkscape::XML::Node *repr); static void sp_guide_release(SPObject *object); static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value); @@ -152,7 +152,7 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) +static void sp_guide_build(SPObject *object, Document *document, Inkscape::XML::Node *repr) { if (((SPObjectClass *) (parent_class))->build) { (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); @@ -243,7 +243,7 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) SPGuide * sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { - SPDocument *doc=sp_desktop_document(desktop); + Document *doc=sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); @@ -269,7 +269,7 @@ sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > pts; Geom::Point A(0, 0); -- cgit v1.2.3 From 51c2905fd3e99955db2d823b79abb763d8097028 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 6 Aug 2009 14:17:17 +0000 Subject: Revert recent refactoring changes by johnce because they break the build, which cannot be fixed easily. (bzr r8422) --- src/sp-guide.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-guide.cpp') diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 170dfa375..f5edf7d97 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -54,7 +54,7 @@ static void sp_guide_init(SPGuide *guide); static void sp_guide_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void sp_guide_build(SPObject *object, Document *document, Inkscape::XML::Node *repr); +static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_guide_release(SPObject *object); static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value); @@ -152,7 +152,7 @@ static void sp_guide_get_property(GObject *object, guint prop_id, GValue *value, } } -static void sp_guide_build(SPObject *object, Document *document, Inkscape::XML::Node *repr) +static void sp_guide_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { if (((SPObjectClass *) (parent_class))->build) { (* ((SPObjectClass *) (parent_class))->build)(object, document, repr); @@ -243,7 +243,7 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) SPGuide * sp_guide_create(SPDesktop *desktop, Geom::Point const &pt1, Geom::Point const &pt2) { - Document *doc=sp_desktop_document(desktop); + SPDocument *doc=sp_desktop_document(desktop); Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); @@ -269,7 +269,7 @@ sp_guide_pt_pairs_to_guides(SPDesktop *dt, std::list > pts; Geom::Point A(0, 0); -- cgit v1.2.3