2006-01-16 22:02:54 +01:00
|
|
|
// Copyright (c) 2005, Rodrigo Braz Monteiro
|
|
|
|
// 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_edit_box.h
|
|
|
|
/// @see subs_edit_box.cpp
|
|
|
|
/// @ingroup main_ui
|
|
|
|
///
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2009-09-11 04:36:34 +02:00
|
|
|
#ifndef AGI_PRE
|
2012-05-03 00:42:25 +02:00
|
|
|
#include <map>
|
2010-07-20 05:11:11 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2009-09-10 12:26:50 +02:00
|
|
|
#include <wx/panel.h>
|
2011-12-22 22:31:09 +01:00
|
|
|
#include <wx/timer.h>
|
2009-09-11 04:36:34 +02:00
|
|
|
#endif
|
|
|
|
|
2011-09-15 07:17:00 +02:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
|
2010-06-26 13:32:16 +02:00
|
|
|
#include "selection_controller.h"
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-01-20 06:14:50 +01:00
|
|
|
namespace agi { namespace vfr { class Framerate; } }
|
2011-01-16 08:17:36 +01:00
|
|
|
namespace agi { struct Context; }
|
2012-01-20 06:14:44 +01:00
|
|
|
struct AssColor;
|
2010-06-26 13:32:16 +02:00
|
|
|
class AssDialogue;
|
2012-01-20 06:14:44 +01:00
|
|
|
class AssStyle;
|
2012-05-03 00:42:25 +02:00
|
|
|
class AssTime;
|
2010-07-20 05:11:11 +02:00
|
|
|
class SubsTextEditCtrl;
|
2006-01-16 22:02:54 +01:00
|
|
|
class TimeEdit;
|
2010-07-20 05:11:11 +02:00
|
|
|
class wxButton;
|
|
|
|
class wxCheckBox;
|
|
|
|
class wxComboBox;
|
|
|
|
class wxRadioButton;
|
|
|
|
class wxSizer;
|
|
|
|
class wxSpinCtrl;
|
2007-04-22 01:16:38 +02:00
|
|
|
class wxStyledTextCtrl;
|
2010-08-03 00:14:11 +02:00
|
|
|
class wxStyledTextEvent;
|
2010-07-20 05:11:11 +02:00
|
|
|
class wxTextCtrl;
|
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
|
|
|
|
2012-01-20 06:14:50 +01:00
|
|
|
template<class Base> class Placeholder;
|
2010-12-31 22:03:18 +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
|
|
|
/// DOCME
|
|
|
|
/// @class SubsEditBox
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @brief Main subtitle edit box
|
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-07-20 05:11:11 +02:00
|
|
|
/// Controls the text edit and all surrounding controls
|
2010-06-26 13:32:16 +02:00
|
|
|
class SubsEditBox : public wxPanel, protected SelectionListener<AssDialogue> {
|
2010-07-20 05:11:11 +02:00
|
|
|
enum TimeField {
|
|
|
|
TIME_START = 0,
|
|
|
|
TIME_END,
|
|
|
|
TIME_DURATION
|
|
|
|
};
|
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-07-20 05:11:11 +02:00
|
|
|
/// Currently active dialogue line
|
|
|
|
AssDialogue *line;
|
|
|
|
/// Last seen grid selection
|
|
|
|
Selection sel;
|
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-07-20 05:11:11 +02:00
|
|
|
/// Are the buttons currently split into two lines?
|
|
|
|
bool splitLineMode;
|
|
|
|
/// Are the controls currently enabled?
|
2006-01-16 22:02:54 +01:00
|
|
|
bool controlState;
|
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
|
|
|
|
2011-01-16 08:17:36 +01:00
|
|
|
agi::Context *c;
|
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
|
|
|
|
2011-09-15 07:17:00 +02:00
|
|
|
agi::signal::Connection file_changed_slot;
|
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
// Box controls
|
2006-01-16 22:02:54 +01:00
|
|
|
wxCheckBox *CommentBox;
|
|
|
|
wxComboBox *StyleBox;
|
2012-01-20 06:14:50 +01:00
|
|
|
Placeholder<wxComboBox> *ActorBox;
|
2006-01-16 22:02:54 +01:00
|
|
|
TimeEdit *StartTime;
|
|
|
|
TimeEdit *EndTime;
|
|
|
|
TimeEdit *Duration;
|
2007-06-18 01:49:51 +02:00
|
|
|
wxSpinCtrl *Layer;
|
2010-07-20 05:11:11 +02:00
|
|
|
wxTextCtrl *MarginL;
|
|
|
|
wxTextCtrl *MarginR;
|
|
|
|
wxTextCtrl *MarginV;
|
2012-01-20 06:14:50 +01:00
|
|
|
Placeholder<wxTextCtrl> *Effect;
|
2006-01-16 22:02:54 +01:00
|
|
|
wxRadioButton *ByTime;
|
|
|
|
wxRadioButton *ByFrame;
|
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
|
|
|
|
2006-12-27 01:00:41 +01:00
|
|
|
wxSizer *TopSizer;
|
|
|
|
wxSizer *MiddleBotSizer;
|
|
|
|
wxSizer *MiddleSizer;
|
|
|
|
wxSizer *BottomSizer;
|
|
|
|
|
2006-01-16 22:02:54 +01:00
|
|
|
void SetControlsState(bool state);
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @brief Update times of selected lines
|
|
|
|
/// @param field Field which changed
|
|
|
|
void CommitTimes(TimeField field);
|
|
|
|
/// @brief Commits the current edit box contents
|
|
|
|
/// @param desc Undo description to use
|
|
|
|
void CommitText(wxString desc);
|
|
|
|
|
2012-05-03 00:42:25 +02:00
|
|
|
/// Last commit ID for undo coalescing
|
2010-07-20 05:11:11 +02:00
|
|
|
int commitId;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
|
|
|
/// Last used commit message to avoid coalescing different types of changes
|
2010-07-20 05:11:11 +02:00
|
|
|
wxString lastCommitType;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
|
|
|
/// Last field to get a time commit, as they all have the same commit message
|
|
|
|
int lastTimeCommitType;
|
|
|
|
|
|
|
|
/// Timer to stop coalescing changes after a break with no edits
|
2011-12-22 22:31:09 +01:00
|
|
|
wxTimer undoTimer;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-05-03 00:42:25 +02:00
|
|
|
/// The start and end times of the selected lines without changes made to
|
|
|
|
/// avoid negative durations, so that they can be restored if future changes
|
|
|
|
/// eliminate the negative durations
|
|
|
|
std::map<AssDialogue *, std::pair<AssTime, AssTime> > initialTimes;
|
|
|
|
|
2012-01-20 06:14:44 +01:00
|
|
|
// Constructor helpers
|
|
|
|
wxTextCtrl *MakeMarginCtrl(wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&));
|
|
|
|
TimeEdit *MakeTimeCtrl(bool end, wxString const& tooltip, void (SubsEditBox::*handler)(wxCommandEvent&));
|
|
|
|
template<class Handler>
|
|
|
|
void MakeButton(wxBitmap const& icon, wxString const& tooltip, Handler const& handler);
|
|
|
|
wxComboBox *MakeComboBox(wxString const& initial_text, int style, void (SubsEditBox::*handler)(wxCommandEvent&), wxString const& tooltip);
|
|
|
|
wxRadioButton *MakeRadio(wxString const& text, bool start, wxString const& tooltip);
|
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
void OnChange(wxStyledTextEvent &event);
|
|
|
|
void OnKeyDown(wxKeyEvent &event);
|
2006-12-24 05:54:35 +01:00
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
void OnActiveLineChanged(AssDialogue *new_line);
|
|
|
|
void OnSelectedSetChanged(const Selection &, const Selection &);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
void OnFrameTimeRadio(wxCommandEvent &event);
|
2006-01-16 22:02:54 +01:00
|
|
|
void OnStyleChange(wxCommandEvent &event);
|
|
|
|
void OnActorChange(wxCommandEvent &event);
|
2007-10-29 16:30:04 +01:00
|
|
|
void OnLayerEnter(wxCommandEvent &event);
|
2007-06-18 01:49:51 +02:00
|
|
|
void OnLayerChange(wxSpinEvent &event);
|
2010-07-20 05:11:11 +02:00
|
|
|
void OnStartTimeChange(wxCommandEvent &);
|
|
|
|
void OnEndTimeChange(wxCommandEvent &);
|
|
|
|
void OnDurationChange(wxCommandEvent &);
|
|
|
|
void OnMarginLChange(wxCommandEvent &);
|
|
|
|
void OnMarginRChange(wxCommandEvent &);
|
|
|
|
void OnMarginVChange(wxCommandEvent &);
|
|
|
|
void OnCommentChange(wxCommandEvent &);
|
|
|
|
void OnEffectChange(wxCommandEvent &);
|
2006-12-27 01:00:41 +01:00
|
|
|
void OnSize(wxSizeEvent &event);
|
2011-12-22 22:31:09 +01:00
|
|
|
void OnUndoTimer(wxTimerEvent&);
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-01-20 06:14:44 +01:00
|
|
|
void OnFlagButton(bool (AssStyle::*field), const char *tag, wxString const& undo_msg);
|
|
|
|
void OnColorButton(AssColor (AssStyle::*field), const char *tag, const char *alt);
|
|
|
|
void OnFontButton();
|
2010-07-20 05:11:11 +02:00
|
|
|
|
2012-01-20 06:14:50 +01:00
|
|
|
void SetPlaceholderCtrl(wxControl *ctrl, wxString const& value);
|
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @brief Set the value of a tag for the currently selected text
|
|
|
|
/// @param tag Tag to set
|
|
|
|
/// @param value New value of tag
|
|
|
|
/// @param atEnd Set the value at the end of the selection rather than beginning
|
|
|
|
void SetTag(wxString tag, wxString value, bool atEnd = false);
|
|
|
|
|
|
|
|
/// @brief Callback function for the color picker
|
|
|
|
/// @param newColor New color selected in the picker
|
|
|
|
void SetColorCallback(wxColor newColor);
|
|
|
|
|
|
|
|
/// Which color is currently being set
|
|
|
|
wxString colorTag;
|
|
|
|
|
|
|
|
/// @brief Set a field in each selected line to a specified value
|
|
|
|
/// @param set Callable which does the setting
|
|
|
|
/// @param value Value to pass to set
|
|
|
|
/// @param desc Undo description to use
|
2011-09-15 07:16:32 +02:00
|
|
|
/// @param type Commit type to use
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @param amend Coalesce sequences of commits of the same type
|
|
|
|
template<class T, class setter>
|
2011-09-15 07:16:32 +02:00
|
|
|
void SetSelectedRows(setter set, T value, wxString desc, int type, bool amend = false);
|
2010-07-20 05:11:11 +02:00
|
|
|
|
|
|
|
/// @brief Set a field in each selected line to a specified value
|
|
|
|
/// @param field Field to set
|
|
|
|
/// @param value Value to set the field to
|
|
|
|
/// @param desc Undo description to use
|
2011-09-15 07:16:32 +02:00
|
|
|
/// @param type Commit type to use
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @param amend Coalesce sequences of commits of the same type
|
|
|
|
template<class T>
|
2011-09-15 07:16:32 +02:00
|
|
|
void SetSelectedRows(T AssDialogue::*field, T value, wxString desc, int type, bool amend = false);
|
2010-12-07 20:09:28 +01:00
|
|
|
|
|
|
|
/// @brief Reload the current line from the file
|
|
|
|
/// @param type AssFile::CommitType
|
2011-12-28 22:27:22 +01:00
|
|
|
void OnCommit(int type);
|
2010-12-31 22:03:18 +01:00
|
|
|
|
2011-10-19 06:05:09 +02:00
|
|
|
/// Regenerate the contents of the actor dropdown list
|
|
|
|
void PopulateActorList();
|
|
|
|
|
2010-12-31 22:03:18 +01:00
|
|
|
/// @brief Enable or disable frame timing mode
|
|
|
|
void UpdateFrameTiming(agi::vfr::Framerate const& fps);
|
2010-06-26 13:32:16 +02:00
|
|
|
public:
|
2006-01-16 22:02:54 +01:00
|
|
|
SubsTextEditCtrl *TextEdit;
|
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @brief Constructor
|
|
|
|
/// @param parent Parent window
|
2011-01-16 08:17:36 +01:00
|
|
|
SubsEditBox(wxWindow *parent, agi::Context *context);
|
2009-05-18 07:33:49 +02:00
|
|
|
~SubsEditBox();
|
2006-01-16 22:02:54 +01:00
|
|
|
};
|