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>
#endif
#include "include/aegisub/hotkey.h"
#include "base_grid.h"
#include "include/aegisub/context.h"
#include "include/aegisub/hotkey.h"
#include "ass_dialogue.h"
#include "ass_file.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()));
}
/// @brief Constructor
/// @param parent
/// @param id
/// @param pos
/// @param size
/// @param style
/// @param name
///
BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxWindow(parent, id, pos, size, style, name)
, context(VideoContext::Get())
BaseGrid::BaseGrid(wxWindow* parent, agi::Context *context, const wxSize& size, long style, const wxString& name)
: wxWindow(parent, -1, wxDefaultPosition, size, style, name)
, lineHeight(1) // non-zero to avoid div by 0
, lastRow(-1)
, extendRow(-1)
, holding(false)
, bmp(0)
, active_line(0)
, batch_level(0)
, batch_active_line_changed(false)
, context(context)
, 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->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);
}
/// @brief Destructor
///
BaseGrid::~BaseGrid() {
@ -137,8 +123,6 @@ BaseGrid::~BaseGrid() {
delete bmp;
}
/// @brief Update style
///
void BaseGrid::UpdateStyle() {
@ -645,11 +629,11 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Lines
else if (curDiag) {
// Set fields
strings.Add(wxString::Format(_T("%i"),curRow+1));
strings.Add(wxString::Format(_T("%i"),curDiag->Layer));
strings.Add(wxString::Format("%i",curRow+1));
strings.Add(wxString::Format("%i",curDiag->Layer));
if (byFrame) {
strings.Add(wxString::Format(_T("%i"),context->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->Start.GetMS(),agi::vfr::START)));
strings.Add(wxString::Format("%i",context->videoController->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END)));
}
else {
strings.Add(curDiag->Start.GetASSFormated());
@ -664,7 +648,7 @@ void BaseGrid::DrawImage(wxDC &dc) {
// Set text
int mode = OPT_GET("Subtitle/Grid/Hide Overrides")->GetInt();
wxString value = _T("");
wxString value;
// Hidden overrides
if (mode == 1 || mode == 2) {
@ -878,7 +862,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
if (dlg == GetActiveLine()) {
SetActiveLine(GetDialogue(GetFirstSelRow()));
}
parentFrame->UpdateToolbar();
wxGetApp().frame->UpdateToolbar();
lastRow = row;
return;
}
@ -886,9 +870,9 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
// Normal click
if ((click || dclick) && !shift && !ctrl && !alt) {
SetActiveLine(dlg);
if (dclick) context->JumpToTime(dlg->Start.GetMS());
if (dclick) context->videoController->JumpToTime(dlg->Start.GetMS());
SelectRow(row,false);
parentFrame->UpdateToolbar();
wxGetApp().frame->UpdateToolbar();
lastRow = row;
return;
}
@ -917,7 +901,7 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
}
SetSelectedSet(newsel);
parentFrame->UpdateToolbar();
wxGetApp().frame->UpdateToolbar();
}
return;
}
@ -1058,9 +1042,9 @@ void BaseGrid::SetColumnWidths() {
// Times
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;
tmp = context->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END);
tmp = context->videoController->FrameAtTime(curDiag->End.GetMS(),agi::vfr::END);
if (tmp > maxEnd) maxEnd = tmp;
}
}
@ -1132,13 +1116,12 @@ int BaseGrid::GetDialogueIndex(AssDialogue *diag) const {
/// @param line
/// @return
///
bool BaseGrid::IsDisplayed(AssDialogue *line) {
VideoContext* con = VideoContext::Get();
if (!con->IsLoaded()) return false;
int frame = con->GetFrameN();
bool BaseGrid::IsDisplayed(const AssDialogue *line) const {
if (!context->videoController->IsLoaded()) return false;
int frame = context->videoController->GetFrameN();
return
con->FrameAtTime(line->Start.GetMS(),agi::vfr::START) <= frame &&
con->FrameAtTime(line->End.GetMS(),agi::vfr::END) >= frame;
context->videoController->FrameAtTime(line->Start.GetMS(),agi::vfr::START) <= frame &&
context->videoController->FrameAtTime(line->End.GetMS(),agi::vfr::END) >= frame;
}
/// @brief Key press
@ -1166,7 +1149,7 @@ void BaseGrid::OnKeyDown(wxKeyEvent &event) {
// Left/right, forward to seek bar if video is loaded
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?
hotkey::check("Video", event.GetKeyCode(), event.GetUnicodeKey(), event.GetModifiers());
}

View file

@ -48,11 +48,10 @@
#include "selection_controller.h"
namespace agi { struct Context; }
class AssEntry;
class AssDialogue;
class SubsEditBox;
class FrameMain;
class VideoContext;
/// DOCME
typedef std::list<AssEntry*>::iterator entryIter;
@ -112,10 +111,7 @@ protected:
/// DOCME
int colWidth[16];
/// DOCME
FrameMain *parentFrame;
VideoContext *context;
agi::Context *context;
/// DOCME
static const int columns = 10;
@ -145,10 +141,6 @@ public:
virtual void PrevLine();
public:
/// DOCME
SubsEditBox *editBox;
/// DOCME
bool byFrame;
@ -161,7 +153,7 @@ public:
void SelectRow(int row, bool addToSelected = false, bool select=true);
void ClearSelection();
bool IsInSelection(int row, int col=0) const;
static bool IsDisplayed(AssDialogue *line);
bool IsDisplayed(const AssDialogue *line) const;
int GetNumberSelection() const;
int GetFirstSelRow() const;
int GetLastSelRow() const;
@ -182,7 +174,7 @@ public:
AssDialogue *GetDialogue(int n) 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();
DECLARE_EVENT_TABLE()

View file

@ -114,7 +114,7 @@ struct time_frame_current : public Command {
}
// 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) {
c->videoController->Stop();
DialogShiftTimes(c->parent, c->subsGrid).ShowModal();
DialogShiftTimes(c).ShowModal();
}
};
@ -226,7 +226,7 @@ struct time_snap_scene : public Command {
}
// 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) {
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) {
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) {
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.")
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.")
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 "dialog_kara_timing_copy.h"
#include "help_button.h"
#include "include/aegisub/context.h"
#include "libresrc/libresrc.h"
#include "main.h"
#include "selection_controller.h"
@ -68,7 +69,18 @@
/// DOCME
#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
/// @class KaraokeLineMatchDisplay
@ -823,15 +835,15 @@ bool KaraokeLineMatchDisplay::UndoMatch()
/// @param parent
/// @param _grid
///
DialogKanjiTimer::DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *_grid)
: wxDialog (parent,-1,_("Kanji timing"),wxDefaultPosition)
DialogKanjiTimer::DialogKanjiTimer(agi::Context *c)
: wxDialog(c->parent,-1,_("Kanji timing"),wxDefaultPosition)
{
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(kara_timing_copier_24)));
// Variables
subs = _grid->ass;
grid = _grid;
subs = c->ass;
grid = c->subsGrid;
currentSourceLine = subs->Line.begin();
currentDestinationLine = subs->Line.begin();
@ -941,7 +953,7 @@ void DialogKanjiTimer::OnClose(wxCommandEvent &event) {
line->Text = p.second;
}
if (modified) {
grid->ass->Commit(_("kanji timing"));
subs->Commit(_("kanji timing"));
LinesToChange.clear();
}
Close();

