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/
2006-01-16 22:02:54 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @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"
2009-09-10 15:06:40 +02:00
# ifndef AGI_PRE
2006-01-16 22:02:54 +01:00
# include <wx/filename.h>
2006-12-27 21:16:47 +01:00
# include <wx/image.h>
2009-09-10 15:06:40 +02:00
# include <wx/mimetype.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>
# endif
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>
# include "aegisub/menu.h"
# include "aegisub/toolbar.h"
# 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 "selection_controller.h"
# include "audio_controller.h"
2009-09-10 15:06:40 +02:00
# include "audio_box.h"
# ifdef WITH_AUTOMATION
# include "auto4_base.h"
# endif
2008-01-22 03:54:16 +01:00
# ifdef WITH_AVISYNTH
2006-02-24 03:54:30 +01:00
# include "avisynth_wrap.h"
2008-01-22 03:54:16 +01:00
# endif
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"
2009-09-10 15:06:40 +02:00
# include "dialog_detached_video.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"
2006-01-16 22:02:54 +01:00
# include "drop.h"
2009-09-10 15:06:40 +02:00
# include "frame_main.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"
# 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 "text_file_writer.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
2009-06-12 18:59:53 +02:00
# ifdef WITH_STARTUPLOG
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2009-06-12 18:59:53 +02:00
# define StartupLog(a) MessageBox(0, a, _T("Aegisub startup log"), 0)
# else
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// DOCME
2009-06-12 18:59:53 +02:00
# define StartupLog(a)
# endif
2010-12-07 20:09:15 +01:00
static void autosave_timer_changed ( wxTimer * timer , const agi : : OptionValue & opt ) ;
2010-08-26 20:38:44 +02:00
2006-01-16 22:02:54 +01:00
FrameMain : : FrameMain ( wxArrayString args )
2007-07-07 05:21:52 +02:00
: wxFrame ( ( wxFrame * ) NULL , - 1 , _T ( " " ) , wxDefaultPosition , wxSize ( 920 , 700 ) , wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN )
2006-01-16 22:02:54 +01:00
{
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " 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
temp_context . parent = this ;
// Bind all commands.
// XXX: This is a hack for now, it will need to be dealt with when other frames are involved.
int count = cmd : : count ( ) ;
for ( int i = 0 ; i < count ; i + + ) {
Bind ( wxEVT_COMMAND_MENU_SELECTED , & FrameMain : : cmd_call , this , i ) ;
}
# ifdef __WXMAC__
Bind ( FrameMain : : OnAbout , & FrameMain : : cmd_call , this , cmd : : id ( " app/about " ) ) ;
# endif
2007-04-03 06:34:56 +02:00
# ifdef __WXGTK__
/* XXX HACK XXX
* Gtk just got initialized . And if we ' re using the SCIM IME ,
2007-09-12 01:22:26 +02:00
* it just did a setlocale ( LC_ALL , " " ) . so , BOOM .
2007-04-03 06:34:56 +02:00
*/
setlocale ( LC_ALL , " " ) ;
setlocale ( LC_CTYPE , " C " ) ;
setlocale ( LC_NUMERIC , " C " ) ;
/* XXX HACK XXX */
# endif
2007-01-11 06:33:36 +01:00
// Set application's frame
AegisubApp : : Get ( ) - > frame = this ;
2006-01-16 22:02:54 +01:00
// Initialize flags
HasSelection = false ;
menuCreated = false ;
2010-12-08 04:36:10 +01:00
blockVideoLoad = false ;
2006-01-16 22:02:54 +01:00
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Install PNG handler " ) ) ;
2006-12-27 21:16:47 +01:00
// Create PNG handler
wxPNGHandler * png = new wxPNGHandler ;
wxImage : : AddHandler ( png ) ;
2010-06-26 16:16:59 +02:00
wxSafeYield ( ) ;
2006-12-28 23:31:33 +01:00
// Storage for subs-file-local scripts
2007-12-31 07:46:22 +01:00
# ifdef WITH_AUTOMATION
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create local Automation script manager " ) ) ;
2006-12-28 23:31:33 +01:00
local_scripts = new Automation4 : : ScriptManager ( ) ;
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
temp_context . local_scripts = local_scripts ;
2007-12-31 07:46:22 +01:00
# endif
2006-12-28 23:31:33 +01:00
2010-12-08 04:36:10 +01:00
// Contexts and controllers
audioController = new AudioController ;
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
temp_context . audioController = audioController ;
2010-12-08 09:09:16 +01:00
audioController - > AddAudioOpenListener ( & FrameMain : : OnAudioOpen , this ) ;
audioController - > AddAudioCloseListener ( & FrameMain : : OnAudioClose , this ) ;
2010-12-08 04:36:10 +01:00
2006-01-16 22:02:54 +01:00
// Create menu and tool bars
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Apply saved Maximized state " ) ) ;
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " App/Maximized " ) - > GetBool ( ) ) Maximize ( true ) ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Initialize toolbar " ) ) ;
2006-01-16 22:02:54 +01:00
InitToolbar ( ) ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Initialize menu bar " ) ) ;
2006-01-16 22:02:54 +01:00
InitMenu ( ) ;
// Create status bar
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create status bar " ) ) ;
2006-12-28 23:31:33 +01:00
CreateStatusBar ( 2 ) ;
2006-01-16 22:02:54 +01:00
// Set icon
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " 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 ;
icon . CopyFromBitmap ( GETIMAGE ( wxicon_misc ) ) ;
SetIcon ( icon ) ;
2009-07-25 22:32:58 +02:00
# endif
2006-01-16 22:02:54 +01:00
// Contents
2007-01-23 05:42:08 +01:00
showVideo = true ;
showAudio = true ;
detachedVideo = NULL ;
2009-05-14 09:02:01 +02:00
stylingAssistant = NULL ;
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
temp_context . stylingAssistant = stylingAssistant ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Initialize inner main window controls " ) ) ;
2006-01-16 22:02:54 +01:00
InitContents ( ) ;
// Set autosave timer
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " 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 ) ;
2010-05-21 03:13:36 +02:00
int time = OPT_GET ( " App/Auto/Save Every Seconds " ) - > GetInt ( ) ;
2006-01-16 22:02:54 +01:00
if ( time > 0 ) {
AutoSave . Start ( time * 1000 ) ;
}
2010-12-07 20:09:15 +01:00
OPT_SUB ( " App/Auto/Save Every Seconds " , autosave_timer_changed , & AutoSave , agi : : signal : : _1 ) ;
2006-01-16 22:02:54 +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
PreviousFocus = NULL ; // Artifact from old hotkey removal not sure what it does.
temp_context . PreviousFocus = PreviousFocus ; // Artifact from old hotkey removal not sure what it does.
2006-01-16 22:02:54 +01:00
// Set drop target
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " 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
// Parse arguments
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Initialize empty file " ) ) ;
2006-12-26 04:32:48 +01:00
LoadSubtitles ( _T ( " " ) ) ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Load files specified on command line " ) ) ;
2006-12-26 04:32:48 +01:00
LoadList ( args ) ;
2007-01-07 23:54:04 +01:00
// Version checker
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " 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 ) ;
2007-01-07 23:54:04 +01: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 ) ;
2010-08-26 20:38:03 +02:00
OPT_SET ( " App/Auto/Check For Updates " ) - > SetBool ( result = = wxYES ) ;
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
PerformVersionCheck ( false ) ;
2008-01-13 06:57:09 +01:00
2010-06-26 16:16:59 +02:00
StartupLog ( _T ( " Display main window " ) ) ;
Show ( ) ;
2010-06-29 00:15:40 +02:00
Freeze ( ) ;
2010-06-26 16:16:59 +02:00
SetDisplayMode ( 1 , 1 ) ;
Thaw ( ) ;
2008-01-13 06:57:09 +01:00
//ShowFullScreen(true,wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Leaving FrameMain constructor " ) ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief FrameMain destructor
2006-01-16 22:02:54 +01:00
FrameMain : : ~ FrameMain ( ) {
2010-12-08 04:36:10 +01:00
VideoContext : : Get ( ) - > SetVideo ( _T ( " " ) ) ;
audioController - > CloseAudio ( ) ;
2006-02-03 01:22:16 +01:00
DeInitContents ( ) ;
2010-12-08 04:36:10 +01:00
delete audioController ;
2007-12-31 07:46:22 +01:00
# ifdef WITH_AUTOMATION
2006-12-28 23:31:33 +01:00
delete local_scripts ;
2007-12-31 07:46:22 +01:00
# endif
2006-01-16 22:02:54 +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 : : cmd_call ( wxCommandEvent & event ) {
int id = event . GetId ( ) ;
LOG_D ( " event/select " ) < < " Id: " < < id ;
cmd : : call ( & temp_context , id ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Initialize toolbar
2006-01-16 22:02:54 +01:00
void FrameMain : : InitToolbar ( ) {
// Create toolbar
wxSystemOptions : : SetOption ( _T ( " msw.remap " ) , 0 ) ;
Toolbar = CreateToolBar ( wxTB_FLAT | wxTB_HORIZONTAL , - 1 , _T ( " Toolbar " ) ) ;
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
toolbar : : toolbar - > GetToolbar ( " main " , Toolbar ) ;
2006-01-16 22:02:54 +01:00
wxArrayString choices ;
2009-10-06 19:43:15 +02:00
for ( int i = 1 ; i < = 24 ; i + + ) {
2006-01-16 22:02:54 +01:00
wxString toAdd = wxString : : Format ( _T ( " %i " ) , int ( i * 12.5 ) ) ;
if ( i % 2 ) toAdd + = _T ( " .5 " ) ;
toAdd + = _T ( " % " ) ;
choices . Add ( toAdd ) ;
}
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
ZoomBox = new wxComboBox ( Toolbar , ID_TOOLBAR_ZOOM_DROPDOWN , _T ( " 75% " ) , wxDefaultPosition , wxDefaultSize , choices , wxCB_DROPDOWN ) ;
2006-01-16 22:02:54 +01:00
Toolbar - > AddControl ( ZoomBox ) ;
Toolbar - > AddSeparator ( ) ;
// Update
Toolbar - > Realize ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Initialize menu bar
2006-01-16 22:02:54 +01:00
void FrameMain : : InitMenu ( ) {
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-09-23 21:40:57 +02:00
# ifdef __WXMAC__
// Make sure special menu items are placed correctly on Mac
wxApp : : s_macAboutMenuItemId = Menu_Help_About ;
wxApp : : s_macExitMenuItemId = Menu_File_Exit ;
wxApp : : s_macPreferencesMenuItemId = Menu_Tools_Options ;
wxApp : : s_macHelpMenuTitleName = _ ( " &Help " ) ;
# endif
2006-01-16 22:02:54 +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
SetMenuBar ( menu : : menu - > GetMainMenu ( ) ) ;
2006-01-16 22:02:54 +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
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Initialize contents
2006-01-16 22:02:54 +01:00
void FrameMain : : InitContents ( ) {
2010-07-09 09:31:48 +02:00
AssFile : : top = ass = new AssFile ;
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
temp_context . ass = ass ;
2010-12-07 20:09:28 +01:00
ass - > AddCommitListener ( & FrameMain : : OnSubtitlesFileChanged , this ) ;
2006-01-16 22:02:54 +01:00
// Set a background panel
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create background panel " ) ) ;
2006-01-16 22:02:54 +01:00
Panel = new wxPanel ( this , - 1 , wxDefaultPosition , wxDefaultSize , wxTAB_TRAVERSAL | wxCLIP_CHILDREN ) ;
// Video area;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create video box " ) ) ;
2010-12-07 20:09:28 +01:00
videoBox = new VideoBox ( Panel , false , ZoomBox , ass ) ;
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
temp_context . videoBox = videoBox ;
2010-12-08 04:36:10 +01:00
VideoContext : : Get ( ) - > audio = audioController ;
wxBoxSizer * videoSizer = new wxBoxSizer ( wxVERTICAL ) ;
videoSizer - > Add ( videoBox , 0 , wxEXPAND ) ;
videoSizer - > AddStretchSpacer ( 1 ) ;
2006-01-16 22:02:54 +01:00
// Subtitles area
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create subtitles grid " ) ) ;
2010-07-09 09:31:48 +02:00
SubsGrid = new SubtitlesGrid ( this , Panel , - 1 , ass , wxDefaultPosition , wxSize ( 600 , 100 ) , wxWANTS_CHARS | wxSUNKEN_BORDER , _T ( " Subs grid " ) ) ;
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
temp_context . SubsGrid = SubsGrid ;
2010-06-16 08:20:33 +02:00
videoBox - > videoSlider - > grid = SubsGrid ;
VideoContext : : Get ( ) - > grid = SubsGrid ;
Search . grid = SubsGrid ;
2006-01-16 22:02:54 +01:00
2010-12-08 04:36:10 +01:00
// Tools area
StartupLog ( _T ( " Create tool area splitter window " ) ) ;
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
audioSash = new wxSashWindow ( Panel , ID_SASH_MAIN_AUDIO , wxDefaultPosition , wxDefaultSize , wxSW_3D | wxCLIP_CHILDREN ) ;
2010-12-08 04:36:10 +01:00
wxBoxSizer * audioSashSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
audioSash - > SetSashVisible ( wxSASH_BOTTOM , true ) ;
2006-01-16 22:02:54 +01:00
// Audio area
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create audio box " ) ) ;
2010-12-08 09:10:00 +01:00
audioBox = new AudioBox ( audioSash , audioController , SubsGrid , ass ) ;
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
temp_context . audioBox = audioBox ;
2006-01-16 22:02:54 +01:00
audioBox - > frameMain = this ;
2010-12-08 04:36:10 +01:00
audioSashSizer - > Add ( audioBox , 1 , wxEXPAND ) ;
audioSash - > SetSizer ( audioSashSizer ) ;
audioBox - > Fit ( ) ;
audioSash - > SetMinimumSizeY ( audioBox - > GetSize ( ) . GetHeight ( ) ) ;
2006-01-16 22:02:54 +01:00
2010-12-08 04:36:10 +01:00
// Editing area
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Create subtitle editing box " ) ) ;
2010-12-07 20:09:28 +01:00
EditBox = new SubsEditBox ( Panel , SubsGrid ) ;
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
temp_context . EditBox = EditBox ;
2006-01-16 22:02:54 +01:00
// Set sizers/hints
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Arrange main sizers " ) ) ;
2010-12-08 04:36:10 +01:00
ToolsSizer = new wxBoxSizer ( wxVERTICAL ) ;
ToolsSizer - > Add ( audioSash , 0 , wxEXPAND ) ;
ToolsSizer - > Add ( EditBox , 1 , wxEXPAND ) ;
TopSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
TopSizer - > Add ( videoSizer , 0 , wxEXPAND , 0 ) ;
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 ) ;
//MainSizer->SetSizeHints(Panel);
//SetSizer(MainSizer);
// Set display
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Perform layout " ) ) ;
2006-01-16 22:02:54 +01:00
Layout ( ) ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Set focus to edting box " ) ) ;
2007-07-03 03:09:39 +02:00
EditBox - > TextEdit - > SetFocus ( ) ;
2009-06-12 18:59:53 +02:00
StartupLog ( _T ( " Leaving InitContents " ) ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Deinitialize controls
2006-02-03 01:22:16 +01:00
void FrameMain : : DeInitContents ( ) {
2007-01-23 05:42:08 +01:00
if ( detachedVideo ) detachedVideo - > Destroy ( ) ;
2009-05-14 09:02:01 +02:00
if ( stylingAssistant ) stylingAssistant - > Destroy ( ) ;
2010-06-26 09:26:27 +02:00
SubsGrid - > ClearMaps ( ) ;
2010-12-08 09:09:00 +01:00
delete audioBox ;
2006-02-03 01:22:16 +01:00
delete EditBox ;
delete videoBox ;
2010-07-09 09:31:48 +02:00
delete ass ;
2009-06-12 02:04:35 +02:00
HelpButton : : ClearPages ( ) ;
2010-07-08 06:29:04 +02:00
VideoContext : : Get ( ) - > audio = NULL ;
2006-02-03 01:22:16 +01:00
}
2006-01-16 22:02:54 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update toolbar
2006-01-16 22:02:54 +01:00
void FrameMain : : UpdateToolbar ( ) {
// Collect flags
2007-01-23 07:32:16 +01:00
bool isVideo = VideoContext : : Get ( ) - > IsLoaded ( ) ;
2006-01-16 22:02:54 +01:00
HasSelection = true ;
2010-06-16 08:20:33 +02:00
int selRows = SubsGrid - > GetNumberSelection ( ) ;
2006-01-16 22:02:54 +01:00
// Update
wxToolBar * toolbar = GetToolBar ( ) ;
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
toolbar - > FindById ( cmd : : id ( " video/jump " ) ) - > Enable ( isVideo ) ;
toolbar - > FindById ( cmd : : id ( " video/zoom/in " ) ) - > Enable ( isVideo & & ! detachedVideo ) ;
toolbar - > FindById ( cmd : : id ( " video/zoom/out " ) ) - > Enable ( isVideo & & ! detachedVideo ) ;
2009-10-10 17:21:26 +02:00
ZoomBox - > Enable ( isVideo & & ! detachedVideo ) ;
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
toolbar - > FindById ( cmd : : id ( " video/jump/start " ) ) - > Enable ( isVideo & & selRows > 0 ) ;
toolbar - > FindById ( cmd : : id ( " video/jump/end " ) ) - > Enable ( isVideo & & selRows > 0 ) ;
toolbar - > FindById ( cmd : : id ( " time/snap/start_video " ) ) - > Enable ( isVideo & & selRows = = 1 ) ;
toolbar - > FindById ( cmd : : id ( " time/snap/end_video " ) ) - > Enable ( isVideo & & selRows = = 1 ) ;
toolbar - > FindById ( cmd : : id ( " subtitle/select/visible " ) ) - > Enable ( isVideo ) ;
toolbar - > FindById ( cmd : : id ( " time/snap/scene " ) ) - > Enable ( isVideo & & selRows > 0 ) ;
toolbar - > FindById ( cmd : : id ( " time/snap/frame " ) ) - > Enable ( isVideo & & selRows > 0 ) ;
2006-01-16 22:02:54 +01:00
toolbar - > Realize ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Open subtitles
/// @param filename
/// @param charset
2006-01-16 22:02:54 +01:00
void FrameMain : : LoadSubtitles ( wxString filename , wxString charset ) {
// First check if there is some loaded
2010-07-09 09:31:48 +02:00
if ( ass & & ass - > loaded ) {
2006-01-16 22:02:54 +01:00
if ( TryToCloseSubs ( ) = = wxCANCEL ) return ;
}
// Setup
2010-08-02 08:32:01 +02:00
bool isFile = ! filename . empty ( ) ;
2006-01-16 22:02:54 +01:00
// Load
try {
2006-02-23 23:47:14 +01:00
// File exists?
if ( isFile ) {
wxFileName fileCheck ( filename ) ;
2010-08-02 08:32:01 +02:00
if ( ! fileCheck . FileExists ( ) ) {
throw agi : : FileNotFoundError ( STD_STR ( filename ) ) ;
}
2006-02-24 00:04:41 +01:00
// Make sure that file isn't actually a timecode file
2009-07-14 23:28:49 +02:00
try {
TextFileReader testSubs ( filename , charset ) ;
2010-08-03 22:21:04 +02:00
wxString cur = testSubs . ReadLineFromFile ( ) ;
if ( cur . Left ( 10 ) = = _T ( " # timecode " ) ) {
LoadVFR ( filename ) ;
OPT_SET ( " Path/Last/Timecodes " ) - > SetString ( STD_STR ( fileCheck . GetPath ( ) ) ) ;
return ;
2006-02-24 00:04:41 +01:00
}
}
2009-07-14 23:28:49 +02:00
catch ( . . . ) {
2010-08-02 08:32:01 +02:00
// if trying to load the file as timecodes fails it's fairly
// safe to assume that it is in fact not a timecode file
2009-07-14 23:28:49 +02:00
}
2006-02-23 23:47:14 +01:00
}
// Proceed into loading
2010-06-26 09:26:27 +02:00
SubsGrid - > ClearMaps ( ) ;
2006-01-16 22:02:54 +01:00
if ( isFile ) {
2010-07-09 09:31:48 +02:00
ass - > Load ( filename , charset ) ;
2010-06-27 06:54:46 +02:00
if ( SubsGrid - > GetRows ( ) ) {
SubsGrid - > SetActiveLine ( SubsGrid - > GetDialogue ( 0 ) ) ;
SubsGrid - > SelectRow ( 0 ) ;
}
2007-06-21 00:23:55 +02:00
wxFileName fn ( filename ) ;
StandardPaths : : SetPathValue ( _T ( " ?script " ) , fn . GetPath ( ) ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Path/Last/Subtitles " ) - > SetString ( STD_STR ( fn . GetPath ( ) ) ) ;
2006-01-16 22:02:54 +01:00
}
else {
2010-06-26 09:26:27 +02:00
SubsGrid - > LoadDefault ( ) ;
2007-06-21 00:23:55 +02:00
StandardPaths : : SetPathValue ( _T ( " ?script " ) , _T ( " " ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-10-11 22:05:59 +02:00
SubsGrid - > SetColumnWidths ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-08-02 08:32:01 +02:00
catch ( agi : : FileNotFoundError const & ) {
wxMessageBox ( filename + L " not found. " , L " Error " , wxOK | wxICON_ERROR , NULL ) ;
config : : mru - > Remove ( " Subtitle " , STD_STR ( filename ) ) ;
return ;
}
2006-04-14 18:46:38 +02:00
catch ( const wchar_t * err ) {
2006-01-16 22:02:54 +01:00
wxMessageBox ( wxString ( err ) , _T ( " Error " ) , wxOK | wxICON_ERROR , NULL ) ;
return ;
}
2009-07-14 23:28:49 +02:00
catch ( wxString err ) {
wxMessageBox ( err , _T ( " Error " ) , wxOK | wxICON_ERROR , NULL ) ;
return ;
}
2006-01-16 22:02:54 +01:00
catch ( . . . ) {
wxMessageBox ( _T ( " Unknown error " ) , _T ( " Error " ) , wxOK | wxICON_ERROR , NULL ) ;
return ;
}
// Save copy
wxFileName origfile ( filename ) ;
2010-08-03 22:21:04 +02:00
if ( ass - > CanSave ( ) & & OPT_GET ( " App/Auto/Backup " ) - > GetBool ( ) & & origfile . FileExists ( ) ) {
2006-01-16 22:02:54 +01:00
// Get path
2010-05-21 03:13:36 +02:00
wxString path = lagi_wxString ( OPT_GET ( " Path/Auto/Backup " ) - > GetString ( ) ) ;
2006-02-20 22:32:58 +01:00
if ( path . IsEmpty ( ) ) path = origfile . GetPath ( ) ;
2006-01-16 22:02:54 +01:00
wxFileName dstpath ( path ) ;
2009-07-14 05:02:17 +02:00
if ( ! dstpath . IsAbsolute ( ) ) path = StandardPaths : : DecodePathMaybeRelative ( path , _T ( " ?user/ " ) ) ;
2006-01-16 22:02:54 +01:00
path + = _T ( " / " ) ;
dstpath . Assign ( path ) ;
if ( ! dstpath . DirExists ( ) ) wxMkdir ( path ) ;
// Save
wxString backup = path + origfile . GetName ( ) + _T ( " .ORIGINAL. " ) + origfile . GetExt ( ) ;
2009-07-14 04:20:40 +02:00
wxCopyFile ( filename , backup , true ) ;
2006-01-16 22:02:54 +01:00
}
// Sync
SynchronizeProject ( true ) ;
// Update title bar
UpdateTitle ( ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Save subtitles
/// @param saveas
/// @param withCharset
/// @return
2006-01-16 22:02:54 +01:00
bool FrameMain : : SaveSubtitles ( bool saveas , bool withCharset ) {
// Try to get filename from file
wxString filename ;
2010-07-09 09:31:48 +02:00
if ( saveas = = false & & ass - > CanSave ( ) ) filename = ass - > filename ;
2006-01-16 22:02:54 +01:00
// Failed, ask user
2006-02-20 22:32:58 +01:00
if ( filename . IsEmpty ( ) ) {
2007-01-21 07:30:19 +01:00
VideoContext : : Get ( ) - > Stop ( ) ;
2010-05-21 03:13:36 +02:00
wxString path = lagi_wxString ( OPT_GET ( " Path/Last/Subtitles " ) - > GetString ( ) ) ;
2010-07-09 09:31:48 +02:00
wxFileName origPath ( ass - > filename ) ;
2010-08-02 08:32:01 +02:00
filename = wxFileSelector ( _ ( " Save subtitles file " ) , path , origPath . GetName ( ) + _T ( " .ass " ) , _T ( " ass " ) , AssFile : : GetWildcardList ( 1 ) , wxFD_SAVE | wxFD_OVERWRITE_PROMPT , this ) ;
2006-01-16 22:02:54 +01:00
}
// Actually save
if ( ! filename . empty ( ) ) {
2006-03-14 05:23:00 +01:00
// Store path
wxFileName filepath ( filename ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Path/Last/Subtitles " ) - > SetString ( STD_STR ( filepath . GetPath ( ) ) ) ;
2006-03-14 05:23:00 +01:00
// Fix me, ghetto hack for correct relative path generation in SynchronizeProject()
2010-07-09 09:31:48 +02:00
ass - > filename = filename ;
2006-03-14 05:23:00 +01:00
// Synchronize
SynchronizeProject ( ) ;
2006-01-16 22:02:54 +01:00
// Get charset
wxString charset = _T ( " " ) ;
if ( withCharset ) {
2010-06-03 22:32:25 +02:00
charset = wxGetSingleChoice ( _ ( " Choose charset code: " ) , _T ( " Charset " ) , agi : : charset : : GetEncodingsList < wxArrayString > ( ) , this , - 1 , - 1 , true , 250 , 200 ) ;
2006-02-20 22:32:58 +01:00
if ( charset . IsEmpty ( ) ) return false ;
2006-01-16 22:02:54 +01:00
}
// Save
try {
2010-07-09 09:31:48 +02:00
ass - > Save ( filename , true , true , charset ) ;
2006-01-16 22:02:54 +01:00
UpdateTitle ( ) ;
}
2010-09-08 22:03:48 +02:00
catch ( const agi : : Exception & err ) {
wxMessageBox ( lagi_wxString ( err . GetMessage ( ) ) , " Error " , wxOK | wxICON_ERROR , NULL ) ;
return false ;
}
2006-04-14 18:46:38 +02:00
catch ( const wchar_t * err ) {
2006-01-16 22:02:54 +01:00
wxMessageBox ( wxString ( err ) , _T ( " Error " ) , wxOK | wxICON_ERROR , NULL ) ;
return false ;
}
catch ( . . . ) {
wxMessageBox ( _T ( " Unknown error " ) , _T ( " Error " ) , wxOK | wxICON_ERROR , NULL ) ;
return false ;
}
return true ;
}
return false ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Try to close subtitles
/// @param enableCancel
/// @return
2006-01-16 22:02:54 +01:00
int FrameMain : : TryToCloseSubs ( bool enableCancel ) {
if ( ass - > IsModified ( ) ) {
int flags = wxYES_NO ;
if ( enableCancel ) flags | = wxCANCEL ;
int result = wxMessageBox ( _ ( " Save before continuing? " ) , _ ( " Unsaved changes " ) , flags , this ) ;
if ( result = = wxYES ) {
// If it fails saving, return cancel anyway
if ( SaveSubtitles ( false ) ) return wxYES ;
else return wxCANCEL ;
}
return result ;
}
else return wxYES ;
}
2009-10-12 00:10:08 +02:00
/// @brief Set the video and audio display visibilty
/// @param video -1: leave unchanged; 0: hide; 1: show
/// @param audio -1: leave unchanged; 0: hide; 1: show
void FrameMain : : SetDisplayMode ( int video , int audio ) {
if ( ! IsShownOnScreen ( ) ) return ;
bool sv = false , sa = false ;
if ( video = = - 1 ) sv = showVideo ;
else if ( video ) sv = VideoContext : : Get ( ) - > IsLoaded ( ) & & ! detachedVideo ;
if ( audio = = - 1 ) sa = showAudio ;
2010-12-08 04:36:10 +01:00
else if ( audio ) sa = 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 ( ) ;
2007-04-13 03:46:50 +02:00
VideoContext : : Get ( ) - > Stop ( ) ;
2007-01-23 05:42:08 +01:00
// Set display
2010-12-08 04:36:10 +01:00
TopSizer - > Show ( videoBox , showVideo , true ) ;
ToolsSizer - > Show ( audioSash , showAudio , true ) ;
2006-01-16 22:02:54 +01:00
// Update
UpdateToolbar ( ) ;
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
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Update title bar
2006-01-16 22:02:54 +01:00
void FrameMain : : UpdateTitle ( ) {
// Determine if current subs are modified
2010-07-09 09:31:48 +02:00
bool subsMod = ass - > IsModified ( ) ;
2006-01-16 22:02:54 +01:00
// Create ideal title
wxString newTitle = _T ( " " ) ;
2007-09-22 05:07:16 +02:00
# ifndef __WXMAC__
2006-01-16 22:02:54 +01:00
if ( subsMod ) newTitle < < _T ( " * " ) ;
2010-07-09 09:31:48 +02:00
if ( ass - > filename ! = _T ( " " ) ) {
wxFileName file ( ass - > filename ) ;
2006-01-16 22:02:54 +01:00
newTitle < < file . GetFullName ( ) ;
}
2009-11-04 06:27:09 +01:00
else newTitle < < _ ( " Untitled " ) ;
2006-05-07 14:38:33 +02:00
newTitle < < _T ( " - Aegisub " ) < < GetAegisubLongVersionString ( ) ;
2007-09-22 05:49:18 +02:00
# else
// 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)
2010-07-09 09:31:48 +02:00
if ( ass - > filename ! = _T ( " " ) ) {
wxFileName file ( ass - > filename ) ;
2007-09-22 05:49:18 +02:00
newTitle < < file . GetFullName ( ) ;
}
2009-11-04 06:27:09 +01:00
else newTitle < < _ ( " untitled " ) ;
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
2010-08-13 02:33:54 +02:00
OSXSetModified ( subsMod ) ;
2007-09-22 05:07:16 +02:00
# endif
2006-01-16 22:02:54 +01:00
// Get current title
wxString curTitle = GetTitle ( ) ;
if ( curTitle ! = newTitle ) SetTitle ( newTitle ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Updates subs with video/whatever data
/// @param fromSubs
2006-01-16 22:02:54 +01:00
void FrameMain : : SynchronizeProject ( bool fromSubs ) {
// Retrieve data from subs
if ( fromSubs ) {
// Reset the state
long videoPos = 0 ;
long videoAr = 0 ;
2006-05-16 01:44:53 +02:00
double videoArValue = 0.0 ;
2010-05-01 03:07:05 +02:00
double videoZoom = 0. ;
2006-01-16 22:02:54 +01:00
2006-05-16 01:44:53 +02:00
// Get AR
2010-07-09 09:31:48 +02:00
wxString arString = ass - > GetScriptInfo ( _T ( " Video Aspect Ratio " ) ) ;
2006-05-16 01:44:53 +02:00
if ( arString . Left ( 1 ) = = _T ( " c " ) ) {
videoAr = 4 ;
arString = arString . Mid ( 1 ) ;
arString . ToDouble ( & videoArValue ) ;
}
else if ( arString . IsNumber ( ) ) arString . ToLong ( & videoAr ) ;
2006-01-16 22:02:54 +01:00
// Get new state info
2010-07-09 09:31:48 +02:00
ass - > GetScriptInfo ( _T ( " Video Position " ) ) . ToLong ( & videoPos ) ;
ass - > GetScriptInfo ( _T ( " Video Zoom Percent " ) ) . ToDouble ( & videoZoom ) ;
2010-12-08 04:36:10 +01:00
wxString curSubsVideo = DecodeRelativePath ( ass - > GetScriptInfo ( _T ( " Video File " ) ) , ass - > filename ) ;
wxString curSubsVFR = DecodeRelativePath ( ass - > GetScriptInfo ( _T ( " VFR File " ) ) , ass - > filename ) ;
wxString curSubsKeyframes = DecodeRelativePath ( ass - > GetScriptInfo ( _T ( " Keyframes File " ) ) , ass - > filename ) ;
wxString curSubsAudio = DecodeRelativePath ( ass - > GetScriptInfo ( _T ( " Audio URI " ) ) , ass - > filename ) ;
2010-07-09 09:31:48 +02:00
wxString AutoScriptString = ass - > GetScriptInfo ( _T ( " Automation Scripts " ) ) ;
2006-01-16 22:02:54 +01:00
// Check if there is anything to change
2010-05-21 03:13:36 +02:00
int autoLoadMode = OPT_GET ( " App/Auto/Load Linked Files " ) - > GetInt ( ) ;
2006-01-16 22:02:54 +01:00
bool hasToLoad = false ;
2010-12-08 04:36:10 +01:00
if ( curSubsAudio ! = audioController - > GetAudioURL ( ) | |
curSubsVFR ! = VideoContext : : Get ( ) - > GetTimecodesName ( ) | |
curSubsVideo ! = VideoContext : : Get ( ) - > videoName | |
curSubsKeyframes ! = VideoContext : : Get ( ) - > GetKeyFramesName ( )
2007-12-31 07:46:22 +01:00
# ifdef WITH_AUTOMATION
| | ! AutoScriptString . IsEmpty ( ) | | local_scripts - > GetScripts ( ) . size ( ) > 0
# endif
) {
2006-01-16 22:02:54 +01:00
hasToLoad = true ;
}
// Decide whether to load or not
bool doLoad = false ;
if ( hasToLoad ) {
if ( autoLoadMode = = 1 ) doLoad = true ;
else if ( autoLoadMode = = 2 ) {
int result = wxMessageBox ( _ ( " Do you want to load/unload the associated files? " ) , _ ( " (Un)Load files? " ) , wxYES_NO ) ;
if ( result = = wxYES ) doLoad = true ;
}
}
if ( doLoad ) {
// Video
2010-12-08 04:36:10 +01:00
if ( curSubsVideo ! = VideoContext : : Get ( ) - > videoName ) {
LoadVideo ( curSubsVideo ) ;
2007-04-17 03:19:04 +02:00
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
VideoContext : : Get ( ) - > SetAspectRatio ( videoAr , videoArValue ) ;
2010-05-01 03:07:05 +02:00
videoBox - > videoDisplay - > SetZoom ( videoZoom ) ;
2007-04-17 03:19:04 +02:00
VideoContext : : Get ( ) - > JumpToFrame ( videoPos ) ;
2006-01-16 22:02:54 +01:00
}
}
2010-12-08 04:36:10 +01:00
VideoContext : : Get ( ) - > LoadTimecodes ( curSubsVFR ) ;
VideoContext : : Get ( ) - > LoadKeyframes ( curSubsKeyframes ) ;
2006-12-18 19:47:45 +01:00
2006-01-16 22:02:54 +01:00
// Audio
2010-12-08 04:36:10 +01:00
if ( curSubsAudio ! = audioController - > GetAudioURL ( ) ) {
audioController - > OpenAudio ( curSubsAudio ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-28 23:31:33 +01:00
// Automation scripts
2007-12-31 07:46:22 +01:00
# ifdef WITH_AUTOMATION
2006-12-28 23:31:33 +01:00
local_scripts - > RemoveAll ( ) ;
wxStringTokenizer tok ( AutoScriptString , _T ( " | " ) , wxTOKEN_STRTOK ) ;
2010-07-09 09:31:48 +02:00
wxFileName assfn ( ass - > filename ) ;
2010-05-21 03:13:36 +02:00
wxString autobasefn ( lagi_wxString ( OPT_GET ( " Path/Automation/Base " ) - > GetString ( ) ) ) ;
2006-12-28 23:31:33 +01:00
while ( tok . HasMoreTokens ( ) ) {
wxString sfnames = tok . GetNextToken ( ) . Trim ( true ) . Trim ( false ) ;
wxString sfnamel = sfnames . Left ( 1 ) ;
sfnames . Remove ( 0 , 1 ) ;
wxString basepath ;
if ( sfnamel = = _T ( " ~ " ) ) {
2010-07-09 09:31:48 +02:00
basepath = assfn . GetPath ( ) ;
2006-12-28 23:31:33 +01:00
} else if ( sfnamel = = _T ( " $ " ) ) {
basepath = autobasefn ;
} else if ( sfnamel = = _T ( " / " ) ) {
basepath = _T ( " " ) ;
} else {
wxLogWarning ( _T ( " Automation Script referenced with unknown location specifier character. \n Location specifier found: %s \n Filename specified: %s " ) ,
sfnamel . c_str ( ) , sfnames . c_str ( ) ) ;
continue ;
}
wxFileName sfname ( sfnames ) ;
sfname . MakeAbsolute ( basepath ) ;
if ( sfname . FileExists ( ) ) {
sfnames = sfname . GetFullPath ( ) ;
2007-06-10 03:49:11 +02:00
local_scripts - > Add ( Automation4 : : ScriptFactory : : CreateFromFile ( sfnames , true ) ) ;
2006-12-28 23:31:33 +01:00
} else {
wxLogWarning ( _T ( " Automation Script referenced could not be found. \n Filename specified: %s%s \n Searched relative to: %s \n Resolved filename: %s " ) ,
sfnamel . c_str ( ) , sfnames . c_str ( ) , basepath . c_str ( ) , sfname . GetFullPath ( ) . c_str ( ) ) ;
}
}
2007-12-31 07:46:22 +01:00
# endif
2006-01-16 22:02:54 +01:00
}
// Display
2009-10-12 00:10:08 +02:00
SetDisplayMode ( 1 , 1 ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-09 09:31:48 +02:00
// Store data on ass
2006-01-16 22:02:54 +01:00
else {
// Setup
wxString seekpos = _T ( " 0 " ) ;
wxString ar = _T ( " 0 " ) ;
wxString zoom = _T ( " 6 " ) ;
2007-01-21 07:30:19 +01:00
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
2010-12-07 20:09:21 +01:00
seekpos = wxString : : Format ( _T ( " %i " ) , VideoContext : : Get ( ) - > GetFrameN ( ) ) ;
2010-05-01 03:07:05 +02:00
zoom = wxString : : Format ( _T ( " %f " ) , videoBox - > videoDisplay - > GetZoom ( ) ) ;
2006-05-16 01:44:53 +02:00
2007-01-23 07:32:16 +01:00
int arType = VideoContext : : Get ( ) - > GetAspectRatioType ( ) ;
2009-04-06 22:01:42 +02:00
if ( arType = = 4 ) ar = wxString ( _T ( " c " ) ) + AegiFloatToString ( VideoContext : : Get ( ) - > GetAspectRatioValue ( ) ) ;
2006-05-16 01:44:53 +02:00
else ar = wxString : : Format ( _T ( " %i " ) , arType ) ;
2006-01-16 22:02:54 +01:00
}
// Store audio data
2010-12-08 04:36:10 +01:00
ass - > SetScriptInfo ( _T ( " Audio URI " ) , MakeRelativePath ( audioController - > GetAudioURL ( ) , ass - > filename ) ) ;
2006-01-16 22:02:54 +01:00
// Store video data
2010-07-09 09:31:48 +02:00
ass - > SetScriptInfo ( _T ( " Video File " ) , MakeRelativePath ( VideoContext : : Get ( ) - > videoName , ass - > filename ) ) ;
ass - > SetScriptInfo ( _T ( " Video Aspect Ratio " ) , ar ) ;
ass - > SetScriptInfo ( _T ( " Video Zoom Percent " ) , zoom ) ;
ass - > SetScriptInfo ( _T ( " Video Position " ) , seekpos ) ;
ass - > SetScriptInfo ( _T ( " VFR File " ) , MakeRelativePath ( VideoContext : : Get ( ) - > GetTimecodesName ( ) , ass - > filename ) ) ;
ass - > SetScriptInfo ( _T ( " Keyframes File " ) , MakeRelativePath ( VideoContext : : Get ( ) - > GetKeyFramesName ( ) , ass - > filename ) ) ;
2006-01-16 22:02:54 +01:00
2006-12-28 23:31:33 +01:00
// Store Automation script data
// Algorithm:
// 1. If script filename has Automation Base Path as a prefix, the path is relative to that (ie. "$")
2010-07-09 09:31:48 +02:00
// 2. Otherwise try making it relative to the ass filename
// 3. If step 2 failed, or absolut path is shorter than path relative to ass, use absolute path ("/")
// 4. Otherwise, use path relative to ass ("~")
2007-12-31 07:46:22 +01:00
# ifdef WITH_AUTOMATION
2006-12-28 23:31:33 +01:00
wxString scripts_string ;
2010-05-21 03:13:36 +02:00
wxString autobasefn ( lagi_wxString ( OPT_GET ( " Path/Automation/Base " ) - > GetString ( ) ) ) ;
2006-12-28 23:31:33 +01:00
const std : : vector < Automation4 : : Script * > & scripts = local_scripts - > GetScripts ( ) ;
2006-12-28 23:41:20 +01:00
for ( unsigned int i = 0 ; i < scripts . size ( ) ; i + + ) {
2006-12-28 23:31:33 +01:00
Automation4 : : Script * script = scripts [ i ] ;
if ( i ! = 0 )
scripts_string + = _T ( " | " ) ;
2010-07-09 09:31:48 +02:00
wxString autobase_rel , assfile_rel ;
2006-12-28 23:31:33 +01:00
wxString scriptfn ( script - > GetFilename ( ) ) ;
autobase_rel = MakeRelativePath ( scriptfn , autobasefn ) ;
2010-07-09 09:31:48 +02:00
assfile_rel = MakeRelativePath ( scriptfn , ass - > filename ) ;
2006-12-28 23:31:33 +01:00
2010-07-09 09:31:48 +02:00
if ( autobase_rel . size ( ) < = scriptfn . size ( ) & & autobase_rel . size ( ) < = assfile_rel . size ( ) ) {
2006-12-28 23:31:33 +01:00
scriptfn = _T ( " $ " ) + autobase_rel ;
2010-07-09 09:31:48 +02:00
} else if ( assfile_rel . size ( ) < = scriptfn . size ( ) & & assfile_rel . size ( ) < = autobase_rel . size ( ) ) {
scriptfn = _T ( " ~ " ) + assfile_rel ;
2006-12-28 23:31:33 +01:00
} else {
scriptfn = _T ( " / " ) + wxFileName ( scriptfn ) . GetFullPath ( wxPATH_UNIX ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-28 23:31:33 +01:00
scripts_string + = scriptfn ;
2006-01-16 22:02:54 +01:00
}
2010-07-09 09:31:48 +02:00
ass - > SetScriptInfo ( _T ( " Automation Scripts " ) , scripts_string ) ;
2007-12-31 07:46:22 +01:00
# endif
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Loads video
/// @param file
/// @param autoload
2006-01-16 22:02:54 +01:00
void FrameMain : : LoadVideo ( wxString file , bool autoload ) {
if ( blockVideoLoad ) return ;
2008-01-12 04:09:48 +01:00
Freeze ( ) ;
2006-01-16 22:02:54 +01:00
try {
2007-01-21 07:30:19 +01:00
VideoContext : : Get ( ) - > SetVideo ( file ) ;
2006-01-16 22:02:54 +01:00
}
2006-04-14 18:46:38 +02:00
catch ( const wchar_t * error ) {
2010-07-08 06:29:04 +02:00
wxMessageBox ( error , _T ( " Error opening video file " ) , wxOK | wxICON_ERROR , this ) ;
2006-01-16 22:02:54 +01:00
}
catch ( . . . ) {
wxMessageBox ( _T ( " Unknown error " ) , _T ( " Error opening video file " ) , wxOK | wxICON_ERROR , this ) ;
}
2007-01-21 07:30:19 +01:00
if ( VideoContext : : Get ( ) - > IsLoaded ( ) ) {
2009-12-12 02:38:09 +01:00
int vidx = VideoContext : : Get ( ) - > GetWidth ( ) , vidy = VideoContext : : Get ( ) - > GetHeight ( ) ;
// Set zoom level based on video resolution and window size
2010-08-13 07:51:26 +02:00
double zoom = videoBox - > videoDisplay - > GetZoom ( ) ;
2009-12-12 02:38:09 +01:00
wxSize windowSize = GetSize ( ) ;
2010-08-13 07:51:26 +02:00
if ( vidx * 3 * zoom > windowSize . GetX ( ) * 4 | | vidy * 4 * zoom > windowSize . GetY ( ) * 6 )
videoBox - > videoDisplay - > SetZoom ( zoom * .25 ) ;
else if ( vidx * 3 * zoom > windowSize . GetX ( ) * 2 | | vidy * 4 * zoom > windowSize . GetY ( ) * 3 )
videoBox - > videoDisplay - > SetZoom ( zoom * .5 ) ;
2009-12-12 02:38:09 +01:00
// Check that the video size matches the script video size specified
2010-06-16 08:20:33 +02:00
int scriptx = SubsGrid - > ass - > GetScriptInfoAsInt ( _T ( " PlayResX " ) ) ;
int scripty = SubsGrid - > ass - > GetScriptInfoAsInt ( _T ( " PlayResY " ) ) ;
2006-01-16 22:02:54 +01:00
if ( scriptx ! = vidx | | scripty ! = vidy ) {
2010-05-21 03:13:36 +02:00
switch ( OPT_GET ( " Video/Check Script Res " ) - > GetInt ( ) ) {
2006-01-16 22:02:54 +01:00
case 1 :
// Ask to change on mismatch
if ( wxMessageBox ( wxString : : Format ( _ ( " The resolution of the loaded video and the resolution specified for the subtitles don't match. \n \n Video resolution: \t %d x %d \n Script resolution: \t %d x %d \n \n Change subtitles resolution to match video? " ) , vidx , vidy , scriptx , scripty ) , _ ( " Resolution mismatch " ) , wxYES_NO , this ) ! = wxYES )
break ;
// Fallthrough to case 2
case 2 :
// Always change script res
2010-06-16 08:20:33 +02:00
SubsGrid - > ass - > SetScriptInfo ( _T ( " PlayResX " ) , wxString : : Format ( _T ( " %d " ) , vidx ) ) ;
SubsGrid - > ass - > SetScriptInfo ( _T ( " PlayResY " ) , wxString : : Format ( _T ( " %d " ) , vidy ) ) ;
2010-07-09 09:31:34 +02:00
SubsGrid - > ass - > Commit ( _ ( " Change script resolution " ) ) ;
2006-01-16 22:02:54 +01:00
break ;
case 0 :
default :
// Never change
break ;
}
}
}
2009-10-12 00:10:08 +02:00
SetDisplayMode ( 1 , - 1 ) ;
2008-01-12 04:09:48 +01:00
2010-05-21 03:13:36 +02:00
DetachVideo ( VideoContext : : Get ( ) - > IsLoaded ( ) & & OPT_GET ( " Video/Detached/Enabled " ) - > GetBool ( ) ) ;
2008-01-12 04:09:48 +01:00
Thaw ( ) ;
2006-01-16 22:02:54 +01:00
}
void FrameMain : : LoadVFR ( wxString filename ) {
2010-07-08 06:29:04 +02:00
if ( filename . empty ( ) ) {
VideoContext : : Get ( ) - > CloseTimecodes ( ) ;
2006-01-16 22:02:54 +01:00
}
else {
2010-07-08 06:29:04 +02:00
VideoContext : : Get ( ) - > LoadTimecodes ( filename ) ;
2006-01-16 22:02:54 +01:00
}
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Open help
2010-06-16 08:20:27 +02:00
void FrameMain : : OpenHelp ( wxString ) {
2008-01-13 22:05:31 +01:00
HelpButton : : OpenPage ( _T ( " Main " ) ) ;
2006-01-16 22:02:54 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Detach video window
/// @param detach
2008-01-12 04:09:48 +01:00
void FrameMain : : DetachVideo ( bool detach ) {
if ( detach ) {
if ( ! detachedVideo ) {
2009-06-06 04:57:42 +02:00
detachedVideo = new DialogDetachedVideo ( this , videoBox - > videoDisplay - > GetClientSize ( ) ) ;
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
temp_context . detachedVideo = detachedVideo ;
2008-01-12 04:09:48 +01:00
detachedVideo - > Show ( ) ;
}
}
2009-10-12 00:10:08 +02:00
else if ( detachedVideo ) {
detachedVideo - > Destroy ( ) ;
detachedVideo = NULL ;
SetDisplayMode ( 1 , - 1 ) ;
2008-01-12 04:09:48 +01:00
}
2009-10-10 17:21:26 +02:00
UpdateToolbar ( ) ;
2008-01-12 04:09:48 +01:00
}
2010-06-16 08:20:27 +02:00
/// @brief Sets status and clear after n milliseconds
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @param text
/// @param ms
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 ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Load list of files
/// @param list
/// @return
2006-01-16 22:02:54 +01:00
bool FrameMain : : LoadList ( wxArrayString list ) {
// Build list
wxArrayString List ;
for ( size_t i = 0 ; i < list . Count ( ) ; i + + ) {
wxFileName file ( list [ i ] ) ;
if ( file . IsRelative ( ) ) file . MakeAbsolute ( ) ;
if ( file . FileExists ( ) ) List . Add ( file . GetFullPath ( ) ) ;
}
// Video formats
wxArrayString videoList ;
videoList . Add ( _T ( " avi " ) ) ;
videoList . Add ( _T ( " mkv " ) ) ;
videoList . Add ( _T ( " mp4 " ) ) ;
videoList . Add ( _T ( " d2v " ) ) ;
videoList . Add ( _T ( " mpg " ) ) ;
videoList . Add ( _T ( " mpeg " ) ) ;
videoList . Add ( _T ( " ogm " ) ) ;
videoList . Add ( _T ( " avs " ) ) ;
videoList . Add ( _T ( " wmv " ) ) ;
videoList . Add ( _T ( " asf " ) ) ;
videoList . Add ( _T ( " mov " ) ) ;
videoList . Add ( _T ( " rm " ) ) ;
2009-07-19 06:13:46 +02:00
videoList . Add ( _T ( " y4m " ) ) ;
videoList . Add ( _T ( " yuv " ) ) ;
2006-01-16 22:02:54 +01:00
// Subtitle formats
wxArrayString subsList ;
subsList . Add ( _T ( " ass " ) ) ;
subsList . Add ( _T ( " ssa " ) ) ;
subsList . Add ( _T ( " srt " ) ) ;
2007-06-19 06:04:46 +02:00
subsList . Add ( _T ( " sub " ) ) ;
2006-01-16 22:02:54 +01:00
subsList . Add ( _T ( " txt " ) ) ;
2007-06-19 06:04:46 +02:00
subsList . Add ( _T ( " ttxt " ) ) ;
2006-01-16 22:02:54 +01:00
// Audio formats
wxArrayString audioList ;
audioList . Add ( _T ( " wav " ) ) ;
audioList . Add ( _T ( " mp3 " ) ) ;
audioList . Add ( _T ( " ogg " ) ) ;
audioList . Add ( _T ( " wma " ) ) ;
audioList . Add ( _T ( " ac3 " ) ) ;
audioList . Add ( _T ( " aac " ) ) ;
audioList . Add ( _T ( " mpc " ) ) ;
audioList . Add ( _T ( " ape " ) ) ;
audioList . Add ( _T ( " flac " ) ) ;
audioList . Add ( _T ( " mka " ) ) ;
2007-06-19 06:04:46 +02:00
audioList . Add ( _T ( " m4a " ) ) ;
2006-01-16 22:02:54 +01:00
// Scan list
wxString audio = _T ( " " ) ;
wxString video = _T ( " " ) ;
wxString subs = _T ( " " ) ;
wxString ext ;
for ( size_t i = 0 ; i < List . Count ( ) ; i + + ) {
wxFileName file ( List [ i ] ) ;
ext = file . GetExt ( ) . Lower ( ) ;
2006-02-20 22:32:58 +01:00
if ( subs . IsEmpty ( ) & & subsList . Index ( ext ) ! = wxNOT_FOUND ) subs = List [ i ] ;
if ( video . IsEmpty ( ) & & videoList . Index ( ext ) ! = wxNOT_FOUND ) video = List [ i ] ;
if ( audio . IsEmpty ( ) & & audioList . Index ( ext ) ! = wxNOT_FOUND ) audio = List [ i ] ;
2006-01-16 22:02:54 +01:00
}
// Set blocking
blockVideoLoad = ( video ! = _T ( " " ) ) ;
// Load files
2006-02-01 03:16:57 +01:00
if ( subs ! = _T ( " " ) ) {
LoadSubtitles ( subs ) ;
}
2006-01-16 22:02:54 +01:00
if ( blockVideoLoad ) {
blockVideoLoad = false ;
LoadVideo ( video ) ;
}
2010-12-08 04:36:10 +01:00
if ( ! audio . IsEmpty ( ) )
audioController - > OpenAudio ( audio ) ;
2006-01-16 22:02:54 +01:00
// Result
return ( ( subs ! = _T ( " " ) ) | | ( audio ! = _T ( " " ) ) | | ( video ! = _T ( " " ) ) ) ;
}
2007-01-26 01:47:42 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Sets the descriptions for undo/redo
2007-01-26 01:47:42 +01:00
void FrameMain : : SetUndoRedoDesc ( ) {
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
wxMenu * editMenu = menu : : menu - > GetMenu ( " main/edit " ) ;
2010-07-09 09:31:48 +02:00
editMenu - > SetHelpString ( 0 , _T ( " Undo " ) + ass - > GetUndoDescription ( ) ) ;
editMenu - > SetHelpString ( 1 , _T ( " Redo " ) + ass - > GetRedoDescription ( ) ) ;
2007-04-03 06:34:56 +02:00
}
2008-01-20 18:34:35 +01:00
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
/// @brief Check if ASSDraw is available
2008-01-20 18:34:35 +01:00
bool FrameMain : : HasASSDraw ( ) {
# ifdef __WINDOWS__
wxFileName fn ( StandardPaths : : DecodePath ( _T ( " ?data/ASSDraw3.exe " ) ) ) ;
return fn . FileExists ( ) ;
# else
return false ;
# endif
}
2010-08-26 20:38:44 +02:00
2010-12-07 20:09:15 +01:00
static void autosave_timer_changed ( wxTimer * timer , const agi : : OptionValue & opt ) {
2010-08-26 20:38:44 +02:00
int freq = opt . GetInt ( ) ;
if ( freq < = 0 ) {
2010-12-07 20:09:15 +01:00
timer - > Stop ( ) ;
2010-08-26 20:38:44 +02:00
}
else {
2010-12-07 20:09:15 +01:00
timer - > Start ( freq * 1000 ) ;
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 )
EVT_SASH_DRAGGED ( ID_SASH_MAIN_AUDIO , FrameMain : : OnAudioBoxResize )
EVT_MENU_OPEN ( FrameMain : : OnMenuOpen )
EVT_KEY_DOWN ( FrameMain : : OnKeyDown )
// EVT_MENU(cmd::id("subtitle/new"), FrameMain::cmd_call)
// EVT_MENU(cmd::id("subtitle/open"), FrameMain::cmd_call)
// EVT_MENU(cmd::id("subtitle/save"), FrameMain::cmd_call)
// EVT_MENU_RANGE(MENU_GRID_START+1,MENU_GRID_END-1,FrameMain::OnGridEvent)
// EVT_COMBOBOX(Toolbar_Zoom_Dropdown, FrameMain::OnSetZoom)
// EVT_TEXT_ENTER(Toolbar_Zoom_Dropdown, FrameMain::OnSetZoom)
# ifdef __WXMAC__
EVT_MENU ( wxID_ABOUT , FrameMain : : OnAbout )
EVT_MENU ( wxID_EXIT , FrameMain : : OnExit )
# endif
END_EVENT_TABLE ( )
/// @brief Redirect grid events to grid
/// @param event
void FrameMain : : OnGridEvent ( wxCommandEvent & event ) {
SubsGrid - > GetEventHandler ( ) - > ProcessEvent ( event ) ;
}
/// @brief Rebuild recent list
/// @param listName
/// @param menu
/// @param startID
void FrameMain : : RebuildRecentList ( wxString listName , wxMenu * menu , int startID ) {
// Wipe previous list
int count = ( int ) menu - > GetMenuItemCount ( ) ;
for ( int i = count ; - - i > = 0 ; ) {
menu - > Destroy ( menu - > FindItemByPosition ( i ) ) ;
}
// Rebuild
int added = 0 ;
wxString n ;
wxArrayString entries = lagi_MRU_wxAS ( listName ) ;
for ( size_t i = 0 ; i < entries . Count ( ) ; i + + ) {
n = wxString : : Format ( _T ( " %ld " ) , i + 1 ) ;
if ( i < 9 ) n = _T ( " & " ) + n ;
wxFileName shortname ( entries [ i ] ) ;
wxString filename = shortname . GetFullName ( ) ;
menu - > Append ( startID + i , n + _T ( " " ) + filename ) ;
added + + ;
}
// Nothing added, add an empty placeholder
if ( added = = 0 ) menu - > Append ( startID , _ ( " Empty " ) ) - > Enable ( false ) ;
}
/// @brief Menu is being opened
/// @param event
void FrameMain : : OnMenuOpen ( wxMenuEvent & event ) {
// Get menu
wxMenuBar * MenuBar = menu : : menu - > GetMainMenu ( ) ;
MenuBar - > Freeze ( ) ;
wxMenu * curMenu = event . GetMenu ( ) ;
// File menu
if ( curMenu = = menu : : menu - > GetMenu ( " main/file " ) ) {
// Rebuild recent
RebuildRecentList ( _T ( " Subtitle " ) , menu : : menu - > GetMenu ( " recent/subtitle " ) , cmd : : id ( " recent/subtitle " ) ) ;
MenuBar - > Enable ( cmd : : id ( " subtitle/open/video " ) , VideoContext : : Get ( ) - > HasSubtitles ( ) ) ;
}
// View menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/view " ) ) {
// Flags
bool aud = audioController - > IsAudioOpen ( ) ;
bool vid = VideoContext : : Get ( ) - > IsLoaded ( ) & & ! detachedVideo ;
// Set states
MenuBar - > Enable ( cmd : : id ( " app/display/audio_subs " ) , aud ) ;
MenuBar - > Enable ( cmd : : id ( " app/display/video_subs " ) , vid ) ;
MenuBar - > Enable ( cmd : : id ( " app/display/full " ) , aud & & vid ) ;
// Select option
if ( ! showVideo & & ! showAudio ) MenuBar - > Check ( cmd : : id ( " app/display/subs " ) , true ) ;
else if ( showVideo & & ! showAudio ) MenuBar - > Check ( cmd : : id ( " app/display/video_subs " ) , true ) ;
else if ( showAudio & & showVideo ) MenuBar - > Check ( cmd : : id ( " app/display/full " ) , true ) ;
else MenuBar - > Check ( cmd : : id ( " app/display/audio_subs " ) , true ) ;
int sub_grid = OPT_GET ( " Subtitle/Grid/Hide Overrides " ) - > GetInt ( ) ;
if ( sub_grid = = 1 ) MenuBar - > Check ( cmd : : id ( " grid/tags/show " ) , true ) ;
if ( sub_grid = = 2 ) MenuBar - > Check ( cmd : : id ( " grid/tags/simplify " ) , true ) ;
if ( sub_grid = = 3 ) MenuBar - > Check ( cmd : : id ( " grid/tags/hide " ) , true ) ;
}
// Video menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/video " ) ) {
bool state = VideoContext : : Get ( ) - > IsLoaded ( ) ;
bool attached = state & & ! detachedVideo ;
// Set states
MenuBar - > Enable ( cmd : : id ( " video/jump " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " video/jump/start " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " video/jump/end " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " main/video/set zoom " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/zoom/50 " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/zoom/100 " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/zoom/200 " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/close " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " main/video/override ar " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/aspect/default " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/aspect/full " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/aspect/wide " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/aspect/cinematic " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/aspect/custom " ) , attached ) ;
MenuBar - > Enable ( cmd : : id ( " video/detach " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " timecode/save " ) , VideoContext : : Get ( ) - > TimecodesLoaded ( ) ) ;
MenuBar - > Enable ( cmd : : id ( " timecode/close " ) , VideoContext : : Get ( ) - > OverTimecodesLoaded ( ) ) ;
MenuBar - > Enable ( cmd : : id ( " keyframe/close " ) , VideoContext : : Get ( ) - > OverKeyFramesLoaded ( ) ) ;
MenuBar - > Enable ( cmd : : id ( " keyframe/save " ) , VideoContext : : Get ( ) - > KeyFramesLoaded ( ) ) ;
MenuBar - > Enable ( cmd : : id ( " video/detach " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " video/show_overscan " ) , state ) ;
// Set AR radio
int arType = VideoContext : : Get ( ) - > GetAspectRatioType ( ) ;
MenuBar - > Check ( cmd : : id ( " video/aspect/default " ) , false ) ;
MenuBar - > Check ( cmd : : id ( " video/aspect/full " ) , false ) ;
MenuBar - > Check ( cmd : : id ( " video/aspect/wide " ) , false ) ;
MenuBar - > Check ( cmd : : id ( " video/aspect/cinematic " ) , false ) ;
MenuBar - > Check ( cmd : : id ( " video/aspect/custom " ) , false ) ;
switch ( arType ) {
case 0 : MenuBar - > Check ( cmd : : id ( " video/aspect/default " ) , true ) ; break ;
case 1 : MenuBar - > Check ( cmd : : id ( " video/aspect/full " ) , true ) ; break ;
case 2 : MenuBar - > Check ( cmd : : id ( " video/aspect/wide " ) , true ) ; break ;
case 3 : MenuBar - > Check ( cmd : : id ( " video/aspect/cinematic " ) , true ) ; break ;
case 4 : MenuBar - > Check ( cmd : : id ( " video/aspect/custom " ) , true ) ; break ;
}
// Set overscan mask
MenuBar - > Check ( cmd : : id ( " video/show_overscan " ) , OPT_GET ( " Video/Overscan Mask " ) - > GetBool ( ) ) ;
// Rebuild recent lists
RebuildRecentList ( _T ( " Video " ) , menu : : menu - > GetMenu ( " recent/video " ) , cmd : : id ( " recent/video " ) ) ;
RebuildRecentList ( _T ( " Timecodes " ) , menu : : menu - > GetMenu ( " recent/timecode " ) , cmd : : id ( " recent/timecode " ) ) ;
RebuildRecentList ( _T ( " Keyframes " ) , menu : : menu - > GetMenu ( " recent/keyframe " ) , cmd : : id ( " recent/keyframe " ) ) ;
}
// Audio menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/audio " ) ) {
bool state = audioController - > IsAudioOpen ( ) ;
bool vidstate = VideoContext : : Get ( ) - > IsLoaded ( ) ;
MenuBar - > Enable ( cmd : : id ( " audio/open/video " ) , vidstate ) ;
MenuBar - > Enable ( cmd : : id ( " audio/close " ) , state ) ;
// Rebuild recent
RebuildRecentList ( _T ( " Audio " ) , menu : : menu - > GetMenu ( " recent/audio " ) , cmd : : id ( " recent/audio " ) ) ;
}
// Subtitles menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/subtitle " ) ) {
// Variables
bool continuous ;
wxArrayInt sels = SubsGrid - > GetSelection ( & continuous ) ;
int count = sels . Count ( ) ;
bool state , state2 ;
// Entries
state = count > 0 ;
MenuBar - > Enable ( cmd : : id ( " subtitle/insert/before " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " subtitle/insert/after " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/split/by_karaoke " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/delete " ) , state ) ;
state2 = count > 0 & & VideoContext : : Get ( ) - > IsLoaded ( ) ;
MenuBar - > Enable ( cmd : : id ( " subtitle/insert/before/videotime " ) , state2 ) ;
MenuBar - > Enable ( cmd : : id ( " subtitle/insert/after/videotime " ) , state2 ) ;
MenuBar - > Enable ( cmd : : id ( " main/subtitle/insert lines " ) , state ) ;
state = count > 0 & & continuous ;
MenuBar - > Enable ( cmd : : id ( " edit/line/duplicate " ) , state ) ;
state = count > 0 & & continuous & & VideoContext : : Get ( ) - > TimecodesLoaded ( ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/duplicate/shift " ) , state ) ;
state = count = = 2 ;
MenuBar - > Enable ( cmd : : id ( " edit/line/swap " ) , state ) ;
state = count > = 2 & & continuous ;
MenuBar - > Enable ( cmd : : id ( " edit/line/join/concatenate " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/join/keep_first " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/join/as_karaoke " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " main/subtitle/join lines " ) , state ) ;
state = ( count = = 2 | | count = = 3 ) & & continuous ;
MenuBar - > Enable ( cmd : : id ( " edit/line/recombine " ) , state ) ;
}
// Timing menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/timing " ) ) {
// Variables
bool continuous ;
wxArrayInt sels = SubsGrid - > GetSelection ( & continuous ) ;
int count = sels . Count ( ) ;
// Video related
bool state = VideoContext : : Get ( ) - > IsLoaded ( ) ;
MenuBar - > Enable ( cmd : : id ( " time/snap/start_video " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " time/snap/end_video " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " time/snap/scene " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " time/frame/current " ) , state ) ;
// Other
state = count > = 2 & & continuous ;
MenuBar - > Enable ( cmd : : id ( " time/continous/start " ) , state ) ;
MenuBar - > Enable ( cmd : : id ( " time/continous/end " ) , state ) ;
}
// Edit menu
else if ( curMenu = = menu : : menu - > GetMenu ( " main/edit " ) ) {
wxMenu * editMenu = menu : : menu - > GetMenu ( " main/edit " ) ;
// Undo state
wxMenuItem * item ;
//H wxString undo_text = _("&Undo") + wxString(_T(" ")) + ass->GetUndoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo"));
// The bottom line needs to be fixed for the new hotkey system
wxString undo_text = _ ( " &Undo " ) + wxString ( _T ( " " ) ) + ass - > GetUndoDescription ( ) + wxString ( _T ( " \t " ) ) + _T ( " Undo " ) ;
item = editMenu - > FindItem ( cmd : : id ( " edit/undo " ) ) ;
item - > SetItemLabel ( undo_text ) ;
item - > Enable ( ! ass - > IsUndoStackEmpty ( ) ) ;
// Redo state
//H wxString redo_text = _("&Redo") + wxString(_T(" ")) + ass->GetRedoDescription() + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo"));
// Same as above.
wxString redo_text = _ ( " &Redo " ) + wxString ( _T ( " " ) ) + ass - > GetRedoDescription ( ) + wxString ( _T ( " \t " ) ) + _T ( " Redo " ) ;
item = editMenu - > FindItem ( cmd : : id ( " edit/redo " ) ) ;
item - > SetItemLabel ( redo_text ) ;
item - > Enable ( ! ass - > IsRedoStackEmpty ( ) ) ;
// Copy/cut/paste
wxArrayInt sels = SubsGrid - > GetSelection ( ) ;
bool can_copy = ( sels . Count ( ) > 0 ) ;
bool can_paste = true ;
if ( wxTheClipboard - > Open ( ) ) {
can_paste = wxTheClipboard - > IsSupported ( wxDF_TEXT ) ;
wxTheClipboard - > Close ( ) ;
}
MenuBar - > Enable ( cmd : : id ( " edit/line/cut " ) , can_copy ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/copy " ) , can_copy ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/paste " ) , can_paste ) ;
MenuBar - > Enable ( cmd : : id ( " edit/line/paste/over " ) , can_copy & & can_paste ) ;
}
// Automation menu
# ifdef WITH_AUTOMATION
else if ( curMenu = = menu : : menu - > GetMenu ( " main/automation " ) ) {
wxMenu * automationMenu = menu : : menu - > GetMenu ( " main/automation " ) ;
// Remove old macro items
for ( unsigned int i = 0 ; i < activeMacroItems . size ( ) ; i + + ) {
wxMenu * p = 0 ;
wxMenuItem * it = MenuBar - > FindItem ( ID_MENU_AUTOMATION_MACRO + i , & p ) ;
if ( it )
p - > Delete ( it ) ;
}
activeMacroItems . clear ( ) ;
// Add new ones
int added = 0 ;
added + = AddMacroMenuItems ( automationMenu , wxGetApp ( ) . global_scripts - > GetMacros ( ) ) ;
added + = AddMacroMenuItems ( automationMenu , local_scripts - > GetMacros ( ) ) ;
// If none were added, show a ghosted notice
if ( added = = 0 ) {
automationMenu - > Append ( ID_MENU_AUTOMATION_MACRO , _ ( " No Automation macros loaded " ) ) - > Enable ( false ) ;
activeMacroItems . push_back ( 0 ) ;
}
}
# endif
MenuBar - > Thaw ( ) ;
}
/// @brief Macro menu creation helper
/// @param menu
/// @param macros
/// @return
int FrameMain : : AddMacroMenuItems ( wxMenu * menu , const std : : vector < Automation4 : : FeatureMacro * > & macros ) {
# ifdef WITH_AUTOMATION
if ( macros . empty ( ) ) {
return 0 ;
}
int id = activeMacroItems . size ( ) ; ;
for ( std : : vector < Automation4 : : FeatureMacro * > : : const_iterator i = macros . begin ( ) ; i ! = macros . end ( ) ; + + i ) {
wxMenuItem * m = menu - > Append ( ID_MENU_AUTOMATION_MACRO + id , ( * i ) - > GetName ( ) , ( * i ) - > GetDescription ( ) ) ;
m - > Enable ( ( * i ) - > Validate ( SubsGrid - > ass , SubsGrid - > GetAbsoluteSelection ( ) , SubsGrid - > GetFirstSelRow ( ) ) ) ;
activeMacroItems . push_back ( * i ) ;
id + + ;
}
return macros . size ( ) ;
# else
return 0 ;
# endif
}
/// @brief General handler for all Automation-generated menu items
/// @param event
void FrameMain : : OnAutomationMacro ( wxCommandEvent & event ) {
# ifdef WITH_AUTOMATION
SubsGrid - > BeginBatch ( ) ;
// First get selection data
std : : vector < int > selected_lines = SubsGrid - > GetAbsoluteSelection ( ) ;
int first_sel = SubsGrid - > GetFirstSelRow ( ) ;
// Run the macro...
activeMacroItems [ event . GetId ( ) - ID_MENU_AUTOMATION_MACRO ] - > Process ( SubsGrid - > ass , selected_lines , first_sel , this ) ;
SubsGrid - > SetSelectionFromAbsolute ( selected_lines ) ;
SubsGrid - > EndBatch ( ) ;
# endif
}
/// @brief Window is attempted to be closed
/// @param event
void FrameMain : : OnCloseWindow ( wxCloseEvent & event ) {
// Stop audio and video
VideoContext : : Get ( ) - > Stop ( ) ;
audioController - > Stop ( ) ;
// Ask user if he wants to save first
bool canVeto = event . CanVeto ( ) ;
int result = TryToCloseSubs ( canVeto ) ;
// Store maximization state
OPT_SET ( " App/Maximized " ) - > SetBool ( IsMaximized ( ) ) ;
// Abort/destroy
if ( canVeto ) {
if ( result = = wxCANCEL ) event . Veto ( ) ;
else Destroy ( ) ;
}
else Destroy ( ) ;
}
/// @brief Autosave the currently open file, if any
void FrameMain : : OnAutoSave ( wxTimerEvent & ) {
try {
if ( ass - > loaded & & ass - > IsModified ( ) ) {
// Set path
wxFileName origfile ( ass - > filename ) ;
wxString path = lagi_wxString ( OPT_GET ( " Path/Auto/Save " ) - > GetString ( ) ) ;
if ( path . IsEmpty ( ) ) path = origfile . GetPath ( ) ;
wxFileName dstpath ( path ) ;
if ( ! dstpath . IsAbsolute ( ) ) path = StandardPaths : : DecodePathMaybeRelative ( path , _T ( " ?user/ " ) ) ;
dstpath . AssignDir ( path ) ;
if ( ! dstpath . DirExists ( ) ) wxMkdir ( path ) ;
wxString name = origfile . GetName ( ) ;
if ( name . IsEmpty ( ) ) {
dstpath . SetFullName ( " Untitled.AUTOSAVE.ass " ) ;
}
else {
dstpath . SetFullName ( name + L " .AUTOSAVE.ass " ) ;
}
ass - > Save ( dstpath . GetFullPath ( ) , false , false ) ;
// Set status bar
StatusTimeout ( _ ( " File backup saved as \" " ) + dstpath . GetFullPath ( ) + _T ( " \" . " ) ) ;
}
}
catch ( const agi : : Exception & err ) {
StatusTimeout ( lagi_wxString ( " Exception when attempting to autosave file: " + err . GetMessage ( ) ) ) ;
}
catch ( wxString err ) {
StatusTimeout ( _T ( " Exception when attempting to autosave file: " ) + err ) ;
}
catch ( const wchar_t * err ) {
StatusTimeout ( _T ( " Exception when attempting to autosave file: " ) + wxString ( err ) ) ;
}
catch ( . . . ) {
StatusTimeout ( _T ( " Unhandled exception when attempting to autosave file. " ) ) ;
}
}
/// @brief Clear statusbar
void FrameMain : : OnStatusClear ( wxTimerEvent & ) {
SetStatusText ( _T ( " " ) , 1 ) ;
}
void FrameMain : : OnAudioBoxResize ( wxSashEvent & event )
{
if ( event . GetDragStatus ( ) = = wxSASH_STATUS_OUT_OF_RANGE )
return ;
wxRect rect = event . GetDragRect ( ) ;
if ( rect . GetHeight ( ) < audioSash - > GetMinimumSizeY ( ) )
rect . SetHeight ( audioSash - > GetMinimumSizeY ( ) ) ;
audioBox - > SetMinSize ( wxSize ( - 1 , rect . GetHeight ( ) ) ) ;
Panel - > Layout ( ) ;
Refresh ( ) ;
}
void FrameMain : : OnAudioOpen ( AudioProvider * provider )
{
SetDisplayMode ( - 1 , 1 ) ;
}
void FrameMain : : OnAudioClose ( )
{
SetDisplayMode ( - 1 , 0 ) ;
}
void FrameMain : : OnSubtitlesFileChanged ( ) {
if ( OPT_GET ( " App/Auto/Save on Every Change " ) - > GetBool ( ) ) {
if ( ass - > IsModified ( ) & & ! ass - > filename . empty ( ) ) SaveSubtitles ( false ) ;
}
UpdateTitle ( ) ;
}
void FrameMain : : OnKeyDown ( wxKeyEvent & event ) {
hotkey : : check ( " Main Frame " , event . GetKeyCode ( ) , event . GetUnicodeKey ( ) , event . GetModifiers ( ) ) ;
}