2006-02-18 22:55:58 +01:00
// Copyright (c) 2006, Rodrigo Braz Monteiro
2006-01-16 22:02:54 +01:00
// 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 subs_grid.cpp
/// @brief Subtitles grid control in main window
/// @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-03-01 04:17:31 +01:00
# include <algorithm>
2010-06-26 09:26:27 +02:00
# include <utility>
2009-09-10 15:06:40 +02:00
2006-03-01 04:17:31 +01:00
# include <wx/clipbrd.h>
# include <wx/filename.h>
2009-09-10 15:06:40 +02:00
# include <wx/tokenzr.h>
# endif
2010-08-02 08:31:38 +02:00
# include "include/aegisub/audio_provider.h"
2006-01-16 22:02:54 +01:00
# include "ass_file.h"
2009-09-10 15:06:40 +02:00
# include "ass_karaoke.h"
# include "ass_override.h"
2006-01-16 22:02:54 +01:00
# include "ass_style.h"
2010-08-02 08:31:38 +02:00
# include "audio_box.h"
# include "audio_display.h"
2009-09-10 15:06:40 +02:00
# include "charset_conv.h"
# include "dialog_paste_over.h"
2006-01-16 22:02:54 +01:00
# include "frame_main.h"
# include "hotkeys.h"
2010-05-21 03:13:36 +02:00
# include "main.h"
2009-09-10 15:06:40 +02:00
# include "subs_edit_box.h"
# include "subs_grid.h"
2006-03-01 04:17:31 +01:00
# include "utils.h"
2009-09-10 15:06:40 +02:00
# include "video_context.h"
# include "video_display.h"
2006-01-16 22:02:54 +01:00
2006-02-18 22:55:58 +01:00
BEGIN_EVENT_TABLE ( SubtitlesGrid , BaseGrid )
2006-01-16 22:02:54 +01:00
EVT_KEY_DOWN ( SubtitlesGrid : : OnKeyDown )
EVT_MENU ( MENU_SWAP , SubtitlesGrid : : OnSwap )
EVT_MENU ( MENU_DUPLICATE , SubtitlesGrid : : OnDuplicate )
EVT_MENU ( MENU_DUPLICATE_NEXT_FRAME , SubtitlesGrid : : OnDuplicateNextFrame )
EVT_MENU ( MENU_JOIN_CONCAT , SubtitlesGrid : : OnJoinConcat )
EVT_MENU ( MENU_JOIN_REPLACE , SubtitlesGrid : : OnJoinReplace )
EVT_MENU ( MENU_ADJOIN , SubtitlesGrid : : OnAdjoin )
EVT_MENU ( MENU_ADJOIN2 , SubtitlesGrid : : OnAdjoin2 )
EVT_MENU ( MENU_INSERT_BEFORE , SubtitlesGrid : : OnInsertBefore )
EVT_MENU ( MENU_INSERT_AFTER , SubtitlesGrid : : OnInsertAfter )
EVT_MENU ( MENU_INSERT_BEFORE_VIDEO , SubtitlesGrid : : OnInsertBeforeVideo )
EVT_MENU ( MENU_INSERT_AFTER_VIDEO , SubtitlesGrid : : OnInsertAfterVideo )
EVT_MENU ( MENU_COPY , SubtitlesGrid : : OnCopyLines )
EVT_MENU ( MENU_PASTE , SubtitlesGrid : : OnPasteLines )
EVT_MENU ( MENU_CUT , SubtitlesGrid : : OnCutLines )
EVT_MENU ( MENU_DELETE , SubtitlesGrid : : OnDeleteLines )
EVT_MENU ( MENU_SET_START_TO_VIDEO , SubtitlesGrid : : OnSetStartToVideo )
EVT_MENU ( MENU_SET_END_TO_VIDEO , SubtitlesGrid : : OnSetEndToVideo )
EVT_MENU ( MENU_SET_VIDEO_TO_START , SubtitlesGrid : : OnSetVideoToStart )
EVT_MENU ( MENU_SET_VIDEO_TO_END , SubtitlesGrid : : OnSetVideoToEnd )
EVT_MENU ( MENU_JOIN_AS_KARAOKE , SubtitlesGrid : : OnJoinAsKaraoke )
2006-03-11 17:11:55 +01:00
EVT_MENU ( MENU_SPLIT_BY_KARAOKE , SubtitlesGrid : : OnSplitByKaraoke )
2006-12-30 23:38:05 +01:00
EVT_MENU ( MENU_RECOMBINE , SubtitlesGrid : : OnRecombine )
2007-01-17 06:06:17 +01:00
EVT_MENU ( MENU_AUDIOCLIP , SubtitlesGrid : : OnAudioClip )
2006-06-27 07:13:41 +02:00
EVT_MENU_RANGE ( MENU_SHOW_COL , MENU_SHOW_COL + 15 , SubtitlesGrid : : OnShowColMenu )
2006-01-16 22:02:54 +01:00
END_EVENT_TABLE ( )
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 Constructor
/// @param parentFr
/// @param parent
/// @param id
/// @param pos
/// @param size
/// @param style
/// @param name
2010-07-09 09:31:48 +02:00
SubtitlesGrid : : SubtitlesGrid ( FrameMain * parentFr , wxWindow * parent , wxWindowID id , AssFile * subs , const wxPoint & pos , const wxSize & size , long style , const wxString & name )
: BaseGrid ( parent , id , pos , size , style , name )
, ass ( subs )
2006-01-16 22:02:54 +01:00
{
byFrame = false ;
editBox = NULL ;
parentFrame = parentFr ;
}
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 Destructor
2006-01-16 22:02:54 +01:00
SubtitlesGrid : : ~ SubtitlesGrid ( ) {
2010-06-26 09:26:27 +02:00
ClearMaps ( ) ;
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 Popup menu
/// @param alternate
2006-06-27 07:13:41 +02:00
void SubtitlesGrid : : OnPopupMenu ( bool alternate ) {
// Alternate
if ( alternate ) {
2010-06-22 02:03:22 +02:00
const wxString strings [ ] = {
_ ( " Line Number " ) ,
_ ( " Layer " ) ,
_ ( " Start " ) ,
_ ( " End " ) ,
_ ( " Style " ) ,
_ ( " Actor " ) ,
_ ( " Effect " ) ,
_ ( " Left " ) ,
_ ( " Right " ) ,
_ ( " Vert " ) ,
} ;
2006-06-27 07:13:41 +02:00
// Create Menu
wxMenu menu ;
2010-06-22 02:03:22 +02:00
for ( size_t i = 0 ; i < columns ; i + + ) {
2006-06-27 07:13:41 +02:00
menu . Append ( MENU_SHOW_COL + i , strings [ i ] , _T ( " " ) , wxITEM_CHECK ) - > Check ( showCol [ i ] ) ;
}
PopupMenu ( & menu ) ;
return ;
}
2006-01-16 22:02:54 +01:00
// Get selections
bool continuous ;
wxArrayInt selections = GetSelection ( & continuous ) ;
int sels = selections . Count ( ) ;
// Show menu if at least one is selected
if ( sels > 0 ) {
wxMenu menu ;
bool state ;
// Insert
state = ( sels = = 1 ) ;
menu . Append ( MENU_INSERT_BEFORE , _ ( " &Insert (before) " ) , _T ( " Inserts a line before current " ) ) - > Enable ( state ) ;
menu . Append ( MENU_INSERT_AFTER , _ ( " Insert (after) " ) , _T ( " Inserts a line after current " ) ) - > Enable ( state ) ;
2010-07-08 06:29:04 +02:00
state = ( sels = = 1 & & context - > IsLoaded ( ) ) ;
2006-01-16 22:02:54 +01:00
menu . Append ( MENU_INSERT_BEFORE_VIDEO , _ ( " Insert at video time (before) " ) , _T ( " Inserts a line after current, starting at video time " ) ) - > Enable ( state ) ;
menu . Append ( MENU_INSERT_AFTER_VIDEO , _ ( " Insert at video time (after) " ) , _T ( " Inserts a line after current, starting at video time " ) ) - > Enable ( state ) ;
menu . AppendSeparator ( ) ;
// Duplicate selection
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_DUPLICATE , _ ( " &Duplicate " ) , _ ( " Duplicate the selected lines " ) ) - > Enable ( continuous ) ;
2010-07-08 06:29:04 +02:00
menu . Append ( MENU_DUPLICATE_NEXT_FRAME , _ ( " &Duplicate and shift by 1 frame " ) , _ ( " Duplicate lines and shift by one frame " ) ) - > Enable ( continuous & & context - > TimecodesLoaded ( ) ) ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_SPLIT_BY_KARAOKE , _ ( " Split (by karaoke) " ) , _ ( " Uses karaoke timing to split line into multiple smaller lines " ) ) - > Enable ( sels > 0 ) ;
2006-01-16 22:02:54 +01:00
// Swaps selection
state = ( sels = = 2 ) ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_SWAP , _ ( " &Swap " ) , _ ( " Swaps the two selected lines " ) ) - > Enable ( state ) ;
2006-01-16 22:02:54 +01:00
// Join selection
state = ( sels > = 2 & & continuous ) ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_JOIN_CONCAT , _ ( " &Join (concatenate) " ) , _ ( " Joins selected lines in a single one, concatenating text together " ) ) - > Enable ( state ) ;
menu . Append ( MENU_JOIN_REPLACE , _ ( " Join (keep first) " ) , _ ( " Joins selected lines in a single one, keeping text of first and discarding remaining " ) ) - > Enable ( state ) ;
menu . Append ( MENU_JOIN_AS_KARAOKE , _ ( " Join (as Karaoke) " ) , _ ( " Joins selected lines in a single one, making each line into a karaoke syllable " ) ) - > Enable ( state ) ;
2006-12-30 23:38:05 +01:00
menu . AppendSeparator ( ) ;
2006-01-16 22:02:54 +01:00
// Adjoin selection
2010-07-23 08:40:22 +02:00
state = ( sels > = 1 & & continuous ) ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_ADJOIN , _ ( " &Make times continuous (change start) " ) , _ ( " Changes times of subs so start times begin on previous's end time " ) ) - > Enable ( state ) ;
menu . Append ( MENU_ADJOIN2 , _ ( " &Make times continuous (change end) " ) , _ ( " Changes times of subs so end times begin on next's start time " ) ) - > Enable ( state ) ;
2006-01-16 22:02:54 +01:00
// Recombine selection
2010-07-12 09:10:40 +02:00
state = ( sels > 1 ) ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_RECOMBINE , _ ( " Recombine Lines " ) , _ ( " Recombine subtitles when they have been split and merged " ) ) - > Enable ( state ) ;
2006-01-16 22:02:54 +01:00
menu . AppendSeparator ( ) ;
2007-01-17 06:06:17 +01:00
//Make audio clip
2007-03-19 21:01:09 +01:00
state = parentFrame - > audioBox - > audioDisplay - > loaded = = true ;
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_AUDIOCLIP , _ ( " Create audio clip " ) , _ ( " Create an audio clip of the selected line " ) ) - > Enable ( state ) ;
2007-01-17 06:06:17 +01:00
menu . AppendSeparator ( ) ;
2006-01-16 22:02:54 +01:00
// Copy/cut/paste
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_COPY , _ ( " &Copy " ) , _ ( " Copies selected lines to clipboard " ) ) ;
menu . Append ( MENU_CUT , _ ( " C&ut " ) , _ ( " Cuts selected lines to clipboard " ) ) ;
menu . Append ( MENU_PASTE , _ ( " &Paste " ) , _ ( " Paste lines from clipboard " ) ) ;
2006-01-16 22:02:54 +01:00
menu . AppendSeparator ( ) ;
// Delete
2007-07-05 17:51:42 +02:00
menu . Append ( MENU_DELETE , _ ( " Delete " ) , _ ( " Delete currently selected lines " ) ) ;
2006-01-16 22:02:54 +01:00
PopupMenu ( & menu ) ;
}
}
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 Process a show/hide column event
/// @param event
2006-06-27 07:13:41 +02:00
void SubtitlesGrid : : OnShowColMenu ( wxCommandEvent & event ) {
int item = event . GetId ( ) - MENU_SHOW_COL ;
showCol [ item ] = ! showCol [ item ] ;
2010-06-22 02:03:22 +02:00
std : : vector < bool > map ( showCol , showCol + columns ) ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Subtitle/Grid/Column " ) - > SetListBool ( map ) ;
2006-06-27 07:13:41 +02:00
// Update
SetColumnWidths ( ) ;
Refresh ( 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 Process keyboard events
/// @param event
2006-01-16 22:02:54 +01:00
void SubtitlesGrid : : OnKeyDown ( wxKeyEvent & event ) {
// Get key
2007-09-22 17:16:48 +02:00
# ifdef __APPLE__
Hotkeys . SetPressed ( event . GetKeyCode ( ) , event . m_metaDown , event . m_altDown , event . m_shiftDown ) ;
# else
2006-01-16 22:02:54 +01:00
Hotkeys . SetPressed ( event . GetKeyCode ( ) , event . m_controlDown , event . m_altDown , event . m_shiftDown ) ;
2007-09-22 17:16:48 +02:00
# endif
2006-01-16 22:02:54 +01:00
// Get selection
bool continuous = false ;
wxArrayInt sels = GetSelection ( & continuous ) ;
int n_found = sels . Count ( ) ;
int n = 0 ;
int n2 = 0 ;
int nrows = GetRows ( ) ;
if ( n_found > 0 ) {
n = sels [ 0 ] ;
n2 = sels [ n_found - 1 ] ;
}
if ( n_found = = 1 ) {
// Move down
if ( Hotkeys . IsPressed ( _T ( " Grid move row down " ) ) ) {
if ( n < nrows - 1 ) {
SwapLines ( n , n + 1 ) ;
SelectRow ( n + 1 ) ;
2010-06-26 13:32:16 +02:00
//editBox->SetToLine(n+1);
2006-01-16 22:02:54 +01:00
}
return ;
}
// Move up
if ( Hotkeys . IsPressed ( _T ( " Grid move row up " ) ) ) {
if ( n > 0 ) {
SwapLines ( n - 1 , n ) ;
SelectRow ( n - 1 ) ;
2010-06-26 13:32:16 +02:00
//editBox->SetToLine(n-1);
2006-01-16 22:02:54 +01:00
}
return ;
}
}
if ( n_found > = 1 ) {
// Copy
if ( Hotkeys . IsPressed ( _T ( " Copy " ) ) ) {
2006-02-23 20:26:14 +01:00
CopyLines ( GetSelection ( ) ) ;
2006-12-24 05:54:35 +01:00
return ;
2006-01-16 22:02:54 +01:00
}
// Cut
if ( Hotkeys . IsPressed ( _T ( " Cut " ) ) ) {
2006-02-23 20:26:14 +01:00
CutLines ( GetSelection ( ) ) ;
2006-12-24 05:54:35 +01:00
return ;
2006-01-16 22:02:54 +01:00
}
// Paste
if ( Hotkeys . IsPressed ( _T ( " Paste " ) ) ) {
2006-02-23 20:26:14 +01:00
PasteLines ( GetFirstSelRow ( ) ) ;
2006-12-24 05:54:35 +01:00
return ;
2006-01-16 22:02:54 +01:00
}
// Delete
if ( Hotkeys . IsPressed ( _T ( " Grid delete rows " ) ) ) {
2006-02-22 07:08:35 +01:00
DeleteLines ( GetSelection ( ) ) ;
2006-01-16 22:02:54 +01:00
return ;
}
if ( continuous ) {
// Duplicate
if ( Hotkeys . IsPressed ( _T ( " Grid duplicate rows " ) ) ) {
DuplicateLines ( n , n2 , false ) ;
return ;
}
// Duplicate and shift
2010-07-08 06:29:04 +02:00
if ( context - > TimecodesLoaded ( ) ) {
2006-01-16 22:02:54 +01:00
if ( Hotkeys . IsPressed ( _T ( " Grid duplicate and shift one frame " ) ) ) {
DuplicateLines ( n , n2 , true ) ;
return ;
}
}
}
}
event . Skip ( ) ;
}
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnDuplicate ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
DuplicateLines ( sels . front ( ) , sels . back ( ) ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnDuplicateNextFrame ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
DuplicateLines ( sels . front ( ) , sels . back ( ) , true ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call swap
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSwap ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
SwapLines ( sels . front ( ) , sels . back ( ) ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call join (concatenate)
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnJoinConcat ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
JoinLines ( sels . front ( ) , sels . back ( ) , true ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call join (replace)
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnJoinReplace ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
JoinLines ( sels . front ( ) , sels . back ( ) , false ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Adjoin lines
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnAdjoin ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
AdjoinLines ( sels . front ( ) , sels . back ( ) , true ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 DOCME
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnAdjoin2 ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
AdjoinLines ( sels . front ( ) , sels . back ( ) , false ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call join as karaoke
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnJoinAsKaraoke ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
wxArrayInt sels = GetSelection ( ) ;
JoinAsKaraoke ( sels . front ( ) , sels . back ( ) ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call split by karaoke
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSplitByKaraoke ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-03-11 17:11:55 +01:00
wxArrayInt sels = GetSelection ( ) ;
2009-07-23 00:30:57 +02:00
bool didSplit = false ;
2006-03-11 17:11:55 +01:00
for ( int i = sels . size ( ) - 1 ; i > = 0 ; i - - ) {
2009-07-23 00:30:57 +02:00
didSplit | = SplitLineByKaraoke ( sels [ i ] ) ;
}
if ( didSplit ) {
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " splitting " ) ) ;
2009-07-23 00:30:57 +02:00
CommitChanges ( ) ;
2006-03-11 17:11:55 +01:00
}
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-03-11 17:11:55 +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 Call insert before
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnInsertBefore ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-01-16 22:02:54 +01:00
// Find line
2006-02-22 07:49:20 +01:00
int n = GetFirstSelRow ( ) ;
2006-01-16 22:02:54 +01:00
// Create line to add
AssDialogue * def = new AssDialogue ;
if ( n = = 0 ) {
def - > Start . SetMS ( 0 ) ;
def - > End = GetDialogue ( n ) - > Start ;
}
2008-10-11 15:28:29 +02:00
else if ( GetDialogue ( n - 1 ) - > End . GetMS ( ) > GetDialogue ( n ) - > Start . GetMS ( ) ) {
2010-05-21 03:13:36 +02:00
def - > Start . SetMS ( GetDialogue ( n ) - > Start . GetMS ( ) - OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2008-10-11 15:28:29 +02:00
def - > End = GetDialogue ( n ) - > Start ;
}
2006-01-16 22:02:54 +01:00
else {
def - > Start = GetDialogue ( n - 1 ) - > End ;
def - > End = GetDialogue ( n ) - > Start ;
}
2010-05-21 03:13:36 +02:00
if ( def - > End . GetMS ( ) < def - > Start . GetMS ( ) ) def - > End . SetMS ( def - > Start . GetMS ( ) + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-01-16 22:02:54 +01:00
def - > Style = GetDialogue ( n ) - > Style ;
// Insert it
InsertLine ( def , n , false ) ;
2006-02-21 22:23:52 +01:00
SelectRow ( n ) ;
2010-06-26 13:32:16 +02:00
SetActiveLine ( def ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call insert after
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnInsertAfter ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-01-16 22:02:54 +01:00
// Find line
2006-02-22 07:49:20 +01:00
int n = GetFirstSelRow ( ) ;
2006-01-16 22:02:54 +01:00
int nrows = GetRows ( ) ;
// Create line to add
AssDialogue * def = new AssDialogue ;
if ( n = = nrows - 1 ) {
def - > Start = GetDialogue ( n ) - > End ;
def - > End = GetDialogue ( n ) - > End ;
2010-05-21 03:13:36 +02:00
def - > End . SetMS ( def - > End . GetMS ( ) + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-01-16 22:02:54 +01:00
}
else {
def - > Start = GetDialogue ( n ) - > End ;
def - > End = GetDialogue ( n + 1 ) - > Start ;
}
2010-05-21 03:13:36 +02:00
if ( def - > End . GetMS ( ) < def - > Start . GetMS ( ) ) def - > End . SetMS ( def - > Start . GetMS ( ) + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-01-16 22:02:54 +01:00
def - > Style = GetDialogue ( n ) - > Style ;
// Insert it
InsertLine ( def , n , true ) ;
2006-02-21 22:23:52 +01:00
SelectRow ( n + 1 ) ;
2010-06-26 13:32:16 +02:00
SetActiveLine ( def ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call insert before with video
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnInsertBeforeVideo ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-01-16 22:02:54 +01:00
// Find line
2006-02-22 07:49:20 +01:00
int n = GetFirstSelRow ( ) ;
2006-01-16 22:02:54 +01:00
// Create line to add
AssDialogue * def = new AssDialogue ;
2010-07-08 06:29:04 +02:00
int video_ms = context - > TimeAtFrame ( context - > GetFrameN ( ) , agi : : vfr : : START ) ;
2006-01-16 22:02:54 +01:00
def - > Start . SetMS ( video_ms ) ;
2010-05-21 03:13:36 +02:00
def - > End . SetMS ( video_ms + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-01-16 22:02:54 +01:00
def - > Style = GetDialogue ( n ) - > Style ;
// Insert it
InsertLine ( def , n , false ) ;
2006-02-21 22:23:52 +01:00
SelectRow ( n ) ;
2010-06-26 13:32:16 +02:00
SetActiveLine ( def ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Call insert after with video
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnInsertAfterVideo ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-01-16 22:02:54 +01:00
// Find line
2006-02-22 07:49:20 +01:00
int n = GetFirstSelRow ( ) ;
2006-01-16 22:02:54 +01:00
// Create line to add
AssDialogue * def = new AssDialogue ;
2010-07-08 06:29:04 +02:00
int video_ms = context - > TimeAtFrame ( context - > GetFrameN ( ) , agi : : vfr : : START ) ;
2006-01-16 22:02:54 +01:00
def - > Start . SetMS ( video_ms ) ;
2010-05-21 03:13:36 +02:00
def - > End . SetMS ( video_ms + OPT_GET ( " Timing/Default Duration " ) - > GetInt ( ) ) ;
2006-01-16 22:02:54 +01:00
def - > Style = GetDialogue ( n ) - > Style ;
// Insert it
InsertLine ( def , n , true ) ;
2006-02-21 22:23:52 +01:00
SelectRow ( n + 1 ) ;
2010-06-26 13:32:16 +02:00
SetActiveLine ( def ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
/// Copy selection to clipboard
void SubtitlesGrid : : OnCopyLines ( wxCommandEvent & ) {
2006-02-22 07:49:20 +01:00
CopyLines ( GetSelection ( ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
/// Cuts selection to clipboard
void SubtitlesGrid : : OnCutLines ( wxCommandEvent & ) {
2006-02-22 07:49:20 +01:00
CutLines ( GetSelection ( ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
/// Paste from clipboard
void SubtitlesGrid : : OnPasteLines ( wxCommandEvent & ) {
2006-02-22 05:59:39 +01:00
PasteLines ( GetFirstSelRow ( ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
/// Copy selection to clipboard
void SubtitlesGrid : : OnDeleteLines ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:08:35 +01:00
DeleteLines ( GetSelection ( ) ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Set start to video pos
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSetStartToVideo ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 05:59:39 +01:00
SetSubsToVideo ( true ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Set end to video pos
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSetEndToVideo ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 05:59:39 +01:00
SetSubsToVideo ( false ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Set video pos to start
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSetVideoToStart ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 05:59:39 +01:00
SetVideoToSubs ( true ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
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 Set video pos to end
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnSetVideoToEnd ( wxCommandEvent & ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 05:59:39 +01:00
SetVideoToSubs ( false ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-12 09:10:40 +02:00
static void trim_text ( AssDialogue * diag ) {
static wxRegEx start ( L " ^( | \\ t| \\ \\ [nNh]) + " ) ;
static wxRegEx end ( L " ( | \\ t| \\ \\ [nNh]) + $ " ) ;
start . ReplaceFirst ( & diag - > Text , " " ) ;
end . ReplaceFirst ( & diag - > Text , " " ) ;
}
static void expand_times ( AssDialogue * src , AssDialogue * dst ) {
using std : : min ;
using std : : max ;
dst - > Start . SetMS ( min ( dst - > Start . GetMS ( ) , src - > Start . GetMS ( ) ) ) ;
dst - > End . SetMS ( max ( dst - > End . GetMS ( ) , src - > End . GetMS ( ) ) ) ;
}
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 Recombine
2010-07-12 09:10:40 +02:00
void SubtitlesGrid : : OnRecombine ( wxCommandEvent & ) {
using namespace std ;
Selection selectedSet = GetSelectedSet ( ) ;
if ( selectedSet . size ( ) < 2 ) return ;
AssDialogue * activeLine = GetActiveLine ( ) ;
vector < AssDialogue * > sel ;
sel . reserve ( selectedSet . size ( ) ) ;
copy ( selectedSet . begin ( ) , selectedSet . end ( ) , back_inserter ( sel ) ) ;
for_each ( sel . begin ( ) , sel . end ( ) , trim_text ) ;
sort ( sel . begin ( ) , sel . end ( ) , & AssFile : : CompStart ) ;
typedef vector < AssDialogue * > : : iterator diag_iter ;
diag_iter end = sel . end ( ) - 1 ;
for ( diag_iter cur = sel . begin ( ) ; cur ! = end ; + + cur ) {
AssDialogue * d1 = * cur ;
diag_iter d2 = cur + 1 ;
// 1, 1+2 (or 2+1), 2 gets turned into 1, 2, 2 so kill the duplicate
if ( d1 - > Text = = ( * d2 ) - > Text ) {
expand_times ( d1 , * d2 ) ;
delete d1 ;
ass - > Line . remove ( d1 ) ;
continue ;
}
2006-11-23 20:08:46 +01:00
2010-07-12 09:10:40 +02:00
// 1, 1+2, 1 turns into 1, 2, [empty]
if ( d1 - > Text . empty ( ) ) {
delete d1 ;
ass - > Line . remove ( d1 ) ;
continue ;
2006-12-30 23:38:05 +01:00
}
2006-01-16 22:02:54 +01:00
2010-07-12 09:10:40 +02:00
// 1, 1+2
while ( d2 < = end & & ( * d2 ) - > Text . StartsWith ( d1 - > Text , & ( * d2 ) - > Text ) ) {
expand_times ( * d2 , d1 ) ;
trim_text ( * d2 ) ;
+ + d2 ;
2007-01-26 05:11:32 +01:00
}
2010-07-12 09:10:40 +02:00
// 1, 2+1
while ( d2 < = end & & ( * d2 ) - > Text . EndsWith ( d1 - > Text , & ( * d2 ) - > Text ) ) {
expand_times ( * d2 , d1 ) ;
trim_text ( * d2 ) ;
+ + d2 ;
2006-12-30 23:38:05 +01:00
}
2006-11-23 20:08:46 +01:00
2010-07-12 09:10:40 +02:00
// 1+2, 2
while ( d2 < = end & & d1 - > Text . EndsWith ( ( * d2 ) - > Text , & d1 - > Text ) ) {
expand_times ( d1 , * d2 ) ;
trim_text ( d1 ) ;
+ + d2 ;
2006-12-30 23:38:05 +01:00
}
2006-01-16 22:02:54 +01:00
2010-07-12 09:10:40 +02:00
// 2+1, 2
while ( d2 < = end & & d1 - > Text . StartsWith ( ( * d2 ) - > Text , & d1 - > Text ) ) {
expand_times ( d1 , * d2 ) ;
trim_text ( d1 ) ;
+ + d2 ;
}
2006-02-01 03:16:57 +01:00
}
2006-11-23 20:08:46 +01:00
2010-07-12 09:10:40 +02:00
ass - > Commit ( _ ( " combining " ) ) ;
UpdateMaps ( ) ;
CommitChanges ( ) ;
// Remove now non-existent lines from the selection
Selection lines ;
transform ( ass - > Line . begin ( ) , ass - > Line . end ( ) , inserter ( lines , lines . begin ( ) ) , cast < AssDialogue * > ( ) ) ;
Selection newSel ;
set_intersection ( lines . begin ( ) , lines . end ( ) , selectedSet . begin ( ) , selectedSet . end ( ) , inserter ( newSel , newSel . begin ( ) ) ) ;
if ( newSel . empty ( ) ) return ;
// Restore selection
SetSelectedSet ( newSel ) ;
if ( find ( newSel . begin ( ) , newSel . end ( ) , activeLine ) = = newSel . end ( ) ) {
activeLine = * newSel . begin ( ) ;
}
SetActiveLine ( activeLine ) ;
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 Export audio clip of line
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : OnAudioClip ( wxCommandEvent & ) {
2007-08-31 16:11:35 +02:00
int64_t num_samples , start = 0 , end = 0 , temp ;
2007-01-17 06:06:17 +01:00
AudioDisplay * audioDisplay = parentFrame - > audioBox - > audioDisplay ;
AudioProvider * provider = audioDisplay - > provider ;
2007-03-19 21:01:09 +01:00
AssDialogue * cur ;
wxArrayInt sel = GetSelection ( ) ;
num_samples = provider - > GetNumSamples ( ) ;
2007-04-04 22:42:44 +02:00
for ( unsigned int i = 0 ; i ! = sel . GetCount ( ) ; i + + ) {
2007-03-19 21:01:09 +01:00
cur = GetDialogue ( sel [ i ] ) ;
temp = audioDisplay - > GetSampleAtMS ( cur - > Start . GetMS ( ) ) ;
start = ( i = = 0 | | temp < start ) ? temp : start ;
temp = audioDisplay - > GetSampleAtMS ( cur - > End . GetMS ( ) ) ;
end = ( i = = 0 | | temp > end ) ? temp : end ;
}
if ( start > num_samples ) {
wxMessageBox ( _ ( " The starting point is beyond the length of the audio loaded. " ) , _ ( " Error " ) ) ;
return ;
}
if ( start = = end | | end = = 0 ) {
wxMessageBox ( _ ( " There is no audio to save. " ) , _ ( " Error " ) ) ;
return ;
}
end = ( end > num_samples ) ? num_samples : end ;
2007-01-17 06:06:17 +01:00
2007-08-07 22:45:41 +02:00
wxString filename = wxFileSelector ( _ ( " Save audio clip " ) , _T ( " " ) , _T ( " " ) , _T ( " wav " ) , _T ( " " ) , wxFD_SAVE | wxFD_OVERWRITE_PROMPT , this ) ;
2007-01-17 06:06:17 +01:00
if ( ! filename . empty ( ) ) {
2009-07-14 23:28:49 +02:00
std : : ofstream outfile ( filename . mb_str ( csConvLocal ) , std : : ios : : binary ) ;
2007-01-17 06:06:17 +01:00
size_t bufsize = ( end - start ) * provider - > GetChannels ( ) * provider - > GetBytesPerSample ( ) ;
int intval ;
short shortval ;
outfile < < " RIFF " ;
outfile . write ( ( char * ) & ( intval = bufsize + 36 ) , 4 ) ;
outfile < < " WAVEfmt " ;
outfile . write ( ( char * ) & ( intval = 16 ) , 4 ) ;
outfile . write ( ( char * ) & ( shortval = 1 ) , 2 ) ;
outfile . write ( ( char * ) & ( shortval = provider - > GetChannels ( ) ) , 2 ) ;
outfile . write ( ( char * ) & ( intval = provider - > GetSampleRate ( ) ) , 4 ) ;
outfile . write ( ( char * ) & ( intval = provider - > GetSampleRate ( ) * provider - > GetChannels ( ) * provider - > GetBytesPerSample ( ) ) , 4 ) ;
outfile . write ( ( char * ) & ( intval = provider - > GetChannels ( ) * provider - > GetBytesPerSample ( ) ) , 2 ) ;
outfile . write ( ( char * ) & ( shortval = provider - > GetBytesPerSample ( ) < < 3 ) , 2 ) ;
outfile < < " data " ;
outfile . write ( ( char * ) & bufsize , 4 ) ;
//samples per read
size_t spr = 65536 / ( provider - > GetBytesPerSample ( ) * provider - > GetChannels ( ) ) ;
2008-01-21 00:37:44 +01:00
for ( int64_t i = start ; i < end ; i + = spr ) {
int len = ( i + ( int64_t ) spr > end ) ? ( end - i ) : spr ;
2007-01-17 06:13:02 +01:00
bufsize = len * ( provider - > GetBytesPerSample ( ) * provider - > GetChannels ( ) ) ;
void * buf = malloc ( bufsize ) ;
2007-01-17 06:06:17 +01:00
if ( buf ) {
provider - > GetAudio ( buf , i , len ) ;
2007-01-17 06:13:02 +01:00
outfile . write ( ( char * ) buf , bufsize ) ;
2007-01-17 06:06:17 +01:00
free ( buf ) ;
}
else if ( spr > 128 ) {
//maybe we can allocate a smaller amount of memory
i - = spr ; //effectively redo this loop again
spr = 128 ;
}
else {
wxMessageBox ( _ ( " Couldn't allocate memory. " ) , _ ( " Error " ) , wxICON_ERROR | wxOK ) ;
2007-01-17 07:38:26 +01:00
break ; // don't return, we need to close the file
2007-01-17 06:06:17 +01:00
}
}
outfile . close ( ) ;
}
}
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 Clears grid and sets it to default
/// @param _ass
2010-06-26 09:26:27 +02:00
void SubtitlesGrid : : LoadDefault ( ) {
2006-01-16 22:02:54 +01:00
ass - > LoadDefault ( ) ;
2010-07-13 07:29:08 +02:00
ClearMaps ( ) ;
2010-06-26 09:26:27 +02:00
UpdateMaps ( ) ;
2010-06-26 16:09:15 +02:00
SetActiveLine ( GetDialogue ( 0 ) ) ;
SelectRow ( 0 ) ;
2006-01-16 22:02:54 +01:00
}
2010-06-26 09:26:27 +02:00
/// @brief Update internal data structures
2010-07-13 07:29:08 +02:00
void SubtitlesGrid : : UpdateMaps ( bool preserve_selected_rows ) {
BaseGrid : : UpdateMaps ( preserve_selected_rows ) ;
2006-01-16 22:02:54 +01:00
if ( editBox ) {
editBox - > UpdateGlobals ( ) ;
}
}
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 Swaps two lines
/// @param n1
/// @param n2
2006-01-16 22:02:54 +01:00
void SubtitlesGrid : : SwapLines ( int n1 , int n2 ) {
2010-06-26 09:26:27 +02:00
AssDialogue * dlg1 = GetDialogue ( n1 ) ;
AssDialogue * dlg2 = GetDialogue ( n2 ) ;
if ( n1 = = 0 | | n2 = = 0 ) return ;
2006-01-16 22:02:54 +01:00
2010-06-26 09:26:27 +02:00
std : : swap ( * dlg1 , * dlg2 ) ;
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " swap lines " ) ) ;
2006-01-16 22:02:54 +01:00
CommitChanges ( ) ;
}
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 Insert a line
/// @param line
/// @param n
/// @param after
/// @param update
2006-01-16 22:02:54 +01:00
void SubtitlesGrid : : InsertLine ( AssDialogue * line , int n , bool after , bool update ) {
2010-06-26 13:32:16 +02:00
AssDialogue * rel_line = GetDialogue ( n + ( after ? 1 : 0 ) ) ;
2010-07-13 07:29:08 +02:00
entryIter pos = std : : find ( ass - > Line . begin ( ) , ass - > Line . end ( ) , rel_line ) ;
2006-01-16 22:02:54 +01:00
entryIter newIter = ass - > Line . insert ( pos , line ) ;
2010-06-26 17:49:05 +02:00
BaseGrid : : UpdateMaps ( ) ;
2006-01-16 22:02:54 +01:00
// Update
if ( update ) {
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " line insertion " ) ) ;
2006-01-16 22:02:54 +01:00
CommitChanges ( ) ;
}
}
2006-02-22 07:49:20 +01:00
void SubtitlesGrid : : CopyLines ( wxArrayInt target ) {
2006-01-16 22:02:54 +01:00
// Prepare text
wxString data = _T ( " " ) ;
AssDialogue * cur ;
2006-02-22 07:49:20 +01:00
int nrows = target . Count ( ) ;
2006-01-16 22:02:54 +01:00
bool first = true ;
for ( int i = 0 ; i < nrows ; i + + ) {
2006-02-22 07:49:20 +01:00
if ( ! first ) data + = _T ( " \r \n " ) ;
first = false ;
cur = GetDialogue ( target [ i ] ) ;
2006-02-27 03:23:50 +01:00
data + = cur - > GetEntryData ( ) ;
2006-01-16 22:02:54 +01:00
}
// Send to clipboard
if ( wxTheClipboard - > Open ( ) ) {
wxTheClipboard - > SetData ( new wxTextDataObject ( data ) ) ;
wxTheClipboard - > Close ( ) ;
}
}
2006-02-22 07:49:20 +01:00
void SubtitlesGrid : : CutLines ( wxArrayInt target ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-02-22 07:49:20 +01:00
CopyLines ( target ) ;
DeleteLines ( target ) ;
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-02-22 05:59:39 +01:00
}
2010-07-20 05:11:11 +02:00
/// @brief Paste lines from clipboard
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 n
/// @param pasteOver
2006-12-17 19:30:19 +01:00
void SubtitlesGrid : : PasteLines ( int n , bool pasteOver ) {
2006-11-23 20:08:46 +01:00
BeginBatch ( ) ;
2006-01-16 22:02:54 +01:00
// Prepare text
2010-07-20 05:11:11 +02:00
wxString data ;
2006-01-16 22:02:54 +01:00
// Read from clipboard
if ( wxTheClipboard - > Open ( ) ) {
if ( wxTheClipboard - > IsSupported ( wxDF_TEXT ) ) {
wxTextDataObject rawdata ;
wxTheClipboard - > GetData ( rawdata ) ;
data = rawdata . GetText ( ) ;
}
wxTheClipboard - > Close ( ) ;
}
// Check if it actually got anything
if ( ! data . empty ( ) ) {
2006-12-17 19:30:19 +01:00
// Insert data
2006-01-16 22:02:54 +01:00
int inserted = 0 ;
2010-06-22 02:03:16 +02:00
std : : vector < bool > pasteOverOptions ;
2006-01-16 22:02:54 +01:00
wxStringTokenizer token ( data , _T ( " \r \n " ) , wxTOKEN_STRTOK ) ;
while ( token . HasMoreTokens ( ) ) {
2006-12-17 19:30:19 +01:00
// Convert data into an AssDialogue
2006-01-16 22:02:54 +01:00
wxString curdata = token . GetNextToken ( ) ;
curdata . Trim ( true ) ;
curdata . Trim ( false ) ;
2006-12-17 19:30:19 +01:00
AssDialogue * curdiag ;
2006-01-16 22:02:54 +01:00
try {
2008-06-15 15:18:28 +02:00
// Try to interpret the line as an ASS line
2006-12-17 19:30:19 +01:00
curdiag = new AssDialogue ( curdata ) ;
2006-01-16 22:02:54 +01:00
}
catch ( . . . ) {
2010-07-20 05:11:11 +02:00
// Line didn't parse correctly, assume it's plain text that
2008-06-15 15:18:28 +02:00
// should be pasted in the Text field only
2006-12-17 19:30:19 +01:00
curdiag = new AssDialogue ( ) ;
curdiag - > Text = curdata ;
2008-06-15 15:18:28 +02:00
// Make sure pasted plain-text lines always are blank-timed
curdiag - > Start . SetMS ( 0 ) ;
curdiag - > End . SetMS ( 0 ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-17 19:30:19 +01:00
// Paste over
if ( pasteOver ) {
if ( n + inserted < GetRows ( ) ) {
// Get list of options to paste over, if not asked yet
2010-06-22 02:03:16 +02:00
if ( pasteOverOptions . empty ( ) ) {
DialogPasteOver diag ( NULL , pasteOverOptions ) ;
2006-12-17 20:41:52 +01:00
if ( ! diag . ShowModal ( ) ) {
delete curdiag ;
return ;
}
2006-12-17 19:30:19 +01:00
}
// Paste over
AssDialogue * target = GetDialogue ( n + inserted ) ;
if ( pasteOverOptions [ 0 ] ) target - > Layer = curdiag - > Layer ;
if ( pasteOverOptions [ 1 ] ) target - > Start = curdiag - > Start ;
if ( pasteOverOptions [ 2 ] ) target - > End = curdiag - > End ;
if ( pasteOverOptions [ 3 ] ) target - > Style = curdiag - > Style ;
if ( pasteOverOptions [ 4 ] ) target - > Actor = curdiag - > Actor ;
2007-01-05 19:27:15 +01:00
if ( pasteOverOptions [ 5 ] ) target - > Margin [ 0 ] = curdiag - > Margin [ 0 ] ;
if ( pasteOverOptions [ 6 ] ) target - > Margin [ 1 ] = curdiag - > Margin [ 1 ] ;
if ( pasteOverOptions [ 7 ] ) target - > Margin [ 2 ] = curdiag - > Margin [ 2 ] ;
2007-03-28 03:37:13 +02:00
if ( pasteOverOptions [ 8 ] ) target - > Effect = curdiag - > Effect ;
if ( pasteOverOptions [ 9 ] ) target - > Text = curdiag - > Text ;
2006-12-17 19:30:19 +01:00
}
delete curdiag ;
}
// Paste normally
else InsertLine ( curdiag , n + inserted , false , false ) ;
// Increment insertion
inserted + + ;
2006-01-16 22:02:54 +01:00
}
2006-12-17 19:30:19 +01:00
// Update data post-insertion
2006-01-16 22:02:54 +01:00
if ( inserted > 0 ) {
// Commit
2006-02-22 07:08:35 +01:00
UpdateMaps ( ) ;
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " paste " ) ) ;
2006-01-16 22:02:54 +01:00
CommitChanges ( ) ;
// Set selection
2006-12-17 19:30:19 +01:00
if ( ! pasteOver ) {
2010-06-26 13:32:16 +02:00
Selection newsel ;
for ( int i = n ; i < n + inserted ; i + + ) {
newsel . insert ( GetDialogue ( i ) ) ;
2006-12-17 19:30:19 +01:00
}
2010-06-26 13:32:16 +02:00
SetSelectedSet ( newsel ) ;
SetActiveLine ( GetDialogue ( GetFirstSelRow ( ) ) ) ;
2006-01-16 22:02:54 +01:00
}
}
}
2006-11-23 20:08:46 +01:00
EndBatch ( ) ;
2006-01-16 22:02:54 +01:00
}
2009-07-23 00:30:57 +02:00
void SubtitlesGrid : : DeleteLines ( wxArrayInt target , bool flagModified ) {
2010-07-13 07:29:08 +02:00
entryIter before_first = std : : find_if ( ass - > Line . begin ( ) , ass - > Line . end ( ) , cast < AssDialogue * > ( ) ) ; - - before_first ;
2010-06-26 13:32:16 +02:00
int old_active_line_index = GetDialogueIndex ( GetActiveLine ( ) ) ;
2006-01-16 22:02:54 +01:00
2010-07-13 07:29:08 +02:00
int row = - 1 ;
int deleted = 0 ;
for ( entryIter cur = ass - > Line . begin ( ) ; cur ! = ass - > Line . end ( ) ; ) {
if ( dynamic_cast < AssDialogue * > ( * cur ) & & + + row = = target [ deleted ] ) {
cur = ass - > Line . erase ( cur ) ;
+ + deleted ;
if ( deleted = = target . size ( ) ) break ;
}
else {
+ + cur ;
}
2006-01-16 22:02:54 +01:00
}
// Add default line if file was wiped
if ( GetRows ( ) = = deleted ) {
AssDialogue * def = new AssDialogue ;
2010-06-26 09:26:27 +02:00
+ + before_first ;
ass - > Line . insert ( before_first , def ) ;
2010-06-26 13:32:16 +02:00
old_active_line_index = 0 ;
2006-01-16 22:02:54 +01:00
}
2006-02-21 03:01:42 +01:00
UpdateMaps ( ) ;
2010-07-13 07:29:08 +02:00
2009-07-23 00:30:57 +02:00
if ( flagModified ) {
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " delete " ) ) ;
2009-07-23 00:30:57 +02:00
CommitChanges ( ) ;
}
2006-01-16 22:02:54 +01:00
}
void SubtitlesGrid : : JoinLines ( int n1 , int n2 , bool concat ) {
2010-07-20 05:11:11 +02:00
int min_ms = INT_MAX ;
int max_ms = INT_MIN ;
wxString finalText ;
2006-01-16 22:02:54 +01:00
// Collect data
AssDialogue * cur ;
int start , end ;
bool gotfirst = false ;
2008-03-06 20:57:14 +01:00
bool gottime = false ;
2006-01-16 22:02:54 +01:00
for ( int i = n1 ; i < = n2 ; i + + ) {
2007-07-27 09:08:22 +02:00
// Get start and end time of current line
2006-01-16 22:02:54 +01:00
cur = GetDialogue ( i ) ;
start = cur - > Start . GetMS ( ) ;
end = cur - > End . GetMS ( ) ;
2007-07-27 09:08:22 +02:00
// Don't take the timing of zero lines
if ( start ! = 0 | | end ! = 0 ) {
if ( start < min_ms ) min_ms = start ;
if ( end > max_ms ) max_ms = end ;
2008-03-06 20:57:14 +01:00
gottime = true ;
2007-07-27 09:08:22 +02:00
}
// Set text
2006-01-16 22:02:54 +01:00
if ( concat | | ! gotfirst ) {
if ( gotfirst ) finalText + = _T ( " \\ N " ) ;
gotfirst = true ;
finalText + = cur - > Text ;
}
}
2008-03-06 20:57:14 +01:00
// If it didn't get any times, then it's probably because they were all 0 lines.
if ( ! gottime ) {
min_ms = 0 ;
max_ms = 0 ;
}
2006-01-16 22:02:54 +01:00
// Apply settings to first line
cur = GetDialogue ( n1 ) ;
cur - > Start . SetMS ( min_ms ) ;
cur - > End . SetMS ( max_ms ) ;
cur - > Text = finalText ;
// Delete remaining lines (this will auto commit)
2010-06-26 13:32:16 +02:00
DeleteLines ( GetRangeArray ( n1 + 1 , n2 ) , false ) ;
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " join lines " ) ) ;
2010-06-26 13:32:16 +02:00
CommitChanges ( ) ;
2006-01-16 22:02:54 +01:00
// Select new line
2010-06-26 13:32:16 +02:00
SetActiveLine ( cur ) ;
2006-01-16 22:02:54 +01:00
SelectRow ( n1 ) ;
}
void SubtitlesGrid : : AdjoinLines ( int n1 , int n2 , bool setStart ) {
2010-07-23 08:40:22 +02:00
if ( n1 = = n2 ) {
if ( setStart ) {
- - n1 ;
}
else {
+ + n2 ;
}
}
2006-01-16 22:02:54 +01:00
// Set start
if ( setStart ) {
AssDialogue * prev = GetDialogue ( n1 ) ;
AssDialogue * cur ;
for ( int i = n1 + 1 ; i < = n2 ; i + + ) {
cur = GetDialogue ( i ) ;
if ( ! cur ) return ;
cur - > Start = prev - > End ;
prev = cur ;
}
}
// Set end
else {
AssDialogue * next ;
AssDialogue * cur = GetDialogue ( n1 ) ;
for ( int i = n1 ; i < n2 ; i + + ) {
next = GetDialogue ( i + 1 ) ;
if ( ! next ) return ;
cur - > End = next - > Start ;
cur = next ;
}
}
2010-07-09 09:31:48 +02:00
ass - > Commit ( _ ( " adjoin " ) ) ;
2006-01-16 22:02:54 +01:00
CommitChanges ( ) ;
}
void SubtitlesGrid : : JoinAsKaraoke ( int n1 , int n2 ) {
wxString finalText = _T ( " " ) ;
// Collect data
AssDialogue * cur ;
int start , end ;
2007-01-11 04:18:14 +01:00
int firststart = 0 ;
2006-01-16 22:02:54 +01:00
int lastend = - 1 ;
int len1 , len2 ;
for ( int i = n1 ; i < = n2 ; i + + ) {
cur = GetDialogue ( i ) ;
// Get times
start = cur - > Start . GetMS ( ) ;
end = cur - > End . GetMS ( ) ;
// Get len
if ( lastend = = - 1 ) {
lastend = start ;
firststart = start ;
}
len1 = ( start - lastend ) / 10 ;
2006-10-20 00:53:06 +02:00
len2 = ( end - start ) / 10 ;
2006-01-16 22:02:54 +01:00
// Create text
if ( len1 ! = 0 ) finalText + = _T ( " { \\ k " ) + wxString : : Format ( _T ( " %i " ) , len1 ) + _T ( " } " ) ;
finalText + = _T ( " { \\ k " ) + wxString : : Format ( _T ( " %i " ) , len2 ) + _T ( " } " ) + cur - > Text ;
lastend = end ;
}
// Apply settings to first line
cur = GetDialogue ( n1 ) ;
cur - > Start . SetMS ( firststart ) ;
cur - > End . SetMS ( lastend ) ;
cur - > Text = finalText ;
// Delete remaining lines (this will auto commit)
2010-06-26 13:32:16 +02:00
DeleteLines ( GetRangeArray ( n1 + 1 , n2 ) , false ) ;
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " join as karaoke " ) ) ;
2010-06-26 13:32:16 +02:00
CommitChanges ( ) ;
2006-01-16 22:02:54 +01:00
// Select new line
2010-06-26 13:32:16 +02:00
SetActiveLine ( cur ) ;
2006-01-16 22:02:54 +01:00
SelectRow ( n1 ) ;
}
void SubtitlesGrid : : DuplicateLines ( int n1 , int n2 , bool nextFrame ) {
AssDialogue * cur ;
bool update = false ;
int step = 0 ;
for ( int i = n1 ; i < = n2 ; i + + ) {
// Create
if ( i = = n2 ) update = true ;
2006-02-27 03:23:50 +01:00
cur = new AssDialogue ( GetDialogue ( i ) - > GetEntryData ( ) ) ;
2006-01-16 22:02:54 +01:00
// Shift to next frame
if ( nextFrame ) {
2010-07-08 06:29:04 +02:00
int posFrame = context - > FrameAtTime ( cur - > End . GetMS ( ) , agi : : vfr : : END ) + 1 ;
cur - > Start . SetMS ( context - > TimeAtFrame ( posFrame , agi : : vfr : : START ) ) ;
cur - > End . SetMS ( context - > TimeAtFrame ( posFrame , agi : : vfr : : END ) ) ;
2006-01-16 22:02:54 +01:00
}
// Insert
InsertLine ( cur , n2 + step , true , update ) ;
step + + ;
}
// Select new lines
2010-06-26 13:32:16 +02:00
Selection newsel ;
for ( int i = n1 ; i < = n2 ; i + + ) {
newsel . insert ( GetDialogue ( i + step ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-06-26 13:32:16 +02:00
SetSelectedSet ( newsel ) ;
SetActiveLine ( GetDialogue ( n1 + step ) ) ;
2006-01-16 22:02:54 +01:00
}
void SubtitlesGrid : : ShiftLineByTime ( int n , int len , int type ) {
2010-07-20 05:11:11 +02:00
assert ( type > = 0 & & type < = 2 ) ;
2006-01-16 22:02:54 +01:00
AssDialogue * cur = GetDialogue ( n ) ;
if ( type ! = 2 ) cur - > Start . SetMS ( cur - > Start . GetMS ( ) + len ) ;
if ( type ! = 1 ) cur - > End . SetMS ( cur - > End . GetMS ( ) + len ) ;
}
void SubtitlesGrid : : ShiftLineByFrames ( int n , int len , int type ) {
2010-07-20 05:11:11 +02:00
assert ( type > = 0 & & type < = 2 ) ;
2006-01-16 22:02:54 +01:00
AssDialogue * cur = GetDialogue ( n ) ;
2010-07-08 06:29:04 +02:00
if ( type ! = 2 ) cur - > Start . SetMS ( context - > TimeAtFrame ( len + context - > FrameAtTime ( cur - > Start . GetMS ( ) , agi : : vfr : : START ) , agi : : vfr : : START ) ) ;
if ( type ! = 1 ) cur - > End . SetMS ( context - > TimeAtFrame ( len + context - > FrameAtTime ( cur - > End . GetMS ( ) , agi : : vfr : : END ) , agi : : vfr : : END ) ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : SplitLine ( AssDialogue * n1 , int pos , bool estimateTimes ) {
AssDialogue * n2 = new AssDialogue ( * n1 ) ;
InsertLine ( n2 , GetDialogueIndex ( n1 ) , true , false ) ;
2006-01-16 22:02:54 +01:00
wxString orig = n1 - > Text ;
2008-01-11 20:45:15 +01:00
n1 - > Text = orig . Left ( pos ) . Trim ( true ) ; // Trim off trailing whitespace
n2 - > Text = orig . Mid ( pos ) . Trim ( false ) ; // Trim off leading whitespace
2006-01-16 22:02:54 +01:00
2010-07-20 05:11:11 +02:00
if ( estimateTimes ) {
2006-01-16 22:02:54 +01:00
double splitPos = double ( pos ) / orig . Length ( ) ;
2007-01-11 04:18:14 +01:00
int splitTime = ( int ) ( ( n1 - > End . GetMS ( ) - n1 - > Start . GetMS ( ) ) * splitPos ) + n1 - > Start . GetMS ( ) ;
2006-01-16 22:02:54 +01:00
n1 - > End . SetMS ( splitTime ) ;
n2 - > Start . SetMS ( splitTime ) ;
}
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " split " ) ) ;
2010-07-20 05:11:11 +02:00
CommitChanges ( false ) ;
2006-01-16 22:02:54 +01:00
}
2009-07-23 00:30:57 +02:00
bool SubtitlesGrid : : SplitLineByKaraoke ( int lineNumber ) {
2006-03-11 17:11:55 +01:00
AssDialogue * line = GetDialogue ( lineNumber ) ;
2009-07-23 00:30:57 +02:00
line - > ParseASSTags ( ) ;
AssKaraokeVector syls ;
ParseAssKaraokeTags ( line , syls ) ;
line - > ClearBlocks ( ) ;
2006-03-11 17:11:55 +01:00
2009-07-23 00:30:57 +02:00
// If there's only 1 or 0 syllables, splitting would be counter-productive.
// 1 syllable means there's no karaoke tags in the line at all and that is
// the case that triggers bug #929.
if ( syls . size ( ) < 2 ) return false ;
2006-03-11 17:11:55 +01:00
2009-07-23 00:30:57 +02:00
// Insert a new line for each syllable
2010-05-19 02:44:44 +02:00
int start_ms = line - > Start . GetMS ( ) ;
2009-07-23 00:30:57 +02:00
int nextpos = lineNumber ;
for ( AssKaraokeVector : : iterator syl = syls . begin ( ) ; syl ! = syls . end ( ) ; + + syl )
{
// Skip blank lines
if ( syl - > unstripped_text . IsEmpty ( ) ) continue ;
AssDialogue * nl = new AssDialogue ( line - > GetEntryData ( ) ) ;
2010-05-19 02:44:44 +02:00
nl - > Start . SetMS ( start_ms ) ;
2009-07-23 00:30:57 +02:00
start_ms + = syl - > duration * 10 ;
2010-05-19 02:44:44 +02:00
nl - > End . SetMS ( start_ms ) ;
2009-07-23 00:30:57 +02:00
nl - > Text = syl - > unstripped_text ;
InsertLine ( nl , nextpos + + , true , false ) ;
2006-03-11 17:11:55 +01:00
}
2009-07-23 00:30:57 +02:00
// Remove the source line
2006-03-11 17:11:55 +01:00
{
wxArrayInt oia ;
oia . Add ( lineNumber ) ;
2009-07-23 00:30:57 +02:00
DeleteLines ( oia , false ) ;
2006-03-11 17:11:55 +01:00
}
2009-07-23 00:30:57 +02:00
return true ;
2006-03-11 17:11:55 +01:00
}
2010-07-20 05:11:11 +02:00
void SubtitlesGrid : : CommitChanges ( bool ebox , bool video , bool autosave ) {
if ( video & & context - > IsLoaded ( ) ) {
2006-01-16 22:02:54 +01:00
bool playing = false ;
2010-07-08 06:29:04 +02:00
if ( context - > IsPlaying ( ) ) {
2006-01-16 22:02:54 +01:00
playing = true ;
2010-07-08 06:29:04 +02:00
context - > Stop ( ) ;
2006-01-16 22:02:54 +01:00
}
2010-07-20 05:11:11 +02:00
context - > Refresh ( ) ;
2006-01-16 22:02:54 +01:00
2010-07-08 06:29:04 +02:00
if ( playing ) context - > Play ( ) ;
2006-01-16 22:02:54 +01:00
}
2006-12-01 00:27:59 +01:00
2010-07-20 05:11:11 +02:00
if ( autosave ) {
2007-01-08 06:32:29 +01:00
// Autosave if option is enabled
2010-05-21 03:13:36 +02:00
if ( OPT_GET ( " App/Auto/Save on Every Change " ) - > GetBool ( ) ) {
2007-01-08 06:32:29 +01:00
if ( ass - > IsModified ( ) & & ! ass - > filename . IsEmpty ( ) ) parentFrame - > SaveSubtitles ( false ) ;
}
2006-12-01 00:27:59 +01:00
2007-01-08 06:32:29 +01:00
// Update parent frame
parentFrame - > UpdateTitle ( ) ;
SetColumnWidths ( ) ;
Refresh ( false ) ;
}
2010-07-20 05:11:11 +02:00
if ( ebox ) {
editBox - > Update ( false , false ) ;
}
2006-01-16 22:02:54 +01:00
}
2006-02-22 05:59:39 +01:00
void SubtitlesGrid : : SetSubsToVideo ( bool start ) {
2010-07-08 06:29:04 +02:00
if ( ! context - > IsLoaded ( ) ) return ;
2006-02-22 05:59:39 +01:00
// Get new time
2010-07-08 06:29:04 +02:00
int ms = context - > TimeAtFrame ( context - > GetFrameN ( ) , start ? agi : : vfr : : START : agi : : vfr : : END ) ;
2006-02-22 05:59:39 +01:00
// Update selection
wxArrayInt sel = GetSelection ( ) ;
2010-07-20 05:11:11 +02:00
bool modified = false ;
2006-02-22 05:59:39 +01:00
for ( size_t i = 0 ; i < sel . Count ( ) ; i + + ) {
2010-07-20 05:11:11 +02:00
AssDialogue * cur = GetDialogue ( sel [ i ] ) ;
2006-02-22 05:59:39 +01:00
if ( cur ) {
2010-07-20 05:11:11 +02:00
modified = true ;
2006-02-22 05:59:39 +01:00
if ( start ) cur - > Start . SetMS ( ms ) ;
else cur - > End . SetMS ( ms ) ;
}
}
if ( modified ) {
2010-07-09 09:31:34 +02:00
ass - > Commit ( _ ( " timing " ) ) ;
2006-02-22 05:59:39 +01:00
CommitChanges ( ) ;
2009-07-03 20:35:46 +02:00
editBox - > Update ( true ) ;
2006-02-22 05:59:39 +01:00
}
}
void SubtitlesGrid : : SetVideoToSubs ( bool start ) {
wxArrayInt sel = GetSelection ( ) ;
if ( sel . Count ( ) = = 0 ) return ;
AssDialogue * cur = GetDialogue ( sel [ 0 ] ) ;
if ( cur ) {
2006-02-24 17:45:10 +01:00
if ( start )
2010-07-08 06:29:04 +02:00
context - > JumpToTime ( cur - > Start . GetMS ( ) ) ;
2006-02-24 17:45:10 +01:00
else
2010-07-08 06:29:04 +02:00
context - > JumpToTime ( cur - > End . GetMS ( ) , agi : : vfr : : END ) ;
2006-02-22 05:59:39 +01:00
}
}
2006-12-28 23:31:33 +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
2010-06-26 09:26:27 +02:00
/// @brief Retrieve a list of selected lines in the actual ASS file (ie. not as displayed in the grid but as represented in the file)
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
/// @return
///
2006-12-28 23:31:33 +01:00
std : : vector < int > SubtitlesGrid : : GetAbsoluteSelection ( ) {
std : : vector < int > result ;
result . reserve ( GetNumberSelection ( ) ) ;
2010-06-26 09:26:27 +02:00
Selection sel ;
GetSelectedSet ( sel ) ;
int line_index = 0 ;
for ( entryIter it = ass - > Line . begin ( ) ; it ! = ass - > Line . end ( ) ; + + it , + + line_index ) {
if ( sel . find ( dynamic_cast < AssDialogue * > ( * it ) ) ! = sel . end ( ) )
result . push_back ( line_index ) ;
2006-12-28 23:31:33 +01:00
}
return result ;
}
2007-02-06 23:58:05 +01:00
2010-06-26 09:26:27 +02:00
/// @brief Update list of selected lines from absolute selection
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 selection
///
2007-02-06 23:58:05 +01:00
void SubtitlesGrid : : SetSelectionFromAbsolute ( std : : vector < int > & selection ) {
2010-06-26 09:26:27 +02:00
Selection newsel ;
2007-02-06 23:58:05 +01:00
2010-06-26 09:26:27 +02:00
std : : sort ( selection . begin ( ) , selection . end ( ) ) ;
int i = 0 ;
2007-02-06 23:58:05 +01:00
std : : list < AssEntry * > : : iterator j = ass - > Line . begin ( ) ;
2010-06-26 09:26:27 +02:00
for ( size_t selveci = 0 ; selveci < selection . size ( ) ; + + selveci ) {
while ( i ! = selection [ selveci ] & & j ! = ass - > Line . end ( ) ) + + i , + + j ;
if ( j = = ass - > Line . end ( ) ) break ; /// @todo Report error somehow
AssDialogue * dlg = dynamic_cast < AssDialogue * > ( * j ) ;
if ( dlg ) newsel . insert ( dlg ) ;
2007-02-06 23:58:05 +01:00
}
2010-06-26 09:26:27 +02:00
SetSelectedSet ( newsel ) ;
2007-02-06 23:58:05 +01:00
}