Kill SubtitlesGrid::SetSubsToVideo

Originally committed to SVN as r5597.
This commit is contained in:
Thomas Goyne 2011-09-15 05:17:22 +00:00
parent 0c4eb020a4
commit 3c4191e649
3 changed files with 17 additions and 29 deletions

View file

@ -165,7 +165,22 @@ struct time_shift : public Command {
} }
}; };
static void snap_subs_video(agi::Context *c, bool start) {
std::set<AssDialogue*> sel = c->selectionController->GetSelectedSet();
if (!c->videoController->IsLoaded() || sel.empty()) return;
int ms = c->videoController->TimeAtFrame(c->videoController->GetFrameN(), start ? agi::vfr::START : agi::vfr::END);
for (std::set<AssDialogue*>::iterator it = sel.begin(); it != sel.end(); ++it) {
if (start)
(*it)->Start.SetMS(ms);
else
(*it)->End.SetMS(ms);
}
c->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME);
}
/// Set end of selected subtitles to current video frame. /// Set end of selected subtitles to current video frame.
struct time_snap_end_video : public validate_video_loaded { struct time_snap_end_video : public validate_video_loaded {
@ -175,7 +190,7 @@ struct time_snap_end_video : public validate_video_loaded {
STR_HELP("Set end of selected subtitles to current video frame.") STR_HELP("Set end of selected subtitles to current video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->subsGrid->SetSubsToVideo(false); snap_subs_video(c, false);
} }
}; };
@ -298,7 +313,7 @@ struct time_snap_start_video : public validate_video_loaded {
STR_HELP("Set start of selected subtitles to current video frame.") STR_HELP("Set start of selected subtitles to current video frame.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->subsGrid->SetSubsToVideo(false); snap_subs_video(c, true);
} }
}; };

View file

@ -553,29 +553,6 @@ bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
return true; return true;
} }
void SubtitlesGrid::SetSubsToVideo(bool start) {
if (!context->videoController->IsLoaded()) return;
// Get new time
int ms = context->videoController->TimeAtFrame(context->videoController->GetFrameN(),start ? agi::vfr::START : agi::vfr::END);
// Update selection
wxArrayInt sel = GetSelection();
bool modified = false;
for (size_t i=0;i<sel.Count();i++) {
AssDialogue *cur = GetDialogue(sel[i]);
if (cur) {
modified = true;
if (start) cur->Start.SetMS(ms);
else cur->End.SetMS(ms);
}
}
if (modified) {
context->ass->Commit(_("timing"), AssFile::COMMIT_DIAG_TIME);
}
}
/// @brief Retrieve a list of selected lines in the actual ASS file (ie. not as displayed in the grid but as represented in the file) /// @brief Retrieve a list of selected lines in the actual ASS file (ie. not as displayed in the grid but as represented in the file)
/// @return /// @return
/// ///

View file

@ -76,10 +76,6 @@ public:
SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr); SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
~SubtitlesGrid(); ~SubtitlesGrid();
/// @brief Set the start/end time of the current subtitle line to the current frame
/// @param start Start vs. End time
void SetSubsToVideo(bool start);
/// @brief Adjoins selected lines, setting each line's start time to the previous line's end time /// @brief Adjoins selected lines, setting each line's start time to the previous line's end time
/// @param n1 First line to adjoin /// @param n1 First line to adjoin
/// @param n2 Last line to adjoin /// @param n2 Last line to adjoin