Fixed warning messages while compiling dialog_export.cpp and added a recent list for keyframe read/write.

Originally committed to SVN as r576.
This commit is contained in:
Rodrigo Braz Monteiro 2006-12-18 17:18:14 +00:00
parent b739497bdf
commit 3d5be2bc55
5 changed files with 127 additions and 56 deletions

View file

@ -61,7 +61,7 @@ DialogExport::DialogExport (wxWindow *parent)
wxString cur = token.GetNextToken();
if (!cur.IsEmpty()) {
n++;
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
if (FilterList->GetString(i) == cur) {
FilterList->Check(i);
break;
@ -72,7 +72,7 @@ DialogExport::DialogExport (wxWindow *parent)
// No filters listed on header, select all
if (n == 0) {
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
FilterList->Check(i);
}
}
@ -137,7 +137,7 @@ DialogExport::~DialogExport() {
// Set script info data
int n = 0;
wxString infoList;
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
if (FilterList->IsChecked(i)) {
infoList += FilterList->GetString(i) + _T("|");
n++;
@ -187,7 +187,7 @@ void DialogExport::OnProcess(wxCommandEvent &event) {
if (filename.empty()) return;
// Add filters
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
if (FilterList->IsChecked(i)) {
Export->AddFilter(FilterList->GetString(i));
}
@ -274,7 +274,7 @@ void DialogExport::OnMoveDown(wxCommandEvent &event) {
void DialogExport::OnSelectAll(wxCommandEvent &event) {
Freeze();
FilterList->Freeze();
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
FilterList->Check(i,true);
wxSizer *sizer = Export->GetSettingsSizer(FilterList->GetString(i));
if (sizer) MainSizer->Show(sizer,true,true);
@ -293,7 +293,7 @@ void DialogExport::OnSelectAll(wxCommandEvent &event) {
void DialogExport::OnSelectNone(wxCommandEvent &event) {
Freeze();
FilterList->Freeze();
for (int i=0;i<FilterList->GetCount();i++) {
for (unsigned int i=0;i<FilterList->GetCount();i++) {
FilterList->Check(i,false);
wxSizer *sizer = Export->GetSettingsSizer(FilterList->GetString(i));
if (sizer) MainSizer->Show(sizer,false,true);

View file

@ -65,6 +65,7 @@
#include "hotkeys.h"
#include "utils.h"
#include "text_file_reader.h"
#include "text_file_writer.h"
/////////////////////////
@ -215,6 +216,7 @@ void FrameMain::InitMenu() {
RecentVids = new wxMenu();
RecentAuds = new wxMenu();
RecentTimecodes = new wxMenu();
RecentKeyframes = new wxMenu();
// Create file menu
fileMenu = new wxMenu();
@ -275,6 +277,8 @@ void FrameMain::InitMenu() {
videoMenu->Append(Menu_Video_Load_Keyframes, _("Open keyframes..."), _("Opens a keyframe list file"));
videoMenu->Append(Menu_Video_Save_Keyframes, _("Save keyframes..."), _("Saves the current keyframe list"))->Enable(false);
videoMenu->Append(Menu_Video_Close_Keyframes, _("Close keyframes"), _("Closes the currently open keyframes list"))->Enable(false);
wxMenuItem *RecentKeyframesParent = new wxMenuItem(videoMenu, Menu_File_Recent_Keyframes_Parent, _("Recent"), _T(""), wxITEM_NORMAL, RecentKeyframes);
videoMenu->Append(RecentKeyframesParent);
videoMenu->AppendSeparator();
AppendBitmapMenuItem (videoMenu,Menu_Video_JumpTo, _("&Jump To...\t") + Hotkeys.GetText(_T("Video Jump")), _("Jump to frame or time"), wxBITMAP(jumpto_button));
videoMenu->AppendSeparator();
@ -998,6 +1002,72 @@ void FrameMain::LoadVFR(wxString filename) {
}
//////////////////
// Load Keyframes
void FrameMain::LoadKeyframes(wxString filename) {
// Open file
wxArrayInt keyFrames;
keyFrames.Empty();
TextFileReader file(filename,_T("ASCII"));
// Read header
wxString cur = file.ReadLineFromFile();
if (cur != _T("# keyframe format v1")) return;
cur = file.ReadLineFromFile();
if (cur.Left(4) != _T("fps ")) return;
cur = cur.Mid(4);
double fps;
cur.ToDouble(&fps);
// Read lines
while (file.HasMoreLines()) {
cur = file.ReadLineFromFile();
if (!cur.IsEmpty() && cur.IsNumber()) {
long temp;
cur.ToLong(&temp);
keyFrames.Add(temp);
}
}
// Set keyframes
videoBox->videoDisplay->SetOverKeyFrames(keyFrames);
// Set FPS
if (!videoBox->videoDisplay->loaded) {
videoBox->videoDisplay->fps = fps;
VFR_Input.SetCFR(fps);
if (!VFR_Output.IsLoaded()) VFR_Output.SetCFR(fps);
}
// Add to recent
Options.AddToRecentList(filename,_T("Recent keyframes"));
// Refresh display
Refresh();
}
//////////////////
// Save Keyframes
void FrameMain::SaveKeyframes(wxString filename) {
// Get keyframes
wxArrayInt keyFrames = videoBox->videoDisplay->GetKeyFrames();
// Write header
TextFileWriter file(filename,_T("ASCII"));
file.WriteLineToFile(_T("# keyframe format v1"));
file.WriteLineToFile(wxString::Format(_T("fps %f"),videoBox->videoDisplay->fps));
// Write keyframes
for (unsigned int i=0;i<keyFrames.Count();i++) {
file.WriteLineToFile(wxString::Format(_T("%i"),keyFrames[i]));
}
// Add to recent
Options.AddToRecentList(filename,_T("Recent keyframes"));
}
/////////////
// Open help
void FrameMain::OpenHelp(wxString page) {

View file

@ -87,6 +87,7 @@ private:
wxMenu *RecentVids;
wxMenu *RecentAuds;
wxMenu *RecentTimecodes;
wxMenu *RecentKeyframes;
wxToolBar *Toolbar;
wxComboBox *ZoomBox;
@ -125,6 +126,7 @@ private:
void OnOpenRecentVideo (wxCommandEvent &event);
void OnOpenRecentAudio (wxCommandEvent &event);
void OnOpenRecentTimecodes (wxCommandEvent &event);
void OnOpenRecentKeyframes (wxCommandEvent &event);
void OnCloseWindow (wxCloseEvent &event);
void OnMenuOpen (wxMenuEvent &event);
@ -283,6 +285,7 @@ enum {
Menu_File_Recent_Vids_Parent,
Menu_File_Recent_Auds_Parent,
Menu_File_Recent_Timecodes_Parent,
Menu_File_Recent_Keyframes_Parent,
Menu_Video_JumpTo,
Menu_View_Zoom_50,
@ -387,7 +390,8 @@ enum {
Menu_File_Recent = 2000,
Menu_Video_Recent = 2200,
Menu_Audio_Recent = 2400,
Menu_Timecodes_Recent = 2500
Menu_Timecodes_Recent = 2500,
Menu_Keyframes_Recent = 2600,
};

View file

@ -82,8 +82,6 @@
#include "dialog_progress.h"
#include "dialog_options.h"
#include "utils.h"
#include "text_file_writer.h"
#include "text_file_reader.h"
////////////////////
@ -122,6 +120,7 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame)
EVT_MENU_RANGE(Menu_Video_Recent,Menu_Video_Recent+99, FrameMain::OnOpenRecentVideo)
EVT_MENU_RANGE(Menu_Audio_Recent,Menu_Audio_Recent+99, FrameMain::OnOpenRecentAudio)
EVT_MENU_RANGE(Menu_Timecodes_Recent,Menu_Timecodes_Recent+99, FrameMain::OnOpenRecentTimecodes)
EVT_MENU_RANGE(Menu_Keyframes_Recent,Menu_Keyframes_Recent+99, FrameMain::OnOpenRecentKeyframes)
EVT_MENU(Menu_File_Exit, FrameMain::OnExit)
EVT_MENU(Menu_File_Open_Video, FrameMain::OnOpenVideo)
@ -319,6 +318,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
for (int i=count;--i>=0;) {
RecentTimecodes->Destroy(RecentTimecodes->FindItemByPosition(i));
}
count = (int)RecentKeyframes->GetMenuItemCount();
for (int i=count;--i>=0;) {
RecentKeyframes->Destroy(RecentKeyframes->FindItemByPosition(i));
}
// Rebuild recent videos
int added = 0;
@ -346,6 +349,19 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) {
added++;
}
if (added == 0) RecentTimecodes->Append(Menu_Timecodes_Recent,_T("Empty"))->Enable(false);
// Rebuild recent Keyframes
added = 0;
entries = Options.GetRecentList(_T("Recent Keyframes"));
for (size_t i=0;i<entries.Count();i++) {
n = wxString::Format(_T("%i"),i+1);
if (i < 9) n = _T("&") + n;
wxFileName shortname(entries[i]);
wxString filename = shortname.GetFullName();
RecentKeyframes->Append(Menu_Keyframes_Recent+i,n + _T(" ") + filename);
added++;
}
if (added == 0) RecentKeyframes->Append(Menu_Keyframes_Recent,_T("Empty"))->Enable(false);
}
// Audio menu
@ -423,6 +439,15 @@ void FrameMain::OnOpenRecentTimecodes(wxCommandEvent &event) {
}
////////////////////////////////
// Open recent Keyframes entry
void FrameMain::OnOpenRecentKeyframes(wxCommandEvent &event) {
int number = event.GetId()-Menu_Keyframes_Recent;
wxString key = _T("Recent Keyframes #") + wxString::Format(_T("%i"),number+1);
LoadKeyframes(Options.AsText(key));
}
////////////////////////////////
// Open recent audio menu entry
void FrameMain::OnOpenRecentAudio(wxCommandEvent &event) {
@ -506,6 +531,7 @@ void FrameMain::OnOpenVideo(wxCommandEvent& WXUNUSED(event)) {
if (!filename.empty()) {
LoadVideo(filename);
Options.SetText(_T("Last open video path"), filename);
Options.Save();
}
}
@ -525,6 +551,7 @@ void FrameMain::OnOpenAudio (wxCommandEvent& WXUNUSED(event)) {
if (!filename.empty()) {
LoadAudio(filename);
Options.SetText(_T("Last open audio path"), filename);
Options.Save();
}
}
@ -548,6 +575,7 @@ void FrameMain::OnOpenSubtitles(wxCommandEvent& WXUNUSED(event)) {
LoadSubtitles(filename);
wxFileName filepath(filename);
Options.SetText(_T("Last open subtitles path"), filepath.GetPath());
Options.Save();
}
}
@ -567,6 +595,7 @@ void FrameMain::OnOpenSubtitlesCharset(wxCommandEvent& WXUNUSED(event)) {
LoadSubtitles(filename,charset);
}
Options.SetText(_T("Last open subtitles path"), filename);
Options.Save();
}
}
@ -619,6 +648,7 @@ void FrameMain::OnOpenVFR(wxCommandEvent &event) {
if (!filename.empty()) {
LoadVFR(filename);
Options.SetText(_T("Last open timecodes path"), filename);
Options.Save();
}
}
@ -634,42 +664,14 @@ void FrameMain::OnCloseVFR(wxCommandEvent &event) {
// Open keyframes
void FrameMain::OnOpenKeyframes (wxCommandEvent &event) {
// Pick file
wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),_T(""),_T(""),_T(".txt"),_T("Text files (*.txt)|*.txt"),wxFILE_MUST_EXIST | wxOPEN);
wxString path = Options.AsText(_T("Last open keyframes path"));
wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),path,_T(""),_T(".txt"),_T("Text files (*.txt)|*.txt"),wxFILE_MUST_EXIST | wxOPEN);
if (filename.IsEmpty()) return;
Options.SetText(_T("Last open keyframes path"),filename);
Options.Save();
// Open file
wxArrayInt keyFrames;
TextFileReader file(filename,_T("ASCII"));
// Read header
wxString cur = file.ReadLineFromFile();
if (cur != _T("# keyframe format v1")) return;
cur = file.ReadLineFromFile();
if (cur.Left(4) != _T("fps ")) return;
cur = cur.Mid(4);
double fps;
cur.ToDouble(&fps);
// Read lines
while (file.HasMoreLines()) {
cur = file.ReadLineFromFile();
long temp;
cur.ToLong(&temp);
keyFrames.Add(temp);
}
// Set keyframes
videoBox->videoDisplay->SetOverKeyFrames(keyFrames);
// Set FPS
if (!videoBox->videoDisplay->loaded) {
videoBox->videoDisplay->fps = fps;
VFR_Input.SetCFR(fps);
if (!VFR_Output.IsLoaded()) VFR_Output.SetCFR(fps);
}
// Refresh display
Refresh();
// Load
LoadKeyframes(filename);
}
@ -684,21 +686,14 @@ void FrameMain::OnCloseKeyframes (wxCommandEvent &event) {
// Save keyframes
void FrameMain::OnSaveKeyframes (wxCommandEvent &event) {
// Pick file
wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),_T(""),_T(""),_T("*.key.txt"),_T("Text files (*.txt)|*.txt"),wxOVERWRITE_PROMPT | wxSAVE);
wxString path = Options.AsText(_T("Last open keyframes path"));
wxString filename = wxFileSelector(_T("Select the Keyframes file to open"),path,_T(""),_T("*.key.txt"),_T("Text files (*.txt)|*.txt"),wxOVERWRITE_PROMPT | wxSAVE);
if (filename.IsEmpty()) return;
Options.SetText(_T("Last open keyframes path"),filename);
Options.Save();
// Get keyframes
wxArrayInt keyFrames = videoBox->videoDisplay->GetKeyFrames();
// Write header
TextFileWriter file(_T("test.txt"),_T("ASCII"));
file.WriteLineToFile(_T("# keyframe format v1"));
file.WriteLineToFile(wxString::Format(_T("fps %f"),videoBox->videoDisplay->fps));
// Write keyframes
for (unsigned int i=0;i<keyFrames.Count();i++) {
file.WriteLineToFile(wxString::Format(_T("%i"),keyFrames[i]));
}
// Save
SaveKeyframes(filename);
}

View file

@ -75,6 +75,7 @@ void OptionsManager::LoadDefaults() {
SetBool(_T("Link Time Boxes Commit"),true);
SetInt(_T("Undo Levels"),8);
SetInt(_T("Recent timecodes max"),16);
SetInt(_T("Recent keyframes max"),16);
SetInt(_T("Recent sub max"),16);
SetInt(_T("Recent vid max"),16);
SetInt(_T("Recent aud max"),16);
@ -271,6 +272,7 @@ void OptionsManager::LoadDefaults() {
SetText(_T("Last open video path"),_T(""));
SetText(_T("Last open audio path"),_T(""));
SetText(_T("Last open timecodes path"),_T(""));
SetText(_T("Last open keyframes path"),_T(""));
SetText(_T("Last open automation path"),_T(""));
}