From 7c743348725ee5546a85c44b4abf74256423608f Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Wed, 29 Aug 2007 14:47:16 +0000 Subject: In ellipse and rect tool: include info about width/height ratio in status messages when Ctrl+dragging (bzr r3609) --- src/rect-context.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/rect-context.cpp') 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); } -- cgit v1.2.3