void DialogShiftTimes::OnHistoryClick(wxCommandEvent &evt) { size_t entry = evt.GetInt(); if (entry >= history->size()) return; json::Object& obj = (*history)[entry]; if (obj["is by time"]) { shift_time->SetTime(AssTime((std::string)obj["amount"])); shift_by_time->SetValue(true); OnByTime(evt); } else { shift_frames->SetValue(to_wx(obj["amount"])); if (shift_by_frames->IsEnabled()) { shift_by_frames->SetValue(true); OnByFrames(evt); } } if (obj["is backward"]) shift_backward->SetValue(true); else shift_forward->SetValue(true); selection_mode->SetSelection((int64_t)obj["mode"]); time_fields->SetSelection((int64_t)obj["fields"]); }
DialogVideoDetails::DialogVideoDetails(agi::Context *c) : wxDialog(c->parent , -1, _("Video Details")) { auto width = c->videoController->GetWidth(); auto height = c->videoController->GetHeight(); auto framecount = c->videoController->GetLength(); auto fps = c->videoController->FPS(); boost::rational<int> ar(width, height); auto fg = new wxFlexGridSizer(2, 5, 10); auto make_field = [&](wxString const& name, wxString const& value) { fg->Add(new wxStaticText(this, -1, name), 0, wxALIGN_CENTRE_VERTICAL); fg->Add(new wxTextCtrl(this, -1, value, wxDefaultPosition, wxSize(300,-1), wxTE_READONLY), 0, wxALIGN_CENTRE_VERTICAL | wxEXPAND); }; make_field(_("File name:"), c->videoController->GetVideoName().wstring()); make_field(_("FPS:"), wxString::Format("%.3f", fps.FPS())); make_field(_("Resolution:"), wxString::Format("%dx%d (%d:%d)", width, height, ar.numerator(), ar.denominator())); make_field(_("Length:"), wxString::Format(_("%d frames (%s)"), framecount, to_wx(AssTime(fps.TimeAtFrame(framecount - 1)).GetAssFormated(true)))); make_field(_("Decoder:"), to_wx(c->videoController->GetProvider()->GetDecoderName())); wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Video")); video_sizer->Add(fg); auto main_sizer = new wxBoxSizer(wxVERTICAL); main_sizer->Add(video_sizer, 1, wxALL|wxEXPAND, 5); main_sizer->Add(CreateSeparatedButtonSizer(wxOK), 0, wxALL|wxEXPAND, 5); SetSizerAndFit(main_sizer); CenterOnParent(); }
void VideoBox::UpdateTimeBoxes() { if (!context->videoController->IsLoaded()) return; int frame = context->videoController->GetFrameN(); int time = context->videoController->TimeAtFrame(frame, agi::vfr::EXACT); // Set the text box for frame number and time VideoPosition->SetValue(wxString::Format("%s - %d", AssTime(time).GetAssFormated(true), frame)); if (boost::binary_search(context->videoController->GetKeyFrames(), frame)) { // Set the background color to indicate this is a keyframe VideoPosition->SetBackgroundColour(to_wx(OPT_GET("Colour/Subtitle Grid/Background/Selection")->GetColor())); VideoPosition->SetForegroundColour(to_wx(OPT_GET("Colour/Subtitle Grid/Selection")->GetColor())); } else { VideoPosition->SetBackgroundColour(wxNullColour); VideoPosition->SetForegroundColour(wxNullColour); } AssDialogue *active_line = context->selectionController->GetActiveLine(); if (!active_line) VideoSubsPos->SetValue(""); else { VideoSubsPos->SetValue(wxString::Format( "%+dms; %+dms", time - active_line->Start, time - active_line->End)); } }
DialogJumpTo::DialogJumpTo(agi::Context *c) : wxDialog(c->parent, -1, _("Jump to"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxWANTS_CHARS) , c(c) , jumpframe(c->videoController->GetFrameN()) { SetIcon(GETICON(jumpto_button_16)); auto LabelFrame = new wxStaticText(this, -1, _("Frame: ")); auto LabelTime = new wxStaticText(this, -1, _("Time: ")); JumpFrame = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(-1,-1),wxTE_PROCESS_ENTER, IntValidator((int)jumpframe)); JumpFrame->SetMaxLength(std::to_string(c->videoController->GetLength() - 1).size()); JumpTime = new TimeEdit(this, -1, c, AssTime(c->videoController->TimeAtFrame(jumpframe)).GetAssFormated(), wxSize(-1,-1)); auto TimesSizer = new wxGridSizer(2, 5, 5); TimesSizer->Add(LabelFrame, 1, wxALIGN_CENTER_VERTICAL); TimesSizer->Add(JumpFrame, wxEXPAND); TimesSizer->Add(LabelTime, 1, wxALIGN_CENTER_VERTICAL); TimesSizer->Add(JumpTime, wxEXPAND); auto ButtonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); // General layout auto MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(TimesSizer, 0, wxALL | wxALIGN_CENTER, 5); MainSizer->Add(ButtonSizer, 0, wxEXPAND | wxLEFT | wxBOTTOM | wxRIGHT, 5); SetSizerAndFit(MainSizer); CenterOnParent(); Bind(wxEVT_INIT_DIALOG, &DialogJumpTo::OnInitDialog, this); Bind(wxEVT_TEXT_ENTER, &DialogJumpTo::OnOK, this); Bind(wxEVT_BUTTON, &DialogJumpTo::OnOK, this, wxID_OK); JumpTime->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditTime, this); JumpFrame->Bind(wxEVT_TEXT, &DialogJumpTo::OnEditFrame, this); }
void DialogDummyVideo::UpdateLengthDisplay() { length_display->SetLabel(wxString::Format(_("Resulting duration: %s"), AssTime(length / fps * 1000).GetAssFormated(true))); }
void BaseGrid::SetColumnWidths() { if (!IsShownOnScreen()) return; // Width/height int w, h; GetClientSize(&w,&h); // DC for text extents test wxClientDC dc(this); dc.SetFont(font); // O(1) widths int marginLen = dc.GetTextExtent("0000").GetWidth(); int labelLen = dc.GetTextExtent(wxString::Format("%d", GetRows())).GetWidth(); int startLen = 0; int endLen = 0; if (!byFrame) startLen = endLen = dc.GetTextExtent(AssTime().GetAssFormated()).GetWidth(); // O(n) widths bool showMargin[3] = { false, false, false }; int styleLen = 0; int actorLen = 0; int effectLen = 0; int maxLayer = 0; int maxStart = 0; int maxEnd = 0; for (int i = 0; i < GetRows(); i++) { AssDialogue *curDiag = GetDialogue(i); maxLayer = std::max(maxLayer, curDiag->Layer); actorLen = std::max(actorLen, dc.GetTextExtent(curDiag->Actor).GetWidth()); styleLen = std::max(styleLen, dc.GetTextExtent(curDiag->Style).GetWidth()); effectLen = std::max(effectLen, dc.GetTextExtent(curDiag->Effect).GetWidth()); // Margins for (int j = 0; j < 3; j++) { if (curDiag->Margin[j]) showMargin[j] = true; } // Times if (byFrame) { maxStart = std::max(maxStart, context->videoController->FrameAtTime(curDiag->Start, agi::vfr::START)); maxEnd = std::max(maxEnd, context->videoController->FrameAtTime(curDiag->End, agi::vfr::END)); } } // Finish layer int layerLen = maxLayer ? dc.GetTextExtent(wxString::Format("%d", maxLayer)).GetWidth() : 0; // Finish times if (byFrame) { startLen = dc.GetTextExtent(wxString::Format("%d", maxStart)).GetWidth(); endLen = dc.GetTextExtent(wxString::Format("%d", maxEnd)).GetWidth(); } // Set column widths colWidth[0] = labelLen; colWidth[1] = layerLen; colWidth[2] = startLen; colWidth[3] = endLen; colWidth[4] = styleLen; colWidth[5] = actorLen; colWidth[6] = effectLen; for (int i = 0; i < 3; i++) colWidth[i + 7] = showMargin[i] ? marginLen : 0; colWidth[10] = 1; // Hide columns for (int i = 0; i < columns; i++) { if (!showCol[i]) colWidth[i] = 0; } wxString col_names[11] = { _("#"), _("L"), _("Start"), _("End"), _("Style"), _("Actor"), _("Effect"), _("Left"), _("Right"), _("Vert"), _("Text") }; // Ensure every visible column is at least as big as its header for (size_t i = 0; i < 11; ++i) { if (colWidth[i]) colWidth[i] = std::max(colWidth[i], dc.GetTextExtent(col_names[i]).GetWidth()); } // Add padding to all non-empty columns for (size_t i = 0; i < 10; ++i) { if (colWidth[i]) colWidth[i] += 10; } // Set size of last int total = std::accumulate(colWidth, colWidth + 10, 0); colWidth[10] = w - total; time_cols_x = colWidth[0] + colWidth[1]; time_cols_w = colWidth[2] + colWidth[3]; text_col_x = total; text_col_w = colWidth[10]; }