View file

@ -34,11 +34,6 @@
/// @ingroup tools_ui kara_timing_copy
///
///////////
// Headers
#ifndef AGI_PRE
#include <vector>
@ -53,13 +48,10 @@
#include "ass_file.h"
#include "kana_table.h"
//////////////
// Prototypes
class SubtitlesGrid;
namespace agi { struct Context; }
class AssOverrideParameter;
class KaraokeLineMatchDisplay;
class SubtitlesGrid;
/// DOCME
@ -114,40 +106,7 @@ class DialogKanjiTimer : public wxDialog {
entryIter FindPrevStyleMatch(entryIter search_from, const wxString &search_style);
public:
DialogKanjiTimer(wxWindow *parent, SubtitlesGrid *grid);
DialogKanjiTimer(agi::Context *context);
void OnKeyDown(wxKeyEvent &event);
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
///
///////////
// Headers
#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_file.h"
#include "ass_override.h"
#include "ass_style.h"
#include "dialog_resample.h"
#include "include/aegisub/context.h"
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "subs_grid.h"
#include "utils.h"
#include "validators.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
/// @param parent
/// @param _grid
///
DialogResample::DialogResample(wxWindow *parent, SubtitlesGrid *_grid)
: wxDialog (parent,-1,_("Resample resolution"),wxDefaultPosition)
DialogResample::DialogResample(agi::Context *c)
: wxDialog(c->parent,-1,_("Resample resolution"),wxDefaultPosition)
{
// Set icon
SetIcon(BitmapToIcon(GETIMAGE(resample_toolbutton_24)));
// Variables
AssFile *subs = _grid->ass;
grid = _grid;
// Margins
MarginSymmetrical = NULL; // Do not remove this
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 *ResSizer = new wxBoxSizer(wxHORIZONTAL);
int sw,sh;
subs->GetResolution(sw,sh);
c->ass->GetResolution(sw,sh);
ResXValue = wxString::Format(_T("%i"),sw);
ResYValue = wxString::Format(_T("%i"),sh);
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
///
void DialogResample::OnResample (wxCommandEvent &event) {
// Resolutions
AssFile *subs = grid->ass;
int x1,y1;
subs->GetResolution(x1,y1);
c->ass->GetResolution(x1,y1);
long x2 = 0;
long y2 = 0;
ResX->GetValue().ToLong(&x2);
@ -261,7 +264,7 @@ void DialogResample::OnResample (wxCommandEvent &event) {
// Iterate through subs
AssStyle *curStyle;
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
curDiag = dynamic_cast<AssDialogue*>(*cur);
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
subs->SetScriptInfo(_T("PlayResX"),wxString::Format(_T("%i"),x2));
subs->SetScriptInfo(_T("PlayResY"),wxString::Format(_T("%i"),y2));
c->ass->SetScriptInfo(_T("PlayResX"),wxString::Format(_T("%i"),x2));
c->ass->SetScriptInfo(_T("PlayResY"),wxString::Format(_T("%i"),y2));
// Flag as modified
subs->Commit(_("resolution resampling"), AssFile::COMMIT_TEXT);
c->ass->Commit(_("resolution resampling"), AssFile::COMMIT_TEXT);
EndModal(0);
}
@ -364,9 +367,5 @@ void DialogResample::OnMarginChange (wxCommandEvent &event) {
}
}
/// DOCME
DialogResample *DialogResample::instance = NULL;

View file

@ -34,11 +34,6 @@
/// @ingroup tools_ui
///
///////////
// Headers
#ifndef AGI_PRE
#include <wx/checkbox.h>
#include <wx/dialog.h>
@ -46,10 +41,7 @@
#include <wx/textctrl.h>
#endif
//////////////
// Prototypes
class SubtitlesGrid;
namespace agi { struct Context; }
class AssOverrideParameter;
@ -60,10 +52,7 @@ class AssOverrideParameter;
///
/// DOCME
class DialogResample : public wxDialog {
private:
/// DOCME
SubtitlesGrid *grid;
agi::Context *c;
/// DOCME
@ -119,34 +108,7 @@ private:
void DoResampleTags (wxString name,int n,AssOverrideParameter *curParam,void *_curDiag);
public:
DialogResample(wxWindow *parent, SubtitlesGrid *grid);
DialogResample(agi::Context *context);
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
///
///////////
// Headers
#include "config.h"
#ifndef AGI_PRE
@ -48,6 +45,7 @@
#include "ass_dialogue.h"
#include "ass_file.h"
#include "dialog_search_replace.h"
#include "include/aegisub/context.h"
#include "frame_main.h"
#include "main.h"
#include "selection_controller.h"
@ -56,6 +54,15 @@
#include "subs_grid.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
/// @param parent
@ -234,7 +241,7 @@ void DialogSearchReplace::FindReplace(int mode) {
wxString ReplaceWith = ReplaceEdit->GetValue();
Search.ReplaceWith = ReplaceWith;
config::mru->Add("Replace", STD_STR(ReplaceWith));
}
}
}
// Replace
@ -346,7 +353,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
return;
}
wxArrayInt sels = grid->GetSelection();
wxArrayInt sels = context->subsGrid->GetSelection();
int firstLine = 0;
if (sels.Count() > 0) firstLine = sels[0];
// if selection has changed reset values
@ -361,7 +368,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
// Setup
int start = curLine;
int nrows = grid->GetRows();
int nrows = context->subsGrid->GetRows();
bool found = false;
wxString *Text = NULL;
size_t tempPos;
@ -434,7 +441,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
}
// Commit
grid->ass->Commit(_("replace"), AssFile::COMMIT_TEXT);
context->ass->Commit(_("replace"), AssFile::COMMIT_TEXT);
}
else {
@ -442,16 +449,16 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
}
// Select
grid->SelectRow(curLine,false);
grid->MakeCellVisible(curLine,0);
context->subsGrid->SelectRow(curLine,false);
context->subsGrid->MakeCellVisible(curLine,0);
if (field == 0) {
grid->SetActiveLine(grid->GetDialogue(curLine));
grid->editBox->TextEdit->SetSelectionU(pos,pos+replaceLen);
context->subsGrid->SetActiveLine(context->subsGrid->GetDialogue(curLine));
context->editBox->TextEdit->SetSelectionU(pos,pos+replaceLen);
}
// Update video
if (updateVideo) {
grid->SetVideoToSubs(true);
context->subsGrid->SetVideoToSubs(true);
}
else if (DoReplace) Modified = true;
@ -468,7 +475,7 @@ void SearchReplaceEngine::ReplaceNext(bool DoReplace) {
void SearchReplaceEngine::ReplaceAll() {
// Setup
wxString *Text;
int nrows = grid->GetRows();
int nrows = context->subsGrid->GetRows();
size_t count = 0;
int regFlags = wxRE_ADVANCED;
if (!matchCase) {
@ -476,11 +483,11 @@ void SearchReplaceEngine::ReplaceAll() {
//else LookFor.MakeLower();
}
bool replaced;
grid->BeginBatch();
context->subsGrid->BeginBatch();
// Selection
bool hasSelection = false;
wxArrayInt sels = grid->GetSelection();
wxArrayInt sels = context->subsGrid->GetSelection();
if (sels.Count() > 0) hasSelection = true;
bool inSel = false;
if (affect == 1) inSel = true;
@ -538,7 +545,7 @@ void SearchReplaceEngine::ReplaceAll() {
// Commit
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));
}
@ -546,7 +553,7 @@ void SearchReplaceEngine::ReplaceAll() {
else {
wxMessageBox(_("No matches found."));
}
grid->EndBatch();
context->subsGrid->EndBatch();
LastWasFind = false;
}
@ -556,7 +563,7 @@ void SearchReplaceEngine::ReplaceAll() {
///
void SearchReplaceEngine::OnDialogOpen() {
// Set curline
wxArrayInt sels = grid->GetSelection();
wxArrayInt sels = context->subsGrid->GetSelection();
curLine = 0;
if (sels.Count() > 0) curLine = sels[0];
@ -603,7 +610,7 @@ void SearchReplaceEngine::OpenDialog (bool replace) {
/// @return
///
wxString *SearchReplaceEngine::GetText(int n,int field) {
AssDialogue *cur = grid->GetDialogue(n);
AssDialogue *cur = context->subsGrid->GetDialogue(n);
if (field == 0) return &cur->Text;
else if (field == 1) return &cur->Style;
else if (field == 2) return &cur->Actor;

View file

@ -34,11 +34,6 @@
/// @ingroup secondary_ui
///
///////////
// Headers
#ifndef AGI_PRE
#include <wx/checkbox.h>
#include <wx/combobox.h>
@ -48,11 +43,7 @@
#include <wx/textctrl.h>
#endif
//////////////
// Prototypes
class SubtitlesGrid;
namespace agi { struct Context; }
/// DOCME
@ -61,8 +52,6 @@ class SubtitlesGrid;
///
/// DOCME
class SearchReplaceEngine {
private:
/// DOCME
int curLine;
@ -85,11 +74,10 @@ private:
bool hasReplace;
wxString *GetText(int n,int field);
public:
public:
/// DOCME
SubtitlesGrid *grid;
agi::Context *context;
/// DOCME
bool isReg;
@ -186,29 +174,3 @@ public:
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
///
///////////
// Headers
#include "config.h"
#ifndef AGI_PRE
@ -46,6 +43,10 @@
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/listbox.h>
#include <wx/radiobox.h>
#include <wx/radiobut.h>
#include <wx/textctrl.h>
#endif
#include "ass_dialogue.h"
@ -53,28 +54,36 @@
#include "ass_time.h"
#include "charset_conv.h"
#include "dialog_shift_times.h"
#include "include/aegisub/context.h"
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "main.h"
#include "standard_paths.h"
#include "subs_grid.h"
#include "timeedit_ctrl.h"
#include "utils.h"
#include "video_context.h"
#include "video_display.h"
/// @brief Constructor
/// @param parent
/// @param _grid
///
DialogShiftTimes::DialogShiftTimes (wxWindow *parent,SubtitlesGrid *_grid)
: wxDialog(parent, -1, _("Shift Times"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("JumpTo"))
// IDs
enum {
TEXT_SHIFT_TIME = 1100,
TEXT_SHIFT_FRAME,
RADIO_BACKWARD,
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
SetIcon(BitmapToIcon(GETIMAGE(shift_times_toolbutton_24)));
// Set initial values
ready = true;
grid = _grid;
shiftframe = 0;
// 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);
// Has selection?
wxArrayInt sel = grid->GetSelection();
wxArrayInt sel = context->subsGrid->GetSelection();
if (sel.Count() == 0) {
SelChoice->Enable(1,false);
SelChoice->Enable(2,false);
@ -226,8 +235,8 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
bool didSomething = false;
// Selection
int nrows = grid->GetRows();
wxArrayInt sel = grid->GetSelection();
int nrows = context->subsGrid->GetRows();
wxArrayInt sel = context->subsGrid->GetSelection();
int firstSel = 0;
if (sel.Count()) firstSel = sel[0];
@ -247,9 +256,9 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
// Shift
for (int i=0;i<nrows;i++) {
if (allrows || (i >= firstSel && selOnward) || grid->IsInSelection(i,0)) {
if (byTime) grid->ShiftLineByTime(i,len,type);
else grid->ShiftLineByFrames(i,len,type);
if (allrows || (i >= firstSel && selOnward) || context->subsGrid->IsInSelection(i,0)) {
if (byTime) context->subsGrid->ShiftLineByTime(i,len,type);
else context->subsGrid->ShiftLineByFrames(i,len,type);
didSomething = true;
}
}
@ -257,8 +266,8 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
// Add entry to history
if (didSomething) {
if (backward) len = -len;
wxString message = _T("");
wxFileName assfile(grid->ass->filename);
wxString message;
wxFileName assfile(context->ass->filename);
wxString filename = assfile.GetFullName();
// File
@ -309,7 +318,7 @@ void DialogShiftTimes::OnOK(wxCommandEvent &event) {
OPT_SET("Tool/Shift Times/Direction")->SetBool(backward);
// End dialog
grid->ass->Commit(_("shifting"), AssFile::COMMIT_TIMES);
context->ass->Commit(_("shifting"), AssFile::COMMIT_TIMES);
EndModal(0);
}

View file

@ -34,26 +34,16 @@
/// @ingroup secondary_ui
///
///////////
// Headers
#ifndef AGI_PRE
#include <wx/dialog.h>
#include <wx/listbox.h>
#include <wx/radiobox.h>
#include <wx/radiobut.h>
#endif
#include "timeedit_ctrl.h"
//////////////
// Prototypes
class SubtitlesGrid;
namespace agi { struct Context; }
class TimeEdit;
class wxListBox;
class wxRadioBox;
class wxRadioButton;
class wxTextCtrl;
/// DOCME
/// @class DialogShiftTimes
@ -61,14 +51,11 @@ class SubtitlesGrid;
///
/// DOCME
class DialogShiftTimes : public wxDialog {
private:
agi::Context *context;
/// DOCME
bool ready;
/// DOCME
SubtitlesGrid *grid;
/// DOCME
int shiftframe;
@ -106,10 +93,6 @@ private:
void AppendToHistory(wxString text);
void LoadHistory(wxString filename);
void OnClear(wxCommandEvent &event);
public:
DialogShiftTimes (wxWindow *parent,SubtitlesGrid *grid);
void OnKey(wxKeyEvent &event);
void OnClose(wxCommandEvent &event);
void OnOK(wxCommandEvent &event);
@ -118,32 +101,8 @@ public:
void OnRadioTime(wxCommandEvent &event);
void OnRadioFrame(wxCommandEvent &event);
public:
DialogShiftTimes (agi::Context *context);
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->MakeCellVisible(line,0);
grid->SetActiveLine(grid->GetDialogue(line));
grid->editBox->TextEdit->SetSelectionU(wordStart,wordEnd);
context->editBox->TextEdit->SetSelectionU(wordStart,wordEnd);
grid->EndBatch();
addButton->Enable(spellchecker->CanAddWord(word));
@ -381,16 +381,12 @@ bool DialogSpellChecker::FindOrDie() {
/// @brief Replace
///
void DialogSpellChecker::Replace() {
// Get dialog
SubtitlesGrid *grid = context->subsGrid;
AssDialogue *diag = grid->GetDialogue(lastLine % grid->GetRows());
AssDialogue *diag = context->subsGrid->GetDialogue(lastLine % context->subsGrid->GetRows());
// Replace
diag->Text = diag->Text.Left(wordStart) + replaceWord->GetValue() + diag->Text.Mid(wordEnd);
lastPos = wordStart + replaceWord->GetValue().Length();
// Commit
grid->ass->Commit(_("Spell check replace"), AssFile::COMMIT_TEXT);
context->ass->Commit(_("Spell check replace"), AssFile::COMMIT_TEXT);
}

View file

@ -52,6 +52,7 @@
#include "ass_style_storage.h"
#include "compat.h"
#include "dialog_style_editor.h"
#include "include/aegisub/context.h"
#include "help_button.h"
#include "libresrc/libresrc.h"
#include "main.h"
@ -63,124 +64,49 @@
#include "validators.h"
///////
// IDs
enum {
/// DOCME
BUTTON_STYLE_FONT = 1050,
/// DOCME
CHECKBOX_STYLE_BOLD,
/// DOCME
CHECKBOX_STYLE_ITALIC,
/// DOCME
CHECKBOX_STYLE_UNDERLINE,
/// DOCME
CHECKBOX_STYLE_STRIKEOUT,
/// DOCME
CHECKBOX_OUTLINE,
/// DOCME
BUTTON_COLOR_1,
/// DOCME
BUTTON_COLOR_2,
/// DOCME
BUTTON_COLOR_3,
/// DOCME
BUTTON_COLOR_4,
/// DOCME
BUTTON_PREVIEW_COLOR,
/// DOCME
RADIO_ALIGNMENT,
/// DOCME
TEXT_FONT_NAME,
/// DOCME
TEXT_FONT_SIZE,
/// DOCME
TEXT_ALPHA_1,
/// DOCME
TEXT_ALPHA_2,
/// DOCME
TEXT_ALPHA_3,
/// DOCME
TEXT_ALPHA_4,
/// DOCME
TEXT_MARGIN_L,
/// DOCME
TEXT_MARGIN_R,
/// DOCME
TEXT_MARGIN_V,
/// DOCME
TEXT_OUTLINE,
/// DOCME
TEXT_SHADOW,
/// DOCME
TEXT_SCALE_X,
/// DOCME
TEXT_SCALE_Y,
/// DOCME
TEXT_ANGLE,
/// DOCME
TEXT_SPACING,
/// DOCME
TEXT_PREVIEW,
/// DOCME
COMBO_ENCODING
};
/// @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)
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *style, agi::Context *c,bool local,AssStyleStorage *store,bool newStyle)
: 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)));
// Set variables
isLocal = local;
isNew = newStyle;
store = _store;
// Set styles
grid = _grid;
style = _style;
work = new AssStyle;
*work = *style;
// Prepare control values
FontSizeValue = AegiFloatToString(style->fontsize);
OutlineValue = AegiFloatToString(style->outline_w);
@ -530,13 +456,13 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Get list of existing styles
wxArrayString styles;
if (isLocal) styles = grid->ass->GetStyles();
if (isLocal) styles = c->ass->GetStyles();
else if (store) styles = store->GetNames();
// Check if style name is unique
for (unsigned int i=0;i<styles.Count();i++) {
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);
return;
}
@ -555,12 +481,12 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
// Update
if (answer == wxYES) {
int n = grid->GetRows();
int n = c->subsGrid->GetRows();
wxArrayString strings;
strings.Add(work->name);
strings.Add(newStyleName);
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;
curDiag->ParseASSTags();
curDiag->ProcessParameters(ReplaceStyle,&strings);
@ -581,7 +507,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
*style = *work;
style->UpdateData();
if (isLocal) {
grid->ass->Commit(_("style change"), AssFile::COMMIT_TEXT);
c->ass->Commit(_("style change"), AssFile::COMMIT_TEXT);
}
// Exit

View file

@ -34,11 +34,6 @@
/// @ingroup style_editor
///