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/
|
|
|
|
|
2012-12-02 16:52:40 +01:00
|
|
|
#include <array>
|
2012-09-25 01:47:38 +02:00
|
|
|
#include <boost/container/map.hpp>
|
2012-12-04 23:35:59 +01:00
|
|
|
#include <boost/flyweight/flyweight_fwd.hpp>
|
2010-07-20 05:11:11 +02:00
|
|
|
#include <vector>
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <wx/combobox.h>
|
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
|
|
|
|
2011-09-15 07:17:00 +02:00
|
|
|
#include <libaegisub/signal.h>
|
|
|
|
|
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; }
|
2014-07-06 16:28:58 +02:00
|
|
|
namespace agi { class Time; }
|
2010-06-26 13:32:16 +02:00
|
|
|
class AssDialogue;
|
2014-05-04 21:46:59 +02:00
|
|
|
class AssStyle;
|
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 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;
|
2014-03-07 18:02:24 +01:00
|
|
|
struct AssDialogueBase;
|
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
|
|
|
|
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
|
2014-03-13 02:39:07 +01:00
|
|
|
class SubsEditBox final : public wxPanel {
|
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
|
|
|
|
2014-05-22 01:23:28 +02:00
|
|
|
std::vector<agi::signal::Connection> connections;
|
2012-10-05 05:22:54 +02:00
|
|
|
|
2010-07-20 05:11:11 +02:00
|
|
|
/// Currently active dialogue line
|
2013-12-12 01:29:48 +01:00
|
|
|
AssDialogue *line = nullptr;
|
2014-05-04 21:46:59 +02:00
|
|
|
AssStyle *active_style = nullptr;
|
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?
|
2013-12-12 01:29:48 +01:00
|
|
|
bool button_bar_split = true;
|
2010-07-20 05:11:11 +02:00
|
|
|
/// Are the controls currently enabled?
|
2013-12-12 01:29:48 +01:00
|
|
|
bool controls_enabled = true;
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
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
|
2012-12-10 19:18:00 +01:00
|
|
|
wxCheckBox *comment_box;
|
|
|
|
wxComboBox *style_box;
|
2014-05-04 21:46:59 +02:00
|
|
|
wxButton *style_edit_button;
|
2012-12-10 19:18:00 +01:00
|
|
|
Placeholder<wxComboBox> *actor_box;
|
|
|
|
TimeEdit *start_time;
|
|
|
|
TimeEdit *end_time;
|
|
|
|
TimeEdit *duration;
|
|
|
|
wxSpinCtrl *layer;
|
|
|
|
std::array<wxTextCtrl *, 3> margin;
|
|
|
|
Placeholder<wxComboBox> *effect_box;
|
|
|
|
wxRadioButton *by_time;
|
|
|
|
wxRadioButton *by_frame;
|
|
|
|
wxTextCtrl *char_count;
|
2012-10-12 01:46:53 +02:00
|
|
|
wxCheckBox *split_box;
|
2012-12-10 19:18:00 +01:00
|
|
|
|
|
|
|
wxSizer *top_sizer;
|
|
|
|
wxSizer *middle_right_sizer;
|
|
|
|
wxSizer *middle_left_sizer;
|
2012-10-12 01:46:53 +02:00
|
|
|
wxSizer *bottom_sizer;
|
2006-12-27 01:00:41 +01:00
|
|
|
|
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
|
2012-10-09 04:07:54 +02:00
|
|
|
void CommitText(wxString const& desc);
|
2014-12-28 21:45:55 +01:00
|
|
|
void Commit(wxString const& desc, int type, bool amend, AssDialogue *line);
|
2010-07-20 05:11:11 +02:00
|
|
|
|
2012-05-03 00:42:25 +02:00
|
|
|
/// Last commit ID for undo coalescing
|
2013-12-12 01:29:48 +01:00
|
|
|
int commit_id = -1;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
|
|
|
/// Last used commit message to avoid coalescing different types of changes
|
2012-12-10 19:18:00 +01:00
|
|
|
wxString last_commit_type;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
|
|
|
/// Last field to get a time commit, as they all have the same commit message
|
2012-12-10 19:18:00 +01:00
|
|
|
int last_time_commit_type;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
|
|
|
/// Timer to stop coalescing changes after a break with no edits
|
2012-12-10 19:18:00 +01:00
|
|
|
wxTimer undo_timer;
|
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
|
2014-07-06 16:28:58 +02:00
|
|
|
boost::container::map<AssDialogue *, std::pair<agi::Time, agi::Time>> initial_times;
|
2012-05-03 00:42:25 +02:00
|
|
|
|
2012-01-20 06:14:44 +01:00
|
|
|
// Constructor helpers
|
2012-12-02 16:47:59 +01:00
|
|
|
wxTextCtrl *MakeMarginCtrl(wxString const& tooltip, int margin, wxString const& commit_msg);
|
2012-12-02 16:36:24 +01:00
|
|
|
TimeEdit *MakeTimeCtrl(wxString const& tooltip, TimeField field);
|
2012-10-09 04:07:54 +02:00
|
|
|
void MakeButton(const char *cmd_name);
|
2012-10-12 01:46:53 +02:00
|
|
|
wxButton *MakeBottomButton(const char *cmd_name);
|
2012-01-20 06:14:44 +01:00
|
|
|
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);
|
2014-03-05 17:28:14 +01:00
|
|
|
void OnSelectedSetChanged();
|
2013-01-04 16:01:50 +01:00
|
|
|
void OnLineInitialTextChanged(std::string const& new_text);
|
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);
|
2010-07-20 05:11:11 +02:00
|
|
|
void OnCommentChange(wxCommandEvent &);
|
|
|
|
void OnEffectChange(wxCommandEvent &);
|
2006-12-27 01:00:41 +01:00
|
|
|
void OnSize(wxSizeEvent &event);
|
2012-10-12 01:46:53 +02:00
|
|
|
void OnSplit(wxCommandEvent&);
|
2006-01-16 22:02:54 +01: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 a field in each selected line to a specified value
|
2012-12-02 16:47:59 +01:00
|
|
|
/// @param set Callable which updates a passed line
|
2010-07-20 05:11:11 +02:00
|
|
|
/// @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
|
2012-12-02 16:47:59 +01:00
|
|
|
template<class setter>
|
|
|
|
void SetSelectedRows(setter set, wxString const& 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>
|
2014-03-07 18:02:24 +01:00
|
|
|
void SetSelectedRows(T AssDialogueBase::*field, T value, wxString const& desc, int type, bool amend = false);
|
2010-12-07 20:09:28 +01:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
template<class T>
|
2014-03-07 18:02:24 +01:00
|
|
|
void SetSelectedRows(T AssDialogueBase::*field, wxString const& value, wxString const& desc, int type, bool amend = false);
|
2013-01-04 16:01:50 +01:00
|
|
|
|
2010-12-07 20:09:28 +01:00
|
|
|
/// @brief Reload the current line from the file
|
2013-01-26 02:57:46 +01:00
|
|
|
/// @param type AssFile::COMMITType
|
2011-12-28 22:27:22 +01:00
|
|
|
void OnCommit(int type);
|
2010-12-31 22:03:18 +01:00
|
|
|
|
2014-04-19 04:10:05 +02:00
|
|
|
void UpdateFields(int type, bool repopulate_lists);
|
|
|
|
|
2012-10-20 16:34:55 +02:00
|
|
|
/// Regenerate a dropdown list with the unique values of a dialogue field
|
2013-01-04 16:01:50 +01:00
|
|
|
void PopulateList(wxComboBox *combo, boost::flyweight<std::string> AssDialogue::*field);
|
2011-10-19 06:05:09 +02:00
|
|
|
|
2010-12-31 22:03:18 +01:00
|
|
|
/// @brief Enable or disable frame timing mode
|
|
|
|
void UpdateFrameTiming(agi::vfr::Framerate const& fps);
|
2012-10-08 16:32:51 +02:00
|
|
|
|
2012-12-06 19:01:47 +01:00
|
|
|
/// Update the character count box for the given text
|
2013-01-04 16:01:50 +01:00
|
|
|
void UpdateCharacterCount(std::string const& text);
|
2012-12-06 19:01:47 +01:00
|
|
|
|
2012-10-11 04:01:31 +02:00
|
|
|
/// Call a command the restore focus to the edit box
|
|
|
|
void CallCommand(const char *cmd_name);
|
|
|
|
|
2014-04-15 17:41:58 +02:00
|
|
|
void SetDurationField();
|
|
|
|
|
2012-12-10 19:18:00 +01:00
|
|
|
SubsTextEditCtrl *edit_ctrl;
|
2012-10-12 01:46:53 +02:00
|
|
|
wxTextCtrl *secondary_editor;
|
2006-01-16 22:02:54 +01:00
|
|
|
|
2012-10-08 16:32:51 +02:00
|
|
|
public:
|
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
|
|
|
};
|