void VisualToolBase::OnCommit(int type) { holding = false; dragging = false; if (type == AssFile::COMMIT_NEW || type & AssFile::COMMIT_SCRIPTINFO) { int script_w, script_h; c->ass->GetResolution(script_w, script_h); script_res = Vector2D(script_w, script_h); OnCoordinateSystemsChanged(); } if (type & AssFile::COMMIT_DIAG_FULL || type & AssFile::COMMIT_DIAG_ADDREM) { active_line = GetActiveDialogueLine(); OnFileChanged(); } }
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 VisualToolDrag::OnSubTool(wxCommandEvent &) { // Toggle \move <-> \pos VideoContext *vc = c->videoController; for (auto line : selection) { Vector2D p1, p2; int t1, t2; bool has_move = GetLineMove(line, p1, p2, t1, t2); if (has_move) SetOverride(line, "\\pos", p1.PStr()); else { p1 = GetLinePosition(line); // Round the start and end times to exact frames int start = vc->TimeAtFrame(vc->FrameAtTime(line->Start, agi::vfr::START)) - line->Start; int end = vc->TimeAtFrame(vc->FrameAtTime(line->Start, agi::vfr::END)) - line->Start; SetOverride(line, "\\move", str(boost::format("(%s,%s,%d,%d)") % p1.Str() % p1.Str() % start % end)); } } Commit(); OnFileChanged(); UpdateToggleButtons(); }