void VisualToolDrag::UpdateDrag(feature_iterator feature) { if (feature->type == DRAG_ORIGIN) { SetOverride(feature->line, "\\org", ToScriptCoords(feature->pos).PStr()); return; } feature_iterator end_feature = feature->parent; if (feature->type == DRAG_END) std::swap(feature, end_feature); if (feature->parent == features.end()) SetOverride(feature->line, "\\pos", ToScriptCoords(feature->pos).PStr()); else SetOverride(feature->line, "\\move", str(boost::format("(%s,%s,%d,%d)") % ToScriptCoords(feature->pos).Str() % ToScriptCoords(end_feature->pos).Str() % feature->time % end_feature->time)); }
void VisualToolRotateXY::UpdateDrag(Feature *feature) { auto org = GetLineOrigin(active_line); if (!org) org = GetLinePosition(active_line); auto d = ToScriptCoords(feature->pos) - org; for (auto line : c->selectionController->GetSelectedSet()) { org = GetLineOrigin(line); if (!org) org = GetLinePosition(line); SetOverride(line, "\\org", (d + org).PStr()); } }
void VisualToolDrag::OnDoubleClick() { Vector2D d = ToScriptCoords(mouse_pos) - (primary ? ToScriptCoords(primary->pos) : GetLinePosition(active_line)); for (auto line : c->selectionController->GetSelectedSet()) { Vector2D p1, p2; int t1, t2; if (GetLineMove(line, p1, p2, t1, t2)) { if (t1 > 0 || t2 > 0) SetOverride(line, "\\move", str(boost::format("(%s,%s,%d,%d)") % (p1 + d).Str() % (p2 + d).Str() % t1 % t2)); else SetOverride(line, "\\move", str(boost::format("(%s,%s)") % (p1 + d).Str() % (p2 + d).Str())); } else SetOverride(line, "\\pos", (GetLinePosition(line) + d).PStr()); if (Vector2D org = GetLineOrigin(line)) SetOverride(line, "\\org", (org + d).PStr()); } Commit(_("positioning")); OnFileChanged(); }
void VisualToolCross::OnDoubleClick() { Vector2D d = ToScriptCoords(mouse_pos) - GetLinePosition(active_line); for (auto line : c->selectionController->GetSelectedSet()) { Vector2D p1, p2; int t1, t2; if (GetLineMove(line, p1, p2, t1, t2)) { if (t1 > 0 || t2 > 0) SetOverride(line, "\\move", str(boost::format("(%s,%s,%d,%d)") % Text(p1 + d) % Text(p2 + d) % t1 % t2)); else SetOverride(line, "\\move", str(boost::format("(%s,%s)") % Text(p1 + d) % Text(p2 + d))); } else SetOverride(line, "\\pos", "(" + Text(GetLinePosition(line) + d) + ")"); if (Vector2D org = GetLineOrigin(line)) SetOverride(line, "\\org", "(" + Text(org + d) + ")"); } Commit(_("positioning")); }
void VisualToolCross::Draw() { if (!mouse_pos) return; // Draw cross gl.SetInvert(); gl.SetLineColour(*wxWHITE, 1.0, 1); float lines[] = { 0.f, mouse_pos.Y(), video_res.X() + video_pos.X() * 2, mouse_pos.Y(), mouse_pos.X(), 0.f, mouse_pos.X(), video_res.Y() + video_pos.Y() * 2 }; gl.DrawLines(2, lines, 4); gl.ClearInvert(); std::string mouse_text = Text(ToScriptCoords(shift_down ? video_res - mouse_pos : mouse_pos)); int tw, th; gl_text->SetFont("Verdana", 12, true, false); gl_text->SetColour(agi::Color(255, 255, 255, 255)); gl_text->GetExtent(mouse_text, tw, th); // Place the text in the corner of the cross closest to the center of the video int dx = mouse_pos.X(); int dy = mouse_pos.Y(); if (dx > video_res.X() / 2) dx -= tw + 4; else dx += 4; if (dy < video_res.Y() / 2) dy += 3; else dy -= th + 3; gl_text->Print(mouse_text, dx, dy); }
void VisualToolRotateXY::UpdateDrag(Feature *feature) { SetOverride(active_line, "\\org", ToScriptCoords(feature->pos).PStr()); }