Kill SubtitlesGrid::ass and SubtitlesGrid::EditBox and convert everything that used them over to agi::Context

Originally committed to SVN as r5215.
This commit is contained in:
Thomas Goyne 2011-01-16 07:17:36 +00:00
parent 778338fa2b
commit df1dce3593
35 changed files with 471 additions and 908 deletions

View File

@ -46,10 +46,11 @@
#include <wx/sizer.h> #include <wx/sizer.h>
#endif #endif
#include "include/aegisub/hotkey.h"
#include "base_grid.h" #include "base_grid.h"
#include "include/aegisub/context.h"
#include "include/aegisub/hotkey.h"
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "ass_style.h" #include "ass_style.h"
@ -70,33 +71,20 @@ static inline void set_difference(const S1 &src1, const S2 &src2, D &dst) {
std::inserter(dst, dst.begin())); std::inserter(dst, dst.begin()));
} }
BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, long style, const wxString& name)
/// @brief Constructor : wxWindow(parent, -1, wxDefaultPosition, size, style, name)
/// @param parent , lineHeight(1) // non-zero to avoid div by 0
/// @param id , lastRow(-1)
/// @param pos , extendRow(-1)
/// @param size , holding(false)
/// @param style , bmp(0)
/// @param name , active_line(0)
/// , batch_level(0)
BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) , batch_active_line_changed(false)
: wxWindow(parent, id, pos, size, style, name) , context(context)
, context(VideoContext::Get()) , yPos(0)
, byFrame(false)
{ {
// Misc variables
lastRow = -1;
yPos = 0;
extendRow = -1;
bmp = NULL;
holding = false;
byFrame = false;
lineHeight = 1; // non-zero to avoid div by 0
active_line = 0;
batch_level = 0;
batch_active_line_changed = false;
// Set scrollbar
scrollBar = new wxScrollBar(this,GRID_SCROLLBAR,wxDefaultPosition,wxDefaultSize,wxSB_VERTICAL); scrollBar = new wxScrollBar(this,GRID_SCROLLBAR,wxDefaultPosition,wxDefaultSize,wxSB_VERTICAL);
scrollBar->SetScrollbar(0,10,100,10); scrollBar->SetScrollbar(0,10,100,10);
@ -128,8 +116,6 @@ BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wx
OPT_SUB("Subtitle/Grid/Highlight Subtitles in Frame", Refresh); OPT_SUB("Subtitle/Grid/Highlight Subtitles in Frame", Refresh);
} }
/// @brief Destructor /// @brief Destructor
/// ///
BaseGrid::~BaseGrid() { BaseGrid::~BaseGrid() {
@ -137,8 +123,6 @@ BaseGrid::~BaseGrid() {
delete bmp; delete bmp;
} }
/// @brief Update style /// @brief Update style
/// ///
void BaseGrid::UpdateStyle() { void BaseGrid::UpdateStyle() {
@ -645,11 +629,11 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Lines // Lines
else if (curDiag) { else if (curDiag) {
// Set fields // Set fields
strings.Add(wxString::Format(_T("%i"),curRow+1)); strings.Add(wxString::Format("%i",curRow+1));
strings.Add(wxString::Format(_T("%i"),curDiag->Layer)); strings.Add(wxString::Format("%i",curDiag->Layer));
if (byFrame) { if (byFrame) {
strings.Add(wxString::Format(_T("%i"),context->FrameAtTime(curDiag->Start.GetMS(),agi::vfr::START))); strings.Add(wxString::Format("%i",context->videoController->FrameAtTime(curDiag->Start.GetMS(),agi::vfr::START)));
strings.Add(wxString::Format(_T("%i"),context->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END))); strings.Add(wxString::Format("%i",context->videoController->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END)));
} }
else { else {
strings.Add(curDiag->Start.GetASSFormated()); strings.Add(curDiag->Start.GetASSFormated());
@ -664,7 +648,7 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Set text // Set text
int mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt(); int mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt();
wxString value = _T(""); wxString value;
// Hidden overrides // Hidden overrides
if (mode == 1 || mode == 2) { if (mode == 1 || mode == 2) {
@ -878,7 +862,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
if (dlg == GetActiveLine()) { if (dlg == GetActiveLine()) {
SetActiveLine(GetDialogue(GetFirstSelRow())); SetActiveLine(GetDialogue(GetFirstSelRow()));
} }
parentFrame->UpdateToolbar(); wxGetApp().frame->UpdateToolbar();
lastRow = row; lastRow = row;
return; return;
} }
@ -886,9 +870,9 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
// Normal click // Normal click
if ((click || dclick) && !shift && !ctrl && !alt) { if ((click || dclick) && !shift && !ctrl && !alt) {
SetActiveLine(dlg); SetActiveLine(dlg);
if (dclick) context->JumpToTime(dlg->Start.GetMS()); if (dclick) context->videoController->JumpToTime(dlg->Start.GetMS());
SelectRow(row,false); SelectRow(row,false);
parentFrame->UpdateToolbar(); wxGetApp().frame->UpdateToolbar();
lastRow = row; lastRow = row;
return; return;
} }
@ -917,7 +901,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
} }
SetSelectedSet(newsel); SetSelectedSet(newsel);
parentFrame->UpdateToolbar(); wxGetApp().frame->UpdateToolbar();
} }
return; return;
} }
@ -1058,9 +1042,9 @@ void BaseGrid::SetColumnWidths() {
// Times // Times
if (byFrame) { if (byFrame) {
int tmp = context->FrameAtTime(curDiag->Start.GetMS(),agi::vfr::START); int tmp = context->videoController->FrameAtTime(curDiag->Start.GetMS(),agi::vfr::START);
if (tmp > maxStart) maxStart = tmp; if (tmp > maxStart) maxStart = tmp;
tmp = context->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END); tmp = context->videoController->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END);
if (tmp > maxEnd) maxEnd = tmp; if (tmp > maxEnd) maxEnd = tmp;
} }
} }
@ -1132,13 +1116,12 @@ int BaseGrid::GetDialogueIndex(AssDialogue *diag) const {
/// @param line /// @param line
/// @return /// @return
/// ///
bool BaseGrid::IsDisplayed(AssDialogue *line) { bool BaseGrid::IsDisplayed(const AssDialogue *line) const {
VideoContext* con = VideoContext::Get(); if (!context->videoController->IsLoaded()) return false;
if (!con->IsLoaded()) return false; int frame = context->videoController->GetFrameN();
int frame = con->GetFrameN();
return return
con->FrameAtTime(line->Start.GetMS(),agi::vfr::START) <= frame && context->videoController->FrameAtTime(line->Start.GetMS(),agi::vfr::START) <= frame &&
con->FrameAtTime(line->End.GetMS(),agi::vfr::END) >= frame; context->videoController->FrameAtTime(line->End.GetMS(),agi::vfr::END) >= frame;
} }
/// @brief Key press /// @brief Key press
@ -1166,7 +1149,7 @@ void BaseGrid::OnKeyDown(wxKeyEvent &event) {
// Left/right, forward to seek bar if video is loaded // Left/right, forward to seek bar if video is loaded
if (key == WXK_LEFT || key == WXK_RIGHT) { if (key == WXK_LEFT || key == WXK_RIGHT) {
if (context->IsLoaded()) { if (context->videoController->IsLoaded()) {
/// todo: is this nessesary, or can left/right just be in the Subtitle Grid category? /// todo: is this nessesary, or can left/right just be in the Subtitle Grid category?
hotkey::check("Video", event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers()); hotkey::check("Video", event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers());
} }

View File

@ -48,11 +48,10 @@
#include "selection_controller.h" #include "selection_controller.h"
namespace agi { struct Context; }
class AssEntry; class AssEntry;
class AssDialogue; class AssDialogue;
class SubsEditBox; class SubsEditBox;
class FrameMain;
class VideoContext;
/// DOCME /// DOCME
typedef std::list<AssEntry*>::iterator entryIter; typedef std::list<AssEntry*>::iterator entryIter;
@ -112,10 +111,7 @@ protected:
/// DOCME /// DOCME
int colWidth[16]; int colWidth[16];
/// DOCME agi::Context *context;
FrameMain *parentFrame;
VideoContext *context;
/// DOCME /// DOCME
static const int columns = 10; static const int columns = 10;
@ -145,10 +141,6 @@ public:
virtual void PrevLine(); virtual void PrevLine();
public: public:
/// DOCME
SubsEditBox *editBox;
/// DOCME /// DOCME
bool byFrame; bool byFrame;
@ -161,7 +153,7 @@ public:
void SelectRow(int row, bool addToSelected = false, bool select=true); void SelectRow(int row, bool addToSelected = false, bool select=true);
void ClearSelection(); void ClearSelection();
bool IsInSelection(int row, int col=0) const; bool IsInSelection(int row, int col=0) const;
static bool IsDisplayed(AssDialogue *line); bool IsDisplayed(const AssDialogue *line) const;
int GetNumberSelection() const; int GetNumberSelection() const;
int GetFirstSelRow() const; int GetFirstSelRow() const;
int GetLastSelRow() const; int GetLastSelRow() const;
@ -182,7 +174,7 @@ public:
AssDialogue *GetDialogue(int n) const; AssDialogue *GetDialogue(int n) const;
int GetDialogueIndex(AssDialogue *diag) const; int GetDialogueIndex(AssDialogue *diag) const;
BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr); BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
~BaseGrid(); ~BaseGrid();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@ -114,7 +114,7 @@ struct time_frame_current : public Command {
} }
// Commit // Commit
c->subsGrid->ass->Commit(_("shift to frame"), AssFile::COMMIT_TIMES); c->ass->Commit(_("shift to frame"), AssFile::COMMIT_TIMES);
} }
}; };
@ -128,7 +128,7 @@ struct time_shift : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoController->Stop(); c->videoController->Stop();
DialogShiftTimes(c->parent, c->subsGrid).ShowModal(); DialogShiftTimes(c).ShowModal();
} }
}; };
@ -226,7 +226,7 @@ struct time_snap_scene : public Command {
} }
// Commit // Commit
c->subsGrid->ass->Commit(_("snap to scene"), AssFile::COMMIT_TIMES); c->ass->Commit(_("snap to scene"), AssFile::COMMIT_TIMES);
} }
}; };

View File

@ -84,7 +84,7 @@ struct tool_export : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoController->Stop(); c->videoController->Stop();
DialogResample(c->parent, c->subsGrid).ShowModal(); DialogResample(c).ShowModal();
} }
}; };
@ -126,7 +126,7 @@ struct tool_resampleres : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoController->Stop(); c->videoController->Stop();
DialogResample(c->parent, c->subsGrid).ShowModal(); DialogResample(c).ShowModal();
} }
}; };
@ -155,7 +155,7 @@ struct tool_style_manager : public Command {
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
c->videoController->Stop(); c->videoController->Stop();
DialogStyleManager(c->parent, c->subsGrid).ShowModal(); DialogStyleManager(c).ShowModal();
} }
}; };
@ -168,7 +168,7 @@ struct tool_time_kanji : public Command {
STR_HELP("Open Kanji timer.") STR_HELP("Open Kanji timer.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
DialogKanjiTimer(c->parent, c->subsGrid).ShowModal(); DialogKanjiTimer(c).ShowModal();
} }
}; };
@ -181,7 +181,7 @@ struct tool_time_postprocess : public Command {
STR_HELP("Runs a post-processor for timing to deal with lead-ins, lead-outs, scene timing and etc.") STR_HELP("Runs a post-processor for timing to deal with lead-ins, lead-outs, scene timing and etc.")
void operator()(agi::Context *c) { void operator()(agi::Context *c) {
DialogTimingProcessor(c->parent, c->subsGrid).ShowModal(); DialogTimingProcessor(c).ShowModal();
} }
}; };

View File

@ -53,6 +53,7 @@
#include "ass_style.h" #include "ass_style.h"
#include "dialog_kara_timing_copy.h" #include "dialog_kara_timing_copy.h"
#include "help_button.h" #include "help_button.h"
#include "include/aegisub/context.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
#include "selection_controller.h" #include "selection_controller.h"
@ -68,7 +69,18 @@
/// DOCME /// DOCME
#define TEXT_LABEL_DEST _("Dest: ") #define TEXT_LABEL_DEST _("Dest: ")
// IDs
enum {
BUTTON_KTSTART = 2500,
BUTTON_KTLINK,
BUTTON_KTUNLINK,
BUTTON_KTSKIPSOURCE,
BUTTON_KTSKIPDEST,
BUTTON_KTGOBACK,
BUTTON_KTACCEPT,
TEXT_SOURCE,
TEXT_DEST
};
/// DOCME /// DOCME
/// @class KaraokeLineMatchDisplay /// @class KaraokeLineMatchDisplay
@ -823,15 +835,15 @@ bool KaraokeLineMatchDisplay::UndoMatch()
/// @param parent /// @param parent
/// @param _grid /// @param _grid
/// ///
DialogKanjiTimer::DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *_grid) DialogKanjiTimer::DialogKanjiTimer(agi::Context *c)
: wxDialog (parent,-1,_("Kanji timing"),wxDefaultPosition) : wxDialog(c->parent,-1,_("Kanji timing"),wxDefaultPosition)
{ {
// Set icon // Set icon
SetIcon(BitmapToIcon(GETIMAGE(kara_timing_copier_24))); SetIcon(BitmapToIcon(GETIMAGE(kara_timing_copier_24)));
// Variables // Variables
subs = _grid->ass; subs = c->ass;
grid = _grid; grid = c->subsGrid;
currentSourceLine = subs->Line.begin(); currentSourceLine = subs->Line.begin();
currentDestinationLine = subs->Line.begin(); currentDestinationLine = subs->Line.begin();
@ -941,7 +953,7 @@ void DialogKanjiTimer::OnClose(wxCommandEvent &event) {
line->Text = p.second; line->Text = p.second;
} }
if (modified) { if (modified) {
grid->ass->Commit(_("kanji timing")); subs->Commit(_("kanji timing"));
LinesToChange.clear(); LinesToChange.clear();
} }
Close(); Close();

View File

@ -34,11 +34,6 @@
/// @ingroup tools_ui kara_timing_copy /// @ingroup tools_ui kara_timing_copy
/// ///
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <vector> #include <vector>
@ -53,13 +48,10 @@
#include "ass_file.h" #include "ass_file.h"
#include "kana_table.h" #include "kana_table.h"
namespace agi { struct Context; }
//////////////
// Prototypes
class SubtitlesGrid;
class AssOverrideParameter; class AssOverrideParameter;
class KaraokeLineMatchDisplay; class KaraokeLineMatchDisplay;
class SubtitlesGrid;
/// DOCME /// DOCME
@ -114,40 +106,7 @@ class DialogKanjiTimer : public wxDialog {
entryIter FindPrevStyleMatch(entryIter search_from, const wxString &search_style); entryIter FindPrevStyleMatch(entryIter search_from, const wxString &search_style);
public: public:
DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *grid); DialogKanjiTimer(agi::Context *context);
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
///////
// IDs
enum {
/// DOCME
BUTTON_KTSTART = 2500,
/// DOCME
BUTTON_KTLINK,
/// DOCME
BUTTON_KTUNLINK,
/// DOCME
BUTTON_KTSKIPSOURCE,
/// DOCME
BUTTON_KTSKIPDEST,
/// DOCME
BUTTON_KTGOBACK,
/// DOCME
BUTTON_KTACCEPT,
/// DOCME
TEXT_SOURCE,
/// DOCME
TEXT_DEST
};

View File

@ -34,38 +34,43 @@
/// @ingroup tools_ui /// @ingroup tools_ui
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <wx/msgdlg.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
#endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "ass_override.h" #include "ass_override.h"
#include "ass_style.h" #include "ass_style.h"
#include "dialog_resample.h" #include "dialog_resample.h"
#include "include/aegisub/context.h"
#include "help_button.h" #include "help_button.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "subs_grid.h"
#include "utils.h" #include "utils.h"
#include "validators.h" #include "validators.h"
#include "video_context.h" #include "video_context.h"
// IDs
enum {
BUTTON_DEST_FROM_VIDEO = 1520,
CHECK_ANAMORPHIC,
CHECK_SYMMETRICAL,
TEXT_MARGIN_T,
TEXT_MARGIN_L,
TEXT_MARGIN_R,
TEXT_MARGIN_B
};
/// @brief Constructor DialogResample::DialogResample(agi::Context *c)
/// @param parent : wxDialog(c->parent,-1,_("Resample resolution"),wxDefaultPosition)
/// @param _grid
///
DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid)
: wxDialog (parent,-1,_("Resample resolution"),wxDefaultPosition)
{ {
// Set icon // Set icon
SetIcon(BitmapToIcon(GETIMAGE(resample_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(resample_toolbutton_24)));
// Variables
AssFile *subs = _grid->ass;
grid = _grid;
// Margins // Margins
MarginSymmetrical = NULL; // Do not remove this MarginSymmetrical = NULL; // Do not remove this
wxSizer *MarginBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Margin offset")); wxSizer *MarginBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Margin offset"));
@ -93,7 +98,7 @@ DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid)
wxSizer *ResBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Resolution")); wxSizer *ResBoxSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Resolution"));
wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL); wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL);
int sw,sh; int sw,sh;
subs->GetResolution(sw,sh); c->ass->GetResolution(sw,sh);
ResXValue = wxString::Format(_T("%i"),sw); ResXValue = wxString::Format(_T("%i"),sw);
ResYValue = wxString::Format(_T("%i"),sh); ResYValue = wxString::Format(_T("%i"),sh);
ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(&ResXValue)); ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(&ResXValue));
@ -222,10 +227,8 @@ void DialogResample::DoResampleTags (wxString name,int n,AssOverrideParameter *c
/// @return /// @return
/// ///
void DialogResample::OnResample (wxCommandEvent &event) { void DialogResample::OnResample (wxCommandEvent &event) {
// Resolutions
AssFile *subs = grid->ass;
int x1,y1; int x1,y1;
subs->GetResolution(x1,y1); c->ass->GetResolution(x1,y1);
long x2 = 0; long x2 = 0;
long y2 = 0; long y2 = 0;
ResX->GetValue().ToLong(&x2); ResX->GetValue().ToLong(&x2);
@ -261,7 +264,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
// Iterate through subs // Iterate through subs
AssStyle *curStyle; AssStyle *curStyle;
AssDialogue *curDiag; AssDialogue *curDiag;
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur++) { for (entryIter cur=c->ass->Line.begin();cur!=c->ass->Line.end();cur++) {
// Apply to dialogues // Apply to dialogues
curDiag = dynamic_cast<AssDialogue*>(*cur); curDiag = dynamic_cast<AssDialogue*>(*cur);
if (curDiag && !(curDiag->Comment && (curDiag->Effect.StartsWith(_T("template")) || curDiag->Effect.StartsWith(_T("code"))))) { if (curDiag && !(curDiag->Comment && (curDiag->Effect.StartsWith(_T("template")) || curDiag->Effect.StartsWith(_T("code"))))) {
@ -316,11 +319,11 @@ void DialogResample::OnResample (wxCommandEvent &event) {
} }
// Change script resolution // Change script resolution
subs->SetScriptInfo(_T("PlayResX"),wxString::Format(_T("%i"),x2)); c->ass->SetScriptInfo(_T("PlayResX"),wxString::Format(_T("%i"),x2));
subs->SetScriptInfo(_T("PlayResY"),wxString::Format(_T("%i"),y2)); c->ass->SetScriptInfo(_T("PlayResY"),wxString::Format(_T("%i"),y2));
// Flag as modified // Flag as modified
subs->Commit(_("resolution resampling"), AssFile::COMMIT_TEXT); c->ass->Commit(_("resolution resampling"), AssFile::COMMIT_TEXT);
EndModal(0); EndModal(0);
} }
@ -364,9 +367,5 @@ void DialogResample::OnMarginChange (wxCommandEvent &event) {
} }
} }
/// DOCME /// DOCME
DialogResample *DialogResample::instance = NULL; DialogResample *DialogResample::instance = NULL;

