From d9ab41468cd941c287fbb056d6a27954ed95b65a Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 22 Dec 2011 21:23:17 +0000 Subject: [PATCH] In the cross visual tool, apply the same roundning rules to the coordinates set on double-click as for the displayed coordinates Originally committed to SVN as r6089. --- aegisub/src/visual_tool_cross.cpp | 15 +++++++++------ aegisub/src/visual_tool_cross.h | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/aegisub/src/visual_tool_cross.cpp b/aegisub/src/visual_tool_cross.cpp index 29f1cba0f..38582c77a 100644 --- a/aegisub/src/visual_tool_cross.cpp +++ b/aegisub/src/visual_tool_cross.cpp @@ -48,15 +48,15 @@ void VisualToolCross::OnDoubleClick() { int t1, t2; if (GetLineMove(*it, p1, p2, t1, t2)) { if (t1 > 0 || t2 > 0) - SetOverride(*it, "\\move", wxString::Format("(%s,%s,%d,%d)", (p1 + d).Str(), (p2 + d).Str(), t1, t2)); + SetOverride(*it, "\\move", wxString::Format("(%s,%s,%d,%d)", Text(p1 + d), Text(p2 + d), t1, t2)); else - SetOverride(*it, "\\move", wxString::Format("(%s,%s)", (p1 + d).Str(), (p2 + d).Str())); + SetOverride(*it, "\\move", wxString::Format("(%s,%s)", Text(p1 + d), Text(p2 + d))); } else - SetOverride(*it, "\\pos", (GetLinePosition(*it) + d).PStr()); + SetOverride(*it, "\\pos", "(" + Text(GetLinePosition(*it) + d) + ")"); if (Vector2D org = GetLineOrigin(*it)) - SetOverride(*it, "\\org", (org + d).PStr()); + SetOverride(*it, "\\org", "(" + Text(org + d) + ")"); } Commit(_("positioning")); @@ -77,8 +77,7 @@ void VisualToolCross::Draw() { gl.DrawLines(2, lines, 4); gl.ClearInvert(); - Vector2D t = ToScriptCoords(shift_down ? video_res - mouse_pos : mouse_pos); - wxString mouse_text = video_res.X() > script_res.X() ? t.Str() : t.DStr(); + wxString mouse_text = Text(ToScriptCoords(shift_down ? video_res - mouse_pos : mouse_pos)); int tw, th; gl_text->SetFont("Verdana", 12, true, false); @@ -100,3 +99,7 @@ void VisualToolCross::Draw() { gl_text->Print(mouse_text, dx, dy); } + +wxString VisualToolCross::Text(Vector2D v) { + return video_res.X() > script_res.X() ? v.Str() : v.DStr(); +} diff --git a/aegisub/src/visual_tool_cross.h b/aegisub/src/visual_tool_cross.h index 07cd8e032..d674c6ffd 100644 --- a/aegisub/src/visual_tool_cross.h +++ b/aegisub/src/visual_tool_cross.h @@ -32,9 +32,11 @@ class OpenGLText; /// @brief A crosshair which shows the current mouse position and on double-click /// shifts the selected lines to the clicked point class VisualToolCross : public VisualTool { + agi::scoped_ptr gl_text; + void OnDoubleClick(); void Draw(); - agi::scoped_ptr gl_text; + wxString Text(Vector2D v); public: VisualToolCross(VideoDisplay *parent, agi::Context *context); ~VisualToolCross();