void VisualToolDrag::UpdateToggleButtons() { bool to_move = true; if (active_line) { Vector2D p1, p2; int t1, t2; to_move = !GetLineMove(active_line, p1, p2, t1, t2); } if (to_move == button_is_move) return; toolbar->SetToolNormalBitmap(toolbar->GetToolByPos(0)->GetId(), to_move ? ICON(visual_move_conv_move) : ICON(visual_move_conv_pos)); button_is_move = to_move; }
void VisualToolDrag::MakeFeatures(AssDialogue *diag, feature_iterator pos) { Vector2D p1 = FromScriptCoords(GetLinePosition(diag)); // Create \pos feature Feature feat; feat.pos = p1; feat.layer = 0; feat.type = DRAG_START; feat.time = 0; feat.line = diag; feat.parent = features.end(); features.insert(pos, feat); feature_iterator cur = prev(pos); feat.parent = cur; if (selection.count(diag)) sel_features.insert(cur); Vector2D p2; int t1, t2; // Create move destination feature if (GetLineMove(diag, p1, p2, t1, t2)) { feat.pos = FromScriptCoords(p2); feat.layer = 1; feat.type = DRAG_END; feat.parent->time = t1; feat.time = t2; feat.line = diag; features.insert(pos, feat); feat.parent->parent = prev(pos); } // Create org feature if (Vector2D org = GetLineOrigin(diag)) { feat.pos = FromScriptCoords(org); feat.layer = -1; feat.type = DRAG_ORIGIN; feat.time = 0; feat.line = diag; features.insert(pos, feat); } }
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 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(); }