View File

@ -34,11 +34,6 @@
/// @ingroup tools_ui /// @ingroup tools_ui
/// ///
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -46,10 +41,7 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#endif #endif
namespace agi { struct Context; }
//////////////
// Prototypes
class SubtitlesGrid;
class AssOverrideParameter; class AssOverrideParameter;
@ -60,10 +52,7 @@ class AssOverrideParameter;
/// ///
/// DOCME /// DOCME
class DialogResample : public wxDialog { class DialogResample : public wxDialog {
private: agi::Context *c;
/// DOCME
SubtitlesGrid *grid;
/// DOCME /// DOCME
@ -119,34 +108,7 @@ private:
void DoResampleTags (wxString name,int n,AssOverrideParameter *curParam,void *_curDiag); void DoResampleTags (wxString name,int n,AssOverrideParameter *curParam,void *_curDiag);
public: public:
DialogResample(wxWindow *parent, SubtitlesGrid *grid); DialogResample(agi::Context *context);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
///////
// IDs
enum {
/// DOCME
BUTTON_DEST_FROM_VIDEO = 1520,
/// DOCME
CHECK_ANAMORPHIC,
/// DOCME
CHECK_SYMMETRICAL,
/// DOCME
TEXT_MARGIN_T,
/// DOCME
TEXT_MARGIN_L,
/// DOCME
TEXT_MARGIN_R,
/// DOCME
TEXT_MARGIN_B
};

View File

@ -34,9 +34,6 @@
/// @ingroup secondary_ui /// @ingroup secondary_ui
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE #ifndef AGI_PRE
@ -48,6 +45,7 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "dialog_search_replace.h" #include "dialog_search_replace.h"
#include "include/aegisub/context.h"
#include "frame_main.h" #include "frame_main.h"
#include "main.h" #include "main.h"
#include "selection_controller.h" #include "selection_controller.h"
@ -56,6 +54,15 @@
#include "subs_grid.h" #include "subs_grid.h"
#include "video_display.h" #include "video_display.h"
// IDs
enum {
BUTTON_FIND_NEXT,
BUTTON_REPLACE_NEXT,
BUTTON_REPLACE_ALL,
CHECK_MATCH_CASE,
CHECK_REGEXP,
CHECK_UPDATE_VIDEO
};
/// @brief Constructor /// @brief Constructor
/// @param parent /// @param parent
@ -234,7 +241,7 @@ void DialogSearchReplace::FindReplace(int mode) {
wxString ReplaceWith = ReplaceEdit->GetValue(); wxString ReplaceWith = ReplaceEdit->GetValue();
Search.ReplaceWith = ReplaceWith; Search.ReplaceWith = ReplaceWith;
config::mru->Add("Replace", STD_STR(ReplaceWith)); config::mru->Add("Replace", STD_STR(ReplaceWith));
} }
} }
// Replace // Replace
@ -346,7 +353,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
return; return;
} }
wxArrayInt sels = grid->GetSelection(); wxArrayInt sels = context->subsGrid->GetSelection();
int firstLine = 0; int firstLine = 0;
if (sels.Count() > 0) firstLine = sels[0]; if (sels.Count() > 0) firstLine = sels[0];
// if selection has changed reset values // if selection has changed reset values
@ -361,7 +368,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
// Setup // Setup
int start = curLine; int start = curLine;
int nrows = grid->GetRows(); int nrows = context->subsGrid->GetRows();
bool found = false; bool found = false;
wxString *Text = NULL; wxString *Text = NULL;
size_t tempPos; size_t tempPos;
@ -434,7 +441,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
} }
// Commit // Commit
grid->ass->Commit(_("replace"), AssFile::COMMIT_TEXT); context->ass->Commit(_("replace"), AssFile::COMMIT_TEXT);
} }
else { else {
@ -442,16 +449,16 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
} }
// Select // Select
grid->SelectRow(curLine,false); context->subsGrid->SelectRow(curLine,false);
grid->MakeCellVisible(curLine,0); context->subsGrid->MakeCellVisible(curLine,0);
if (field == 0) { if (field == 0) {
grid->SetActiveLine(grid->GetDialogue(curLine)); context->subsGrid->SetActiveLine(context->subsGrid->GetDialogue(curLine));
grid->editBox->TextEdit->SetSelectionU(pos,pos+replaceLen); context->editBox->TextEdit->SetSelectionU(pos,pos+replaceLen);
} }
// Update video // Update video
if (updateVideo) { if (updateVideo) {
grid->SetVideoToSubs(true); context->subsGrid->SetVideoToSubs(true);
} }
else if (DoReplace) Modified = true; else if (DoReplace) Modified = true;
@ -468,7 +475,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
void SearchReplaceEngine::ReplaceAll() { void SearchReplaceEngine::ReplaceAll() {
// Setup // Setup
wxString *Text; wxString *Text;
int nrows = grid->GetRows(); int nrows = context->subsGrid->GetRows();
size_t count = 0; size_t count = 0;
int regFlags = wxRE_ADVANCED; int regFlags = wxRE_ADVANCED;
if (!matchCase) { if (!matchCase) {
@ -476,11 +483,11 @@ void SearchReplaceEngine::ReplaceAll() {
//else LookFor.MakeLower(); //else LookFor.MakeLower();
} }
bool replaced; bool replaced;
grid->BeginBatch(); context->subsGrid->BeginBatch();
// Selection // Selection
bool hasSelection = false; bool hasSelection = false;
wxArrayInt sels = grid->GetSelection(); wxArrayInt sels = context->subsGrid->GetSelection();
if (sels.Count() > 0) hasSelection = true; if (sels.Count() > 0) hasSelection = true;
bool inSel = false; bool inSel = false;
if (affect == 1) inSel = true; if (affect == 1) inSel = true;
@ -538,7 +545,7 @@ void SearchReplaceEngine::ReplaceAll() {
// Commit // Commit
if (count > 0) { if (count > 0) {
grid->ass->Commit(_("replace"), AssFile::COMMIT_TEXT); context->ass->Commit(_("replace"), AssFile::COMMIT_TEXT);
wxMessageBox(wxString::Format(_("%i matches were replaced."),count)); wxMessageBox(wxString::Format(_("%i matches were replaced."),count));
} }
@ -546,7 +553,7 @@ void SearchReplaceEngine::ReplaceAll() {
else { else {
wxMessageBox(_("No matches found.")); wxMessageBox(_("No matches found."));
} }
grid->EndBatch(); context->subsGrid->EndBatch();
LastWasFind = false; LastWasFind = false;
} }
@ -556,7 +563,7 @@ void SearchReplaceEngine::ReplaceAll() {
/// ///
void SearchReplaceEngine::OnDialogOpen() { void SearchReplaceEngine::OnDialogOpen() {
// Set curline // Set curline
wxArrayInt sels = grid->GetSelection(); wxArrayInt sels = context->subsGrid->GetSelection();
curLine = 0; curLine = 0;
if (sels.Count() > 0) curLine = sels[0]; if (sels.Count() > 0) curLine = sels[0];
@ -603,7 +610,7 @@ void SearchReplaceEngine::OpenDialog (bool replace) {
/// @return /// @return
/// ///
wxString *SearchReplaceEngine::GetText(int n,int field) { wxString *SearchReplaceEngine::GetText(int n,int field) {
AssDialogue *cur = grid->GetDialogue(n); AssDialogue *cur = context->subsGrid->GetDialogue(n);
if (field == 0) return &cur->Text; if (field == 0) return &cur->Text;
else if (field == 1) return &cur->Style; else if (field == 1) return &cur->Style;
else if (field == 2) return &cur->Actor; else if (field == 2) return &cur->Actor;

View File

@ -34,11 +34,6 @@
/// @ingroup secondary_ui /// @ingroup secondary_ui
/// ///
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/combobox.h> #include <wx/combobox.h>
@ -48,11 +43,7 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#endif #endif
namespace agi { struct Context; }
//////////////
// Prototypes
class SubtitlesGrid;
/// DOCME /// DOCME
@ -61,8 +52,6 @@ class SubtitlesGrid;
/// ///
/// DOCME /// DOCME
class SearchReplaceEngine { class SearchReplaceEngine {
private:
/// DOCME /// DOCME
int curLine; int curLine;
@ -85,11 +74,10 @@ private:
bool hasReplace; bool hasReplace;
wxString *GetText(int n,int field); wxString *GetText(int n,int field);
public:
public:
/// DOCME /// DOCME
SubtitlesGrid *grid; agi::Context *context;
/// DOCME /// DOCME
bool isReg; bool isReg;
@ -186,29 +174,3 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
///////
// IDs
enum {
/// DOCME
BUTTON_FIND_NEXT,
/// DOCME
BUTTON_REPLACE_NEXT,
/// DOCME
BUTTON_REPLACE_ALL,
/// DOCME
CHECK_MATCH_CASE,
/// DOCME
CHECK_REGEXP,
/// DOCME
CHECK_UPDATE_VIDEO
};

View File

@ -34,9 +34,6 @@
/// @ingroup secondary_ui /// @ingroup secondary_ui
/// ///
///////////
// Headers
#include "config.h" #include "config.h"
#ifndef AGI_PRE #ifndef AGI_PRE
@ -46,6 +43,10 @@
#include <wx/filefn.h> #include <wx/filefn.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/listbox.h>
#include <wx/radiobox.h>
#include <wx/radiobut.h>
#include <wx/textctrl.h>
#endif #endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
@ -53,28 +54,36 @@
#include "ass_time.h" #include "ass_time.h"
#include "charset_conv.h" #include "charset_conv.h"
#include "dialog_shift_times.h" #include "dialog_shift_times.h"
#include "include/aegisub/context.h"
#include "help_button.h" #include "help_button.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
#include "standard_paths.h" #include "standard_paths.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "timeedit_ctrl.h"
#include "utils.h" #include "utils.h"
#include "video_context.h" #include "video_context.h"
#include "video_display.h"
/// @brief Constructor // IDs
/// @param parent enum {
/// @param _grid TEXT_SHIFT_TIME = 1100,
/// TEXT_SHIFT_FRAME,
DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid) RADIO_BACKWARD,
: wxDialog(parent, -1, _("Shift Times"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("JumpTo")) RADIO_FORWARD,
RADIO_TIME,
RADIO_FRAME,
SHIFT_CLEAR_HISTORY
};
DialogShiftTimes::DialogShiftTimes (agi::Context *context)
: wxDialog(context->parent, -1, _("Shift Times"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("JumpTo"))
, context(context)
{ {
// Set icon // Set icon
SetIcon(BitmapToIcon(GETIMAGE(shift_times_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(shift_times_toolbutton_24)));
// Set initial values // Set initial values
ready = true; ready = true;
grid = _grid;
shiftframe = 0; shiftframe = 0;
// Static-box sizers before anything else // Static-box sizers before anything else
@ -168,7 +177,7 @@ DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid)
if (OPT_GET("Tool/Shift Times/Direction")->GetBool()) DirectionBackward->SetValue(true); if (OPT_GET("Tool/Shift Times/Direction")->GetBool()) DirectionBackward->SetValue(true);
// Has selection? // Has selection?
wxArrayInt sel = grid->GetSelection(); wxArrayInt sel = context->subsGrid->GetSelection();
if (sel.Count() == 0) { if (sel.Count() == 0) {
SelChoice->Enable(1,false); SelChoice->Enable(1,false);
SelChoice->Enable(2,false); SelChoice->Enable(2,false);
@ -226,8 +235,8 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
bool didSomething = false; bool didSomething = false;
// Selection // Selection
int nrows = grid->GetRows(); int nrows = context->subsGrid->GetRows();
wxArrayInt sel = grid->GetSelection(); wxArrayInt sel = context->subsGrid->GetSelection();
int firstSel = 0; int firstSel = 0;
if (sel.Count()) firstSel = sel[0]; if (sel.Count()) firstSel = sel[0];
@ -247,9 +256,9 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
// Shift // Shift
for (int i=0;i<nrows;i++) { for (int i=0;i<nrows;i++) {
if (allrows || (i >= firstSel && selOnward) || grid->IsInSelection(i,0)) { if (allrows || (i >= firstSel && selOnward) || context->subsGrid->IsInSelection(i,0)) {
if (byTime) grid->ShiftLineByTime(i,len,type); if (byTime) context->subsGrid->ShiftLineByTime(i,len,type);
else grid->ShiftLineByFrames(i,len,type); else context->subsGrid->ShiftLineByFrames(i,len,type);
didSomething = true; didSomething = true;
} }
} }
@ -257,8 +266,8 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
// Add entry to history // Add entry to history
if (didSomething) { if (didSomething) {
if (backward) len = -len; if (backward) len = -len;
wxString message = _T(""); wxString message;
wxFileName assfile(grid->ass->filename); wxFileName assfile(context->ass->filename);
wxString filename = assfile.GetFullName(); wxString filename = assfile.GetFullName();
// File // File
@ -309,7 +318,7 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
OPT_SET("Tool/Shift Times/Direction")->SetBool(backward); OPT_SET("Tool/Shift Times/Direction")->SetBool(backward);
// End dialog // End dialog
grid->ass->Commit(_("shifting"), AssFile::COMMIT_TIMES); context->ass->Commit(_("shifting"), AssFile::COMMIT_TIMES);
EndModal(0); EndModal(0);
} }

View File

@ -34,26 +34,16 @@
/// @ingroup secondary_ui /// @ingroup secondary_ui
/// ///
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/dialog.h> #include <wx/dialog.h>
#include <wx/listbox.h>
#include <wx/radiobox.h>
#include <wx/radiobut.h>
#endif #endif
#include "timeedit_ctrl.h" namespace agi { struct Context; }
class TimeEdit;
class wxListBox;
////////////// class wxRadioBox;
// Prototypes class wxRadioButton;
class SubtitlesGrid; class wxTextCtrl;
/// DOCME /// DOCME
/// @class DialogShiftTimes /// @class DialogShiftTimes
@ -61,14 +51,11 @@ class SubtitlesGrid;
/// ///
/// DOCME /// DOCME
class DialogShiftTimes : public wxDialog { class DialogShiftTimes : public wxDialog {
private: agi::Context *context;
/// DOCME /// DOCME
bool ready; bool ready;
/// DOCME
SubtitlesGrid *grid;
/// DOCME /// DOCME
int shiftframe; int shiftframe;
@ -106,10 +93,6 @@ private:
void AppendToHistory(wxString text); void AppendToHistory(wxString text);
void LoadHistory(wxString filename); void LoadHistory(wxString filename);
void OnClear(wxCommandEvent &event); void OnClear(wxCommandEvent &event);
public:
DialogShiftTimes (wxWindow *parent,SubtitlesGrid *grid);
void OnKey(wxKeyEvent &event); void OnKey(wxKeyEvent &event);
void OnClose(wxCommandEvent &event); void OnClose(wxCommandEvent &event);
void OnOK(wxCommandEvent &event); void OnOK(wxCommandEvent &event);
@ -118,32 +101,8 @@ public:
void OnRadioTime(wxCommandEvent &event); void OnRadioTime(wxCommandEvent &event);
void OnRadioFrame(wxCommandEvent &event); void OnRadioFrame(wxCommandEvent &event);
public:
DialogShiftTimes (agi::Context *context);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
///////
// IDs
enum {
/// DOCME
TEXT_SHIFT_TIME = 1100,
/// DOCME
TEXT_SHIFT_FRAME,
/// DOCME
RADIO_BACKWARD,
/// DOCME
RADIO_FORWARD,
/// DOCME
RADIO_TIME,
/// DOCME
RADIO_FRAME,
/// DOCME
SHIFT_CLEAR_HISTORY
};

View File

@ -274,7 +274,7 @@ void DialogSpellChecker::SetWord(wxString word) {
grid->SelectRow(line,false); grid->SelectRow(line,false);
grid->MakeCellVisible(line,0); grid->MakeCellVisible(line,0);
grid->SetActiveLine(grid->GetDialogue(line)); grid->SetActiveLine(grid->GetDialogue(line));
grid->editBox->TextEdit->SetSelectionU(wordStart,wordEnd); context->editBox->TextEdit->SetSelectionU(wordStart,wordEnd);
grid->EndBatch(); grid->EndBatch();
addButton->Enable(spellchecker->CanAddWord(word)); addButton->Enable(spellchecker->CanAddWord(word));
@ -381,16 +381,12 @@ bool DialogSpellChecker::FindOrDie() {
/// @brief Replace /// @brief Replace
/// ///
void DialogSpellChecker::Replace() { void DialogSpellChecker::Replace() {
// Get dialog AssDialogue *diag = context->subsGrid->GetDialogue(lastLine % context->subsGrid->GetRows());
SubtitlesGrid *grid = context->subsGrid;
AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows());
// Replace
diag->Text = diag->Text.Left(wordStart) + replaceWord->GetValue() + diag->Text.Mid(wordEnd); diag->Text = diag->Text.Left(wordStart) + replaceWord->GetValue() + diag->Text.Mid(wordEnd);
lastPos = wordStart + replaceWord->GetValue().Length(); lastPos = wordStart + replaceWord->GetValue().Length();
// Commit context->ass->Commit(_("Spell check replace"), AssFile::COMMIT_TEXT);
grid->ass->Commit(_("Spell check replace"), AssFile::COMMIT_TEXT);
} }

View File

@ -52,6 +52,7 @@
#include "ass_style_storage.h" #include "ass_style_storage.h"
#include "compat.h" #include "compat.h"
#include "dialog_style_editor.h" #include "dialog_style_editor.h"
#include "include/aegisub/context.h"
#include "help_button.h" #include "help_button.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
@ -63,124 +64,49 @@
#include "validators.h" #include "validators.h"
///////
// IDs // IDs
enum { enum {
/// DOCME
BUTTON_STYLE_FONT = 1050, BUTTON_STYLE_FONT = 1050,
/// DOCME
CHECKBOX_STYLE_BOLD, CHECKBOX_STYLE_BOLD,
/// DOCME
CHECKBOX_STYLE_ITALIC, CHECKBOX_STYLE_ITALIC,
/// DOCME
CHECKBOX_STYLE_UNDERLINE, CHECKBOX_STYLE_UNDERLINE,
/// DOCME
CHECKBOX_STYLE_STRIKEOUT, CHECKBOX_STYLE_STRIKEOUT,
/// DOCME
CHECKBOX_OUTLINE, CHECKBOX_OUTLINE,
/// DOCME
BUTTON_COLOR_1, BUTTON_COLOR_1,
/// DOCME
BUTTON_COLOR_2, BUTTON_COLOR_2,
/// DOCME
BUTTON_COLOR_3, BUTTON_COLOR_3,
/// DOCME
BUTTON_COLOR_4, BUTTON_COLOR_4,
/// DOCME
BUTTON_PREVIEW_COLOR, BUTTON_PREVIEW_COLOR,
/// DOCME
RADIO_ALIGNMENT, RADIO_ALIGNMENT,
/// DOCME
TEXT_FONT_NAME, TEXT_FONT_NAME,
/// DOCME
TEXT_FONT_SIZE, TEXT_FONT_SIZE,
/// DOCME
TEXT_ALPHA_1, TEXT_ALPHA_1,
/// DOCME
TEXT_ALPHA_2, TEXT_ALPHA_2,
/// DOCME
TEXT_ALPHA_3, TEXT_ALPHA_3,
/// DOCME
TEXT_ALPHA_4, TEXT_ALPHA_4,
/// DOCME
TEXT_MARGIN_L, TEXT_MARGIN_L,
/// DOCME
TEXT_MARGIN_R, TEXT_MARGIN_R,
/// DOCME
TEXT_MARGIN_V, TEXT_MARGIN_V,
/// DOCME
TEXT_OUTLINE, TEXT_OUTLINE,
/// DOCME
TEXT_SHADOW, TEXT_SHADOW,
/// DOCME
TEXT_SCALE_X, TEXT_SCALE_X,
/// DOCME
TEXT_SCALE_Y, TEXT_SCALE_Y,
/// DOCME
TEXT_ANGLE, TEXT_ANGLE,
/// DOCME
TEXT_SPACING, TEXT_SPACING,
/// DOCME
TEXT_PREVIEW, TEXT_PREVIEW,
/// DOCME
COMBO_ENCODING COMBO_ENCODING
}; };
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *style, agi::Context *c,bool local,AssStyleStorage *store,bool newStyle)
/// @brief Constructor
/// @param parent
/// @param _style
/// @param _grid
/// @param local
/// @param _store
///
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, SubtitlesGrid *_grid,bool local,AssStyleStorage *_store,bool newStyle)
: wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor")) : wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor"))
, c(c)
, isLocal(local)
, isNew(newStyle)
, work(new AssStyle(*style))
, store(store)
{ {
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24)));
// Set variables
isLocal = local;
isNew = newStyle;
store = _store;
// Set styles
grid = _grid;
style = _style;
work = new AssStyle;
*work = *style;
// Prepare control values // Prepare control values
FontSizeValue = AegiFloatToString(style->fontsize); FontSizeValue = AegiFloatToString(style->fontsize);
OutlineValue = AegiFloatToString(style->outline_w); OutlineValue = AegiFloatToString(style->outline_w);
@ -530,13 +456,13 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Get list of existing styles // Get list of existing styles
wxArrayString styles; wxArrayString styles;
if (isLocal) styles = grid->ass->GetStyles(); if (isLocal) styles = c->ass->GetStyles();
else if (store) styles = store->GetNames(); else if (store) styles = store->GetNames();
// Check if style name is unique // Check if style name is unique
for (unsigned int i=0;i<styles.Count();i++) { for (unsigned int i=0;i<styles.Count();i++) {
if (newStyleName.CmpNoCase(styles[i]) == 0) { if (newStyleName.CmpNoCase(styles[i]) == 0) {
if ((isLocal && (grid->ass->GetStyle(styles[i]) != style)) || (!isLocal && (store->GetStyle(styles[i]) != style))) { if ((isLocal && (c->ass->GetStyle(styles[i]) != style)) || (!isLocal && (store->GetStyle(styles[i]) != style))) {
wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR|wxOK); wxMessageBox(_T("There is already a style with this name. Please choose another name."),_T("Style name conflict."),wxICON_ERROR|wxOK);
return; return;
} }
@ -555,12 +481,12 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Update // Update
if (answer == wxYES) { if (answer == wxYES) {
int n = grid->GetRows(); int n = c->subsGrid->GetRows();
wxArrayString strings; wxArrayString strings;
strings.Add(work->name); strings.Add(work->name);
strings.Add(newStyleName); strings.Add(newStyleName);
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
AssDialogue *curDiag = grid->GetDialogue(i); AssDialogue *curDiag = c->subsGrid->GetDialogue(i);
if (curDiag->Style == work->name) curDiag->Style = newStyleName; if (curDiag->Style == work->name) curDiag->Style = newStyleName;
curDiag->ParseASSTags(); curDiag->ParseASSTags();
curDiag->ProcessParameters(ReplaceStyle,&strings); curDiag->ProcessParameters(ReplaceStyle,&strings);
@ -581,7 +507,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
*style = *work; *style = *work;
style->UpdateData(); style->UpdateData();
if (isLocal) { if (isLocal) {
grid->ass->Commit(_("style change"), AssFile::COMMIT_TEXT); c->ass->Commit(_("style change"), AssFile::COMMIT_TEXT);
} }
// Exit // Exit

View File

@ -34,11 +34,6 @@
/// @ingroup style_editor /// @ingroup style_editor
/// ///
////////////
// Includes
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/combobox.h> #include <wx/combobox.h>
@ -49,23 +44,18 @@
#include "colour_button.h" #include "colour_button.h"
namespace agi { struct Context; }
//////////////
// Prototypes
class AssStyle; class AssStyle;
class SubtitlesGrid;
class SubtitlesPreview; class SubtitlesPreview;
class AssStyleStorage; class AssStyleStorage;
/// DOCME /// DOCME
/// @class DialogStyleEditor /// @class DialogStyleEditor
/// @brief DOCME /// @brief DOCME
/// ///
/// DOCME /// DOCME
class DialogStyleEditor : public wxDialog { class DialogStyleEditor : public wxDialog {
private: agi::Context *c;
/// DOCME /// DOCME
bool isLocal; bool isLocal;
@ -81,9 +71,6 @@ private:
/// DOCME /// DOCME
AssStyle *work; AssStyle *work;
/// DOCME
SubtitlesGrid *grid;
/// DOCME /// DOCME
AssStyleStorage *store; AssStyleStorage *store;
@ -218,7 +205,7 @@ private:
void OnPreviewColourChange (wxCommandEvent &event); void OnPreviewColourChange (wxCommandEvent &event);
public: public:
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid,bool local,AssStyleStorage *store,bool newStyle=false); DialogStyleEditor(wxWindow *parent,AssStyle *style, agi::Context *c,bool local,AssStyleStorage *store,bool newStyle=false);
~DialogStyleEditor(); ~DialogStyleEditor();
void Apply (bool apply,bool close); void Apply (bool apply,bool close);

View File

@ -51,6 +51,7 @@
#include "dialog_selected_choices.h" #include "dialog_selected_choices.h"
#include "dialog_style_editor.h" #include "dialog_style_editor.h"
#include "dialog_style_manager.h" #include "dialog_style_manager.h"
#include "include/aegisub/context.h"
#include "help_button.h" #include "help_button.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
@ -89,18 +90,12 @@ enum {
LIST_CURRENT LIST_CURRENT
}; };
/// @brief Constructor DialogStyleManager::DialogStyleManager (agi::Context *context)
/// @param parent : wxDialog (context->parent,-1,_("Styles Manager"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogStylesManager"))
/// @param _grid , c(context)
DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
: wxDialog (parent,-1,_("Styles Manager"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogStylesManager"))
{ {
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24)));
// Vars
grid = _grid;
// Catalog // Catalog
wxSizer *CatalogBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Catalog of available storages")); wxSizer *CatalogBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Catalog of available storages"));
CatalogList = new wxComboBox(this,LIST_CATALOG, _T(""), wxDefaultPosition, wxSize(-1,-1), 0, NULL, wxCB_READONLY | wxCB_READONLY, wxDefaultValidator, _T("Catalog List")); CatalogList = new wxComboBox(this,LIST_CATALOG, _T(""), wxDefaultPosition, wxSize(-1,-1), 0, NULL, wxCB_READONLY | wxCB_READONLY, wxDefaultValidator, _T("Catalog List"));
@ -225,18 +220,17 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
// Populate lists // Populate lists
LoadCatalog(); LoadCatalog();
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
//Set key handlers for lists //Set key handlers for lists
CatalogList->PushEventHandler(new DialogStyleManagerEvent(this)); CatalogList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
StorageList->PushEventHandler(new DialogStyleManagerEvent(this)); StorageList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
CurrentList->PushEventHandler(new DialogStyleManagerEvent(this)); CurrentList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
// Select default item // Select default item
wxString selected_style; wxString selected_style;
if (_grid) { if (AssDialogue *dia = context->selectionController->GetActiveLine()) {
AssDialogue *dia = _grid->GetDialogue(_grid->GetFirstSelRow()); selected_style = dia->Style;
if(dia) selected_style = dia->Style;
} }
if (StorageList->GetCount() && StorageList->SetStringSelection(selected_style)) { if (StorageList->GetCount() && StorageList->SetStringSelection(selected_style)) {
@ -258,11 +252,8 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
DialogStyleManager::~DialogStyleManager() { DialogStyleManager::~DialogStyleManager() {
int sel = CatalogList->GetSelection(); int sel = CatalogList->GetSelection();
if (sel != wxNOT_FOUND) { if (sel != wxNOT_FOUND) {
grid->ass->SetScriptInfo(_T("Last Style Storage"),CatalogList->GetString(sel)); c->ass->SetScriptInfo("Last Style Storage",CatalogList->GetString(sel));
} }
CatalogList->PopEventHandler(true);
StorageList->PopEventHandler(true);
CurrentList->PopEventHandler(true);
Store.Clear(); Store.Clear();
} }
@ -299,7 +290,7 @@ void DialogStyleManager::LoadCatalog () {
// Set to default if available // Set to default if available
StorageActions(false); StorageActions(false);
wxString pickStyle = grid->ass->GetScriptInfo(_T("Last Style Storage")); wxString pickStyle = c->ass->GetScriptInfo(_T("Last Style Storage"));
if (pickStyle.IsEmpty()) pickStyle = _T("Default"); if (pickStyle.IsEmpty()) pickStyle = _T("Default");
int opt = CatalogList->FindString(pickStyle, false); int opt = CatalogList->FindString(pickStyle, false);
if (opt != wxNOT_FOUND) { if (opt != wxNOT_FOUND) {
@ -492,7 +483,7 @@ void DialogStyleManager::OnStorageEdit (wxCommandEvent &) {
int n = StorageList->GetSelections(selections); int n = StorageList->GetSelections(selections);
if (n == 1) { if (n == 1) {
AssStyle *selStyle = styleStorageMap[selections[0]]; AssStyle *selStyle = styleStorageMap[selections[0]];
DialogStyleEditor editor(this,selStyle,grid,false,&Store); DialogStyleEditor editor(this,selStyle,c,false,&Store);
if (editor.ShowModal()) { if (editor.ShowModal()) {
StorageList->SetString(selections[0],selStyle->name); StorageList->SetString(selections[0],selStyle->name);
Store.Save(CatalogList->GetString(CatalogList->GetSelection())); Store.Save(CatalogList->GetString(CatalogList->GetSelection()));
@ -507,7 +498,7 @@ void DialogStyleManager::OnCurrentEdit (wxCommandEvent &) {
int n = CurrentList->GetSelections(selections); int n = CurrentList->GetSelections(selections);
if (n == 1) { if (n == 1) {
AssStyle *selStyle = styleMap[selections[0]]; AssStyle *selStyle = styleMap[selections[0]];
DialogStyleEditor editor(this,selStyle,grid,true,&Store); DialogStyleEditor editor(this,selStyle,c,true,&Store);
if (editor.ShowModal()) { if (editor.ShowModal()) {
CurrentList->SetString(selections[0],selStyle->name); CurrentList->SetString(selections[0],selStyle->name);
} }
@ -599,15 +590,15 @@ void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &) {
} }
if (addStyle) { if (addStyle) {
AssStyle *temp = new AssStyle(*styleStorageMap.at(selections[i])); AssStyle *temp = new AssStyle(*styleStorageMap.at(selections[i]));
grid->ass->InsertStyle(temp); c->ass->InsertStyle(temp);
copied.push_back(styleName); copied.push_back(styleName);
} }
} }
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
for (list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name) { for (list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name) {
CurrentList->SetStringSelection(*name, true); CurrentList->SetStringSelection(*name, true);
} }
grid->ass->Commit(_("style copy")); c->ass->Commit(_("style copy"));
wxCommandEvent dummy; wxCommandEvent dummy;
OnCurrentChange(dummy); OnCurrentChange(dummy);
} }
@ -623,7 +614,7 @@ void DialogStyleManager::OnStorageCopy (wxCommandEvent &) {
newName += temp->name; newName += temp->name;
temp->name = newName; temp->name = newName;
DialogStyleEditor editor(this,temp,grid,false,&Store,true); DialogStyleEditor editor(this,temp,c,false,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
Store.style.push_back(temp); Store.style.push_back(temp);
@ -646,16 +637,16 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &) {
newName += temp->name; newName += temp->name;
temp->name = newName; temp->name = newName;
DialogStyleEditor editor(this,temp,grid,true,&Store,true); DialogStyleEditor editor(this,temp,c,true,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
grid->ass->InsertStyle(temp); c->ass->InsertStyle(temp);
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
CurrentList->SetStringSelection(temp->name); // but even without this, the copy/delete/copy-to-storage buttons stay enabled? CurrentList->SetStringSelection(temp->name); // but even without this, the copy/delete/copy-to-storage buttons stay enabled?
} }
else delete temp; else delete temp;
grid->ass->Commit(_("style copy")); c->ass->Commit(_("style copy"));
UpdateMoveButtons(); UpdateMoveButtons();
} }
@ -700,14 +691,14 @@ void DialogStyleManager::PasteToCurrent() {
try { try {
s = new AssStyle(st.GetNextToken().Trim(true)); s = new AssStyle(st.GetNextToken().Trim(true));
if (s->Valid) { if (s->Valid) {
while (grid->ass->GetStyle(s->name) != NULL) while (c->ass->GetStyle(s->name) != NULL)
s->name = _T("Copy of ") + s->name; s->name = _T("Copy of ") + s->name;
s->UpdateData(); s->UpdateData();
grid->ass->InsertStyle(s); c->ass->InsertStyle(s);
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
grid->ass->Commit(_("style paste")); c->ass->Commit(_("style paste"));
} }
else else
wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this); wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
@ -763,7 +754,7 @@ void DialogStyleManager::PasteToStorage() {
void DialogStyleManager::OnStorageNew (wxCommandEvent &) { void DialogStyleManager::OnStorageNew (wxCommandEvent &) {
AssStyle *temp = new AssStyle; AssStyle *temp = new AssStyle;
DialogStyleEditor editor(this,temp,grid,false,&Store,true); DialogStyleEditor editor(this,temp,c,false,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
Store.style.push_back(temp); Store.style.push_back(temp);
@ -779,11 +770,11 @@ void DialogStyleManager::OnStorageNew (wxCommandEvent &) {
void DialogStyleManager::OnCurrentNew (wxCommandEvent &) { void DialogStyleManager::OnCurrentNew (wxCommandEvent &) {
AssStyle *temp = new AssStyle; AssStyle *temp = new AssStyle;
DialogStyleEditor editor(this,temp,grid,true,&Store,true); DialogStyleEditor editor(this,temp,c,true,&Store,true);
int modified = editor.ShowModal(); int modified = editor.ShowModal();
if (modified) { if (modified) {
grid->ass->InsertStyle(temp); c->ass->InsertStyle(temp);
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
CurrentList->SetStringSelection(temp->name); CurrentList->SetStringSelection(temp->name);
} }
else delete temp; else delete temp;
@ -841,10 +832,10 @@ void DialogStyleManager::OnCurrentDelete (wxCommandEvent &) {
AssStyle *temp; AssStyle *temp;
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
temp = styleMap.at(selections[i]); temp = styleMap.at(selections[i]);
grid->ass->Line.remove(temp); c->ass->Line.remove(temp);
delete temp; delete temp;
} }
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
// Set buttons // Set buttons
MoveToStorage->Enable(false); MoveToStorage->Enable(false);
@ -852,7 +843,7 @@ void DialogStyleManager::OnCurrentDelete (wxCommandEvent &) {
CurrentCopy->Enable(false); CurrentCopy->Enable(false);
CurrentDelete->Enable(false); CurrentDelete->Enable(false);
grid->ass->Commit(_("style delete")); c->ass->Commit(_("style delete"));
} }
UpdateMoveButtons(); UpdateMoveButtons();
} }
@ -898,7 +889,7 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
// The GetString->FindString mess is a silly workaround for the fact that to vsfilter // The GetString->FindString mess is a silly workaround for the fact that to vsfilter
// (and the duplicate check a few lines above), style names aren't case sensitive, but to the // (and the duplicate check a few lines above), style names aren't case sensitive, but to the
// rest of Aegisub they are. // rest of Aegisub they are.
*(grid->ass->GetStyle(CurrentList->GetString(CurrentList->FindString(styles[selections[i]], false)))) = *temp.GetStyle(styles[selections[i]]); *(c->ass->GetStyle(CurrentList->GetString(CurrentList->FindString(styles[selections[i]], false)))) = *temp.GetStyle(styles[selections[i]]);
} }
continue; continue;
} }
@ -907,13 +898,13 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
modified = true; modified = true;
AssStyle *tempStyle = new AssStyle; AssStyle *tempStyle = new AssStyle;
*tempStyle = *temp.GetStyle(styles[selections[i]]); *tempStyle = *temp.GetStyle(styles[selections[i]]);
grid->ass->InsertStyle(tempStyle); c->ass->InsertStyle(tempStyle);
} }
// Update // Update
if (modified) { if (modified) {
LoadCurrentStyles(grid->ass); LoadCurrentStyles(c->ass);
grid->ass->Commit(_("style import")); c->ass->Commit(_("style import"));
} }
} }
catch (...) { catch (...) {
@ -990,8 +981,6 @@ void DialogStyleManager::OnCurrentSort (wxCommandEvent &) { MoveStyles(false,4);
/// @param storage /// @param storage
/// @param type /// @param type
void DialogStyleManager::MoveStyles(bool storage, int type) { void DialogStyleManager::MoveStyles(bool storage, int type) {
// Variables
AssFile *subs = grid->ass;
wxListBox *list; wxListBox *list;
if (storage) list = StorageList; if (storage) list = StorageList;
else list = CurrentList; else list = CurrentList;
@ -1097,19 +1086,19 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
// Replace styles // Replace styles
entryIter next; entryIter next;
int curn = 0; int curn = 0;
for (entryIter cur=subs->Line.begin();cur!=subs->Line.end();cur = next) { for (entryIter cur=c->ass->Line.begin();cur!=c->ass->Line.end();cur = next) {
next = cur; next = cur;
next++; next++;
AssStyle *style = dynamic_cast<AssStyle*>(*cur); AssStyle *style = dynamic_cast<AssStyle*>(*cur);
if (style) { if (style) {
subs->Line.insert(cur,styls[curn]); c->ass->Line.insert(cur,styls[curn]);
subs->Line.erase(cur); c->ass->Line.erase(cur);
curn++; curn++;
} }
} }
// Flag as modified // Flag as modified
grid->ass->Commit(_("style move")); c->ass->Commit(_("style move"));
} }
// Update // Update
@ -1183,16 +1172,3 @@ int DialogStyleManager::lastx = -1;
/// DOCME /// DOCME
int DialogStyleManager::lasty = -1; int DialogStyleManager::lasty = -1;
/// @brief DialogStyleManagerEvent stuff
/// @param ctrl
DialogStyleManagerEvent::DialogStyleManagerEvent(DialogStyleManager *ctrl) {
control = ctrl;
}
BEGIN_EVENT_TABLE(DialogStyleManagerEvent, wxEvtHandler)
EVT_KEY_DOWN(DialogStyleManagerEvent::OnKeyDown)
END_EVENT_TABLE()
void DialogStyleManagerEvent::OnKeyDown(wxKeyEvent &event) {
control->OnKeyDown(event); //we need to access controls, so rather than make the controls public...
}

View File

@ -50,9 +50,7 @@
#include "ass_style_storage.h" #include "ass_style_storage.h"
namespace agi { struct Context; }
//////////////
// Prototypes
class AssFile; class AssFile;
class AssStyle; class AssStyle;
class SubtitlesGrid; class SubtitlesGrid;
@ -65,7 +63,7 @@ class SubtitlesGrid;
/// ///
/// DOCME /// DOCME
class DialogStyleManager : public wxDialog { class DialogStyleManager : public wxDialog {
private: agi::Context *c;
/// DOCME /// DOCME
std::vector<AssStyle*> styleMap; std::vector<AssStyle*> styleMap;
@ -73,11 +71,6 @@ private:
/// DOCME /// DOCME
std::vector<AssStyle*> styleStorageMap; std::vector<AssStyle*> styleStorageMap;
/// DOCME
SubtitlesGrid *grid;
/// DOCME /// DOCME
wxComboBox *CatalogList; wxComboBox *CatalogList;
@ -164,14 +157,9 @@ private:
/// DOCME /// DOCME
static int lastx, lasty; static int lastx, lasty;
public:
/// DOCME /// DOCME
wxSizer *MainSizer; wxSizer *MainSizer;
DialogStyleManager(wxWindow *parent,SubtitlesGrid *grid);
~DialogStyleManager();
void OnClose (wxCommandEvent &event); void OnClose (wxCommandEvent &event);
void OnChangeCatalog (wxCommandEvent &event); void OnChangeCatalog (wxCommandEvent &event);
void OnCatalogNew (wxCommandEvent &event); void OnCatalogNew (wxCommandEvent &event);
@ -204,23 +192,10 @@ public:
void PasteToCurrent(); void PasteToCurrent();
void PasteToStorage(); void PasteToStorage();
DECLARE_EVENT_TABLE()
};
/// DOCME
/// @class DialogStyleManagerEvent
/// @brief DOCME
///
/// DOCME
class DialogStyleManagerEvent : public wxEvtHandler {
private:
/// DOCME
DialogStyleManager *control;
void OnKeyDown(wxKeyEvent &event);
public: public:
DialogStyleManagerEvent(DialogStyleManager *control);
DialogStyleManager(agi::Context *context);
~DialogStyleManager();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -62,6 +62,14 @@
#include "video_context.h" #include "video_context.h"
#include "video_display.h" #include "video_display.h"
// IDs
enum {
ENTER_STYLE_BOX,
STYLE_LIST,
BUTTON_PLAY_VIDEO,
BUTTON_PLAY_AUDIO
};
/// @brief Constructor /// @brief Constructor
/// @param parent /// @param parent
@ -69,24 +77,20 @@
/// ///
DialogStyling::DialogStyling(agi::Context *context) DialogStyling::DialogStyling(agi::Context *context)
: wxDialog(context->parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX) : wxDialog(context->parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX)
, c(context)
, needCommit(false)
, linen(-1)
{ {
// Set icon // Set icon
SetIcon(BitmapToIcon(GETIMAGE(styling_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(styling_toolbutton_24)));
// Variables
grid = context->subsGrid;
audio = context->audioController;
video = context->videoController;
needCommit = false;
linen = -1;
// Top sizer // Top sizer
wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Current line")); wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Current line"));
CurLine = new wxTextCtrl(this,-1,_("Current line"),wxDefaultPosition,wxSize(300,60),wxTE_MULTILINE | wxTE_READONLY); CurLine = new wxTextCtrl(this,-1,_("Current line"),wxDefaultPosition,wxSize(300,60),wxTE_MULTILINE | wxTE_READONLY);
TopSizer->Add(CurLine,1,wxEXPAND,0); TopSizer->Add(CurLine,1,wxEXPAND,0);
// Left sizer // Left sizer
Styles = new wxListBox(this,STYLE_LIST,wxDefaultPosition,wxSize(150,180),grid->ass->GetStyles()); Styles = new wxListBox(this,STYLE_LIST,wxDefaultPosition,wxSize(150,180),context->ass->GetStyles());
wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Styles available")); wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Styles available"));
LeftSizer->Add(Styles,1,wxEXPAND,0); LeftSizer->Add(Styles,1,wxEXPAND,0);
@ -99,7 +103,6 @@ DialogStyling::DialogStyling(agi::Context *context)
RightTop->Add(TypeBox,1,wxEXPAND); RightTop->Add(TypeBox,1,wxEXPAND);
// Shortcuts // Shortcuts
//wxStaticText *Keys = new wxStaticText(this,-1,_("Enter:\t\tAccept changes\nPage up:\tPrevious line\nPage down:\tNext line\nEnd:\t\tPlay sound\nClick on list:\tSet style\nCtrl+enter:\tAccept without going to next"));
wxSizer *KeysInnerSizer = new wxGridSizer(2,0,5); wxSizer *KeysInnerSizer = new wxGridSizer(2,0,5);
//H KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Styling Assistant Accept")) + _T(": "))); //H KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Styling Assistant Accept")) + _T(": ")));
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Accept changes"))); KeysInnerSizer->Add(new wxStaticText(this,-1,_("Accept changes")));
@ -165,29 +168,24 @@ DialogStyling::DialogStyling(agi::Context *context)
origColour = TypeBox->GetBackgroundColour(); origColour = TypeBox->GetBackgroundColour();
} }
/// @brief Destructor /// @brief Destructor
/// ///
DialogStyling::~DialogStyling () { DialogStyling::~DialogStyling () {
GetPosition(&lastx, &lasty); GetPosition(&lastx, &lasty);
if (needCommit) { if (needCommit) {
grid->ass->Commit(_("style changes"), AssFile::COMMIT_TEXT); c->ass->Commit(_("style changes"), AssFile::COMMIT_TEXT);
} }
} }
/// @brief Jump to line /// @brief Jump to line
/// @param n /// @param n
/// @return /// @return
/// ///
void DialogStyling::JumpToLine(int n) { void DialogStyling::JumpToLine(int n) {
// Check stuff
if (n == -1) return; if (n == -1) return;
// Get line // Get line
AssDialogue *nextLine = grid->GetDialogue(n); AssDialogue *nextLine = c->subsGrid->GetDialogue(n);
if (!nextLine) return; if (!nextLine) return;
line = nextLine; line = nextLine;
@ -210,33 +208,29 @@ void DialogStyling::JumpToLine(int n) {
TypeBox->SetSelection(0,TypeBox->GetValue().Length()); TypeBox->SetSelection(0,TypeBox->GetValue().Length());
// Update grid // Update grid
grid->SelectRow(linen,false); c->subsGrid->SelectRow(linen,false);
grid->MakeCellVisible(linen,0); c->subsGrid->MakeCellVisible(linen,0);
grid->SetActiveLine(grid->GetDialogue(linen)); c->subsGrid->SetActiveLine(line);
// Update display // Update display
if (PreviewCheck->IsChecked()) VideoContext::Get()->JumpToTime(line->Start.GetMS()); if (PreviewCheck->IsChecked()) c->videoController->JumpToTime(line->Start.GetMS());
} }
/// @brief Set style of current line /// @brief Set style of current line
/// @param curName /// @param curName
/// @param jump /// @param jump
/// ///
void DialogStyling::SetStyle (wxString curName, bool jump) { void DialogStyling::SetStyle (wxString curName, bool jump) {
// Get line AssDialogue *line = c->subsGrid->GetDialogue(linen);
AssDialogue *line = grid->GetDialogue(linen);
// Update line
line->Style = curName; line->Style = curName;
// Update grid/subs // Update grid/subs
grid->Refresh(false);
if (PreviewCheck->IsChecked()) { if (PreviewCheck->IsChecked()) {
grid->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT); c->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT);
}
else {
needCommit = true;
} }
else needCommit = true;
// Next line // Next line
if (jump) JumpToLine(linen+1); if (jump) JumpToLine(linen+1);
@ -265,19 +259,18 @@ void DialogStyling::OnActivate(wxActivateEvent &event) {
// Dialog lost focus // Dialog lost focus
if (!event.GetActive()) { if (!event.GetActive()) {
if (needCommit) { if (needCommit) {
grid->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT); c->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT);
needCommit = false; needCommit = false;
} }
return; return;
} }
// Enable/disable play video/audio buttons // Enable/disable play video/audio buttons
PlayVideoButton->Enable(video->IsLoaded()); PlayVideoButton->Enable(c->videoController->IsLoaded());
/// @todo Reinstate this when the audio controller is made reachable from here PlayAudioButton->Enable(c->audioController->IsAudioOpen());
//PlayAudioButton->Enable(audio->loaded);
// Fix style list // Fix style list
Styles->Set(grid->ass->GetStyles()); Styles->Set(c->ass->GetStyles());
// Fix line selection // Fix line selection
JumpToLine(grid->GetFirstSelRow()); JumpToLine(c->subsGrid->GetFirstSelRow());
} }
@ -372,7 +365,7 @@ void DialogStyling::OnListClicked(wxCommandEvent &event) {
/// @param event /// @param event
/// ///
void DialogStyling::OnPlayVideoButton(wxCommandEvent &event) { void DialogStyling::OnPlayVideoButton(wxCommandEvent &event) {
video->PlayLine(); c->videoController->PlayLine();
TypeBox->SetFocus(); TypeBox->SetFocus();
} }
@ -381,9 +374,9 @@ void DialogStyling::OnPlayVideoButton(wxCommandEvent &event) {
/// @param event /// @param event
/// ///
void DialogStyling::OnPlayAudioButton(wxCommandEvent &event) { void DialogStyling::OnPlayAudioButton(wxCommandEvent &event) {
audio->PlayRange(SampleRange( c->audioController->PlayRange(SampleRange(
audio->SamplesFromMilliseconds(line->Start.GetMS()), c->audioController->SamplesFromMilliseconds(line->Start.GetMS()),
audio->SamplesFromMilliseconds(line->End.GetMS()))); c->audioController->SamplesFromMilliseconds(line->End.GetMS())));
TypeBox->SetFocus(); TypeBox->SetFocus();
} }
@ -393,12 +386,11 @@ void DialogStyling::OnPlayAudioButton(wxCommandEvent &event) {
/// @param parent /// @param parent
/// ///
StyleEditBox::StyleEditBox(DialogStyling *parent) StyleEditBox::StyleEditBox(DialogStyling *parent)
: wxTextCtrl(parent,ENTER_STYLE_BOX,_T(""),wxDefaultPosition,wxSize(180,-1),wxTE_PROCESS_ENTER) : wxTextCtrl(parent,ENTER_STYLE_BOX,"",wxDefaultPosition,wxSize(180,-1),wxTE_PROCESS_ENTER)
, diag(parent)
{ {
diag = parent;
} }
//////////////////////////// ////////////////////////////
// Event table for edit box // Event table for edit box
BEGIN_EVENT_TABLE(StyleEditBox,wxTextCtrl) BEGIN_EVENT_TABLE(StyleEditBox,wxTextCtrl)
@ -499,5 +491,3 @@ int DialogStyling::lastx = -1;
/// DOCME /// DOCME
int DialogStyling::lasty = -1; int DialogStyling::lasty = -1;

View File

@ -34,11 +34,6 @@
/// @ingroup tools_ui /// @ingroup tools_ui
/// ///
#pragma once
///////////
// Headers
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/colour.h> #include <wx/colour.h>
@ -61,8 +56,6 @@ class VideoContext;
/// ///
/// DOCME /// DOCME
class StyleEditBox : public wxTextCtrl { class StyleEditBox : public wxTextCtrl {
private:
/// DOCME /// DOCME
DialogStyling *diag; DialogStyling *diag;
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
@ -83,10 +76,7 @@ public:
class DialogStyling : public wxDialog { class DialogStyling : public wxDialog {
friend class StyleEditBox; friend class StyleEditBox;
private: agi::Context *c;
/// DOCME
SubtitlesGrid *grid;
/// DOCME /// DOCME
wxColour origColour; wxColour origColour;
@ -130,19 +120,12 @@ private:
static int lastx, lasty; static int lastx, lasty;
public: public:
/// DOCME /// DOCME
int linen; int linen;
/// DOCME /// DOCME
AssDialogue *line; AssDialogue *line;
/// DOCME
AudioController *audio;
/// DOCME
VideoContext *video;
DialogStyling(agi::Context *context); DialogStyling(agi::Context *context);
~DialogStyling (); ~DialogStyling ();
@ -150,21 +133,3 @@ public:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
///////
// IDs
enum {
/// DOCME
ENTER_STYLE_BOX,
/// DOCME
STYLE_LIST,
/// DOCME
BUTTON_PLAY_VIDEO,
/// DOCME
BUTTON_PLAY_AUDIO
};

View File

@ -36,11 +36,16 @@
#include "config.h" #include "config.h"
#ifndef AGI_PRE
#include <algorithm>
#endif
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "ass_time.h" #include "ass_time.h"
#include "dialog_timing_processor.h" #include "dialog_timing_processor.h"
#include "help_button.h" #include "help_button.h"
#include "include/aegisub/context.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
#include "selection_controller.h" #include "selection_controller.h"
@ -62,28 +67,24 @@ enum {
TIMING_STYLE_LIST TIMING_STYLE_LIST
}; };
/// @brief Constructor DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
/// @param parent : wxDialog(c->parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE)
/// @param _grid , c(c)
/// , leadInTime(wxString::Format("%d", OPT_GET("Audio/Lead/IN")->GetInt()))
DialogTimingProcessor::DialogTimingProcessor(wxWindow *parent,SubtitlesGrid *_grid) , leadOutTime(wxString::Format("%d", OPT_GET("Audio/Lead/OUT")->GetInt()))
: wxDialog(parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE) , thresStartBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start Before")->GetInt()))
, thresStartAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start After")->GetInt()))
, thresEndBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End Before")->GetInt()))
, thresEndAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End After")->GetInt()))
, adjsThresTime(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent")->GetInt()))
{ {
SetIcon(BitmapToIcon(GETIMAGE(timing_processor_toolbutton_24))); SetIcon(BitmapToIcon(GETIMAGE(timing_processor_toolbutton_24)));
// Set variables // Set variables
grid = _grid;
leadInTime = AegiIntegerToString(OPT_GET("Audio/Lead/IN")->GetInt());
leadOutTime = AegiIntegerToString(OPT_GET("Audio/Lead/OUT")->GetInt());
thresStartBefore = AegiIntegerToString(OPT_GET("Tool/Timing Post Processor/Threshold/Key Start Before")->GetInt());
thresStartAfter = AegiIntegerToString(OPT_GET("Tool/Timing Post Processor/Threshold/Key Start After")->GetInt());
thresEndBefore = AegiIntegerToString(OPT_GET("Tool/Timing Post Processor/Threshold/Key End Before")->GetInt());
thresEndAfter = AegiIntegerToString(OPT_GET("Tool/Timing Post Processor/Threshold/Key End After")->GetInt());
adjsThresTime = AegiIntegerToString(OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent")->GetInt());
// Styles box // Styles box
wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles")); wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles"));
wxArrayString styles = grid->ass->GetStyles(); wxArrayString styles = c->ass->GetStyles();
StyleList = new wxCheckListBox(this,TIMING_STYLE_LIST,wxDefaultPosition,wxSize(150,150),styles); StyleList = new wxCheckListBox(this,TIMING_STYLE_LIST,wxDefaultPosition,wxSize(150,150),styles);
StyleList->SetToolTip(_("Select styles to process. Unchecked ones will be ignored.")); StyleList->SetToolTip(_("Select styles to process. Unchecked ones will be ignored."));
wxButton *all = new wxButton(this,BUTTON_SELECT_ALL,_("All")); wxButton *all = new wxButton(this,BUTTON_SELECT_ALL,_("All"));
@ -295,87 +296,57 @@ void DialogTimingProcessor::OnApply(wxCommandEvent &) {
OPT_SET("Tool/Timing Post Processor/Only Selection")->SetBool(onlySelection->IsChecked()); OPT_SET("Tool/Timing Post Processor/Only Selection")->SetBool(onlySelection->IsChecked());
// Check if rows are valid // Check if rows are valid
bool valid = true; for (entryIter cur = c->ass->Line.begin(); cur != c->ass->Line.end(); ++cur) {
AssDialogue *tempDiag; if (AssDialogue *tempDiag = dynamic_cast<AssDialogue*>(*cur)) {
int i = 0;
for (std::list<AssEntry*>::iterator cur=grid->ass->Line.begin();cur!=grid->ass->Line.end();cur++) {
tempDiag = dynamic_cast<AssDialogue*>(*cur);
if (tempDiag) {
i++;
if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) { if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) {
valid = false; wxMessageBox(
break; wxString::Format(
_("One of the lines in the file (%i) has negative duration. Aborting."),
std::distance(c->ass->Line.begin(), cur)),
_("Invalid script"),
wxICON_ERROR|wxOK);
EndModal(0);
return;
} }
} }
} }
if (valid) Process(); Process();
else wxMessageBox(wxString::Format(_("One of the lines in the file (%i) has negative duration. Aborting."),i),_("Invalid script"),wxICON_ERROR|wxOK);
EndModal(0); EndModal(0);
} }
int DialogTimingProcessor::GetClosestKeyFrame(int frame) { int DialogTimingProcessor::GetClosestKeyFrame(int frame) {
// Linear dumb search, not very efficient, but it doesn't really matter std::vector<int>::iterator pos = lower_bound(KeyFrames.begin(), KeyFrames.end(), frame);
int closest = 0; if (distance(pos, KeyFrames.end()) < 2) return KeyFrames.back();
size_t n = KeyFrames.size(); return frame - *pos < *(pos + 1) - frame ? *pos : *(pos + 1);
for (size_t i=0;i<n;i++) {
if (abs(KeyFrames[i]-frame) < abs(closest-frame)) {
closest = KeyFrames[i];
}
}
return closest;
} }
/// @brief Check if style is listed static bool bad_line(std::set<wxString> *styles, AssDialogue *d) {
/// @param styleName return !d || d->Comment || styles->find(d->Style) == styles->end();
/// @return
///
bool DialogTimingProcessor::StyleOK(wxString styleName) {
size_t len = StyleList->GetCount();
for (size_t i=0;i<len;i++) {
if (StyleList->GetString(i) == styleName && StyleList->IsChecked(i)) return true;
}
return false;
} }
/// @brief Sort dialogues
///
void DialogTimingProcessor::SortDialogues() { void DialogTimingProcessor::SortDialogues() {
// Copy from original to temporary list std::set<wxString> styles;
std::list<AssDialogue*> temp; for (size_t i = 0; i < StyleList->GetCount(); ++i) {
AssDialogue *tempDiag; if (StyleList->IsChecked(i)) {
int count = grid->GetRows(); styles.insert(StyleList->GetString(i));
for (int i=0;i<count;i++) {
tempDiag = grid->GetDialogue(i);
if (tempDiag && StyleOK(tempDiag->Style) && !tempDiag->Comment) {
if (!onlySelection->IsChecked() || grid->IsInSelection(i)) {
temp.push_back(tempDiag);
}
} }
} }
// Sort temporary list
AssFile::Sort(temp);
// Copy temporary list to final vector
Sorted.clear(); Sorted.clear();
for (std::list<AssDialogue*>::iterator cur=temp.begin();cur!=temp.end();cur++) { Sorted.reserve(c->ass->Line.size());
Sorted.push_back(*cur); if (onlySelection->IsChecked()) {
SelectionController<AssDialogue>::Selection sel = c->selectionController->GetSelectedSet();
remove_copy_if(sel.begin(), sel.end(), back_inserter(Sorted),
bind(bad_line, &styles, std::tr1::placeholders::_1));
} }
} else {
std::vector<AssDialogue*> tmp(c->ass->Line.size());
/// @brief Gets sorted dialogue transform(c->ass->Line.begin(), c->ass->Line.end(), back_inserter(tmp), cast<AssDialogue*>());
/// @param n remove_copy_if(tmp.begin(), tmp.end(), back_inserter(Sorted),
/// @return bind(bad_line, &styles, std::tr1::placeholders::_1));
///
AssDialogue *DialogTimingProcessor::GetSortedDialogue(int n) {
try {
return Sorted.at(n);
}
catch (...) {
return NULL;
} }
sort(Sorted.begin(), Sorted.end(), AssFile::CompStart);
} }
/// @brief Actually process subtitles /// @brief Actually process subtitles
@ -394,121 +365,75 @@ void DialogTimingProcessor::Process() {
// Add lead-in/out // Add lead-in/out
if (addIn || addOut) { if (addIn || addOut) {
// Variables
AssDialogue *cur;
AssDialogue *comp;
int start,end;
int startLead,endLead;
int compStart,compEnd;
// For each row
for (int i=0;i<rows;i++) { for (int i=0;i<rows;i++) {
// Get line and check if it's OK AssDialogue *cur = Sorted[i];
cur = GetSortedDialogue(i);
// Set variables
start = cur->Start.GetMS();
end = cur->End.GetMS();
if (addIn) startLead = start - inVal;
else startLead = start;
if (addOut) endLead = end + outVal;
else endLead = end;
// Compare to every previous line (yay for O(n^2)!) to see if it's OK to add lead-in // Compare to every previous line (yay for O(n^2)!) to see if it's OK to add lead-in
if (addIn) { if (inVal) {
int startLead = cur->Start.GetMS() - inVal;
for (int j=0;j<i;j++) { for (int j=0;j<i;j++) {
comp = GetSortedDialogue(j); AssDialogue *comp = Sorted[j];
// Check if they don't already collide (ignore it in that case) // Check if they don't already collide (ignore it in that case)
if (cur->CollidesWith(comp)) continue; if (cur->CollidesWith(comp)) continue;
// Get comparison times // Get comparison times
compEnd = comp->End.GetMS(); startLead = std::max(startLead, comp->End.GetMS());
// Limit lead-in if needed
if (compEnd > startLead) startLead = compEnd;
} }
cur->Start.SetMS(startLead);
} }
// Compare to every line to see how far can lead-out be extended // Compare to every line to see how far can lead-out be extended
if (addOut) { if (outVal) {
int endLead = cur->End.GetMS() + outVal;
for (int j=i+1;j<rows;j++) { for (int j=i+1;j<rows;j++) {
comp = GetSortedDialogue(j); AssDialogue *comp = Sorted[j];
// Check if they don't already collide (ignore it in that case) // Check if they don't already collide (ignore it in that case)
if (cur->CollidesWith(comp)) continue; if (cur->CollidesWith(comp)) continue;
// Get comparison times // Get comparison times
compStart = comp->Start.GetMS(); endLead = std::min(endLead, comp->Start.GetMS());
// Limit lead-in if needed
if (compStart < endLead) endLead = compStart;
} }
cur->End.SetMS(endLead);
} }
// Set times
cur->Start.SetMS(startLead);
cur->End.SetMS(endLead);
} }
} }
// Make adjacent // Make adjacent
if (adjsEnable->IsChecked()) { if (adjsEnable->IsChecked()) {
// Variables AssDialogue *prev = Sorted.front();
AssDialogue *cur;
AssDialogue *prev = NULL;
int curStart,prevEnd;
long adjsThres = 0; long adjsThres = 0;
int dist;
// Get threshold
adjacentThres->GetValue().ToLong(&adjsThres); adjacentThres->GetValue().ToLong(&adjsThres);
// Get bias
float bias = adjacentBias->GetValue() / 100.0; float bias = adjacentBias->GetValue() / 100.0;
// For each row for (int i=1; i < rows;i++) {
for (int i=0;i<rows;i++) { AssDialogue *cur = Sorted[i];
// Get line and check if it's OK
cur = GetSortedDialogue(i);
// Check if previous is OK
if (!prev) {
prev = cur;
continue;
}
// Check if they don't collide // Check if they don't collide
if (cur->CollidesWith(prev)) continue; if (cur->CollidesWith(prev)) continue;
// Compare distance // Compare distance
curStart = cur->Start.GetMS(); int curStart = cur->Start.GetMS();
prevEnd = prev->End.GetMS(); int prevEnd = prev->End.GetMS();
dist = curStart-prevEnd; int dist = curStart-prevEnd;
if (dist > 0 && dist < adjsThres) { if (dist > 0 && dist < adjsThres) {
int setPos = prevEnd+int(dist*bias); int setPos = prevEnd+int(dist*bias);
cur->Start.SetMS(setPos); cur->Start.SetMS(setPos);
prev->End.SetMS(setPos); prev->End.SetMS(setPos);
} }
// Set previous
prev = cur; prev = cur;
} }
} }
// Keyframe snapping // Keyframe snapping
if (keysEnable->IsChecked()) { if (keysEnable->IsChecked()) {
// Get keyframes KeyFrames = c->videoController->GetKeyFrames();
VideoContext *con = VideoContext::Get(); KeyFrames.push_back(c->videoController->GetLength() - 1);
KeyFrames = con->GetKeyFrames();
KeyFrames.push_back(con->GetLength()-1);
// Variables
int startF,endF;
int closest;
AssDialogue *cur;
// Get variables
long beforeStart = 0; long beforeStart = 0;
long afterStart = 0; long afterStart = 0;
long beforeEnd = 0; long beforeEnd = 0;
@ -518,29 +443,27 @@ void DialogTimingProcessor::Process() {
keysEndBefore->GetValue().ToLong(&beforeEnd); keysEndBefore->GetValue().ToLong(&beforeEnd);
keysEndAfter->GetValue().ToLong(&afterEnd); keysEndAfter->GetValue().ToLong(&afterEnd);
// For each row
for (int i=0;i<rows;i++) { for (int i=0;i<rows;i++) {
// Get line and check if it's OK AssDialogue *cur = Sorted[i];
cur = GetSortedDialogue(i);
// Get start/end frames // Get start/end frames
startF = con->FrameAtTime(cur->Start.GetMS(),agi::vfr::START); int startF = c->videoController->FrameAtTime(cur->Start.GetMS(),agi::vfr::START);
endF = con->FrameAtTime(cur->End.GetMS(),agi::vfr::END); int endF = c->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END);
// Get closest for start // Get closest for start
closest = GetClosestKeyFrame(startF); int closest = GetClosestKeyFrame(startF);
if ((closest > startF && closest-startF <= beforeStart) || (closest < startF && startF-closest <= afterStart)) { if ((closest > startF && closest-startF <= beforeStart) || (closest < startF && startF-closest <= afterStart)) {
cur->Start.SetMS(con->TimeAtFrame(closest,agi::vfr::START)); cur->Start.SetMS(c->videoController->TimeAtFrame(closest,agi::vfr::START));
} }
// Get closest for end // Get closest for end
closest = GetClosestKeyFrame(endF)-1; closest = GetClosestKeyFrame(endF)-1;
if ((closest > endF && closest-endF <= beforeEnd) || (closest < endF && endF-closest <= afterEnd)) { if ((closest > endF && closest-endF <= beforeEnd) || (closest < endF && endF-closest <= afterEnd)) {
cur->End.SetMS(con->TimeAtFrame(closest,agi::vfr::END)); cur->End.SetMS(c->videoController->TimeAtFrame(closest,agi::vfr::END));
} }
} }
} }
// Update grid // Update grid
grid->ass->Commit(_("timing processor"), AssFile::COMMIT_TIMES); c->ass->Commit(_("timing processor"), AssFile::COMMIT_TIMES);
} }

View File

@ -46,8 +46,9 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#endif #endif
class SubtitlesGrid; namespace agi { struct Context; }
class AssDialogue; class AssDialogue;
class SubtitlesGrid;
/// DOCME /// DOCME
/// @class DialogTimingProcessor /// @class DialogTimingProcessor
@ -55,8 +56,7 @@ class AssDialogue;
/// ///
/// DOCME /// DOCME
class DialogTimingProcessor : public wxDialog { class DialogTimingProcessor : public wxDialog {
/// DOCME agi::Context *c;
SubtitlesGrid *grid;
/// DOCME /// DOCME
wxStaticBoxSizer *KeyframesSizer; wxStaticBoxSizer *KeyframesSizer;
@ -132,15 +132,13 @@ class DialogTimingProcessor : public wxDialog {
void UpdateControls(); void UpdateControls();
void Process(); void Process();
int GetClosestKeyFrame(int frame); int GetClosestKeyFrame(int frame);
bool StyleOK(wxString styleName);
/// DOCME /// DOCME
std::vector<AssDialogue*> Sorted; std::vector<AssDialogue*> Sorted;
AssDialogue *GetSortedDialogue(int n);
void SortDialogues(); void SortDialogues();
public: public:
DialogTimingProcessor(wxWindow *parent,SubtitlesGrid *grid); DialogTimingProcessor(agi::Context *c);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@ -297,10 +297,10 @@ void FrameMain::InitContents() {
videoSizer->AddStretchSpacer(1); videoSizer->AddStretchSpacer(1);
StartupLog("Create subtitles grid"); StartupLog("Create subtitles grid");
context->subsGrid = SubsGrid = new SubtitlesGrid(this,Panel,-1,context->ass,wxDefaultPosition,wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,"Subs grid"); context->subsGrid = SubsGrid = new SubtitlesGrid(Panel,context.get(),wxSize(600,100),wxWANTS_CHARS | wxSUNKEN_BORDER,"Subs grid");
context->selectionController = context->subsGrid; context->selectionController = context->subsGrid;
context->videoBox->videoSlider->grid = SubsGrid; context->videoBox->videoSlider->grid = SubsGrid;
Search.grid = SubsGrid; Search.context = context.get();
StartupLog("Create tool area splitter window"); StartupLog("Create tool area splitter window");
audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN); audioSash = new wxSashWindow(Panel, ID_SASH_MAIN_AUDIO, wxDefaultPosition, wxDefaultSize, wxSW_3D|wxCLIP_CHILDREN);
@ -316,7 +316,7 @@ void FrameMain::InitContents() {
audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight()); audioSash->SetMinimumSizeY(audioBox->GetSize().GetHeight());
StartupLog("Create subtitle editing box"); StartupLog("Create subtitle editing box");
context->editBox = EditBox = new SubsEditBox(Panel, SubsGrid); context->editBox = EditBox = new SubsEditBox(Panel, context.get());
StartupLog("Arrange main sizers"); StartupLog("Arrange main sizers");
ToolsSizer = new wxBoxSizer(wxVERTICAL); ToolsSizer = new wxBoxSizer(wxVERTICAL);
@ -1085,7 +1085,7 @@ int FrameMain::AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::Fe
int id = activeMacroItems.size();; int id = activeMacroItems.size();;
for (std::vector<Automation4::FeatureMacro*>::const_iterator i = macros.begin(); i != macros.end(); ++i) { for (std::vector<Automation4::FeatureMacro*>::const_iterator i = macros.begin(); i != macros.end(); ++i) {
wxMenuItem * m = menu->Append(ID_MENU_AUTOMATION_MACRO + id, (*i)->GetName(), (*i)->GetDescription()); wxMenuItem * m = menu->Append(ID_MENU_AUTOMATION_MACRO + id, (*i)->GetName(), (*i)->GetDescription());
m->Enable((*i)->Validate(SubsGrid->ass, SubsGrid->GetAbsoluteSelection(), SubsGrid->GetFirstSelRow())); m->Enable((*i)->Validate(context->ass, SubsGrid->GetAbsoluteSelection(), SubsGrid->GetFirstSelRow()));
activeMacroItems.push_back(*i); activeMacroItems.push_back(*i);
id++; id++;
} }
@ -1105,7 +1105,7 @@ void FrameMain::OnAutomationMacro (wxCommandEvent &event) {
std::vector<int> selected_lines = SubsGrid->GetAbsoluteSelection(); std::vector<int> selected_lines = SubsGrid->GetAbsoluteSelection();
int first_sel = SubsGrid->GetFirstSelRow(); int first_sel = SubsGrid->GetFirstSelRow();
// Run the macro... // Run the macro...
activeMacroItems[event.GetId()-ID_MENU_AUTOMATION_MACRO]->Process(SubsGrid->ass, selected_lines, first_sel, this); activeMacroItems[event.GetId()-ID_MENU_AUTOMATION_MACRO]->Process(context->ass, selected_lines, first_sel, this);
SubsGrid->SetSelectionFromAbsolute(selected_lines); SubsGrid->SetSelectionFromAbsolute(selected_lines);
SubsGrid->EndBatch(); SubsGrid->EndBatch();
#endif #endif

View File

@ -63,7 +63,7 @@
#include "audio_controller.h" #include "audio_controller.h"
#include "dialog_colorpicker.h" #include "dialog_colorpicker.h"
#include "dialog_search_replace.h" #include "dialog_search_replace.h"
#include "frame_main.h" #include "include/aegisub/context.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "main.h" #include "main.h"
#include "selection_controller.h" #include "selection_controller.h"
@ -162,15 +162,13 @@ void bind_focus_handler(T *control, Event event, wxString value, wxString alt, w
control->Bind(event, handler); control->Bind(event, handler);
} }
SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid) SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxRAISED_BORDER, "SubsEditBox") : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxRAISED_BORDER, "SubsEditBox")
, line(NULL) , line(NULL)
, splitLineMode(false) , splitLineMode(false)
, controlState(true) , controlState(true)
, grid(grid) , c(context)
{ {
grid->editBox = this;
// Top controls // Top controls
wxArrayString styles; wxArrayString styles;
styles.Add(_T("Default")); styles.Add(_T("Default"));
@ -261,7 +259,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,5); MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,5);
// Text editor // Text editor
TextEdit = new SubsTextEditCtrl(this, wxSize(300,50), wxBORDER_SUNKEN, grid); TextEdit = new SubsTextEditCtrl(this, wxSize(300,50), wxBORDER_SUNKEN, c->subsGrid);
TextEdit->Bind(wxEVT_KEY_DOWN, &SubsEditBox::OnKeyDown, this); TextEdit->Bind(wxEVT_KEY_DOWN, &SubsEditBox::OnKeyDown, this);
TextEdit->SetUndoCollection(false); TextEdit->SetUndoCollection(false);
BottomSizer = new wxBoxSizer(wxHORIZONTAL); BottomSizer = new wxBoxSizer(wxHORIZONTAL);
@ -331,12 +329,12 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
wxSizeEvent evt; wxSizeEvent evt;
OnSize(evt); OnSize(evt);
grid->AddSelectionListener(this); c->subsGrid->AddSelectionListener(this);
grid->ass->AddCommitListener(&SubsEditBox::Update, this); c->ass->AddCommitListener(&SubsEditBox::Update, this);
VideoContext::Get()->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this); context->videoController->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this);
} }
SubsEditBox::~SubsEditBox() { SubsEditBox::~SubsEditBox() {
grid->RemoveSelectionListener(this); c->subsGrid->RemoveSelectionListener(this);
} }
void SubsEditBox::Update(int type) { void SubsEditBox::Update(int type) {
@ -344,13 +342,13 @@ void SubsEditBox::Update(int type) {
if (type == AssFile::COMMIT_FULL || type == AssFile::COMMIT_UNDO) { if (type == AssFile::COMMIT_FULL || type == AssFile::COMMIT_UNDO) {
/// @todo maybe preserve selection over undo? /// @todo maybe preserve selection over undo?
StyleBox->Clear(); StyleBox->Clear();
StyleBox->Append(grid->ass->GetStyles()); StyleBox->Append(c->ass->GetStyles());
ActorBox->Freeze(); ActorBox->Freeze();
ActorBox->Clear(); ActorBox->Clear();
int nrows = grid->GetRows(); int nrows = c->subsGrid->GetRows();
for (int i=0;i<nrows;i++) { for (int i=0;i<nrows;i++) {
wxString actor = grid->GetDialogue(i)->Actor; wxString actor = c->subsGrid->GetDialogue(i)->Actor;
// OSX doesn't like combo boxes that are empty. // OSX doesn't like combo boxes that are empty.
if (actor.empty()) actor = "Actor"; if (actor.empty()) actor = "Actor";
if (ActorBox->FindString(actor) == wxNOT_FOUND) { if (ActorBox->FindString(actor) == wxNOT_FOUND) {
@ -396,20 +394,20 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
Update(AssFile::COMMIT_TEXT); Update(AssFile::COMMIT_TEXT);
/// @todo VideoContext should be doing this /// @todo VideoContext should be doing this
if (VideoContext::Get()->IsLoaded()) { if (c->videoController->IsLoaded()) {
bool sync; bool sync;
if (Search.hasFocus) sync = OPT_GET("Tool/Search Replace/Video Update")->GetBool(); if (Search.hasFocus) sync = OPT_GET("Tool/Search Replace/Video Update")->GetBool();
else sync = OPT_GET("Video/Subtitle Sync")->GetBool(); else sync = OPT_GET("Video/Subtitle Sync")->GetBool();
if (sync) { if (sync) {
VideoContext::Get()->Stop(); c->videoController->Stop();
VideoContext::Get()->JumpToTime(line->Start.GetMS()); c->videoController->JumpToTime(line->Start.GetMS());
} }
} }
SetEvtHandlerEnabled(true); SetEvtHandlerEnabled(true);
} }
void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) { void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
sel = grid->GetSelectedSet(); sel = c->subsGrid->GetSelectedSet();
} }
void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) { void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
@ -421,7 +419,7 @@ void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
ByTime->SetValue(true); ByTime->SetValue(true);
StartTime->SetByFrame(false); StartTime->SetByFrame(false);
EndTime->SetByFrame(false); EndTime->SetByFrame(false);
grid->SetByFrame(false); c->subsGrid->SetByFrame(false);
} }
} }
@ -444,16 +442,16 @@ void SubsEditBox::OnCommitButton(wxCommandEvent &) {
} }
void SubsEditBox::NextLine() { void SubsEditBox::NextLine() {
int next = grid->GetLastSelRow() + 1; int next = c->subsGrid->GetLastSelRow() + 1;
if (next >= grid->GetRows()) { if (next >= c->subsGrid->GetRows()) {
AssDialogue *cur = grid->GetDialogue(next-1); AssDialogue *cur = c->subsGrid->GetDialogue(next-1);
AssDialogue *newline = new AssDialogue; AssDialogue *newline = new AssDialogue;
newline->Start = cur->End; newline->Start = cur->End;
newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt(); newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt();
newline->Style = cur->Style; newline->Style = cur->Style;
grid->InsertLine(newline,next-1,true,true); c->subsGrid->InsertLine(newline,next-1,true,true);
} }
grid->NextLine(); c->subsGrid->NextLine();
} }
void SubsEditBox::OnChange(wxStyledTextEvent &event) { void SubsEditBox::OnChange(wxStyledTextEvent &event) {
@ -473,7 +471,7 @@ void SubsEditBox::SetSelectedRows(setter set, T value, wxString desc, bool amend
for_each(sel.begin(), sel.end(), std::tr1::bind(set, _1, value)); for_each(sel.begin(), sel.end(), std::tr1::bind(set, _1, value));
commitId = grid->ass->Commit(desc, AssFile::COMMIT_TEXT, (amend && desc == lastCommitType) ? commitId : -1); commitId = c->ass->Commit(desc, AssFile::COMMIT_TEXT, (amend && desc == lastCommitType) ? commitId : -1);
lastCommitType = desc; lastCommitType = desc;
} }
@ -506,7 +504,7 @@ void SubsEditBox::CommitTimes(TimeField field) {
} }
} }
timeCommitId[field] = grid->ass->Commit(_("modify times"), AssFile::COMMIT_TIMES, timeCommitId[field]); timeCommitId[field] = c->ass->Commit(_("modify times"), AssFile::COMMIT_TIMES, timeCommitId[field]);
} }
void SubsEditBox::OnSize(wxSizeEvent &evt) { void SubsEditBox::OnSize(wxSizeEvent &evt) {
@ -547,7 +545,7 @@ void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
StartTime->SetByFrame(byFrame); StartTime->SetByFrame(byFrame);
EndTime->SetByFrame(byFrame); EndTime->SetByFrame(byFrame);
Duration->SetByFrame(byFrame); Duration->SetByFrame(byFrame);
grid->SetByFrame(byFrame); c->subsGrid->SetByFrame(byFrame);
event.Skip(); event.Skip();
} }
@ -634,14 +632,14 @@ void SubsEditBox::OnDurationChange(wxCommandEvent &) {
} }
void SubsEditBox::OnMarginLChange(wxCommandEvent &) { void SubsEditBox::OnMarginLChange(wxCommandEvent &) {
SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<0>), MarginL->GetValue(), _("MarginL change")); SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<0>), MarginL->GetValue(), _("MarginL change"));
AssDialogue *cur = grid->GetDialogue(grid->GetFirstSelRow()); AssDialogue *cur = c->subsGrid->GetDialogue(c->subsGrid->GetFirstSelRow());
if (cur) if (cur)
MarginL->ChangeValue(cur->GetMarginString(0,false)); MarginL->ChangeValue(cur->GetMarginString(0,false));
} }
void SubsEditBox::OnMarginRChange(wxCommandEvent &) { void SubsEditBox::OnMarginRChange(wxCommandEvent &) {
SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<1>), MarginR->GetValue(), _("MarginR change")); SetSelectedRows(std::mem_fun(&AssDialogue::SetMarginString<1>), MarginR->GetValue(), _("MarginR change"));
AssDialogue *cur = grid->GetDialogue(grid->GetFirstSelRow()); AssDialogue *cur = c->subsGrid->GetDialogue(c->subsGrid->GetFirstSelRow());
if (cur) if (cur)
MarginR->ChangeValue(cur->GetMarginString(1,false)); MarginR->ChangeValue(cur->GetMarginString(1,false));
} }
@ -653,7 +651,7 @@ static void set_margin_v(AssDialogue* diag, wxString value) {
void SubsEditBox::OnMarginVChange(wxCommandEvent &) { void SubsEditBox::OnMarginVChange(wxCommandEvent &) {
SetSelectedRows(set_margin_v, MarginV->GetValue(), _("MarginV change")); SetSelectedRows(set_margin_v, MarginV->GetValue(), _("MarginV change"));
AssDialogue *cur = grid->GetDialogue(grid->GetFirstSelRow()); AssDialogue *cur = c->subsGrid->GetDialogue(c->subsGrid->GetFirstSelRow());
if (cur) if (cur)
MarginV->ChangeValue(cur->GetMarginString(2,false)); MarginV->ChangeValue(cur->GetMarginString(2,false));
} }
@ -746,7 +744,7 @@ void SubsEditBox::OnFlagButton(wxCommandEvent &evt) {
wxString tagname; wxString tagname;
wxString desc; wxString desc;
bool state = false; bool state = false;
AssStyle *style = grid->ass->GetStyle(line->Style); AssStyle *style = c->ass->GetStyle(line->Style);
AssStyle defStyle; AssStyle defStyle;
if (!style) style = &defStyle; if (!style) style = &defStyle;
if (id == BUTTON_BOLD) { if (id == BUTTON_BOLD) {
@ -797,7 +795,7 @@ void SubsEditBox::OnFontButton(wxCommandEvent &) {
int blockn = BlockAtPos(selstart); int blockn = BlockAtPos(selstart);
wxFont startfont; wxFont startfont;
AssStyle *style = grid->ass->GetStyle(line->Style); AssStyle *style = c->ass->GetStyle(line->Style);
AssStyle defStyle; AssStyle defStyle;
if (!style) style = &defStyle; if (!style) style = &defStyle;
@ -838,7 +836,7 @@ void SubsEditBox::OnColorButton(wxCommandEvent &evt) {
wxString alt; wxString alt;
wxColor color; wxColor color;
AssStyle *style = grid->ass->GetStyle(line->Style); AssStyle *style = c->ass->GetStyle(line->Style);
AssStyle defStyle; AssStyle defStyle;
if (!style) style = &defStyle; if (!style) style = &defStyle;
if (id == BUTTON_COLOR1) { if (id == BUTTON_COLOR1) {
@ -871,7 +869,7 @@ void SubsEditBox::OnColorButton(wxCommandEvent &evt) {
color = get_value(*line, blockn, color, colorTag, alt); color = get_value(*line, blockn, color, colorTag, alt);
wxString initialText = line->Text; wxString initialText = line->Text;
wxColor newColor = GetColorFromUser<SubsEditBox, &SubsEditBox::SetColorCallback>(((AegisubApp*)wxTheApp)->frame, color, this); wxColor newColor = GetColorFromUser<SubsEditBox, &SubsEditBox::SetColorCallback>(c->parent, color, this);
if (newColor == color) { if (newColor == color) {
TextEdit->SetTextTo(initialText); TextEdit->SetTextTo(initialText);
TextEdit->SetSelectionU(selstart, selend); TextEdit->SetSelectionU(selstart, selend);

View File

@ -42,8 +42,8 @@
#include "selection_controller.h" #include "selection_controller.h"
namespace agi { struct Context; }
class AssDialogue; class AssDialogue;
class SubtitlesGrid;
class SubsTextEditCtrl; class SubsTextEditCtrl;
class TimeEdit; class TimeEdit;
class wxButton; class wxButton;
@ -55,7 +55,6 @@ class wxSpinCtrl;
class wxStyledTextCtrl; class wxStyledTextCtrl;
class wxStyledTextEvent; class wxStyledTextEvent;
class wxTextCtrl; class wxTextCtrl;
class AudioController;
namespace agi { namespace vfr { class Framerate; } } namespace agi { namespace vfr { class Framerate; } }
@ -84,8 +83,7 @@ class SubsEditBox : public wxPanel, protected SelectionListener<AssDialogue> {
wxColour disabledBgColour; wxColour disabledBgColour;
wxColour origBgColour; wxColour origBgColour;
// Externally supplied controls agi::Context *c;
SubtitlesGrid *grid;
// Box controls // Box controls
wxCheckBox *CommentBox; wxCheckBox *CommentBox;
@ -196,7 +194,6 @@ public:
/// @brief Constructor /// @brief Constructor
/// @param parent Parent window /// @param parent Parent window
/// @param grid Associated grid SubsEditBox(wxWindow *parent, agi::Context *context);
SubsEditBox(wxWindow *parent, SubtitlesGrid *grid);
~SubsEditBox(); ~SubsEditBox();
}; };

View File

@ -103,21 +103,15 @@ END_EVENT_TABLE()
/// @param size /// @param size
/// @param style /// @param style
/// @param name /// @param name
SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID id, AssFile *subs, const wxPoint& pos, const wxSize& size, long style, const wxString& name) SubtitlesGrid::SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxSize& size, long style, const wxString& name)
: BaseGrid(parent,id,pos,size,style,name) : BaseGrid(parent,context,size,style,name)
, ass(subs) , seekListener(context->videoController->AddSeekListener(&SubtitlesGrid::Refresh, this, false, (const wxRect *)NULL))
{ {
byFrame = false;
editBox = NULL;
parentFrame = parentFr;
seekListener = VideoContext::Get()->AddSeekListener(&SubtitlesGrid::Refresh, this, false, (const wxRect *)NULL);
OnHighlightVisibleChange(*OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame")); OnHighlightVisibleChange(*OPT_GET("Subtitle/Grid/Highlight Subtitles in Frame"));
OPT_SUB("Subtitle/Grid/Highlight Subtitles in Frame", &SubtitlesGrid::OnHighlightVisibleChange, this); OPT_SUB("Subtitle/Grid/Highlight Subtitles in Frame", &SubtitlesGrid::OnHighlightVisibleChange, this);
OPT_SUB("Subtitle/Grid/Hide Overrides", std::tr1::bind(&SubtitlesGrid::Refresh, this, false, (const wxRect*)0)); OPT_SUB("Subtitle/Grid/Hide Overrides", std::tr1::bind(&SubtitlesGrid::Refresh, this, false, (const wxRect*)0));
ass->AddCommitListener(&SubtitlesGrid::OnSubtitlesCommit, this); context->ass->AddCommitListener(&SubtitlesGrid::OnSubtitlesCommit, this);
ass->AddFileOpenListener(&SubtitlesGrid::OnSubtitlesOpen, this); context->ass->AddFileOpenListener(&SubtitlesGrid::OnSubtitlesOpen, this);
} }
/// @brief Destructor /// @brief Destructor
@ -196,14 +190,14 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
state = (sels == 1); state = (sels == 1);
menu.Append(MENU_INSERT_BEFORE,_("&Insert (before)"),_T("Inserts a line before current"))->Enable(state); 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); menu.Append(MENU_INSERT_AFTER,_("Insert (after)"),_T("Inserts a line after current"))->Enable(state);
state = (sels == 1 && context->IsLoaded()); state = (sels == 1 && context->videoController->IsLoaded());
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_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.Append(MENU_INSERT_AFTER_VIDEO,_("Insert at video time (after)"),_T("Inserts a line after current, starting at video time"))->Enable(state);
menu.AppendSeparator(); menu.AppendSeparator();
// Duplicate selection // Duplicate selection
menu.Append(MENU_DUPLICATE,_("&Duplicate"),_("Duplicate the selected lines"))->Enable(continuous); menu.Append(MENU_DUPLICATE,_("&Duplicate"),_("Duplicate the selected lines"))->Enable(continuous);
menu.Append(MENU_DUPLICATE_NEXT_FRAME,_("&Duplicate and shift by 1 frame"),_("Duplicate lines and shift by one frame"))->Enable(continuous && context->TimecodesLoaded()); menu.Append(MENU_DUPLICATE_NEXT_FRAME,_("&Duplicate and shift by 1 frame"),_("Duplicate lines and shift by one frame"))->Enable(continuous && context->videoController->TimecodesLoaded());
menu.Append(MENU_SPLIT_BY_KARAOKE,_("Split (by karaoke)"),_("Uses karaoke timing to split line into multiple smaller lines"))->Enable(sels > 0); menu.Append(MENU_SPLIT_BY_KARAOKE,_("Split (by karaoke)"),_("Uses karaoke timing to split line into multiple smaller lines"))->Enable(sels > 0);
// Swaps selection // Swaps selection
@ -228,7 +222,7 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
menu.AppendSeparator(); menu.AppendSeparator();
//Make audio clip //Make audio clip
state = parentFrame->context->audioController->IsAudioOpen()==true; state = context->audioController->IsAudioOpen();
menu.Append(MENU_AUDIOCLIP,_("Create audio clip"),_("Create an audio clip of the selected line"))->Enable(state); menu.Append(MENU_AUDIOCLIP,_("Create audio clip"),_("Create an audio clip of the selected line"))->Enable(state);
menu.AppendSeparator(); menu.AppendSeparator();
@ -343,7 +337,7 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) {
} }
// Duplicate and shift // Duplicate and shift
if (context->TimecodesLoaded()) { if (context->videoController->TimecodesLoaded()) {
if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) { if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) {
DuplicateLines(n,n2,true); DuplicateLines(n,n2,true);
return; return;
@ -427,7 +421,7 @@ void SubtitlesGrid::OnSplitByKaraoke (wxCommandEvent &) {
didSplit |= SplitLineByKaraoke(sels[i]); didSplit |= SplitLineByKaraoke(sels[i]);
} }
if (didSplit) { if (didSplit) {
ass->Commit(_("splitting")); context->ass->Commit(_("splitting"));
} }
EndBatch(); EndBatch();
} }
@ -498,7 +492,7 @@ void SubtitlesGrid::OnInsertBeforeVideo (wxCommandEvent &) {
// Create line to add // Create line to add
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
int video_ms = context->TimeAtFrame(context->GetFrameN(),agi::vfr::START); int video_ms = context->videoController->TimeAtFrame(context->videoController->GetFrameN(),agi::vfr::START);
def->Start.SetMS(video_ms); def->Start.SetMS(video_ms);
def->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt()); def->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt());
def->Style = GetDialogue(n)->Style; def->Style = GetDialogue(n)->Style;
@ -518,7 +512,7 @@ void SubtitlesGrid::OnInsertAfterVideo (wxCommandEvent &) {
// Create line to add // Create line to add
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
int video_ms = context->TimeAtFrame(context->GetFrameN(),agi::vfr::START); int video_ms = context->videoController->TimeAtFrame(context->videoController->GetFrameN(),agi::vfr::START);
def->Start.SetMS(video_ms); def->Start.SetMS(video_ms);
def->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt()); def->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt());
def->Style = GetDialogue(n)->Style; def->Style = GetDialogue(n)->Style;
@ -616,14 +610,14 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
if (d1->Text == (*d2)->Text) { if (d1->Text == (*d2)->Text) {
expand_times(d1, *d2); expand_times(d1, *d2);
delete d1; delete d1;
ass->Line.remove(d1); context->ass->Line.remove(d1);
continue; continue;
} }
// 1, 1+2, 1 turns into 1, 2, [empty] // 1, 1+2, 1 turns into 1, 2, [empty]
if (d1->Text.empty()) { if (d1->Text.empty()) {
delete d1; delete d1;
ass->Line.remove(d1); context->ass->Line.remove(d1);
continue; continue;
} }
@ -656,11 +650,11 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
} }
} }
ass->Commit(_("combining")); context->ass->Commit(_("combining"));
// Remove now non-existent lines from the selection // Remove now non-existent lines from the selection
Selection lines; Selection lines;
transform(ass->Line.begin(), ass->Line.end(), inserter(lines, lines.begin()), cast<AssDialogue*>()); transform(context->ass->Line.begin(), context->ass->Line.end(), inserter(lines, lines.begin()), cast<AssDialogue*>());
Selection newSel; Selection newSel;
set_intersection(lines.begin(), lines.end(), selectedSet.begin(), selectedSet.end(), inserter(newSel, newSel.begin())); set_intersection(lines.begin(), lines.end(), selectedSet.begin(), selectedSet.end(), inserter(newSel, newSel.begin()));
@ -677,7 +671,7 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
/// @brief Export audio clip of line /// @brief Export audio clip of line
void SubtitlesGrid::OnAudioClip(wxCommandEvent &) { void SubtitlesGrid::OnAudioClip(wxCommandEvent &) {
int64_t num_samples,start=0,end=0,temp; int64_t num_samples,start=0,end=0,temp;
AudioController *audioController = parentFrame->context->audioController; AudioController *audioController = context->audioController;
const AudioProvider *provider = audioController->GetAudioProvider(); const AudioProvider *provider = audioController->GetAudioProvider();
AssDialogue *cur; AssDialogue *cur;
wxArrayInt sel = GetSelection(); wxArrayInt sel = GetSelection();
@ -763,7 +757,7 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
std::swap(*dlg1, *dlg2); std::swap(*dlg1, *dlg2);
ass->Commit(_("swap lines")); context->ass->Commit(_("swap lines"));
} }
/// @brief Insert a line /// @brief Insert a line
@ -773,14 +767,14 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
/// @param update /// @param update
void SubtitlesGrid::InsertLine(AssDialogue *line,int n,bool after,bool update) { void SubtitlesGrid::InsertLine(AssDialogue *line,int n,bool after,bool update) {
AssDialogue *rel_line = GetDialogue(n); AssDialogue *rel_line = GetDialogue(n);
entryIter pos = std::find(ass->Line.begin(), ass->Line.end(), rel_line); entryIter pos = std::find(context->ass->Line.begin(), context->ass->Line.end(), rel_line);
if (after) ++pos; if (after) ++pos;
entryIter newIter = ass->Line.insert(pos,line); entryIter newIter = context->ass->Line.insert(pos,line);
// Update // Update
if (update) { if (update) {
ass->Commit(_("line insertion")); context->ass->Commit(_("line insertion"));
} }
else { else {
UpdateMaps(); UpdateMaps();
@ -896,7 +890,7 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
// Update data post-insertion // Update data post-insertion
if (inserted > 0) { if (inserted > 0) {
ass->Commit(_("paste"), pasteOver ? AssFile::COMMIT_TEXT : AssFile::COMMIT_FULL); context->ass->Commit(_("paste"), pasteOver ? AssFile::COMMIT_TEXT : AssFile::COMMIT_FULL);
// Set selection // Set selection
if (!pasteOver) { if (!pasteOver) {
@ -913,14 +907,14 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
} }
void SubtitlesGrid::DeleteLines(wxArrayInt target, bool flagModified) { void SubtitlesGrid::DeleteLines(wxArrayInt target, bool flagModified) {
entryIter before_first = std::find_if(ass->Line.begin(), ass->Line.end(), cast<AssDialogue*>()); --before_first; entryIter before_first = std::find_if(context->ass->Line.begin(), context->ass->Line.end(), cast<AssDialogue*>()); --before_first;
int old_active_line_index = GetDialogueIndex(GetActiveLine()); int old_active_line_index = GetDialogueIndex(GetActiveLine());
int row = -1; int row = -1;
int deleted = 0; int deleted = 0;
for (entryIter cur = ass->Line.begin(); cur != ass->Line.end();) { for (entryIter cur = context->ass->Line.begin(); cur != context->ass->Line.end();) {
if (dynamic_cast<AssDialogue*>(*cur) && ++row == target[deleted]) { if (dynamic_cast<AssDialogue*>(*cur) && ++row == target[deleted]) {
cur = ass->Line.erase(cur); cur = context->ass->Line.erase(cur);
++deleted; ++deleted;
if (deleted == target.size()) break; if (deleted == target.size()) break;
} }
@ -933,12 +927,12 @@ void SubtitlesGrid::DeleteLines(wxArrayInt target, bool flagModified) {
if (GetRows() == deleted) { if (GetRows() == deleted) {
AssDialogue *def = new AssDialogue; AssDialogue *def = new AssDialogue;
++before_first; ++before_first;
ass->Line.insert(before_first, def); context->ass->Line.insert(before_first, def);
old_active_line_index = 0; old_active_line_index = 0;
} }
if (flagModified) { if (flagModified) {
ass->Commit(_("delete")); context->ass->Commit(_("delete"));
} }
else { else {
UpdateMaps(); UpdateMaps();
@ -991,7 +985,7 @@ void SubtitlesGrid::JoinLines(int n1,int n2,bool concat) {
// Delete remaining lines (this will auto commit) // Delete remaining lines (this will auto commit)
DeleteLines(GetRangeArray(n1+1,n2), false); DeleteLines(GetRangeArray(n1+1,n2), false);
ass->Commit(_("join lines")); context->ass->Commit(_("join lines"));
// Select new line // Select new line
SetActiveLine(cur); SetActiveLine(cur);
@ -1031,7 +1025,7 @@ void SubtitlesGrid::AdjoinLines(int n1,int n2,bool setStart) {
} }
} }
ass->Commit(_("adjoin")); context->ass->Commit(_("adjoin"));
} }
void SubtitlesGrid::JoinAsKaraoke(int n1,int n2) { void SubtitlesGrid::JoinAsKaraoke(int n1,int n2) {
@ -1073,7 +1067,7 @@ void SubtitlesGrid::JoinAsKaraoke(int n1,int n2) {
// Delete remaining lines (this will auto commit) // Delete remaining lines (this will auto commit)
DeleteLines(GetRangeArray(n1+1,n2), false); DeleteLines(GetRangeArray(n1+1,n2), false);
ass->Commit(_("join as karaoke")); context->ass->Commit(_("join as karaoke"));
// Select new line // Select new line
SetActiveLine(cur); SetActiveLine(cur);
@ -1091,9 +1085,9 @@ void SubtitlesGrid::DuplicateLines(int n1,int n2,bool nextFrame) {
// Shift to next frame // Shift to next frame
if (nextFrame) { if (nextFrame) {
int posFrame = context->FrameAtTime(cur->End.GetMS(),agi::vfr::END) + 1; int posFrame = context->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END) + 1;
cur->Start.SetMS(context->TimeAtFrame(posFrame,agi::vfr::START)); cur->Start.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::START));
cur->End.SetMS(context->TimeAtFrame(posFrame,agi::vfr::END)); cur->End.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::END));
} }
// Insert // Insert
@ -1122,8 +1116,8 @@ void SubtitlesGrid::ShiftLineByFrames(int n,int len,int type) {
assert(type >= 0 && type <= 2); assert(type >= 0 && type <= 2);
AssDialogue *cur = GetDialogue(n); AssDialogue *cur = GetDialogue(n);
if (type != 2) cur->Start.SetMS(context->TimeAtFrame(len + context->FrameAtTime(cur->Start.GetMS(),agi::vfr::START),agi::vfr::START)); if (type != 2) cur->Start.SetMS(context->videoController->TimeAtFrame(len + context->videoController->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)); if (type != 1) cur->End.SetMS(context->videoController->TimeAtFrame(len + context->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END),agi::vfr::END));
} }
void SubtitlesGrid::SplitLine(AssDialogue *n1,int pos,bool estimateTimes) { void SubtitlesGrid::SplitLine(AssDialogue *n1,int pos,bool estimateTimes) {
@ -1141,7 +1135,7 @@ void SubtitlesGrid::SplitLine(AssDialogue *n1,int pos,bool estimateTimes) {
n2->Start.SetMS(splitTime); n2->Start.SetMS(splitTime);
} }
ass->Commit(_("split")); context->ass->Commit(_("split"));
} }
bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) { bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
@ -1184,10 +1178,10 @@ bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
} }
void SubtitlesGrid::SetSubsToVideo(bool start) { void SubtitlesGrid::SetSubsToVideo(bool start) {
if (!context->IsLoaded()) return; if (!context->videoController->IsLoaded()) return;
// Get new time // Get new time
int ms = context->TimeAtFrame(context->GetFrameN(),start ? agi::vfr::START : agi::vfr::END); int ms = context->videoController->TimeAtFrame(context->videoController->GetFrameN(),start ? agi::vfr::START : agi::vfr::END);
// Update selection // Update selection
wxArrayInt sel = GetSelection(); wxArrayInt sel = GetSelection();
@ -1202,7 +1196,7 @@ void SubtitlesGrid::SetSubsToVideo(bool start) {
} }
if (modified) { if (modified) {
ass->Commit(_("timing"), AssFile::COMMIT_TIMES); context->ass->Commit(_("timing"), AssFile::COMMIT_TIMES);
} }
} }
@ -1212,9 +1206,9 @@ void SubtitlesGrid::SetVideoToSubs(bool start) {
AssDialogue *cur = GetDialogue(sel[0]); AssDialogue *cur = GetDialogue(sel[0]);
if (cur) { if (cur) {
if (start) if (start)
context->JumpToTime(cur->Start.GetMS()); context->videoController->JumpToTime(cur->Start.GetMS());
else else
context->JumpToTime(cur->End.GetMS(), agi::vfr::END); context->videoController->JumpToTime(cur->End.GetMS(), agi::vfr::END);
} }
} }
@ -1231,7 +1225,7 @@ std::vector<int> SubtitlesGrid::GetAbsoluteSelection() {
GetSelectedSet(sel); GetSelectedSet(sel);
int line_index = 0; int line_index = 0;
for (entryIter it = ass->Line.begin(); it != ass->Line.end(); ++it, ++line_index) { for (entryIter it = context->ass->Line.begin(); it != context->ass->Line.end(); ++it, ++line_index) {
if (sel.find(dynamic_cast<AssDialogue*>(*it)) != sel.end()) if (sel.find(dynamic_cast<AssDialogue*>(*it)) != sel.end())
result.push_back(line_index); result.push_back(line_index);
} }
@ -1248,11 +1242,11 @@ void SubtitlesGrid::SetSelectionFromAbsolute(std::vector<int> &selection) {
std::sort(selection.begin(), selection.end()); std::sort(selection.begin(), selection.end());
int i = 0; int i = 0;
std::list<AssEntry*>::iterator j = ass->Line.begin(); std::list<AssEntry*>::iterator j = context->ass->Line.begin();
for (size_t selveci = 0; selveci < selection.size(); ++selveci) { for (size_t selveci = 0; selveci < selection.size(); ++selveci) {
while (i != selection[selveci] && j != ass->Line.end()) ++i, ++j; while (i != selection[selveci] && j != context->ass->Line.end()) ++i, ++j;
if (j == ass->Line.end()) break; /// @todo Report error somehow if (j == context->ass->Line.end()) break; /// @todo Report error somehow
AssDialogue *dlg = dynamic_cast<AssDialogue*>(*j); AssDialogue *dlg = dynamic_cast<AssDialogue*>(*j);
if (dlg) newsel.insert(dlg); if (dlg) newsel.insert(dlg);
} }

View File

@ -52,11 +52,7 @@
namespace agi { class OptionValue; } namespace agi { class OptionValue; }
class AssFile;
class AssEntry; class AssEntry;
class AssDialogue;
class SubsEditBox;
class FrameMain;
typedef std::list<AssEntry*>::iterator entryIter; typedef std::list<AssEntry*>::iterator entryIter;
@ -66,7 +62,6 @@ typedef std::list<AssEntry*>::iterator entryIter;
/// ///
/// DOCME /// DOCME
class SubtitlesGrid: public BaseGrid { class SubtitlesGrid: public BaseGrid {
private:
agi::signal::Connection seekListener; agi::signal::Connection seekListener;
void OnPopupMenu(bool alternate=false); void OnPopupMenu(bool alternate=false);
@ -103,10 +98,7 @@ private:
void OnSubtitlesOpen(); void OnSubtitlesOpen();
public: public:
/// Currently open file SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
AssFile *ass;
SubtitlesGrid(FrameMain* parentFrame,wxWindow *parent, wxWindowID id, AssFile *subs, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
~SubtitlesGrid(); ~SubtitlesGrid();
/// @brief Jump to the start/end time of the current subtitle line /// @brief Jump to the start/end time of the current subtitle line

View File

@ -158,7 +158,7 @@ VideoDisplay::VideoDisplay(
slots.push_back(con->videoController->AddSeekListener(&VideoDisplay::SetFrame, this)); slots.push_back(con->videoController->AddSeekListener(&VideoDisplay::SetFrame, this));
slots.push_back(con->videoController->AddVideoOpenListener(&VideoDisplay::OnVideoOpen, this)); slots.push_back(con->videoController->AddVideoOpenListener(&VideoDisplay::OnVideoOpen, this));
slots.push_back(con->videoController->AddARChangeListener(&VideoDisplay::UpdateSize, this)); slots.push_back(con->videoController->AddARChangeListener(&VideoDisplay::UpdateSize, this));
slots.push_back(model->AddCommitListener(&VideoDisplay::OnCommit, this)); slots.push_back(con->ass->AddCommitListener(&VideoDisplay::OnCommit, this));
SetCursor(wxNullCursor); SetCursor(wxNullCursor);
} }

View File

@ -47,7 +47,6 @@
#include <libaegisub/signal.h> #include <libaegisub/signal.h>
// Prototypes // Prototypes
class AssFile;
class FrameReadyEvent; class FrameReadyEvent;
class VideoBox; class VideoBox;
class VideoContext; class VideoContext;
@ -186,8 +185,6 @@ class VideoDisplay : public wxGLCanvas {
/// The dropdown box for selecting zoom levels /// The dropdown box for selecting zoom levels
wxComboBox *zoomBox; wxComboBox *zoomBox;
AssFile *model;
public: public:
/// The VideoBox this display is contained in /// The VideoBox this display is contained in
VideoBox *box; VideoBox *box;

View File

@ -69,7 +69,7 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context,
, commitId(-1) , commitId(-1)
, selChanged(false) , selChanged(false)
, selectedFeatures(selFeatures) , selectedFeatures(selFeatures)
, grid(context->subsGrid) , c(context)
, parent(parent) , parent(parent)
, holding(false) , holding(false)
, dragging(false) , dragging(false)
@ -81,15 +81,15 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context,
, ctrlDown(false) , ctrlDown(false)
, altDown(false) , altDown(false)
{ {
frameNumber = context->videoController->GetFrameN(); frameNumber = c->videoController->GetFrameN();
curDiag = GetActiveDialogueLine(); curDiag = GetActiveDialogueLine();
grid->AddSelectionListener(this); c->selectionController->AddSelectionListener(this);
curFeature = features.begin(); curFeature = features.begin();
} }
template<class FeatureType> template<class FeatureType>
VisualTool<FeatureType>::~VisualTool() { VisualTool<FeatureType>::~VisualTool() {
grid->RemoveSelectionListener(this); c->selectionController->RemoveSelectionListener(this);
} }
template<class FeatureType> template<class FeatureType>
@ -203,7 +203,7 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
else { else {
selChanged = false; selChanged = false;
} }
if (curFeature->line) grid->SetActiveLine(curFeature->line); if (curFeature->line) c->selectionController->SetActiveLine(curFeature->line);
if (InitializeDrag(curFeature)) { if (InitializeDrag(curFeature)) {
dragStartX = video.x; dragStartX = video.x;
@ -222,8 +222,8 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
if (!altDown) { if (!altDown) {
ClearSelection(); ClearSelection();
Selection sel; Selection sel;
sel.insert(grid->GetActiveLine()); sel.insert(c->selectionController->GetActiveLine());
grid->SetSelectedSet(sel); c->selectionController->SetSelectedSet(sel);
needRender = true; needRender = true;
} }
if (curDiag && InitializeHold()) { if (curDiag && InitializeHold()) {
@ -248,14 +248,14 @@ void VisualTool<FeatureType>::Commit(wxString message) {
if (message.empty()) { if (message.empty()) {
message = _("visual typesetting"); message = _("visual typesetting");
} }
commitId = grid->ass->Commit(message, AssFile::COMMIT_TEXT, commitId); commitId = c->ass->Commit(message, AssFile::COMMIT_TEXT, commitId);
externalChange = true; externalChange = true;
} }
template<class FeatureType> template<class FeatureType>
AssDialogue* VisualTool<FeatureType>::GetActiveDialogueLine() { AssDialogue* VisualTool<FeatureType>::GetActiveDialogueLine() {
AssDialogue *diag = grid->GetActiveLine(); AssDialogue *diag = c->selectionController->GetActiveLine();
if (diag && grid->IsDisplayed(diag)) if (diag && c->subsGrid->IsDisplayed(diag))
return diag; return diag;
return NULL; return NULL;
} }
@ -312,7 +312,7 @@ void VisualTool<FeatureType>::SetFrame(int newFrameNumber) {
template<class FeatureType> template<class FeatureType>
void VisualTool<FeatureType>::OnActiveLineChanged(AssDialogue *new_line) { void VisualTool<FeatureType>::OnActiveLineChanged(AssDialogue *new_line) {
if (new_line && !grid->IsDisplayed(new_line)) { if (new_line && !c->subsGrid->IsDisplayed(new_line)) {
new_line = NULL; new_line = NULL;
} }
if (new_line != curDiag) { if (new_line != curDiag) {
@ -335,7 +335,7 @@ void VisualTool<FeatureType>::SetSelection(feature_iterator feat) {
Selection sel; Selection sel;
sel.insert(line); sel.insert(line);
grid->SetSelectedSet(sel); c->selectionController->SetSelectedSet(sel);
} }
} }
@ -344,9 +344,9 @@ template<class FeatureType>
void VisualTool<FeatureType>::AddSelection(feature_iterator feat) { void VisualTool<FeatureType>::AddSelection(feature_iterator feat) {
if (selFeatures.insert(feat).second && feat->line) { if (selFeatures.insert(feat).second && feat->line) {
lineSelCount[feat->line] += 1; lineSelCount[feat->line] += 1;
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
if (sel.insert(feat->line).second) { if (sel.insert(feat->line).second) {
grid->SetSelectedSet(sel); c->selectionController->SetSelectedSet(sel);
} }
} }
} }
@ -360,7 +360,7 @@ void VisualTool<FeatureType>::RemoveSelection(feature_iterator feat) {
lineSelCount[line] -= 1; lineSelCount[line] -= 1;
assert(lineSelCount[line] >= 0); assert(lineSelCount[line] >= 0);
if (lineSelCount[line] <= 0) { if (lineSelCount[line] <= 0) {
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
// Don't deselect the only selected line // Don't deselect the only selected line
if (sel.size() <= 1) return; if (sel.size() <= 1) return;
@ -369,11 +369,11 @@ void VisualTool<FeatureType>::RemoveSelection(feature_iterator feat) {
// Set the active line to an arbitrary selected line if we just // Set the active line to an arbitrary selected line if we just
// deselected the active line // deselected the active line
if (line == grid->GetActiveLine()) { if (line == c->selectionController->GetActiveLine()) {
grid->SetActiveLine(*sel.begin()); c->selectionController->SetActiveLine(*sel.begin());
} }
grid->SetSelectedSet(sel); c->selectionController->SetSelectedSet(sel);
} }
} }
} }
@ -435,7 +435,7 @@ void VisualTool<FeatureType>::GetLinePosition(AssDialogue *diag,int &x, int &y,
for (int i=0;i<4;i++) margin[i] = diag->Margin[i]; for (int i=0;i<4;i++) margin[i] = diag->Margin[i];
int align = 2; int align = 2;
AssStyle *style = grid->ass->GetStyle(diag->Style); AssStyle *style = c->ass->GetStyle(diag->Style);
if (style) { if (style) {
align = style->alignment; align = style->alignment;
for (int i=0;i<4;i++) { for (int i=0;i<4;i++) {
@ -444,7 +444,7 @@ void VisualTool<FeatureType>::GetLinePosition(AssDialogue *diag,int &x, int &y,
} }
int sw,sh; int sw,sh;
VideoContext::Get()->GetScriptSize(sw,sh); c->videoController->GetScriptSize(sw,sh);
// Process margins // Process margins
margin[1] = sw - margin[1]; margin[1] = sw - margin[1];
@ -515,7 +515,7 @@ template<class FeatureType>
void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) { void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) {
rx = ry = rz = 0.f; rx = ry = rz = 0.f;
AssStyle *style = grid->ass->GetStyle(diag->Style); AssStyle *style = c->ass->GetStyle(diag->Style);
if (style) { if (style) {
rz = style->angle; rz = style->angle;
} }
@ -533,7 +533,7 @@ template<class FeatureType>
void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) { void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) {
scalX = scalY = 100.f; scalX = scalY = 100.f;
AssStyle *style = grid->ass->GetStyle(diag->Style); AssStyle *style = c->ass->GetStyle(diag->Style);
if (style) { if (style) {
scalX = style->scalex; scalX = style->scalex;
scalY = style->scaley; scalY = style->scaley;
@ -551,7 +551,7 @@ template<class FeatureType>
void VisualTool<FeatureType>::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,bool &inverse) { void VisualTool<FeatureType>::GetLineClip(AssDialogue *diag,int &x1,int &y1,int &x2,int &y2,bool &inverse) {
x1 = y1 = 0; x1 = y1 = 0;
int sw,sh; int sw,sh;
VideoContext::Get()->GetScriptSize(sw,sh); c->videoController->GetScriptSize(sw,sh);
x2 = sw-1; x2 = sw-1;
y2 = sh-1; y2 = sh-1;
inverse = false; inverse = false;

View File

@ -155,7 +155,7 @@ protected:
/// Read-only reference to the set of selected features for subclasses /// Read-only reference to the set of selected features for subclasses
const std::set<feature_iterator, ltaddr> &selectedFeatures; const std::set<feature_iterator, ltaddr> &selectedFeatures;
typedef typename std::set<feature_iterator, ltaddr>::const_iterator sel_iterator; typedef typename std::set<feature_iterator, ltaddr>::const_iterator sel_iterator;
SubtitlesGrid *grid; agi::Context *c;
VideoDisplay *parent; /// VideoDisplay which this belongs to, used to frame conversion VideoDisplay *parent; /// VideoDisplay which this belongs to, used to frame conversion
bool holding; /// Is a hold currently in progress? bool holding; /// Is a hold currently in progress?
AssDialogue *curDiag; /// Active dialogue line; NULL if it is not visible on the current frame AssDialogue *curDiag; /// Active dialogue line; NULL if it is not visible on the current frame

View File

@ -36,6 +36,7 @@
#include "config.h" #include "config.h"
#include "ass_file.h" #include "ass_file.h"
#include "include/aegisub/context.h"
#include "gl_text.h" #include "gl_text.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "video_context.h" #include "video_context.h"
@ -61,7 +62,7 @@ bool VisualToolCross::Update() {
dx -= vx; dx -= vx;
dy -= vy; dy -= vy;
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
int x1, y1; int x1, y1;
GetLinePosition(*cur, x1, y1); GetLinePosition(*cur, x1, y1);

View File

@ -37,6 +37,7 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "include/aegisub/context.h"
#include "libresrc/libresrc.h" #include "libresrc/libresrc.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "utils.h" #include "utils.h"
@ -64,7 +65,7 @@ VisualToolDrag::VisualToolDrag(VideoDisplay *parent, agi::Context *context, Vide
toolBar->Realize(); toolBar->Realize();
toolBar->Show(true); toolBar->Show(true);
grid->GetSelectedSet(selection); c->selectionController->GetSelectedSet(selection);
OnFileChanged(); OnFileChanged();
} }
@ -124,9 +125,9 @@ void VisualToolDrag::OnFileChanged() {
ClearSelection(); ClearSelection();
primary = NULL; primary = NULL;
for (int i = grid->GetRows() - 1; i >=0; i--) { for (int i = c->subsGrid->GetRows() - 1; i >=0; i--) {
AssDialogue *diag = grid->GetDialogue(i); AssDialogue *diag = c->subsGrid->GetDialogue(i);
if (BaseGrid::IsDisplayed(diag)) { if (c->subsGrid->IsDisplayed(diag)) {
MakeFeatures(diag); MakeFeatures(diag);
} }
} }
@ -134,14 +135,14 @@ void VisualToolDrag::OnFileChanged() {
} }
void VisualToolDrag::OnFrameChanged() { void VisualToolDrag::OnFrameChanged() {
if (primary && !BaseGrid::IsDisplayed(primary->line)) primary = NULL; if (primary && !c->subsGrid->IsDisplayed(primary->line)) primary = NULL;
feature_iterator feat = features.begin(); feature_iterator feat = features.begin();
feature_iterator end = features.end(); feature_iterator end = features.end();
for (int i = grid->GetRows() - 1; i >=0; i--) { for (int i = c->subsGrid->GetRows() - 1; i >=0; i--) {
AssDialogue *diag = grid->GetDialogue(i); AssDialogue *diag = c->subsGrid->GetDialogue(i);
if (BaseGrid::IsDisplayed(diag)) { if (c->subsGrid->IsDisplayed(diag)) {
// Features don't exist and should // Features don't exist and should
if (feat == end || feat->line != diag) { if (feat == end || feat->line != diag) {
MakeFeatures(diag, feat); MakeFeatures(diag, feat);
@ -163,10 +164,10 @@ void VisualToolDrag::OnFrameChanged() {
} }
void VisualToolDrag::OnSelectedSetChanged(const Selection &added, const Selection &removed) { void VisualToolDrag::OnSelectedSetChanged(const Selection &added, const Selection &removed) {
grid->GetSelectedSet(selection); c->selectionController->GetSelectedSet(selection);
if (!externalChange) return; if (!externalChange) return;
externalChange = false; externalChange = false;
grid->BeginBatch(); c->subsGrid->BeginBatch();
for (feature_iterator cur = features.begin(); cur != features.end(); ++cur) { for (feature_iterator cur = features.begin(); cur != features.end(); ++cur) {
// Remove all deselected lines // Remove all deselected lines
@ -179,7 +180,7 @@ void VisualToolDrag::OnSelectedSetChanged(const Selection &added, const Selectio
} }
} }
grid->EndBatch(); c->subsGrid->EndBatch();
externalChange = true; externalChange = true;
} }
@ -290,7 +291,7 @@ bool VisualToolDrag::InitializeDrag(feature_iterator feature) {
// Set time of clicked feature to the current frame and shift all other // Set time of clicked feature to the current frame and shift all other
// selected features by the same amount // selected features by the same amount
if (feature->type != DRAG_ORIGIN) { if (feature->type != DRAG_ORIGIN) {
int time = VideoContext::Get()->TimeAtFrame(frameNumber) - feature->line->Start.GetMS(); int time = c->videoController->TimeAtFrame(frameNumber) - feature->line->Start.GetMS();
int change = time - feature->time; int change = time - feature->time;
for (sel_iterator cur = selectedFeatures.begin(); cur != selectedFeatures.end(); ++cur) { for (sel_iterator cur = selectedFeatures.begin(); cur != selectedFeatures.end(); ++cur) {

View File

@ -41,6 +41,7 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "include/aegisub/context.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "utils.h" #include "utils.h"
#include "video_context.h" #include "video_context.h"
@ -188,7 +189,7 @@ void VisualToolRotateXY::UpdateHold() {
} }
void VisualToolRotateXY::CommitHold() { void VisualToolRotateXY::CommitHold() {
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
SetOverride(*cur, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX)); SetOverride(*cur, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX));
SetOverride(*cur, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY)); SetOverride(*cur, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY));

View File

@ -41,6 +41,7 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "include/aegisub/context.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "utils.h" #include "utils.h"
#include "video_context.h" #include "video_context.h"
@ -150,7 +151,7 @@ void VisualToolRotateZ::UpdateHold() {
} }
void VisualToolRotateZ::CommitHold() { void VisualToolRotateZ::CommitHold() {
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
SetOverride(*cur, L"\\frz",wxString::Format(L"(%0.3g)",curAngle)); SetOverride(*cur, L"\\frz",wxString::Format(L"(%0.3g)",curAngle));
} }

View File

@ -41,6 +41,7 @@
#include "ass_dialogue.h" #include "ass_dialogue.h"
#include "ass_file.h" #include "ass_file.h"
#include "include/aegisub/context.h"
#include "subs_grid.h" #include "subs_grid.h"
#include "utils.h" #include "utils.h"
#include "video_context.h" #include "video_context.h"
@ -145,7 +146,7 @@ void VisualToolScale::UpdateHold() {
} }
void VisualToolScale::CommitHold() { void VisualToolScale::CommitHold() {
Selection sel = grid->GetSelectedSet(); Selection sel = c->selectionController->GetSelectedSet();
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) { for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
SetOverride(*cur, L"\\fscx",wxString::Format(L"(%0.3g)",curScaleX)); SetOverride(*cur, L"\\fscx",wxString::Format(L"(%0.3g)",curScaleX));
SetOverride(*cur, L"\\fscy",wxString::Format(L"(%0.3g)",curScaleY)); SetOverride(*cur, L"\\fscy",wxString::Format(L"(%0.3g)",curScaleY));