2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro, Niels Martin Hansen
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
/// @file frame_main.cpp
/// @brief Main window creation and control management
/// @ingroup main_ui
2006-01-16 22:02:54 +01:00
2009-01-04 07:31:48 +01:00
# include "config.h"
2011-07-15 06:05:49 +02:00
# include "frame_main.h"
2011-01-08 13:10:40 +01:00
# include <wx/clipbrd.h>
2011-11-30 00:18:24 +01:00
# include <wx/dnd.h>
2006-01-16 22:02:54 +01:00
# include <wx/filename.h>
2006-12-27 21:16:47 +01:00
# include <wx/image.h>
2012-12-02 00:57:02 +01:00
# include <wx/msgdlg.h>
2007-09-12 01:22:26 +02:00
# include <wx/statline.h>
2009-09-10 15:06:40 +02:00
# include <wx/sysopt.h>
# include <wx/tokenzr.h>
2008-01-16 19:29:29 +01:00
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# include <libaegisub/log.h>
2011-01-16 08:16:00 +01:00
# include "include/aegisub/context.h"
2011-01-05 19:40:37 +01:00
# include "include/aegisub/menu.h"
# include "include/aegisub/toolbar.h"
# include "include/aegisub/hotkey.h"
2009-09-10 15:06:40 +02:00
# include "ass_file.h"
2010-12-08 04:36:10 +01:00
# include "audio_controller.h"
2009-09-10 15:06:40 +02:00
# include "audio_box.h"
# include "auto4_base.h"
2010-05-21 03:13:36 +02:00
# include "compat.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# include "command/command.h"
2012-03-09 01:23:41 +01:00
# include "dialog_detached_video.h"
# include "dialog_manager.h"
2006-01-16 22:02:54 +01:00
# include "dialog_search_replace.h"
2009-09-10 15:06:40 +02:00
# include "dialog_version_check.h"
# include "help_button.h"
2009-07-24 02:08:25 +02:00
# include "libresrc/libresrc.h"
2009-09-10 15:06:40 +02:00
# include "main.h"
2013-01-07 02:50:09 +01:00
# include "options.h"
2009-09-10 15:06:40 +02:00
# include "standard_paths.h"
# include "subs_edit_box.h"
2010-07-20 05:11:11 +02:00
# include "subs_edit_ctrl.h"
2009-09-10 15:06:40 +02:00
# include "subs_grid.h"
# include "text_file_reader.h"
# include "utils.h"
# include "version.h"
# include "video_box.h"
# include "video_context.h"
# include "video_display.h"
# include "video_provider_manager.h"
# include "video_slider.h"
2006-01-16 22:02:54 +01:00
2011-07-15 06:05:49 +02:00
enum {
ID_APP_TIMER_AUTOSAVE = 12001 ,
ID_APP_TIMER_STATUSCLEAR = 12002 ,
ID_SASH_MAIN_AUDIO = 14001
} ;
2009-06-12 18:59:53 +02:00
# ifdef WITH_STARTUPLOG
2011-07-15 06:05:49 +02:00
# define StartupLog(a) MessageBox(0, a, "Aegisub startup log", 0)
2009-06-12 18:59:53 +02:00
# else
2011-12-22 22:30:40 +01:00
# define StartupLog(a) LOG_I("frame_main / init") << a
2009-06-12 18:59:53 +02:00
# endif
2012-01-20 02:04:24 +01:00
static void autosave_timer_changed ( wxTimer * timer ) ;
2010-08-26 20:38:44 +02:00
2012-08-04 18:31:44 +02:00
wxDEFINE_EVENT ( FILE_LIST_DROPPED , wxThreadEvent ) ;
static void get_files_to_load ( wxArrayString const & list , wxString & subs , wxString & audio , wxString & video ) {
// Keep these lists sorted
// Video formats
const wxString videoList [ ] = {
" asf " ,
" avi " ,
" avs " ,
" d2v " ,
" m2ts " ,
2012-12-06 05:23:32 +01:00
" m4v " ,
2012-08-04 18:31:44 +02:00
" mkv " ,
" mov " ,
" mp4 " ,
" mpeg " ,
" mpg " ,
" ogm " ,
" rm " ,
" rmvb " ,
" ts " ,
" webm "
" wmv " ,
" y4m " ,
" yuv "
} ;
// Subtitle formats
const wxString subsList [ ] = {
" ass " ,
" srt " ,
" ssa " ,
" sub " ,
" ttxt " ,
" txt "
} ;
// Audio formats
const wxString audioList [ ] = {
" aac " ,
" ac3 " ,
" ape " ,
" dts " ,
" flac " ,
" m4a " ,
" mka " ,
" mp3 " ,
" ogg " ,
" w64 " ,
" wav " ,
" wma "
} ;
// Scan list
2012-11-04 04:53:03 +01:00
for ( wxFileName file : list ) {
2012-08-04 18:31:44 +02:00
if ( file . IsRelative ( ) ) file . MakeAbsolute ( ) ;
if ( ! file . FileExists ( ) ) continue ;
wxString ext = file . GetExt ( ) . Lower ( ) ;
if ( subs . empty ( ) & & std : : binary_search ( subsList , subsList + countof ( subsList ) , ext ) )
subs = file . GetFullPath ( ) ;
if ( video . empty ( ) & & std : : binary_search ( videoList , videoList + countof ( videoList ) , ext ) )
video = file . GetFullPath ( ) ;
if ( audio . empty ( ) & & std : : binary_search ( audioList , audioList + countof ( audioList ) , ext ) )
audio = file . GetFullPath ( ) ;
}
}
2011-11-30 00:18:24 +01:00
/// Handle files drag and dropped onto Aegisub
class AegisubFileDropTarget : public wxFileDropTarget {
FrameMain * parent ;
public :
AegisubFileDropTarget ( FrameMain * parent ) : parent ( parent ) { }
bool OnDropFiles ( wxCoord , wxCoord , const wxArrayString & filenames ) {
2012-08-04 18:31:44 +02:00
wxString subs , audio , video ;
get_files_to_load ( filenames , subs , audio , video ) ;
if ( ! subs & & ! audio & & ! video )
return false ;
wxThreadEvent * evt = new wxThreadEvent ( FILE_LIST_DROPPED ) ;
evt - > SetPayload ( filenames ) ;
parent - > QueueEvent ( evt ) ;
return true ;
2011-11-30 00:18:24 +01:00
}
} ;
2006-01-16 22:02:54 +01:00
FrameMain : : FrameMain ( wxArrayString args )
2011-07-15 06:05:49 +02:00
: wxFrame ( 0 , - 1 , " " , wxDefaultPosition , wxSize ( 920 , 700 ) , wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN )
2011-01-16 08:16:54 +01:00
, context ( new agi : : Context )
, showVideo ( true )
, showAudio ( true )
, blockVideoLoad ( false )
2012-03-27 06:23:45 +02:00
, blockAudioLoad ( false )
2006-01-16 22:02:54 +01:00
{
2011-01-16 08:16:54 +01:00
StartupLog ( " Entering FrameMain constructor " ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2007-04-03 06:34:56 +02:00
# ifdef __WXGTK__
2011-11-25 20:27:19 +01:00
// XXX HACK XXX
// We need to set LC_ALL to "" here for input methods to work reliably.
setlocale ( LC_ALL , " " ) ;
// However LC_NUMERIC must be "C", otherwise some parsing fails.
2007-04-03 06:34:56 +02:00
setlocale ( LC_NUMERIC , " C " ) ;
# endif
2011-11-25 20:29:17 +01:00
# ifdef __APPLE__
2012-08-27 04:13:11 +02:00
// When run from an app bundle, LC_CTYPE defaults to "C", which breaks on
// anything involving unicode and in some cases number formatting.
// The right thing to do here would be to query CoreFoundation for the user's
// locale and add .UTF-8 to that, but :effort:
LOG_D ( " locale " ) < < setlocale ( LC_ALL , 0 ) ;
setlocale ( LC_CTYPE , " en_US.UTF-8 " ) ;
LOG_D ( " locale " ) < < setlocale ( LC_ALL , 0 ) ;
2011-11-25 20:29:17 +01:00
# endif
2007-04-03 06:34:56 +02:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Initializing context models " ) ;
2012-03-09 01:23:30 +01:00
memset ( context . get ( ) , 0 , sizeof ( * context ) ) ;
2011-01-16 08:16:54 +01:00
AssFile : : top = context - > ass = new AssFile ;
2011-01-20 06:57:23 +01:00
context - > ass - > AddCommitListener ( & FrameMain : : UpdateTitle , this ) ;
2011-01-16 08:16:54 +01:00
context - > ass - > AddFileOpenListener ( & FrameMain : : OnSubtitlesOpen , this ) ;
context - > ass - > AddFileSaveListener ( & FrameMain : : UpdateTitle , this ) ;
2006-01-16 22:02:54 +01:00
2011-09-28 21:45:55 +02:00
context - > local_scripts = new Automation4 : : LocalScriptManager ( context . get ( ) ) ;
2006-12-27 21:16:47 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Initializing context controls " ) ;
2011-09-28 21:51:35 +02:00
context - > audioController = new AudioController ( context . get ( ) ) ;
2011-01-16 08:16:54 +01:00
context - > audioController - > AddAudioOpenListener ( & FrameMain : : OnAudioOpen , this ) ;
context - > audioController - > AddAudioCloseListener ( & FrameMain : : OnAudioClose , this ) ;
2010-06-26 16:16:59 +02:00
2011-01-16 08:17:02 +01:00
// Initialized later due to that the selection controller is currently the subtitles grid
context - > selectionController = 0 ;
2011-01-16 08:16:54 +01:00
context - > videoController = VideoContext : : Get ( ) ; // derp
context - > videoController - > AddVideoOpenListener ( & FrameMain : : OnVideoOpen , this ) ;
StartupLog ( " Initializing context frames " ) ;
context - > parent = this ;
context - > previousFocus = 0 ;
StartupLog ( " Install PNG handler " ) ;
wxImage : : AddHandler ( new wxPNGHandler ) ;
2011-11-25 20:29:17 +01:00
# ifndef __APPLE__
2011-01-16 08:16:54 +01:00
wxSafeYield ( ) ;
2011-11-25 20:29:17 +01:00
# endif
2010-12-08 04:36:10 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Apply saved Maximized state " ) ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " App/Maximized " ) - > GetBool ( ) ) Maximize ( true ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Initialize toolbar " ) ;
2006-01-16 22:02:54 +01:00
InitToolbar ( ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Initialize menu bar " ) ;
2011-08-27 08:29:36 +02:00
menu : : GetMenuBar ( " main " , this , context . get ( ) ) ;
2012-03-25 06:05:06 +02:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Create status bar " ) ;
2006-12-28 23:31:33 +01:00
CreateStatusBar ( 2 ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Set icon " ) ;
2010-12-11 17:47:03 +01:00
# ifdef _WIN32
2009-07-25 22:32:58 +02:00
SetIcon ( wxICON ( wxicon ) ) ;
# else
2009-07-25 22:07:07 +02:00
wxIcon icon ;
2011-01-11 18:00:11 +01:00
icon . CopyFromBitmap ( GETIMAGE ( wxicon ) ) ;
2009-07-25 22:07:07 +02:00
SetIcon ( icon ) ;
2009-07-25 22:32:58 +02:00
# endif
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Create views and inner main window controls " ) ;
2012-03-09 01:23:41 +01:00
context - > dialog = new DialogManager ;
2006-01-16 22:02:54 +01:00
InitContents ( ) ;
2011-07-30 01:16:36 +02:00
OPT_SUB ( " Video/Detached/Enabled " , & FrameMain : : OnVideoDetach , this , agi : : signal : : _1 ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:17:08 +01:00
StartupLog ( " Complete context initialization " ) ;
context - > videoController - > SetContext ( context . get ( ) ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Set up Auto Save " ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
AutoSave . SetOwner ( this , ID_APP_TIMER_AUTOSAVE ) ;
2012-01-20 02:04:24 +01:00
autosave_timer_changed ( & AutoSave ) ;
OPT_SUB ( " App/Auto/Save " , autosave_timer_changed , & AutoSave ) ;
OPT_SUB ( " App/Auto/Save Every Seconds " , autosave_timer_changed , & AutoSave ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Set up drag/drop target " ) ;
2006-01-16 22:02:54 +01:00
SetDropTarget ( new AegisubFileDropTarget ( this ) ) ;
2006-12-26 04:32:48 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Load default file " ) ;
context - > ass - > LoadDefault ( ) ;
2011-09-30 22:43:04 +02:00
StartupLog ( " Display main window " ) ;
2012-05-26 22:16:08 +02:00
AddFullScreenButton ( this ) ;
2011-09-30 22:43:04 +02:00
Show ( ) ;
SetDisplayMode ( 1 , 1 ) ;
2007-01-07 23:54:04 +01:00
2012-02-14 01:35:25 +01:00
StartupLog ( " Load files specified on command line " ) ;
LoadList ( args ) ;
2007-01-07 23:54:04 +01:00
// Version checker
2011-01-16 08:16:54 +01:00
StartupLog ( " Possibly perform automatic updates check " ) ;
2010-08-26 20:38:03 +02:00
if ( OPT_GET ( " App/First Start " ) - > GetBool ( ) ) {
OPT_SET ( " App/First Start " ) - > SetBool ( false ) ;
2012-06-21 04:09:40 +02:00
# ifdef WITH_UPDATE_CHECKER
2012-03-29 01:59:19 +02:00
int result = wxMessageBox ( _ ( " Do you want Aegisub to check for updates whenever it starts? You can still do it manually via the Help menu. " ) , _ ( " Check for updates? " ) , wxYES_NO | wxCENTER ) ;
2010-08-26 20:38:03 +02:00
OPT_SET ( " App/Auto/Check For Updates " ) - > SetBool ( result = = wxYES ) ;
2012-05-15 15:39:55 +02:00
config : : opt - > Flush ( ) ;
2012-06-21 04:09:40 +02:00
# endif
2007-01-07 23:54:04 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
2012-06-21 04:09:40 +02:00
# ifdef WITH_UPDATE_CHECKER
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
PerformVersionCheck ( false ) ;
2012-06-21 04:09:40 +02:00
# endif
2008-01-13 06:57:09 +01:00
2012-08-04 18:31:44 +02:00
Bind ( FILE_LIST_DROPPED , & FrameMain : : OnFilesDropped , this ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Leaving FrameMain constructor " ) ;
2006-01-16 22:02:54 +01:00
}
2012-05-15 15:39:24 +02:00
/// @brief Delete everything but @a keep and its parents
/// @param window Root window to delete the children of
/// @param keep Window to keep alive
/// @return Was @a keep found?
static bool delete_children ( wxWindow * window , wxWindow * keep ) {
bool found = false ;
while ( window - > GetChildren ( ) . size ( ) > ( size_t ) found ) {
2012-12-23 00:35:13 +01:00
auto it = window - > GetChildren ( ) . begin ( ) ;
2012-05-15 15:39:24 +02:00
if ( * it = = keep )
found = true ;
if ( found ) {
if ( + + it ! = window - > GetChildren ( ) . end ( ) )
( * it ) - > wxWindowBase : : Destroy ( ) ;
}
else if ( ! delete_children ( * it , keep ) )
( * it ) - > wxWindowBase : : Destroy ( ) ;
else
found = true ;
}
return found ;
}
2011-07-30 01:16:46 +02:00
2012-05-15 15:39:24 +02:00
FrameMain : : ~ FrameMain ( ) {
2012-05-16 16:23:16 +02:00
wxGetApp ( ) . frame = 0 ;
2011-01-16 08:16:54 +01:00
context - > videoController - > SetVideo ( " " ) ;
context - > audioController - > CloseAudio ( ) ;
2011-07-30 01:16:46 +02:00
2012-05-15 15:39:24 +02:00
// SubsGrid needs to be deleted last due to being the selection
// controller, but everything else needs to be deleted before the context
// is cleaned up
delete_children ( this , SubsGrid ) ;
2011-07-30 01:16:46 +02:00
2011-07-15 06:05:49 +02:00
delete context - > ass ;
HelpButton : : ClearPages ( ) ;
2011-01-16 08:16:54 +01:00
delete context - > audioController ;
delete context - > local_scripts ;
2006-01-16 22:02:54 +01:00
}
2012-01-23 00:44:24 +01:00
void FrameMain : : InitToolbar ( ) {
2011-07-15 06:05:49 +02:00
wxSystemOptions : : SetOption ( " msw.remap " , 0 ) ;
2012-01-23 00:44:24 +01:00
OPT_SUB ( " App/Show Toolbar " , & FrameMain : : EnableToolBar , this ) ;
EnableToolBar ( * OPT_GET ( " App/Show Toolbar " ) ) ;
}
void FrameMain : : EnableToolBar ( agi : : OptionValue const & opt ) {
if ( opt . GetBool ( ) ) {
if ( ! GetToolBar ( ) ) {
toolbar : : AttachToolbar ( this , " main " , context . get ( ) , " Default " ) ;
GetToolBar ( ) - > Realize ( ) ;
}
}
else if ( wxToolBar * old_tb = GetToolBar ( ) ) {
SetToolBar ( 0 ) ;
delete old_tb ;
Layout ( ) ;
}
2006-01-16 22:02:54 +01:00
}
void FrameMain : : InitContents ( ) {
2011-01-16 08:16:54 +01:00
StartupLog ( " Create background panel " ) ;
2011-11-30 00:18:42 +01:00
wxPanel * Panel = new wxPanel ( this , - 1 , wxDefaultPosition , wxDefaultSize , wxTAB_TRAVERSAL | wxCLIP_CHILDREN ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Create subtitles grid " ) ;
2012-10-15 03:57:57 +02:00
context - > subsGrid = SubsGrid = new SubtitlesGrid ( Panel , context . get ( ) ) ;
2011-01-16 08:17:02 +01:00
context - > selectionController = context - > subsGrid ;
2011-01-16 08:17:36 +01:00
Search . context = context . get ( ) ;
2006-01-16 22:02:54 +01:00
2011-11-04 06:11:24 +01:00
StartupLog ( " Create video box " ) ;
2011-11-12 02:23:18 +01:00
videoBox = new VideoBox ( Panel , false , context . get ( ) ) ;
2011-11-04 06:11:24 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Create audio box " ) ;
2011-09-29 07:33:04 +02:00
context - > audioBox = audioBox = new AudioBox ( Panel , context . get ( ) ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Create subtitle editing box " ) ;
2011-11-30 00:18:42 +01:00
SubsEditBox * EditBox = new SubsEditBox ( Panel , context . get ( ) ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:54 +01:00
StartupLog ( " Arrange main sizers " ) ;
2010-12-08 04:36:10 +01:00
ToolsSizer = new wxBoxSizer ( wxVERTICAL ) ;
2011-09-29 07:33:04 +02:00
ToolsSizer - > Add ( audioBox , 0 , wxEXPAND ) ;
2010-12-08 04:36:10 +01:00
ToolsSizer - > Add ( EditBox , 1 , wxEXPAND ) ;
TopSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2011-09-30 22:42:55 +02:00
TopSizer - > Add ( videoBox , 0 , wxEXPAND , 0 ) ;
2010-12-08 04:36:10 +01:00
TopSizer - > Add ( ToolsSizer , 1 , wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM , 5 ) ;
MainSizer = new wxBoxSizer ( wxVERTICAL ) ;
2007-07-07 05:21:52 +02:00
MainSizer - > Add ( new wxStaticLine ( Panel ) , 0 , wxEXPAND | wxALL , 0 ) ;
2006-01-16 22:02:54 +01:00
MainSizer - > Add ( TopSizer , 0 , wxEXPAND | wxALL , 0 ) ;
2010-12-08 04:36:10 +01:00
MainSizer - > Add ( SubsGrid , 1 , wxEXPAND | wxALL , 0 ) ;
2006-01-16 22:02:54 +01:00
Panel - > SetSizer ( MainSizer ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Perform layout " ) ;
2006-01-16 22:02:54 +01:00
Layout ( ) ;
2011-01-16 08:16:54 +01:00
StartupLog ( " Leaving InitContents " ) ;
2006-01-16 22:02:54 +01:00
}
2012-10-12 05:26:51 +02:00
void FrameMain : : LoadSubtitles ( wxString const & filename , wxString const & charset ) {
2011-01-16 08:16:54 +01:00
if ( context - > ass - > loaded ) {
2006-01-16 22:02:54 +01:00
if ( TryToCloseSubs ( ) = = wxCANCEL ) return ;
}
try {
2011-01-16 08:16:33 +01:00
// Make sure that file isn't actually a timecode file
try {
2012-10-12 05:26:51 +02:00
TextFileReader testSubs ( filename , charset ) ;
2011-01-16 08:16:33 +01:00
wxString cur = testSubs . ReadLineFromFile ( ) ;
2011-07-15 06:05:49 +02:00
if ( cur . Left ( 10 ) = = " # timecode " ) {
2011-01-16 08:16:54 +01:00
context - > videoController - > LoadTimecodes ( filename ) ;
2011-01-16 08:16:33 +01:00
return ;
2010-06-27 06:54:46 +02:00
}
2006-01-16 22:02:54 +01:00
}
2011-01-16 08:16:33 +01:00
catch ( . . . ) {
// if trying to load the file as timecodes fails it's fairly
// safe to assume that it is in fact not a timecode file
2006-01-16 22:02:54 +01:00
}
2011-01-16 08:16:33 +01:00
2012-10-12 05:26:51 +02:00
context - > ass - > Load ( filename , charset ) ;
wxFileName file ( filename ) ;
StandardPaths : : SetPathValue ( " ?script " , file . GetPath ( ) ) ;
2012-12-23 00:18:38 +01:00
config : : mru - > Add ( " Subtitle " , from_wx ( filename ) ) ;
OPT_SET ( " Path/Last/Subtitles " ) - > SetString ( from_wx ( file . GetPath ( ) ) ) ;
2012-10-12 05:26:51 +02:00
// Save backup of file
if ( context - > ass - > CanSave ( ) & & OPT_GET ( " App/Auto/Backup " ) - > GetBool ( ) ) {
if ( file . FileExists ( ) ) {
2012-12-23 00:18:38 +01:00
wxString path = to_wx ( OPT_GET ( " Path/Auto/Backup " ) - > GetString ( ) ) ;
2012-10-12 05:26:51 +02:00
if ( path . empty ( ) ) path = file . GetPath ( ) ;
wxFileName dstpath ( StandardPaths : : DecodePath ( path + " / " ) ) ;
if ( ! dstpath . DirExists ( ) )
wxMkdir ( dstpath . GetPath ( ) ) ;
dstpath . SetFullName ( file . GetName ( ) + " .ORIGINAL. " + file . GetExt ( ) ) ;
wxCopyFile ( file . GetFullPath ( ) , dstpath . GetFullPath ( ) , true ) ;
}
}
2006-01-16 22:02:54 +01:00
}
2012-01-12 23:31:54 +01:00
catch ( agi : : FileNotFoundError const & ) {
2012-03-29 01:59:19 +02:00
wxMessageBox ( filename + " not found. " , " Error " , wxOK | wxICON_ERROR | wxCENTER , this ) ;
2012-12-23 00:18:38 +01:00
config : : mru - > Remove ( " Subtitle " , from_wx ( filename ) ) ;
2010-08-02 08:32:01 +02:00
return ;
}
2012-10-12 05:18:47 +02:00
catch ( agi : : Exception const & err ) {
2012-12-23 00:18:38 +01:00
wxMessageBox ( to_wx ( err . GetChainedMessage ( ) ) , " Error " , wxOK | wxICON_ERROR | wxCENTER , this ) ;
2012-10-12 05:18:47 +02:00
}
2006-01-16 22:02:54 +01:00
catch ( . . . ) {
2012-03-29 01:59:19 +02:00
wxMessageBox ( " Unknown error " , " Error " , wxOK | wxICON_ERROR | wxCENTER , this ) ;
2006-01-16 22:02:54 +01:00
return ;
}
}
int FrameMain : : TryToCloseSubs ( bool enableCancel ) {
2011-01-16 08:16:54 +01:00
if ( context - > ass - > IsModified ( ) ) {
2006-01-16 22:02:54 +01:00
int flags = wxYES_NO ;
if ( enableCancel ) flags | = wxCANCEL ;
2011-11-16 22:58:58 +01:00
int result = wxMessageBox ( wxString : : Format ( _ ( " Do you want to save changes to %s? " ) , GetScriptFileName ( ) ) , _ ( " Unsaved changes " ) , flags , this ) ;
2006-01-16 22:02:54 +01:00
if ( result = = wxYES ) {
2012-02-07 02:22:23 +01:00
cmd : : call ( " subtitle/save " , context . get ( ) ) ;
2006-01-16 22:02:54 +01:00
// If it fails saving, return cancel anyway
2011-01-20 06:57:15 +01:00
return context - > ass - > IsModified ( ) ? wxCANCEL : wxYES ;
2006-01-16 22:02:54 +01:00
}
return result ;
}
2011-01-20 06:57:15 +01:00
else {
return wxYES ;
}
2006-01-16 22:02:54 +01:00
}
2009-10-12 00:10:08 +02:00
void FrameMain : : SetDisplayMode ( int video , int audio ) {
if ( ! IsShownOnScreen ( ) ) return ;
bool sv = false , sa = false ;
if ( video = = - 1 ) sv = showVideo ;
2012-03-09 01:23:41 +01:00
else if ( video ) sv = context - > videoController - > IsLoaded ( ) & & ! context - > dialog - > Get < DialogDetachedVideo > ( ) ;
2009-10-12 00:10:08 +02:00
if ( audio = = - 1 ) sa = showAudio ;
2011-01-16 08:16:54 +01:00
else if ( audio ) sa = context - > audioController - > IsAudioOpen ( ) ;
2006-01-16 22:02:54 +01:00
2007-01-23 05:42:08 +01:00
// See if anything changed
2009-10-12 00:10:08 +02:00
if ( sv = = showVideo & & sa = = showAudio ) return ;
showVideo = sv ;
showAudio = sa ;
2007-01-23 05:42:08 +01:00
2010-06-29 00:15:40 +02:00
bool didFreeze = ! IsFrozen ( ) ;
if ( didFreeze ) Freeze ( ) ;
2011-01-16 08:16:54 +01:00
context - > videoController - > Stop ( ) ;
2007-04-13 03:46:50 +02:00
2010-12-08 04:36:10 +01:00
TopSizer - > Show ( videoBox , showVideo , true ) ;
2011-09-29 07:33:04 +02:00
ToolsSizer - > Show ( audioBox , showAudio , true ) ;
2006-01-16 22:02:54 +01:00
2006-07-11 03:58:53 +02:00
MainSizer - > CalcMin ( ) ;
MainSizer - > RecalcSizes ( ) ;
2006-01-16 22:02:54 +01:00
MainSizer - > Layout ( ) ;
2006-05-05 20:52:09 +02:00
Layout ( ) ;
2010-06-29 00:15:40 +02:00
if ( didFreeze ) Thaw ( ) ;
2006-01-16 22:02:54 +01:00
}
void FrameMain : : UpdateTitle ( ) {
2011-01-16 08:16:33 +01:00
wxString newTitle ;
2011-07-15 06:05:49 +02:00
if ( context - > ass - > IsModified ( ) ) newTitle < < " * " ;
2011-11-16 22:58:58 +01:00
newTitle < < GetScriptFileName ( ) ;
2011-01-16 08:16:33 +01:00
# ifndef __WXMAC__
newTitle < < " - Aegisub " < < GetAegisubLongVersionString ( ) ;
2007-09-22 05:49:18 +02:00
# endif
2009-08-01 04:00:30 +02:00
2010-12-08 04:36:10 +01:00
# if defined(__WXMAC__) && !defined(__LP64__)
2007-09-22 05:07:16 +02:00
// On Mac, set the mark in the close button
2011-01-16 08:16:54 +01:00
OSXSetModified ( context - > ass - > IsModified ( ) ) ;
2007-09-22 05:07:16 +02:00
# endif
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:33 +01:00
if ( GetTitle ( ) ! = newTitle ) SetTitle ( newTitle ) ;
2006-01-16 22:02:54 +01:00
}
2011-01-16 08:16:27 +01:00
void FrameMain : : OnVideoOpen ( ) {
2011-01-16 08:16:54 +01:00
if ( ! context - > videoController - > IsLoaded ( ) ) {
2011-01-16 08:16:27 +01:00
SetDisplayMode ( 0 , - 1 ) ;
return ;
2006-01-16 22:02:54 +01:00
}
2011-01-16 08:16:27 +01:00
Freeze ( ) ;
2011-01-16 08:16:54 +01:00
int vidx = context - > videoController - > GetWidth ( ) ,
vidy = context - > videoController - > GetHeight ( ) ;
2011-01-16 08:16:27 +01:00
// Set zoom level based on video resolution and window size
2011-11-12 02:23:29 +01:00
double zoom = context - > videoDisplay - > GetZoom ( ) ;
2011-01-16 08:16:27 +01:00
wxSize windowSize = GetSize ( ) ;
if ( vidx * 3 * zoom > windowSize . GetX ( ) * 4 | | vidy * 4 * zoom > windowSize . GetY ( ) * 6 )
2011-11-12 02:23:29 +01:00
context - > videoDisplay - > SetZoom ( zoom * .25 ) ;
2011-01-16 08:16:27 +01:00
else if ( vidx * 3 * zoom > windowSize . GetX ( ) * 2 | | vidy * 4 * zoom > windowSize . GetY ( ) * 3 )
2011-11-12 02:23:29 +01:00
context - > videoDisplay - > SetZoom ( zoom * .5 ) ;
2011-01-16 08:16:27 +01:00
2009-10-12 00:10:08 +02:00
SetDisplayMode ( 1 , - 1 ) ;
2008-01-12 04:09:48 +01:00
2012-03-09 01:23:41 +01:00
if ( OPT_GET ( " Video/Detached/Enabled " ) - > GetBool ( ) & & ! context - > dialog - > Get < DialogDetachedVideo > ( ) )
2011-07-30 01:16:36 +02:00
cmd : : call ( " video/detach " , context . get ( ) ) ;
2008-01-12 04:09:48 +01:00
Thaw ( ) ;
2012-03-27 06:23:45 +02:00
2012-09-22 02:58:22 +02:00
if ( ! blockAudioLoad & & OPT_GET ( " Video/Open Audio " ) - > GetBool ( ) & & context - > audioController - > GetAudioURL ( ) ! = context - > videoController - > GetVideoName ( ) ) {
2012-03-27 06:23:45 +02:00
try {
context - > audioController - > OpenAudio ( context - > videoController - > GetVideoName ( ) ) ;
}
2012-04-03 19:38:38 +02:00
catch ( agi : : UserCancelException const & ) { }
2012-03-27 06:23:45 +02:00
// Opening a video with no audio data isn't an error, so just log
// and move on
catch ( agi : : FileNotAccessibleError const & ) {
LOG_D ( " video/open/audio " ) < < " File " < < context - > videoController - > GetVideoName ( ) < < " found by video provider but not audio provider " ;
}
catch ( agi : : AudioDataNotFoundError const & e ) {
LOG_D ( " video/open/audio " ) < < " File " < < context - > videoController - > GetVideoName ( ) < < " has no audio data: " < < e . GetChainedMessage ( ) ;
}
catch ( agi : : AudioOpenError const & err ) {
2012-12-23 00:18:38 +01:00
wxMessageBox ( to_wx ( err . GetMessage ( ) ) , " Error loading audio " , wxOK | wxICON_ERROR | wxCENTER ) ;
2012-03-27 06:23:45 +02:00
}
}
2006-01-16 22:02:54 +01:00
}
2011-07-30 01:16:36 +02:00
void FrameMain : : OnVideoDetach ( agi : : OptionValue const & opt ) {
if ( opt . GetBool ( ) )
SetDisplayMode ( 0 , - 1 ) ;
else if ( context - > videoController - > IsLoaded ( ) )
SetDisplayMode ( 1 , - 1 ) ;
2008-01-12 04:09:48 +01:00
}
2006-01-16 22:02:54 +01:00
void FrameMain : : StatusTimeout ( wxString text , int ms ) {
SetStatusText ( text , 1 ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
StatusClear . SetOwner ( this , ID_APP_TIMER_STATUSCLEAR ) ;
2006-01-16 22:02:54 +01:00
StatusClear . Start ( ms , true ) ;
}
2012-08-04 18:31:44 +02:00
void FrameMain : : OnFilesDropped ( wxThreadEvent & evt ) {
LoadList ( evt . GetPayload < wxArrayString > ( ) ) ;
}
2006-01-16 22:02:54 +01:00
2012-08-04 18:31:44 +02:00
bool FrameMain : : LoadList ( wxArrayString list ) {
2012-03-27 06:23:45 +02:00
wxString audio , video , subs ;
2012-08-04 18:31:44 +02:00
get_files_to_load ( list , subs , audio , video ) ;
2006-01-16 22:02:54 +01:00
2011-01-16 08:16:27 +01:00
blockVideoLoad = ! video . empty ( ) ;
2012-03-27 06:23:45 +02:00
blockAudioLoad = ! audio . empty ( ) ;
2006-01-16 22:02:54 +01:00
// Load files
2012-03-27 06:23:45 +02:00
if ( subs . size ( ) )
2006-02-01 03:16:57 +01:00
LoadSubtitles ( subs ) ;
2012-03-27 06:23:45 +02:00
2006-01-16 22:02:54 +01:00
if ( blockVideoLoad ) {
blockVideoLoad = false ;
2011-01-16 08:16:54 +01:00
context - > videoController - > SetVideo ( video ) ;
2006-01-16 22:02:54 +01:00
}
2012-03-27 06:23:45 +02:00
if ( blockAudioLoad ) {
blockAudioLoad = false ;
try {
context - > audioController - > OpenAudio ( audio ) ;
} catch ( agi : : UserCancelException const & ) { }
}
2006-01-16 22:02:54 +01:00
2012-02-15 22:24:00 +01:00
bool loaded_any = subs . size ( ) | | audio . size ( ) | | video . size ( ) ;
if ( loaded_any )
Refresh ( false ) ;
return loaded_any ;
2006-01-16 22:02:54 +01:00
}
2007-01-26 01:47:42 +01:00
2012-01-20 02:04:24 +01:00
static void autosave_timer_changed ( wxTimer * timer ) {
int freq = OPT_GET ( " App/Auto/Save Every Seconds " ) - > GetInt ( ) ;
if ( freq > 0 & & OPT_GET ( " App/Auto/Save " ) - > GetBool ( ) )
2010-12-07 20:09:15 +01:00
timer - > Start ( freq * 1000 ) ;
2012-01-20 02:04:24 +01:00
else
timer - > Stop ( ) ;
2010-08-26 20:38:44 +02:00
}
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
BEGIN_EVENT_TABLE ( FrameMain , wxFrame )
EVT_TIMER ( ID_APP_TIMER_AUTOSAVE , FrameMain : : OnAutoSave )
EVT_TIMER ( ID_APP_TIMER_STATUSCLEAR , FrameMain : : OnStatusClear )
EVT_CLOSE ( FrameMain : : OnCloseWindow )
2012-04-27 21:07:49 +02:00
EVT_CHAR_HOOK ( FrameMain : : OnKeyDown )
2011-10-25 21:40:57 +02:00
EVT_MOUSEWHEEL ( FrameMain : : OnMouseWheel )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
END_EVENT_TABLE ( )
void FrameMain : : OnCloseWindow ( wxCloseEvent & event ) {
// Stop audio and video
2011-01-16 08:16:54 +01:00
context - > videoController - > Stop ( ) ;
context - > audioController - > Stop ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Ask user if he wants to save first
bool canVeto = event . CanVeto ( ) ;
int result = TryToCloseSubs ( canVeto ) ;
2012-03-12 00:04:49 +01:00
if ( canVeto & & result = = wxCANCEL ) {
event . Veto ( ) ;
return ;
}
delete context - > dialog ;
context - > dialog = 0 ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Store maximization state
OPT_SET ( " App/Maximized " ) - > SetBool ( IsMaximized ( ) ) ;
2012-03-12 00:04:49 +01:00
Destroy ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
2011-07-15 06:05:49 +02:00
void FrameMain : : OnAutoSave ( wxTimerEvent & ) try {
2011-09-29 20:17:27 +02:00
wxString fn = context - > ass - > AutoSave ( ) ;
if ( ! fn . empty ( ) )
StatusTimeout ( wxString : : Format ( _ ( " File backup saved as \" %s \" . " ) , fn ) ) ;
2011-08-27 08:29:57 +02:00
}
catch ( const agi : : Exception & err ) {
2012-12-23 00:18:38 +01:00
StatusTimeout ( to_wx ( " Exception when attempting to autosave file: " + err . GetMessage ( ) ) ) ;
2011-08-27 08:29:57 +02:00
}
catch ( wxString err ) {
2011-07-15 06:05:49 +02:00
StatusTimeout ( " Exception when attempting to autosave file: " + err ) ;
2011-08-27 08:29:57 +02:00
}
2011-09-28 21:43:11 +02:00
catch ( const char * err ) {
2011-07-15 06:05:49 +02:00
StatusTimeout ( " Exception when attempting to autosave file: " + wxString ( err ) ) ;
2011-08-27 08:29:57 +02:00
}
catch ( . . . ) {
2011-07-15 06:05:49 +02:00
StatusTimeout ( " Unhandled exception when attempting to autosave file. " ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
void FrameMain : : OnStatusClear ( wxTimerEvent & ) {
2011-07-15 06:05:49 +02:00
SetStatusText ( " " , 1 ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
2011-12-22 22:09:31 +01:00
void FrameMain : : OnAudioOpen ( AudioProvider * ) {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
SetDisplayMode ( - 1 , 1 ) ;
}
2011-07-15 06:05:49 +02:00
void FrameMain : : OnAudioClose ( ) {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
SetDisplayMode ( - 1 , 0 ) ;
}
2011-01-16 08:16:33 +01:00
void FrameMain : : OnSubtitlesOpen ( ) {
UpdateTitle ( ) ;
/// @todo figure out how to move this to the relevant controllers without
/// prompting for each file loaded/unloaded
// Load stuff from the new script
2012-03-27 06:23:45 +02:00
wxString curSubsVideo = DecodeRelativePath ( context - > ass - > GetScriptInfo ( " Video File " ) , context - > ass - > filename ) ;
wxString curSubsVFR = DecodeRelativePath ( context - > ass - > GetScriptInfo ( " VFR File " ) , context - > ass - > filename ) ;
wxString curSubsKeyframes = DecodeRelativePath ( context - > ass - > GetScriptInfo ( " Keyframes File " ) , context - > ass - > filename ) ;
2012-04-21 17:13:40 +02:00
wxString curSubsAudio = DecodeRelativePath ( context - > ass - > GetScriptInfo ( " Audio URI " ) , context - > ass - > filename ) ;
2011-01-16 08:16:33 +01:00
2012-03-27 06:23:45 +02:00
bool videoChanged = ! blockVideoLoad & & curSubsVideo ! = context - > videoController - > GetVideoName ( ) ;
bool timecodesChanged = curSubsVFR ! = context - > videoController - > GetTimecodesName ( ) ;
bool keyframesChanged = curSubsKeyframes ! = context - > videoController - > GetKeyFramesName ( ) ;
bool audioChanged = ! blockAudioLoad & & curSubsAudio ! = context - > audioController - > GetAudioURL ( ) ;
2011-01-16 08:16:33 +01:00
// Check if there is anything to change
int autoLoadMode = OPT_GET ( " App/Auto/Load Linked Files " ) - > GetInt ( ) ;
2012-03-27 06:23:45 +02:00
if ( autoLoadMode = = 0 | | ( ! videoChanged & & ! timecodesChanged & & ! keyframesChanged & & ! audioChanged ) ) {
SetDisplayMode ( 1 , 1 ) ;
return ;
}
if ( autoLoadMode = = 2 ) {
2012-03-28 01:14:42 +02:00
if ( wxMessageBox ( _ ( " Do you want to load/unload the associated files? " ) , _ ( " (Un)Load files? " ) , wxYES_NO | wxCENTRE , this ) ! = wxYES ) {
2012-03-27 06:23:45 +02:00
SetDisplayMode ( 1 , 1 ) ;
return ;
2011-01-16 08:16:33 +01:00
}
}
2012-07-24 04:40:29 +02:00
if ( audioChanged )
blockAudioLoad = true ;
2012-03-27 06:23:45 +02:00
// Video
if ( videoChanged ) {
2012-07-24 04:40:31 +02:00
wxString arString = context - > ass - > GetScriptInfo ( " Video Aspect Ratio " ) ;
2012-03-27 06:23:45 +02:00
context - > videoController - > SetVideo ( curSubsVideo ) ;
if ( context - > videoController - > IsLoaded ( ) ) {
context - > videoController - > JumpToFrame ( context - > ass - > GetScriptInfoAsInt ( " Video Position " ) ) ;
long videoAr = 0 ;
double videoArValue = 0. ;
if ( arString . StartsWith ( " c " ) ) {
videoAr = 4 ;
arString . Mid ( 1 ) . ToDouble ( & videoArValue ) ;
2011-01-16 08:16:33 +01:00
}
2012-03-27 06:23:45 +02:00
else
arString . ToLong ( & videoAr ) ;
context - > videoController - > SetAspectRatio ( videoAr , videoArValue ) ;
double videoZoom = 0. ;
if ( context - > ass - > GetScriptInfo ( " Video Zoom Percent " ) . ToDouble ( & videoZoom ) )
context - > videoDisplay - > SetZoom ( videoZoom ) ;
2011-01-16 08:16:33 +01:00
}
2012-03-27 06:23:45 +02:00
}
2011-01-16 08:16:33 +01:00
2012-03-27 06:23:45 +02:00
context - > videoController - > LoadTimecodes ( curSubsVFR ) ;
context - > videoController - > LoadKeyframes ( curSubsKeyframes ) ;
2011-01-16 08:16:33 +01:00
2012-03-27 06:23:45 +02:00
// Audio
if ( audioChanged ) {
2012-07-24 04:40:29 +02:00
blockAudioLoad = false ;
2012-03-27 06:23:45 +02:00
try {
if ( ! curSubsAudio )
context - > audioController - > CloseAudio ( ) ;
else
context - > audioController - > OpenAudio ( curSubsAudio ) ;
2011-01-16 08:16:33 +01:00
}
2012-03-27 06:23:45 +02:00
catch ( agi : : UserCancelException const & ) { }
2012-09-22 03:07:30 +02:00
catch ( agi : : FileNotAccessibleError const & err ) {
2012-12-23 00:18:38 +01:00
config : : mru - > Remove ( " Audio " , from_wx ( curSubsAudio ) ) ;
wxMessageBox ( to_wx ( err . GetMessage ( ) ) , " Error opening audio " , wxOK | wxICON_ERROR | wxCENTER , this ) ;
2012-09-22 03:07:30 +02:00
}
2011-01-16 08:16:33 +01:00
}
2012-03-27 06:23:45 +02:00
SetDisplayMode ( 1 , 1 ) ;
2011-01-16 08:16:33 +01:00
}
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
void FrameMain : : OnKeyDown ( wxKeyEvent & event ) {
2012-03-13 00:34:34 +01:00
hotkey : : check ( " Main Frame " , context . get ( ) , event ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
2011-10-25 21:40:57 +02:00
void FrameMain : : OnMouseWheel ( wxMouseEvent & evt ) {
ForwardMouseWheelEvent ( this , evt ) ;
}
2011-11-16 22:58:58 +01:00
wxString FrameMain : : GetScriptFileName ( ) const {
if ( context - > ass - > filename . empty ( ) ) {
// Apple HIG says "untitled" should not be capitalised
// and the window is a document window, it shouldn't contain the app name
// (The app name is already present in the menu bar)
# ifndef __WXMAC__
return _ ( " Untitled " ) ;
# else
return _ ( " untitled " ) ;
# endif
}
2012-03-27 06:23:45 +02:00
else
return wxFileName ( context - > ass - > filename ) . GetFullName ( ) ;
2011-11-16 22:58:58 +01:00
}