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.
This commit is contained in:
Thomas Goyne 2011-12-22 21:23:17 +00:00
parent 25f4e4b426
commit d9ab41468c
2 changed files with 12 additions and 7 deletions

View file

@ -48,15 +48,15 @@ void VisualToolCross::OnDoubleClick() {
int t1, t2; int t1, t2;
if (GetLineMove(*it, p1, p2, t1, t2)) { if (GetLineMove(*it, p1, p2, t1, t2)) {
if (t1 > 0 || t2 > 0) 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 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 else
SetOverride(*it, "\\pos", (GetLinePosition(*it) + d).PStr()); SetOverride(*it, "\\pos", "(" + Text(GetLinePosition(*it) + d) + ")");
if (Vector2D org = GetLineOrigin(*it)) if (Vector2D org = GetLineOrigin(*it))
SetOverride(*it, "\\org", (org + d).PStr()); SetOverride(*it, "\\org", "(" + Text(org + d) + ")");
} }
Commit(_("positioning")); Commit(_("positioning"));
@ -77,8 +77,7 @@ void VisualToolCross::Draw() {
gl.DrawLines(2, lines, 4); gl.DrawLines(2, lines, 4);
gl.ClearInvert(); gl.ClearInvert();
Vector2D t = ToScriptCoords(shift_down ? video_res - mouse_pos : mouse_pos); wxString mouse_text = Text(ToScriptCoords(shift_down ? video_res - mouse_pos : mouse_pos));
wxString mouse_text = video_res.X() > script_res.X() ? t.Str() : t.DStr();
int tw, th; int tw, th;
gl_text->SetFont("Verdana", 12, true, false); gl_text->SetFont("Verdana", 12, true, false);
@ -100,3 +99,7 @@ void VisualToolCross::Draw() {
gl_text->Print(mouse_text, dx, dy); gl_text->Print(mouse_text, dx, dy);
} }
wxString VisualToolCross::Text(Vector2D v) {
return video_res.X() > script_res.X() ? v.Str() : v.DStr();
}

View file

@ -32,9 +32,11 @@ class OpenGLText;
/// @brief A crosshair which shows the current mouse position and on double-click /// @brief A crosshair which shows the current mouse position and on double-click
/// shifts the selected lines to the clicked point /// shifts the selected lines to the clicked point
class VisualToolCross : public VisualTool<VisualDraggableFeature> { class VisualToolCross : public VisualTool<VisualDraggableFeature> {
agi::scoped_ptr<OpenGLText> gl_text;
void OnDoubleClick(); void OnDoubleClick();
void Draw(); void Draw();
agi::scoped_ptr<OpenGLText> gl_text; wxString Text(Vector2D v);
public: public:
VisualToolCross(VideoDisplay *parent, agi::Context *context); VisualToolCross(VideoDisplay *parent, agi::Context *context);
~VisualToolCross(); ~VisualToolCross();