From 035ce2118b56630a7ea1d16e7ff1db04a06a66b2 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Wed, 29 Aug 2007 14:47:16 +0000 Subject: [PATCH] In ellipse and rect tool: include info about width/height ratio in status messages when Ctrl+dragging --- src/arc-context.cpp | 20 +++++++++++++++++--- src/rect-context.cpp | 20 +++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/arc-context.cpp b/src/arc-context.cpp index ab6b3a01d..c2ec30a64 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -439,9 +439,23 @@ static void sp_arc_drag(SPArcContext *ac, NR::Point pt, guint state) r.midpoint()[NR::X], r.midpoint()[NR::Y], r.dimensions()[NR::X] / 2, r.dimensions()[NR::Y] / 2); - GString *xs = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::X], desktop->namedview->getDefaultMetric()); - GString *ys = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::Y], desktop->namedview->getDefaultMetric()); - ac->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s; with Ctrl to make circle or integer-ratio ellipse; with Shift to draw around the starting point"), xs->str, ys->str); + double rdimx = r.dimensions()[NR::X]; + double rdimy = r.dimensions()[NR::Y]; + GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric()); + GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric()); + if (state & GDK_CONTROL_MASK) { + int ratio_x, ratio_y; + if (fabs (rdimx) > fabs (rdimy)) { + ratio_x = (int) rint (rdimx / rdimy); + ratio_y = 1; + } else { + ratio_x = 1; + ratio_y = (int) rint (rdimy / rdimx); + } + ac->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + } else { + ac->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Ellipse: %s × %s; with Ctrl to make square or integer-ratio ellipse; with Shift to draw around the starting point"), xs->str, ys->str); + } g_string_free(xs, FALSE); g_string_free(ys, FALSE); } diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 9c25f91c0..d069e052c 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -487,9 +487,23 @@ static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state) } // status text - GString *xs = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::X], desktop->namedview->getDefaultMetric()); - GString *ys = SP_PX_TO_METRIC_STRING(r.dimensions()[NR::Y], desktop->namedview->getDefaultMetric()); - rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s; with Ctrl to make square or integer-ratio rectangle; with Shift to draw around the starting point"), xs->str, ys->str); + double rdimx = r.dimensions()[NR::X]; + double rdimy = r.dimensions()[NR::Y]; + GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric()); + GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric()); + if (state & GDK_CONTROL_MASK) { + int ratio_x, ratio_y; + if (fabs (rdimx) > fabs (rdimy)) { + ratio_x = (int) rint (rdimx / rdimy); + ratio_y = 1; + } else { + ratio_x = 1; + ratio_y = (int) rint (rdimy / rdimx); + } + rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s (constrained to ratio %d:%d); with Shift to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y); + } else { + rc._message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Rectangle: %s × %s; with Ctrl to make square or integer-ratio rectangle; with Shift to draw around the starting point"), xs->str, ys->str); + } g_string_free(xs, FALSE); g_string_free(ys, FALSE); } -- 2.30.2