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:
parent
778338fa2b
commit
df1dce3593
35 changed files with 471 additions and 908 deletions
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -87,9 +76,8 @@ private:
|
|||
wxString *GetText(int n,int field);
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
/// @ingroup style_editor
|
||||
///
|
||||
|
||||
|
||||
|
||||
|
||||
////////////
|
||||
// Includes
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/combobox.h>
|
||||
|
@ -49,23 +44,18 @@
|
|||
|
||||
#include "colour_button.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
namespace agi { struct Context; }
|
||||
class AssStyle;
|
||||
class SubtitlesGrid;
|
||||
class SubtitlesPreview;
|
||||
class AssStyleStorage;
|
||||
|
||||
|
||||
|
||||
/// DOCME
|
||||
/// @class DialogStyleEditor
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class DialogStyleEditor : public wxDialog {
|
||||
private:
|
||||
agi::Context *c;
|
||||
|
||||
/// DOCME
|
||||
bool isLocal;
|
||||
|
@ -81,9 +71,6 @@ private:
|
|||
/// DOCME
|
||||
AssStyle *work;
|
||||
|
||||
/// DOCME
|
||||
SubtitlesGrid *grid;
|
||||
|
||||
/// DOCME
|
||||
AssStyleStorage *store;
|
||||
|
||||
|
@ -218,7 +205,7 @@ private:
|
|||
void OnPreviewColourChange (wxCommandEvent &event);
|
||||
|
||||
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();
|
||||
|
||||
void Apply (bool apply,bool close);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "dialog_selected_choices.h"
|
||||
#include "dialog_style_editor.h"
|
||||
#include "dialog_style_manager.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "help_button.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "main.h"
|
||||
|
@ -89,18 +90,12 @@ enum {
|
|||
LIST_CURRENT
|
||||
};
|
||||
|
||||
/// @brief Constructor
|
||||
/// @param parent
|
||||
/// @param _grid
|
||||
DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
|
||||
: wxDialog (parent,-1,_("Styles Manager"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogStylesManager"))
|
||||
DialogStyleManager::DialogStyleManager (agi::Context *context)
|
||||
: wxDialog (context->parent,-1,_("Styles Manager"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE,_T("DialogStylesManager"))
|
||||
, c(context)
|
||||
{
|
||||
// Set icon
|
||||
SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24)));
|
||||
|
||||
// Vars
|
||||
grid = _grid;
|
||||
|
||||
// Catalog
|
||||
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"));
|
||||
|
@ -225,18 +220,17 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
|
|||
|
||||
// Populate lists
|
||||
LoadCatalog();
|
||||
LoadCurrentStyles(grid->ass);
|
||||
LoadCurrentStyles(c->ass);
|
||||
|
||||
//Set key handlers for lists
|
||||
CatalogList->PushEventHandler(new DialogStyleManagerEvent(this));
|
||||
StorageList->PushEventHandler(new DialogStyleManagerEvent(this));
|
||||
CurrentList->PushEventHandler(new DialogStyleManagerEvent(this));
|
||||
CatalogList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
|
||||
StorageList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
|
||||
CurrentList->Bind(wxEVT_KEY_DOWN, &DialogStyleManager::OnKeyDown, this);
|
||||
|
||||
// Select default item
|
||||
wxString selected_style;
|
||||
if (_grid) {
|
||||
AssDialogue *dia = _grid->GetDialogue(_grid->GetFirstSelRow());
|
||||
if(dia) selected_style = dia->Style;
|
||||
if (AssDialogue *dia = context->selectionController->GetActiveLine()) {
|
||||
selected_style = dia->Style;
|
||||
}
|
||||
|
||||
if (StorageList->GetCount() && StorageList->SetStringSelection(selected_style)) {
|
||||
|
@ -258,11 +252,8 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
|
|||
DialogStyleManager::~DialogStyleManager() {
|
||||
int sel = CatalogList->GetSelection();
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -299,7 +290,7 @@ void DialogStyleManager::LoadCatalog () {
|
|||
|
||||
// Set to default if available
|
||||
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");
|
||||
int opt = CatalogList->FindString(pickStyle, false);
|
||||
if (opt != wxNOT_FOUND) {
|
||||
|
@ -492,7 +483,7 @@ void DialogStyleManager::OnStorageEdit (wxCommandEvent &) {
|
|||
int n = StorageList->GetSelections(selections);
|
||||
if (n == 1) {
|
||||
AssStyle *selStyle = styleStorageMap[selections[0]];
|
||||
DialogStyleEditor editor(this,selStyle,grid,false,&Store);
|
||||
DialogStyleEditor editor(this,selStyle,c,false,&Store);
|
||||
if (editor.ShowModal()) {
|
||||
StorageList->SetString(selections[0],selStyle->name);
|
||||
Store.Save(CatalogList->GetString(CatalogList->GetSelection()));
|
||||
|
@ -507,7 +498,7 @@ void DialogStyleManager::OnCurrentEdit (wxCommandEvent &) {
|
|||
int n = CurrentList->GetSelections(selections);
|
||||
if (n == 1) {
|
||||
AssStyle *selStyle = styleMap[selections[0]];
|
||||
DialogStyleEditor editor(this,selStyle,grid,true,&Store);
|
||||
DialogStyleEditor editor(this,selStyle,c,true,&Store);
|
||||
if (editor.ShowModal()) {
|
||||
CurrentList->SetString(selections[0],selStyle->name);
|
||||
}
|
||||
|
@ -599,15 +590,15 @@ void DialogStyleManager::OnCopyToCurrent (wxCommandEvent &) {
|
|||
}
|
||||
if (addStyle) {
|
||||
AssStyle *temp = new AssStyle(*styleStorageMap.at(selections[i]));
|
||||
grid->ass->InsertStyle(temp);
|
||||
c->ass->InsertStyle(temp);
|
||||
copied.push_back(styleName);
|
||||
}
|
||||
}
|
||||
LoadCurrentStyles(grid->ass);
|
||||
LoadCurrentStyles(c->ass);
|
||||
for (list<wxString>::iterator name = copied.begin(); name != copied.end(); ++name) {
|
||||
CurrentList->SetStringSelection(*name, true);
|
||||
}
|
||||
grid->ass->Commit(_("style copy"));
|
||||
c->ass->Commit(_("style copy"));
|
||||
wxCommandEvent dummy;
|
||||
OnCurrentChange(dummy);
|
||||
}
|
||||
|
@ -623,7 +614,7 @@ void DialogStyleManager::OnStorageCopy (wxCommandEvent &) {
|
|||
newName += temp->name;
|
||||
temp->name = newName;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid,false,&Store,true);
|
||||
DialogStyleEditor editor(this,temp,c,false,&Store,true);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
Store.style.push_back(temp);
|
||||
|
@ -646,16 +637,16 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &) {
|
|||
newName += temp->name;
|
||||
temp->name = newName;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid,true,&Store,true);
|
||||
DialogStyleEditor editor(this,temp,c,true,&Store,true);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
grid->ass->InsertStyle(temp);
|
||||
LoadCurrentStyles(grid->ass);
|
||||
c->ass->InsertStyle(temp);
|
||||
LoadCurrentStyles(c->ass);
|
||||
CurrentList->SetStringSelection(temp->name); // but even without this, the copy/delete/copy-to-storage buttons stay enabled?
|
||||
}
|
||||
else delete temp;
|
||||
|
||||
grid->ass->Commit(_("style copy"));
|
||||
c->ass->Commit(_("style copy"));
|
||||
UpdateMoveButtons();
|
||||
}
|
||||
|
||||
|
@ -700,14 +691,14 @@ void DialogStyleManager::PasteToCurrent() {
|
|||
try {
|
||||
s = new AssStyle(st.GetNextToken().Trim(true));
|
||||
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->UpdateData();
|
||||
grid->ass->InsertStyle(s);
|
||||
LoadCurrentStyles(grid->ass);
|
||||
c->ass->InsertStyle(s);
|
||||
LoadCurrentStyles(c->ass);
|
||||
|
||||
grid->ass->Commit(_("style paste"));
|
||||
c->ass->Commit(_("style paste"));
|
||||
}
|
||||
else
|
||||
wxMessageBox(_("Could not parse style"), _("Could not parse style"), wxOK | wxICON_EXCLAMATION , this);
|
||||
|
@ -763,7 +754,7 @@ void DialogStyleManager::PasteToStorage() {
|
|||
void DialogStyleManager::OnStorageNew (wxCommandEvent &) {
|
||||
AssStyle *temp = new AssStyle;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid,false,&Store,true);
|
||||
DialogStyleEditor editor(this,temp,c,false,&Store,true);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
Store.style.push_back(temp);
|
||||
|
@ -779,11 +770,11 @@ void DialogStyleManager::OnStorageNew (wxCommandEvent &) {
|
|||
void DialogStyleManager::OnCurrentNew (wxCommandEvent &) {
|
||||
AssStyle *temp = new AssStyle;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid,true,&Store,true);
|
||||
DialogStyleEditor editor(this,temp,c,true,&Store,true);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
grid->ass->InsertStyle(temp);
|
||||
LoadCurrentStyles(grid->ass);
|
||||
c->ass->InsertStyle(temp);
|
||||
LoadCurrentStyles(c->ass);
|
||||
CurrentList->SetStringSelection(temp->name);
|
||||
}
|
||||
else delete temp;
|
||||
|
@ -841,10 +832,10 @@ void DialogStyleManager::OnCurrentDelete (wxCommandEvent &) {
|
|||
AssStyle *temp;
|
||||
for (int i=0;i<n;i++) {
|
||||
temp = styleMap.at(selections[i]);
|
||||
grid->ass->Line.remove(temp);
|
||||
c->ass->Line.remove(temp);
|
||||
delete temp;
|
||||
}
|
||||
LoadCurrentStyles(grid->ass);
|
||||
LoadCurrentStyles(c->ass);
|
||||
|
||||
// Set buttons
|
||||
MoveToStorage->Enable(false);
|
||||
|
@ -852,7 +843,7 @@ void DialogStyleManager::OnCurrentDelete (wxCommandEvent &) {
|
|||
CurrentCopy->Enable(false);
|
||||
CurrentDelete->Enable(false);
|
||||
|
||||
grid->ass->Commit(_("style delete"));
|
||||
c->ass->Commit(_("style delete"));
|
||||
}
|
||||
UpdateMoveButtons();
|
||||
}
|
||||
|
@ -898,7 +889,7 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
|
|||
// 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
|
||||
// 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;
|
||||
}
|
||||
|
@ -907,13 +898,13 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &) {
|
|||
modified = true;
|
||||
AssStyle *tempStyle = new AssStyle;
|
||||
*tempStyle = *temp.GetStyle(styles[selections[i]]);
|
||||
grid->ass->InsertStyle(tempStyle);
|
||||
c->ass->InsertStyle(tempStyle);
|
||||
}
|
||||
|
||||
// Update
|
||||
if (modified) {
|
||||
LoadCurrentStyles(grid->ass);
|
||||
grid->ass->Commit(_("style import"));
|
||||
LoadCurrentStyles(c->ass);
|
||||
c->ass->Commit(_("style import"));
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -990,8 +981,6 @@ void DialogStyleManager::OnCurrentSort (wxCommandEvent &) { MoveStyles(false,4);
|
|||
/// @param storage
|
||||
/// @param type
|
||||
void DialogStyleManager::MoveStyles(bool storage, int type) {
|
||||
// Variables
|
||||
AssFile *subs = grid->ass;
|
||||
wxListBox *list;
|
||||
if (storage) list = StorageList;
|
||||
else list = CurrentList;
|
||||
|
@ -1097,19 +1086,19 @@ void DialogStyleManager::MoveStyles(bool storage, int type) {
|
|||
// Replace styles
|
||||
entryIter next;
|
||||
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++;
|
||||
AssStyle *style = dynamic_cast<AssStyle*>(*cur);
|
||||
if (style) {
|
||||
subs->Line.insert(cur,styls[curn]);
|
||||
subs->Line.erase(cur);
|
||||
c->ass->Line.insert(cur,styls[curn]);
|
||||
c->ass->Line.erase(cur);
|
||||
curn++;
|
||||
}
|
||||
}
|
||||
|
||||
// Flag as modified
|
||||
grid->ass->Commit(_("style move"));
|
||||
c->ass->Commit(_("style move"));
|
||||
}
|
||||
|
||||
// Update
|
||||
|
@ -1183,16 +1172,3 @@ int DialogStyleManager::lastx = -1;
|
|||
|
||||
/// DOCME
|
||||
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...
|
||||
}
|
||||
|
|
|
@ -50,9 +50,7 @@
|
|||
|
||||
#include "ass_style_storage.h"
|
||||
|
||||
|
||||
//////////////
|
||||
// Prototypes
|
||||
namespace agi { struct Context; }
|
||||
class AssFile;
|
||||
class AssStyle;
|
||||
class SubtitlesGrid;
|
||||
|
@ -65,7 +63,7 @@ class SubtitlesGrid;
|
|||
///
|
||||
/// DOCME
|
||||
class DialogStyleManager : public wxDialog {
|
||||
private:
|
||||
agi::Context *c;
|
||||
|
||||
/// DOCME
|
||||
std::vector<AssStyle*> styleMap;
|
||||
|
@ -73,11 +71,6 @@ private:
|
|||
/// DOCME
|
||||
std::vector<AssStyle*> styleStorageMap;
|
||||
|
||||
|
||||
/// DOCME
|
||||
SubtitlesGrid *grid;
|
||||
|
||||
|
||||
/// DOCME
|
||||
wxComboBox *CatalogList;
|
||||
|
||||
|
@ -164,14 +157,9 @@ private:
|
|||
/// DOCME
|
||||
static int lastx, lasty;
|
||||
|
||||
public:
|
||||
|
||||
/// DOCME
|
||||
wxSizer *MainSizer;
|
||||
|
||||
DialogStyleManager(wxWindow *parent,SubtitlesGrid *grid);
|
||||
~DialogStyleManager();
|
||||
|
||||
void OnClose (wxCommandEvent &event);
|
||||
void OnChangeCatalog (wxCommandEvent &event);
|
||||
void OnCatalogNew (wxCommandEvent &event);
|
||||
|
@ -204,23 +192,10 @@ public:
|
|||
void PasteToCurrent();
|
||||
void PasteToStorage();
|
||||
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// DOCME
|
||||
/// @class DialogStyleManagerEvent
|
||||
/// @brief DOCME
|
||||
///
|
||||
/// DOCME
|
||||
class DialogStyleManagerEvent : public wxEvtHandler {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
DialogStyleManager *control;
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
|
||||
public:
|
||||
DialogStyleManagerEvent(DialogStyleManager *control);
|
||||
|
||||
DialogStyleManager(agi::Context *context);
|
||||
~DialogStyleManager();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -62,6 +62,14 @@
|
|||
#include "video_context.h"
|
||||
#include "video_display.h"
|
||||
|
||||
// IDs
|
||||
enum {
|
||||
ENTER_STYLE_BOX,
|
||||
STYLE_LIST,
|
||||
BUTTON_PLAY_VIDEO,
|
||||
BUTTON_PLAY_AUDIO
|
||||
};
|
||||
|
||||
|
||||
/// @brief Constructor
|
||||
/// @param parent
|
||||
|
@ -69,24 +77,20 @@
|
|||
///
|
||||
DialogStyling::DialogStyling(agi::Context *context)
|
||||
: wxDialog(context->parent, -1, _("Styling assistant"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX)
|
||||
, c(context)
|
||||
, needCommit(false)
|
||||
, linen(-1)
|
||||
{
|
||||
// Set icon
|
||||
SetIcon(BitmapToIcon(GETIMAGE(styling_toolbutton_24)));
|
||||
|
||||
// Variables
|
||||
grid = context->subsGrid;
|
||||
audio = context->audioController;
|
||||
video = context->videoController;
|
||||
needCommit = false;
|
||||
linen = -1;
|
||||
|
||||
// Top sizer
|
||||
wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Current line"));
|
||||
CurLine = new wxTextCtrl(this,-1,_("Current line"),wxDefaultPosition,wxSize(300,60),wxTE_MULTILINE | wxTE_READONLY);
|
||||
TopSizer->Add(CurLine,1,wxEXPAND,0);
|
||||
|
||||
// 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"));
|
||||
LeftSizer->Add(Styles,1,wxEXPAND,0);
|
||||
|
||||
|
@ -99,7 +103,6 @@ DialogStyling::DialogStyling(agi::Context *context)
|
|||
RightTop->Add(TypeBox,1,wxEXPAND);
|
||||
|
||||
// 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);
|
||||
//H KeysInnerSizer->Add(new wxStaticText(this,-1,Hotkeys.GetText(_T("Styling Assistant Accept")) + _T(": ")));
|
||||
KeysInnerSizer->Add(new wxStaticText(this,-1,_("Accept changes")));
|
||||
|
@ -165,29 +168,24 @@ DialogStyling::DialogStyling(agi::Context *context)
|
|||
origColour = TypeBox->GetBackgroundColour();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Destructor
|
||||
///
|
||||
DialogStyling::~DialogStyling () {
|
||||
GetPosition(&lastx, &lasty);
|
||||
if (needCommit) {
|
||||
grid->ass->Commit(_("style changes"), AssFile::COMMIT_TEXT);
|
||||
c->ass->Commit(_("style changes"), AssFile::COMMIT_TEXT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// @brief Jump to line
|
||||
/// @param n
|
||||
/// @return
|
||||
///
|
||||
void DialogStyling::JumpToLine(int n) {
|
||||
// Check stuff
|
||||
if (n == -1) return;
|
||||
|
||||
// Get line
|
||||
AssDialogue *nextLine = grid->GetDialogue(n);
|
||||
AssDialogue *nextLine = c->subsGrid->GetDialogue(n);
|
||||
if (!nextLine) return;
|
||||
line = nextLine;
|
||||
|
||||
|
@ -210,33 +208,29 @@ void DialogStyling::JumpToLine(int n) {
|
|||
TypeBox->SetSelection(0,TypeBox->GetValue().Length());
|
||||
|
||||
// Update grid
|
||||
grid->SelectRow(linen,false);
|
||||
grid->MakeCellVisible(linen,0);
|
||||
grid->SetActiveLine(grid->GetDialogue(linen));
|
||||
c->subsGrid->SelectRow(linen,false);
|
||||
c->subsGrid->MakeCellVisible(linen,0);
|
||||
c->subsGrid->SetActiveLine(line);
|
||||
|
||||
// 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
|
||||
/// @param curName
|
||||
/// @param jump
|
||||
///
|
||||
void DialogStyling::SetStyle (wxString curName, bool jump) {
|
||||
// Get line
|
||||
AssDialogue *line = grid->GetDialogue(linen);
|
||||
|
||||
// Update line
|
||||
AssDialogue *line = c->subsGrid->GetDialogue(linen);
|
||||
line->Style = curName;
|
||||
|
||||
// Update grid/subs
|
||||
grid->Refresh(false);
|
||||
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
|
||||
if (jump) JumpToLine(linen+1);
|
||||
|
@ -265,19 +259,18 @@ void DialogStyling::OnActivate(wxActivateEvent &event) {
|
|||
// Dialog lost focus
|
||||
if (!event.GetActive()) {
|
||||
if (needCommit) {
|
||||
grid->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT);
|
||||
c->ass->Commit(_("styling assistant"), AssFile::COMMIT_TEXT);
|
||||
needCommit = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Enable/disable play video/audio buttons
|
||||
PlayVideoButton->Enable(video->IsLoaded());
|
||||
/// @todo Reinstate this when the audio controller is made reachable from here
|
||||
//PlayAudioButton->Enable(audio->loaded);
|
||||
PlayVideoButton->Enable(c->videoController->IsLoaded());
|
||||
PlayAudioButton->Enable(c->audioController->IsAudioOpen());
|
||||
// Fix style list
|
||||
Styles->Set(grid->ass->GetStyles());
|
||||
Styles->Set(c->ass->GetStyles());
|
||||
// Fix line selection
|
||||
JumpToLine(grid->GetFirstSelRow());
|
||||
JumpToLine(c->subsGrid->GetFirstSelRow());
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,7 +365,7 @@ void DialogStyling::OnListClicked(wxCommandEvent &event) {
|
|||
/// @param event
|
||||
///
|
||||
void DialogStyling::OnPlayVideoButton(wxCommandEvent &event) {
|
||||
video->PlayLine();
|
||||
c->videoController->PlayLine();
|
||||
TypeBox->SetFocus();
|
||||
}
|
||||
|
||||
|
@ -381,9 +374,9 @@ void DialogStyling::OnPlayVideoButton(wxCommandEvent &event) {
|
|||
/// @param event
|
||||
///
|
||||
void DialogStyling::OnPlayAudioButton(wxCommandEvent &event) {
|
||||
audio->PlayRange(SampleRange(
|
||||
audio->SamplesFromMilliseconds(line->Start.GetMS()),
|
||||
audio->SamplesFromMilliseconds(line->End.GetMS())));
|
||||
c->audioController->PlayRange(SampleRange(
|
||||
c->audioController->SamplesFromMilliseconds(line->Start.GetMS()),
|
||||
c->audioController->SamplesFromMilliseconds(line->End.GetMS())));
|
||||
TypeBox->SetFocus();
|
||||
}
|
||||
|
||||
|
@ -393,12 +386,11 @@ void DialogStyling::OnPlayAudioButton(wxCommandEvent &event) {
|
|||
/// @param 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
|
||||
BEGIN_EVENT_TABLE(StyleEditBox,wxTextCtrl)
|
||||
|
@ -499,5 +491,3 @@ int DialogStyling::lastx = -1;
|
|||
|
||||
/// DOCME
|
||||
int DialogStyling::lasty = -1;
|
||||
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@
|
|||
/// @ingroup tools_ui
|
||||
///
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
///////////
|
||||
// Headers
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/checkbox.h>
|
||||
#include <wx/colour.h>
|
||||
|
@ -61,8 +56,6 @@ class VideoContext;
|
|||
///
|
||||
/// DOCME
|
||||
class StyleEditBox : public wxTextCtrl {
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
DialogStyling *diag;
|
||||
void OnKeyDown(wxKeyEvent &event);
|
||||
|
@ -83,10 +76,7 @@ public:
|
|||
class DialogStyling : public wxDialog {
|
||||
friend class StyleEditBox;
|
||||
|
||||
private:
|
||||
|
||||
/// DOCME
|
||||
SubtitlesGrid *grid;
|
||||
agi::Context *c;
|
||||
|
||||
/// DOCME
|
||||
wxColour origColour;
|
||||
|
@ -130,19 +120,12 @@ private:
|
|||
static int lastx, lasty;
|
||||
|
||||
public:
|
||||
|
||||
/// DOCME
|
||||
int linen;
|
||||
|
||||
/// DOCME
|
||||
AssDialogue *line;
|
||||
|
||||
/// DOCME
|
||||
AudioController *audio;
|
||||
|
||||
/// DOCME
|
||||
VideoContext *video;
|
||||
|
||||
DialogStyling(agi::Context *context);
|
||||
~DialogStyling ();
|
||||
|
||||
|
@ -150,21 +133,3 @@ public:
|
|||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
///////
|
||||
// IDs
|
||||
enum {
|
||||
|
||||
/// DOCME
|
||||
ENTER_STYLE_BOX,
|
||||
|
||||
/// DOCME
|
||||
STYLE_LIST,
|
||||
|
||||
/// DOCME
|
||||
BUTTON_PLAY_VIDEO,
|
||||
|
||||
/// DOCME
|
||||
BUTTON_PLAY_AUDIO
|
||||
};
|
||||
|
|
|
@ -36,11 +36,16 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "ass_time.h"
|
||||
#include "dialog_timing_processor.h"
|
||||
#include "help_button.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "main.h"
|
||||
#include "selection_controller.h"
|
||||
|
@ -62,28 +67,24 @@ enum {
|
|||
TIMING_STYLE_LIST
|
||||
};
|
||||
|
||||
/// @brief Constructor
|
||||
/// @param parent
|
||||
/// @param _grid
|
||||
///
|
||||
DialogTimingProcessor::DialogTimingProcessor(wxWindow *parent,SubtitlesGrid *_grid)
|
||||
: wxDialog(parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE)
|
||||
DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
||||
: wxDialog(c->parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE)
|
||||
, c(c)
|
||||
, leadInTime(wxString::Format("%d", OPT_GET("Audio/Lead/IN")->GetInt()))
|
||||
, leadOutTime(wxString::Format("%d", OPT_GET("Audio/Lead/OUT")->GetInt()))
|
||||
, 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)));
|
||||
|
||||
// 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
|
||||
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->SetToolTip(_("Select styles to process. Unchecked ones will be ignored."));
|
||||
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());
|
||||
|
||||
// Check if rows are valid
|
||||
bool valid = true;
|
||||
AssDialogue *tempDiag;
|
||||
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++;
|
||||
for (entryIter cur = c->ass->Line.begin(); cur != c->ass->Line.end(); ++cur) {
|
||||
if (AssDialogue *tempDiag = dynamic_cast<AssDialogue*>(*cur)) {
|
||||
if (tempDiag->Start.GetMS() > tempDiag->End.GetMS()) {
|
||||
valid = false;
|
||||
break;
|
||||
wxMessageBox(
|
||||
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();
|
||||
else wxMessageBox(wxString::Format(_("One of the lines in the file (%i) has negative duration. Aborting."),i),_("Invalid script"),wxICON_ERROR|wxOK);
|
||||
|
||||
Process();
|
||||
EndModal(0);
|
||||
}
|
||||
|
||||
int DialogTimingProcessor::GetClosestKeyFrame(int frame) {
|
||||
// Linear dumb search, not very efficient, but it doesn't really matter
|
||||
int closest = 0;
|
||||
size_t n = KeyFrames.size();
|
||||
for (size_t i=0;i<n;i++) {
|
||||
if (abs(KeyFrames[i]-frame) < abs(closest-frame)) {
|
||||
closest = KeyFrames[i];
|
||||
}
|
||||
}
|
||||
return closest;
|
||||
std::vector<int>::iterator pos = lower_bound(KeyFrames.begin(), KeyFrames.end(), frame);
|
||||
if (distance(pos, KeyFrames.end()) < 2) return KeyFrames.back();
|
||||
return frame - *pos < *(pos + 1) - frame ? *pos : *(pos + 1);
|
||||
}
|
||||
|
||||
/// @brief Check if style is listed
|
||||
/// @param styleName
|
||||
/// @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;
|
||||
static bool bad_line(std::set<wxString> *styles, AssDialogue *d) {
|
||||
return !d || d->Comment || styles->find(d->Style) == styles->end();
|
||||
}
|
||||
|
||||
/// @brief Sort dialogues
|
||||
///
|
||||
void DialogTimingProcessor::SortDialogues() {
|
||||
// Copy from original to temporary list
|
||||
std::list<AssDialogue*> temp;
|
||||
AssDialogue *tempDiag;
|
||||
int count = grid->GetRows();
|
||||
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);
|
||||
}
|
||||
std::set<wxString> styles;
|
||||
for (size_t i = 0; i < StyleList->GetCount(); ++i) {
|
||||
if (StyleList->IsChecked(i)) {
|
||||
styles.insert(StyleList->GetString(i));
|
||||
}
|
||||
}
|
||||
|
||||
// Sort temporary list
|
||||
AssFile::Sort(temp);
|
||||
|
||||
// Copy temporary list to final vector
|
||||
Sorted.clear();
|
||||
for (std::list<AssDialogue*>::iterator cur=temp.begin();cur!=temp.end();cur++) {
|
||||
Sorted.push_back(*cur);
|
||||
Sorted.reserve(c->ass->Line.size());
|
||||
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());
|
||||
transform(c->ass->Line.begin(), c->ass->Line.end(), back_inserter(tmp), cast<AssDialogue*>());
|
||||
remove_copy_if(tmp.begin(), tmp.end(), back_inserter(Sorted),
|
||||
bind(bad_line, &styles, std::tr1::placeholders::_1));
|
||||
}
|
||||
|
||||
/// @brief Gets sorted dialogue
|
||||
/// @param n
|
||||
/// @return
|
||||
///
|
||||
AssDialogue *DialogTimingProcessor::GetSortedDialogue(int n) {
|
||||
try {
|
||||
return Sorted.at(n);
|
||||
}
|
||||
catch (...) {
|
||||
return NULL;
|
||||
}
|
||||
sort(Sorted.begin(), Sorted.end(), AssFile::CompStart);
|
||||
}
|
||||
|
||||
/// @brief Actually process subtitles
|
||||
|
@ -394,121 +365,75 @@ void DialogTimingProcessor::Process() {
|
|||
|
||||
// Add lead-in/out
|
||||
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++) {
|
||||
// Get line and check if it's OK
|
||||
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;
|
||||
AssDialogue *cur = Sorted[i];
|
||||
|
||||
// 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++) {
|
||||
comp = GetSortedDialogue(j);
|
||||
AssDialogue *comp = Sorted[j];
|
||||
|
||||
// Check if they don't already collide (ignore it in that case)
|
||||
if (cur->CollidesWith(comp)) continue;
|
||||
|
||||
// Get comparison times
|
||||
compEnd = comp->End.GetMS();
|
||||
|
||||
// Limit lead-in if needed
|
||||
if (compEnd > startLead) startLead = compEnd;
|
||||
startLead = std::max(startLead, comp->End.GetMS());
|
||||
}
|
||||
cur->Start.SetMS(startLead);
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
comp = GetSortedDialogue(j);
|
||||
AssDialogue *comp = Sorted[j];
|
||||
|
||||
// Check if they don't already collide (ignore it in that case)
|
||||
if (cur->CollidesWith(comp)) continue;
|
||||
|
||||
// Get comparison times
|
||||
compStart = comp->Start.GetMS();
|
||||
|
||||
// Limit lead-in if needed
|
||||
if (compStart < endLead) endLead = compStart;
|
||||
endLead = std::min(endLead, comp->Start.GetMS());
|
||||
}
|
||||
}
|
||||
|
||||
// Set times
|
||||
cur->Start.SetMS(startLead);
|
||||
cur->End.SetMS(endLead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Make adjacent
|
||||
if (adjsEnable->IsChecked()) {
|
||||
// Variables
|
||||
AssDialogue *cur;
|
||||
AssDialogue *prev = NULL;
|
||||
int curStart,prevEnd;
|
||||
long adjsThres = 0;
|
||||
int dist;
|
||||
AssDialogue *prev = Sorted.front();
|
||||
|
||||
// Get threshold
|
||||
long adjsThres = 0;
|
||||
adjacentThres->GetValue().ToLong(&adjsThres);
|
||||
|
||||
// Get bias
|
||||
float bias = adjacentBias->GetValue() / 100.0;
|
||||
|
||||
// For each row
|
||||
for (int i=0;i<rows;i++) {
|
||||
// Get line and check if it's OK
|
||||
cur = GetSortedDialogue(i);
|
||||
|
||||
// Check if previous is OK
|
||||
if (!prev) {
|
||||
prev = cur;
|
||||
continue;
|
||||
}
|
||||
for (int i=1; i < rows;i++) {
|
||||
AssDialogue *cur = Sorted[i];
|
||||
|
||||
// Check if they don't collide
|
||||
if (cur->CollidesWith(prev)) continue;
|
||||
|
||||
// Compare distance
|
||||
curStart = cur->Start.GetMS();
|
||||
prevEnd = prev->End.GetMS();
|
||||
dist = curStart-prevEnd;
|
||||
int curStart = cur->Start.GetMS();
|
||||
int prevEnd = prev->End.GetMS();
|
||||
int dist = curStart-prevEnd;
|
||||
if (dist > 0 && dist < adjsThres) {
|
||||
int setPos = prevEnd+int(dist*bias);
|
||||
cur->Start.SetMS(setPos);
|
||||
prev->End.SetMS(setPos);
|
||||
}
|
||||
|
||||
// Set previous
|
||||
prev = cur;
|
||||
}
|
||||
}
|
||||
|
||||
// Keyframe snapping
|
||||
if (keysEnable->IsChecked()) {
|
||||
// Get keyframes
|
||||
VideoContext *con = VideoContext::Get();
|
||||
KeyFrames = con->GetKeyFrames();
|
||||
KeyFrames.push_back(con->GetLength()-1);
|
||||
KeyFrames = c->videoController->GetKeyFrames();
|
||||
KeyFrames.push_back(c->videoController->GetLength() - 1);
|
||||
|
||||
// Variables
|
||||
int startF,endF;
|
||||
int closest;
|
||||
AssDialogue *cur;
|
||||
|
||||
// Get variables
|
||||
long beforeStart = 0;
|
||||
long afterStart = 0;
|
||||
long beforeEnd = 0;
|
||||
|
@ -518,29 +443,27 @@ void DialogTimingProcessor::Process() {
|
|||
keysEndBefore->GetValue().ToLong(&beforeEnd);
|
||||
keysEndAfter->GetValue().ToLong(&afterEnd);
|
||||
|
||||
// For each row
|
||||
for (int i=0;i<rows;i++) {
|
||||
// Get line and check if it's OK
|
||||
cur = GetSortedDialogue(i);
|
||||
AssDialogue *cur = Sorted[i];
|
||||
|
||||
// Get start/end frames
|
||||
startF = con->FrameAtTime(cur->Start.GetMS(),agi::vfr::START);
|
||||
endF = con->FrameAtTime(cur->End.GetMS(),agi::vfr::END);
|
||||
int startF = c->videoController->FrameAtTime(cur->Start.GetMS(),agi::vfr::START);
|
||||
int endF = c->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END);
|
||||
|
||||
// Get closest for start
|
||||
closest = GetClosestKeyFrame(startF);
|
||||
int closest = GetClosestKeyFrame(startF);
|
||||
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
|
||||
closest = GetClosestKeyFrame(endF)-1;
|
||||
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
|
||||
grid->ass->Commit(_("timing processor"), AssFile::COMMIT_TIMES);
|
||||
c->ass->Commit(_("timing processor"), AssFile::COMMIT_TIMES);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,9 @@
|
|||
#include <wx/textctrl.h>
|
||||
#endif
|
||||
|
||||
class SubtitlesGrid;
|
||||
namespace agi { struct Context; }
|
||||
class AssDialogue;
|
||||
class SubtitlesGrid;
|
||||
|
||||
/// DOCME
|
||||
/// @class DialogTimingProcessor
|
||||
|
@ -55,8 +56,7 @@ class AssDialogue;
|
|||
///
|
||||
/// DOCME
|
||||
class DialogTimingProcessor : public wxDialog {
|
||||
/// DOCME
|
||||
SubtitlesGrid *grid;
|
||||
agi::Context *c;
|
||||
|
||||
/// DOCME
|
||||
wxStaticBoxSizer *KeyframesSizer;
|
||||
|
@ -132,15 +132,13 @@ class DialogTimingProcessor : public wxDialog {
|
|||
void UpdateControls();
|
||||
void Process();
|
||||
int GetClosestKeyFrame(int frame);
|
||||
bool StyleOK(wxString styleName);
|
||||
|
||||
/// DOCME
|
||||
std::vector<AssDialogue*> Sorted;
|
||||
AssDialogue *GetSortedDialogue(int n);
|
||||
void SortDialogues();
|
||||
|
||||
public:
|
||||
DialogTimingProcessor(wxWindow *parent,SubtitlesGrid *grid);
|
||||
DialogTimingProcessor(agi::Context *c);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
|
|
@ -297,10 +297,10 @@ void FrameMain::InitContents() {
|
|||
videoSizer->AddStretchSpacer(1);
|
||||
|
||||
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->videoBox->videoSlider->grid = SubsGrid;
|
||||
Search.grid = SubsGrid;
|
||||
Search.context = context.get();
|
||||
|
||||
StartupLog("Create tool area splitter window");
|
||||
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());
|
||||
|
||||
StartupLog("Create subtitle editing box");
|
||||
context->editBox = EditBox = new SubsEditBox(Panel, SubsGrid);
|
||||
context->editBox = EditBox = new SubsEditBox(Panel, context.get());
|
||||
|
||||
StartupLog("Arrange main sizers");
|
||||
ToolsSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -1085,7 +1085,7 @@ int FrameMain::AddMacroMenuItems(wxMenu *menu, const std::vector<Automation4::Fe
|
|||
int id = activeMacroItems.size();;
|
||||
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());
|
||||
m->Enable((*i)->Validate(SubsGrid->ass, SubsGrid->GetAbsoluteSelection(), SubsGrid->GetFirstSelRow()));
|
||||
m->Enable((*i)->Validate(context->ass, SubsGrid->GetAbsoluteSelection(), SubsGrid->GetFirstSelRow()));
|
||||
activeMacroItems.push_back(*i);
|
||||
id++;
|
||||
}
|
||||
|
@ -1105,7 +1105,7 @@ void FrameMain::OnAutomationMacro (wxCommandEvent &event) {
|
|||
std::vector<int> selected_lines = SubsGrid->GetAbsoluteSelection();
|
||||
int first_sel = SubsGrid->GetFirstSelRow();
|
||||
// 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->EndBatch();
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
#include "audio_controller.h"
|
||||
#include "dialog_colorpicker.h"
|
||||
#include "dialog_search_replace.h"
|
||||
#include "frame_main.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "main.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);
|
||||
}
|
||||
|
||||
SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
|
||||
SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
|
||||
: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxRAISED_BORDER, "SubsEditBox")
|
||||
, line(NULL)
|
||||
, splitLineMode(false)
|
||||
, controlState(true)
|
||||
, grid(grid)
|
||||
, c(context)
|
||||
{
|
||||
grid->editBox = this;
|
||||
|
||||
// Top controls
|
||||
wxArrayString styles;
|
||||
styles.Add(_T("Default"));
|
||||
|
@ -261,7 +259,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
|
|||
MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,5);
|
||||
|
||||
// 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->SetUndoCollection(false);
|
||||
BottomSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -331,12 +329,12 @@ SubsEditBox::SubsEditBox(wxWindow *parent, SubtitlesGrid *grid)
|
|||
wxSizeEvent evt;
|
||||
OnSize(evt);
|
||||
|
||||
grid->AddSelectionListener(this);
|
||||
grid->ass->AddCommitListener(&SubsEditBox::Update, this);
|
||||
VideoContext::Get()->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this);
|
||||
c->subsGrid->AddSelectionListener(this);
|
||||
c->ass->AddCommitListener(&SubsEditBox::Update, this);
|
||||
context->videoController->AddTimecodesListener(&SubsEditBox::UpdateFrameTiming, this);
|
||||
}
|
||||
SubsEditBox::~SubsEditBox() {
|
||||
grid->RemoveSelectionListener(this);
|
||||
c->subsGrid->RemoveSelectionListener(this);
|
||||
}
|
||||
|
||||
void SubsEditBox::Update(int type) {
|
||||
|
@ -344,13 +342,13 @@ void SubsEditBox::Update(int type) {
|
|||
if (type == AssFile::COMMIT_FULL || type == AssFile::COMMIT_UNDO) {
|
||||
/// @todo maybe preserve selection over undo?
|
||||
StyleBox->Clear();
|
||||
StyleBox->Append(grid->ass->GetStyles());
|
||||
StyleBox->Append(c->ass->GetStyles());
|
||||
|
||||
ActorBox->Freeze();
|
||||
ActorBox->Clear();
|
||||
int nrows = grid->GetRows();
|
||||
int nrows = c->subsGrid->GetRows();
|
||||
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.
|
||||
if (actor.empty()) actor = "Actor";
|
||||
if (ActorBox->FindString(actor) == wxNOT_FOUND) {
|
||||
|
@ -396,20 +394,20 @@ void SubsEditBox::OnActiveLineChanged(AssDialogue *new_line) {
|
|||
Update(AssFile::COMMIT_TEXT);
|
||||
|
||||
/// @todo VideoContext should be doing this
|
||||
if (VideoContext::Get()->IsLoaded()) {
|
||||
if (c->videoController->IsLoaded()) {
|
||||
bool sync;
|
||||
if (Search.hasFocus) sync = OPT_GET("Tool/Search Replace/Video Update")->GetBool();
|
||||
else sync = OPT_GET("Video/Subtitle Sync")->GetBool();
|
||||
|
||||
if (sync) {
|
||||
VideoContext::Get()->Stop();
|
||||
VideoContext::Get()->JumpToTime(line->Start.GetMS());
|
||||
c->videoController->Stop();
|
||||
c->videoController->JumpToTime(line->Start.GetMS());
|
||||
}
|
||||
}
|
||||
SetEvtHandlerEnabled(true);
|
||||
}
|
||||
void SubsEditBox::OnSelectedSetChanged(const Selection &, const Selection &) {
|
||||
sel = grid->GetSelectedSet();
|
||||
sel = c->subsGrid->GetSelectedSet();
|
||||
}
|
||||
|
||||
void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
|
||||
|
@ -421,7 +419,7 @@ void SubsEditBox::UpdateFrameTiming(agi::vfr::Framerate const& fps) {
|
|||
ByTime->SetValue(true);
|
||||
StartTime->SetByFrame(false);
|
||||
EndTime->SetByFrame(false);
|
||||
grid->SetByFrame(false);
|
||||
c->subsGrid->SetByFrame(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,16 +442,16 @@ void SubsEditBox::OnCommitButton(wxCommandEvent &) {
|
|||
}
|
||||
|
||||
void SubsEditBox::NextLine() {
|
||||
int next = grid->GetLastSelRow() + 1;
|
||||
if (next >= grid->GetRows()) {
|
||||
AssDialogue *cur = grid->GetDialogue(next-1);
|
||||
int next = c->subsGrid->GetLastSelRow() + 1;
|
||||
if (next >= c->subsGrid->GetRows()) {
|
||||
AssDialogue *cur = c->subsGrid->GetDialogue(next-1);
|
||||
AssDialogue *newline = new AssDialogue;
|
||||
newline->Start = cur->End;
|
||||
newline->End = cur->End + OPT_GET("Timing/Default Duration")->GetInt();
|
||||
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) {
|
||||
|
@ -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));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -547,7 +545,7 @@ void SubsEditBox::OnFrameTimeRadio(wxCommandEvent &event) {
|
|||
StartTime->SetByFrame(byFrame);
|
||||
EndTime->SetByFrame(byFrame);
|
||||
Duration->SetByFrame(byFrame);
|
||||
grid->SetByFrame(byFrame);
|
||||
c->subsGrid->SetByFrame(byFrame);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
@ -634,14 +632,14 @@ void SubsEditBox::OnDurationChange(wxCommandEvent &) {
|
|||
}
|
||||
void SubsEditBox::OnMarginLChange(wxCommandEvent &) {
|
||||
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)
|
||||
MarginL->ChangeValue(cur->GetMarginString(0,false));
|
||||
}
|
||||
|
||||
void SubsEditBox::OnMarginRChange(wxCommandEvent &) {
|
||||
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)
|
||||
MarginR->ChangeValue(cur->GetMarginString(1,false));
|
||||
}
|
||||
|
@ -653,7 +651,7 @@ static void set_margin_v(AssDialogue* diag, wxString value) {
|
|||
|
||||
void SubsEditBox::OnMarginVChange(wxCommandEvent &) {
|
||||
SetSelectedRows(set_margin_v, MarginV->GetValue(), _("MarginV change"));
|
||||
AssDialogue *cur = grid->GetDialogue(grid->GetFirstSelRow());
|
||||
AssDialogue *cur = c->subsGrid->GetDialogue(c->subsGrid->GetFirstSelRow());
|
||||
if (cur)
|
||||
MarginV->ChangeValue(cur->GetMarginString(2,false));
|
||||
}
|
||||
|
@ -746,7 +744,7 @@ void SubsEditBox::OnFlagButton(wxCommandEvent &evt) {
|
|||
wxString tagname;
|
||||
wxString desc;
|
||||
bool state = false;
|
||||
AssStyle *style = grid->ass->GetStyle(line->Style);
|
||||
AssStyle *style = c->ass->GetStyle(line->Style);
|
||||
AssStyle defStyle;
|
||||
if (!style) style = &defStyle;
|
||||
if (id == BUTTON_BOLD) {
|
||||
|
@ -797,7 +795,7 @@ void SubsEditBox::OnFontButton(wxCommandEvent &) {
|
|||
int blockn = BlockAtPos(selstart);
|
||||
|
||||
wxFont startfont;
|
||||
AssStyle *style = grid->ass->GetStyle(line->Style);
|
||||
AssStyle *style = c->ass->GetStyle(line->Style);
|
||||
AssStyle defStyle;
|
||||
if (!style) style = &defStyle;
|
||||
|
||||
|
@ -838,7 +836,7 @@ void SubsEditBox::OnColorButton(wxCommandEvent &evt) {
|
|||
wxString alt;
|
||||
|
||||
wxColor color;
|
||||
AssStyle *style = grid->ass->GetStyle(line->Style);
|
||||
AssStyle *style = c->ass->GetStyle(line->Style);
|
||||
AssStyle defStyle;
|
||||
if (!style) style = &defStyle;
|
||||
if (id == BUTTON_COLOR1) {
|
||||
|
@ -871,7 +869,7 @@ void SubsEditBox::OnColorButton(wxCommandEvent &evt) {
|
|||
|
||||
color = get_value(*line, blockn, color, colorTag, alt);
|
||||
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) {
|
||||
TextEdit->SetTextTo(initialText);
|
||||
TextEdit->SetSelectionU(selstart, selend);
|
||||
|
|
|
@ -42,8 +42,8 @@
|
|||
|
||||
#include "selection_controller.h"
|
||||
|
||||
namespace agi { struct Context; }
|
||||
class AssDialogue;
|
||||
class SubtitlesGrid;
|
||||
class SubsTextEditCtrl;
|
||||
class TimeEdit;
|
||||
class wxButton;
|
||||
|
@ -55,7 +55,6 @@ class wxSpinCtrl;
|
|||
class wxStyledTextCtrl;
|
||||
class wxStyledTextEvent;
|
||||
class wxTextCtrl;
|
||||
class AudioController;
|
||||
|
||||
namespace agi { namespace vfr { class Framerate; } }
|
||||
|
||||
|
@ -84,8 +83,7 @@ class SubsEditBox : public wxPanel, protected SelectionListener<AssDialogue> {
|
|||
wxColour disabledBgColour;
|
||||
wxColour origBgColour;
|
||||
|
||||
// Externally supplied controls
|
||||
SubtitlesGrid *grid;
|
||||
agi::Context *c;
|
||||
|
||||
// Box controls
|
||||
wxCheckBox *CommentBox;
|
||||
|
@ -196,7 +194,6 @@ public:
|
|||
|
||||
/// @brief Constructor
|
||||
/// @param parent Parent window
|
||||
/// @param grid Associated grid
|
||||
SubsEditBox(wxWindow *parent, SubtitlesGrid *grid);
|
||||
SubsEditBox(wxWindow *parent, agi::Context *context);
|
||||
~SubsEditBox();
|
||||
};
|
||||
|
|
|
@ -103,21 +103,15 @@ END_EVENT_TABLE()
|
|||
/// @param size
|
||||
/// @param style
|
||||
/// @param name
|
||||
SubtitlesGrid::SubtitlesGrid(FrameMain* parentFr, wxWindow *parent, wxWindowID id, AssFile *subs, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
|
||||
: BaseGrid(parent,id,pos,size,style,name)
|
||||
, ass(subs)
|
||||
SubtitlesGrid::SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxSize& size, long style, const wxString& name)
|
||||
: BaseGrid(parent,context,size,style,name)
|
||||
, 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"));
|
||||
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));
|
||||
ass->AddCommitListener(&SubtitlesGrid::OnSubtitlesCommit, this);
|
||||
ass->AddFileOpenListener(&SubtitlesGrid::OnSubtitlesOpen, this);
|
||||
context->ass->AddCommitListener(&SubtitlesGrid::OnSubtitlesCommit, this);
|
||||
context->ass->AddFileOpenListener(&SubtitlesGrid::OnSubtitlesOpen, this);
|
||||
}
|
||||
|
||||
/// @brief Destructor
|
||||
|
@ -196,14 +190,14 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
|
|||
state = (sels == 1);
|
||||
menu.Append(MENU_INSERT_BEFORE,_("&Insert (before)"),_T("Inserts a line before current"))->Enable(state);
|
||||
menu.Append(MENU_INSERT_AFTER,_("Insert (after)"),_T("Inserts a line after current"))->Enable(state);
|
||||
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_AFTER_VIDEO,_("Insert at video time (after)"),_T("Inserts a line after current, starting at video time"))->Enable(state);
|
||||
menu.AppendSeparator();
|
||||
|
||||
// Duplicate selection
|
||||
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);
|
||||
|
||||
// Swaps selection
|
||||
|
@ -228,7 +222,7 @@ void SubtitlesGrid::OnPopupMenu(bool alternate) {
|
|||
menu.AppendSeparator();
|
||||
|
||||
//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.AppendSeparator();
|
||||
|
||||
|
@ -343,7 +337,7 @@ void SubtitlesGrid::OnKeyDown(wxKeyEvent &event) {
|
|||
}
|
||||
|
||||
// Duplicate and shift
|
||||
if (context->TimecodesLoaded()) {
|
||||
if (context->videoController->TimecodesLoaded()) {
|
||||
if (Hotkeys.IsPressed(_T("Grid duplicate and shift one frame"))) {
|
||||
DuplicateLines(n,n2,true);
|
||||
return;
|
||||
|
@ -427,7 +421,7 @@ void SubtitlesGrid::OnSplitByKaraoke (wxCommandEvent &) {
|
|||
didSplit |= SplitLineByKaraoke(sels[i]);
|
||||
}
|
||||
if (didSplit) {
|
||||
ass->Commit(_("splitting"));
|
||||
context->ass->Commit(_("splitting"));
|
||||
}
|
||||
EndBatch();
|
||||
}
|
||||
|
@ -498,7 +492,7 @@ void SubtitlesGrid::OnInsertBeforeVideo (wxCommandEvent &) {
|
|||
|
||||
// Create line to add
|
||||
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->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
def->Style = GetDialogue(n)->Style;
|
||||
|
@ -518,7 +512,7 @@ void SubtitlesGrid::OnInsertAfterVideo (wxCommandEvent &) {
|
|||
|
||||
// Create line to add
|
||||
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->End.SetMS(video_ms+OPT_GET("Timing/Default Duration")->GetInt());
|
||||
def->Style = GetDialogue(n)->Style;
|
||||
|
@ -616,14 +610,14 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
|
|||
if (d1->Text == (*d2)->Text) {
|
||||
expand_times(d1, *d2);
|
||||
delete d1;
|
||||
ass->Line.remove(d1);
|
||||
context->ass->Line.remove(d1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1, 1+2, 1 turns into 1, 2, [empty]
|
||||
if (d1->Text.empty()) {
|
||||
delete d1;
|
||||
ass->Line.remove(d1);
|
||||
context->ass->Line.remove(d1);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -656,11 +650,11 @@ void SubtitlesGrid::OnRecombine(wxCommandEvent &) {
|
|||
}
|
||||
}
|
||||
|
||||
ass->Commit(_("combining"));
|
||||
context->ass->Commit(_("combining"));
|
||||
|
||||
// Remove now non-existent lines from the selection
|
||||
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;
|
||||
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
|
||||
void SubtitlesGrid::OnAudioClip(wxCommandEvent &) {
|
||||
int64_t num_samples,start=0,end=0,temp;
|
||||
AudioController *audioController = parentFrame->context->audioController;
|
||||
AudioController *audioController = context->audioController;
|
||||
const AudioProvider *provider = audioController->GetAudioProvider();
|
||||
AssDialogue *cur;
|
||||
wxArrayInt sel = GetSelection();
|
||||
|
@ -763,7 +757,7 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
|
|||
|
||||
std::swap(*dlg1, *dlg2);
|
||||
|
||||
ass->Commit(_("swap lines"));
|
||||
context->ass->Commit(_("swap lines"));
|
||||
}
|
||||
|
||||
/// @brief Insert a line
|
||||
|
@ -773,14 +767,14 @@ void SubtitlesGrid::SwapLines(int n1,int n2) {
|
|||
/// @param update
|
||||
void SubtitlesGrid::InsertLine(AssDialogue *line,int n,bool after,bool update) {
|
||||
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;
|
||||
|
||||
entryIter newIter = ass->Line.insert(pos,line);
|
||||
entryIter newIter = context->ass->Line.insert(pos,line);
|
||||
|
||||
// Update
|
||||
if (update) {
|
||||
ass->Commit(_("line insertion"));
|
||||
context->ass->Commit(_("line insertion"));
|
||||
}
|
||||
else {
|
||||
UpdateMaps();
|
||||
|
@ -896,7 +890,7 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
|||
|
||||
// Update data post-insertion
|
||||
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
|
||||
if (!pasteOver) {
|
||||
|
@ -913,14 +907,14 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
|||
}
|
||||
|
||||
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 row = -1;
|
||||
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]) {
|
||||
cur = ass->Line.erase(cur);
|
||||
cur = context->ass->Line.erase(cur);
|
||||
++deleted;
|
||||
if (deleted == target.size()) break;
|
||||
}
|
||||
|
@ -933,12 +927,12 @@ void SubtitlesGrid::DeleteLines(wxArrayInt target, bool flagModified) {
|
|||
if (GetRows() == deleted) {
|
||||
AssDialogue *def = new AssDialogue;
|
||||
++before_first;
|
||||
ass->Line.insert(before_first, def);
|
||||
context->ass->Line.insert(before_first, def);
|
||||
old_active_line_index = 0;
|
||||
}
|
||||
|
||||
if (flagModified) {
|
||||
ass->Commit(_("delete"));
|
||||
context->ass->Commit(_("delete"));
|
||||
}
|
||||
else {
|
||||
UpdateMaps();
|
||||
|
@ -991,7 +985,7 @@ void SubtitlesGrid::JoinLines(int n1,int n2,bool concat) {
|
|||
// Delete remaining lines (this will auto commit)
|
||||
DeleteLines(GetRangeArray(n1+1,n2), false);
|
||||
|
||||
ass->Commit(_("join lines"));
|
||||
context->ass->Commit(_("join lines"));
|
||||
|
||||
// Select new line
|
||||
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) {
|
||||
|
@ -1073,7 +1067,7 @@ void SubtitlesGrid::JoinAsKaraoke(int n1,int n2) {
|
|||
// Delete remaining lines (this will auto commit)
|
||||
DeleteLines(GetRangeArray(n1+1,n2), false);
|
||||
|
||||
ass->Commit(_("join as karaoke"));
|
||||
context->ass->Commit(_("join as karaoke"));
|
||||
|
||||
// Select new line
|
||||
SetActiveLine(cur);
|
||||
|
@ -1091,9 +1085,9 @@ void SubtitlesGrid::DuplicateLines(int n1,int n2,bool nextFrame) {
|
|||
|
||||
// Shift to next frame
|
||||
if (nextFrame) {
|
||||
int posFrame = context->FrameAtTime(cur->End.GetMS(),agi::vfr::END) + 1;
|
||||
cur->Start.SetMS(context->TimeAtFrame(posFrame,agi::vfr::START));
|
||||
cur->End.SetMS(context->TimeAtFrame(posFrame,agi::vfr::END));
|
||||
int posFrame = context->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END) + 1;
|
||||
cur->Start.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::START));
|
||||
cur->End.SetMS(context->videoController->TimeAtFrame(posFrame,agi::vfr::END));
|
||||
}
|
||||
|
||||
// Insert
|
||||
|
@ -1122,8 +1116,8 @@ void SubtitlesGrid::ShiftLineByFrames(int n,int len,int type) {
|
|||
assert(type >= 0 && type <= 2);
|
||||
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 != 1) cur->End.SetMS(context->TimeAtFrame(len + context->FrameAtTime(cur->End.GetMS(),agi::vfr::END),agi::vfr::END));
|
||||
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->videoController->TimeAtFrame(len + context->videoController->FrameAtTime(cur->End.GetMS(),agi::vfr::END),agi::vfr::END));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ass->Commit(_("split"));
|
||||
context->ass->Commit(_("split"));
|
||||
}
|
||||
|
||||
bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
|
||||
|
@ -1184,10 +1178,10 @@ bool SubtitlesGrid::SplitLineByKaraoke(int lineNumber) {
|
|||
}
|
||||
|
||||
void SubtitlesGrid::SetSubsToVideo(bool start) {
|
||||
if (!context->IsLoaded()) return;
|
||||
if (!context->videoController->IsLoaded()) return;
|
||||
|
||||
// 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
|
||||
wxArrayInt sel = GetSelection();
|
||||
|
@ -1202,7 +1196,7 @@ void SubtitlesGrid::SetSubsToVideo(bool start) {
|
|||
}
|
||||
|
||||
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]);
|
||||
if (cur) {
|
||||
if (start)
|
||||
context->JumpToTime(cur->Start.GetMS());
|
||||
context->videoController->JumpToTime(cur->Start.GetMS());
|
||||
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);
|
||||
|
||||
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())
|
||||
result.push_back(line_index);
|
||||
}
|
||||
|
@ -1248,11 +1242,11 @@ void SubtitlesGrid::SetSelectionFromAbsolute(std::vector<int> &selection) {
|
|||
std::sort(selection.begin(), selection.end());
|
||||
|
||||
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) {
|
||||
while (i != selection[selveci] && j != ass->Line.end()) ++i, ++j;
|
||||
if (j == ass->Line.end()) break; /// @todo Report error somehow
|
||||
while (i != selection[selveci] && j != context->ass->Line.end()) ++i, ++j;
|
||||
if (j == context->ass->Line.end()) break; /// @todo Report error somehow
|
||||
AssDialogue *dlg = dynamic_cast<AssDialogue*>(*j);
|
||||
if (dlg) newsel.insert(dlg);
|
||||
}
|
||||
|
|
|
@ -52,11 +52,7 @@
|
|||
|
||||
namespace agi { class OptionValue; }
|
||||
|
||||
class AssFile;
|
||||
class AssEntry;
|
||||
class AssDialogue;
|
||||
class SubsEditBox;
|
||||
class FrameMain;
|
||||
|
||||
typedef std::list<AssEntry*>::iterator entryIter;
|
||||
|
||||
|
@ -66,7 +62,6 @@ typedef std::list<AssEntry*>::iterator entryIter;
|
|||
///
|
||||
/// DOCME
|
||||
class SubtitlesGrid: public BaseGrid {
|
||||
private:
|
||||
agi::signal::Connection seekListener;
|
||||
|
||||
void OnPopupMenu(bool alternate=false);
|
||||
|
@ -103,10 +98,7 @@ private:
|
|||
void OnSubtitlesOpen();
|
||||
|
||||
public:
|
||||
/// Currently open file
|
||||
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(wxWindow *parent, agi::Context *context, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr);
|
||||
~SubtitlesGrid();
|
||||
|
||||
/// @brief Jump to the start/end time of the current subtitle line
|
||||
|
|
|
@ -158,7 +158,7 @@ VideoDisplay::VideoDisplay(
|
|||
slots.push_back(con->videoController->AddSeekListener(&VideoDisplay::SetFrame, this));
|
||||
slots.push_back(con->videoController->AddVideoOpenListener(&VideoDisplay::OnVideoOpen, 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);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include <libaegisub/signal.h>
|
||||
|
||||
// Prototypes
|
||||
class AssFile;
|
||||
class FrameReadyEvent;
|
||||
class VideoBox;
|
||||
class VideoContext;
|
||||
|
@ -186,8 +185,6 @@ class VideoDisplay : public wxGLCanvas {
|
|||
/// The dropdown box for selecting zoom levels
|
||||
wxComboBox *zoomBox;
|
||||
|
||||
AssFile *model;
|
||||
|
||||
public:
|
||||
/// The VideoBox this display is contained in
|
||||
VideoBox *box;
|
||||
|
|
|
@ -69,7 +69,7 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context,
|
|||
, commitId(-1)
|
||||
, selChanged(false)
|
||||
, selectedFeatures(selFeatures)
|
||||
, grid(context->subsGrid)
|
||||
, c(context)
|
||||
, parent(parent)
|
||||
, holding(false)
|
||||
, dragging(false)
|
||||
|
@ -81,15 +81,15 @@ VisualTool<FeatureType>::VisualTool(VideoDisplay *parent, agi::Context *context,
|
|||
, ctrlDown(false)
|
||||
, altDown(false)
|
||||
{
|
||||
frameNumber = context->videoController->GetFrameN();
|
||||
frameNumber = c->videoController->GetFrameN();
|
||||
curDiag = GetActiveDialogueLine();
|
||||
grid->AddSelectionListener(this);
|
||||
c->selectionController->AddSelectionListener(this);
|
||||
curFeature = features.begin();
|
||||
}
|
||||
|
||||
template<class FeatureType>
|
||||
VisualTool<FeatureType>::~VisualTool() {
|
||||
grid->RemoveSelectionListener(this);
|
||||
c->selectionController->RemoveSelectionListener(this);
|
||||
}
|
||||
|
||||
template<class FeatureType>
|
||||
|
@ -203,7 +203,7 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
|
|||
else {
|
||||
selChanged = false;
|
||||
}
|
||||
if (curFeature->line) grid->SetActiveLine(curFeature->line);
|
||||
if (curFeature->line) c->selectionController->SetActiveLine(curFeature->line);
|
||||
|
||||
if (InitializeDrag(curFeature)) {
|
||||
dragStartX = video.x;
|
||||
|
@ -222,8 +222,8 @@ void VisualTool<FeatureType>::OnMouseEvent(wxMouseEvent &event) {
|
|||
if (!altDown) {
|
||||
ClearSelection();
|
||||
Selection sel;
|
||||
sel.insert(grid->GetActiveLine());
|
||||
grid->SetSelectedSet(sel);
|
||||
sel.insert(c->selectionController->GetActiveLine());
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
needRender = true;
|
||||
}
|
||||
if (curDiag && InitializeHold()) {
|
||||
|
@ -248,14 +248,14 @@ void VisualTool<FeatureType>::Commit(wxString message) {
|
|||
if (message.empty()) {
|
||||
message = _("visual typesetting");
|
||||
}
|
||||
commitId = grid->ass->Commit(message, AssFile::COMMIT_TEXT, commitId);
|
||||
commitId = c->ass->Commit(message, AssFile::COMMIT_TEXT, commitId);
|
||||
externalChange = true;
|
||||
}
|
||||
|
||||
template<class FeatureType>
|
||||
AssDialogue* VisualTool<FeatureType>::GetActiveDialogueLine() {
|
||||
AssDialogue *diag = grid->GetActiveLine();
|
||||
if (diag && grid->IsDisplayed(diag))
|
||||
AssDialogue *diag = c->selectionController->GetActiveLine();
|
||||
if (diag && c->subsGrid->IsDisplayed(diag))
|
||||
return diag;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ void VisualTool<FeatureType>::SetFrame(int newFrameNumber) {
|
|||
|
||||
template<class FeatureType>
|
||||
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;
|
||||
}
|
||||
if (new_line != curDiag) {
|
||||
|
@ -335,7 +335,7 @@ void VisualTool<FeatureType>::SetSelection(feature_iterator feat) {
|
|||
|
||||
Selection sel;
|
||||
sel.insert(line);
|
||||
grid->SetSelectedSet(sel);
|
||||
c->selectionController->SetSelectedSet(sel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,9 +344,9 @@ template<class FeatureType>
|
|||
void VisualTool<FeatureType>::AddSelection(feature_iterator feat) {
|
||||
if (selFeatures.insert(feat).second && feat->line) {
|
||||
lineSelCount[feat->line] += 1;
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
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;
|
||||
assert(lineSelCount[line] >= 0);
|
||||
if (lineSelCount[line] <= 0) {
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
|
||||
// Don't deselect the only selected line
|
||||
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
|
||||
// deselected the active line
|
||||
if (line == grid->GetActiveLine()) {
|
||||
grid->SetActiveLine(*sel.begin());
|
||||
if (line == c->selectionController->GetActiveLine()) {
|
||||
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];
|
||||
int align = 2;
|
||||
|
||||
AssStyle *style = grid->ass->GetStyle(diag->Style);
|
||||
AssStyle *style = c->ass->GetStyle(diag->Style);
|
||||
if (style) {
|
||||
align = style->alignment;
|
||||
for (int i=0;i<4;i++) {
|
||||
|
@ -444,7 +444,7 @@ void VisualTool<FeatureType>::GetLinePosition(AssDialogue *diag,int &x, int &y,
|
|||
}
|
||||
|
||||
int sw,sh;
|
||||
VideoContext::Get()->GetScriptSize(sw,sh);
|
||||
c->videoController->GetScriptSize(sw,sh);
|
||||
|
||||
// Process margins
|
||||
margin[1] = sw - margin[1];
|
||||
|
@ -515,7 +515,7 @@ template<class FeatureType>
|
|||
void VisualTool<FeatureType>::GetLineRotation(AssDialogue *diag,float &rx,float &ry,float &rz) {
|
||||
rx = ry = rz = 0.f;
|
||||
|
||||
AssStyle *style = grid->ass->GetStyle(diag->Style);
|
||||
AssStyle *style = c->ass->GetStyle(diag->Style);
|
||||
if (style) {
|
||||
rz = style->angle;
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ template<class FeatureType>
|
|||
void VisualTool<FeatureType>::GetLineScale(AssDialogue *diag,float &scalX,float &scalY) {
|
||||
scalX = scalY = 100.f;
|
||||
|
||||
AssStyle *style = grid->ass->GetStyle(diag->Style);
|
||||
AssStyle *style = c->ass->GetStyle(diag->Style);
|
||||
if (style) {
|
||||
scalX = style->scalex;
|
||||
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) {
|
||||
x1 = y1 = 0;
|
||||
int sw,sh;
|
||||
VideoContext::Get()->GetScriptSize(sw,sh);
|
||||
c->videoController->GetScriptSize(sw,sh);
|
||||
x2 = sw-1;
|
||||
y2 = sh-1;
|
||||
inverse = false;
|
||||
|
|
|
@ -155,7 +155,7 @@ protected:
|
|||
/// Read-only reference to the set of selected features for subclasses
|
||||
const std::set<feature_iterator, ltaddr> &selectedFeatures;
|
||||
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
|
||||
bool holding; /// Is a hold currently in progress?
|
||||
AssDialogue *curDiag; /// Active dialogue line; NULL if it is not visible on the current frame
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "gl_text.h"
|
||||
#include "subs_grid.h"
|
||||
#include "video_context.h"
|
||||
|
@ -61,7 +62,7 @@ bool VisualToolCross::Update() {
|
|||
dx -= vx;
|
||||
dy -= vy;
|
||||
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
||||
int x1, y1;
|
||||
GetLinePosition(*cur, x1, y1);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "libresrc/libresrc.h"
|
||||
#include "subs_grid.h"
|
||||
#include "utils.h"
|
||||
|
@ -64,7 +65,7 @@ VisualToolDrag::VisualToolDrag(VideoDisplay *parent, agi::Context *context, Vide
|
|||
toolBar->Realize();
|
||||
toolBar->Show(true);
|
||||
|
||||
grid->GetSelectedSet(selection);
|
||||
c->selectionController->GetSelectedSet(selection);
|
||||
OnFileChanged();
|
||||
}
|
||||
|
||||
|
@ -124,9 +125,9 @@ void VisualToolDrag::OnFileChanged() {
|
|||
ClearSelection();
|
||||
primary = NULL;
|
||||
|
||||
for (int i = grid->GetRows() - 1; i >=0; i--) {
|
||||
AssDialogue *diag = grid->GetDialogue(i);
|
||||
if (BaseGrid::IsDisplayed(diag)) {
|
||||
for (int i = c->subsGrid->GetRows() - 1; i >=0; i--) {
|
||||
AssDialogue *diag = c->subsGrid->GetDialogue(i);
|
||||
if (c->subsGrid->IsDisplayed(diag)) {
|
||||
MakeFeatures(diag);
|
||||
}
|
||||
}
|
||||
|
@ -134,14 +135,14 @@ void VisualToolDrag::OnFileChanged() {
|
|||
}
|
||||
|
||||
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 end = features.end();
|
||||
|
||||
for (int i = grid->GetRows() - 1; i >=0; i--) {
|
||||
AssDialogue *diag = grid->GetDialogue(i);
|
||||
if (BaseGrid::IsDisplayed(diag)) {
|
||||
for (int i = c->subsGrid->GetRows() - 1; i >=0; i--) {
|
||||
AssDialogue *diag = c->subsGrid->GetDialogue(i);
|
||||
if (c->subsGrid->IsDisplayed(diag)) {
|
||||
// Features don't exist and should
|
||||
if (feat == end || feat->line != diag) {
|
||||
MakeFeatures(diag, feat);
|
||||
|
@ -163,10 +164,10 @@ void VisualToolDrag::OnFrameChanged() {
|
|||
}
|
||||
|
||||
void VisualToolDrag::OnSelectedSetChanged(const Selection &added, const Selection &removed) {
|
||||
grid->GetSelectedSet(selection);
|
||||
c->selectionController->GetSelectedSet(selection);
|
||||
if (!externalChange) return;
|
||||
externalChange = false;
|
||||
grid->BeginBatch();
|
||||
c->subsGrid->BeginBatch();
|
||||
|
||||
for (feature_iterator cur = features.begin(); cur != features.end(); ++cur) {
|
||||
// Remove all deselected lines
|
||||
|
@ -179,7 +180,7 @@ void VisualToolDrag::OnSelectedSetChanged(const Selection &added, const Selectio
|
|||
}
|
||||
}
|
||||
|
||||
grid->EndBatch();
|
||||
c->subsGrid->EndBatch();
|
||||
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
|
||||
// selected features by the same amount
|
||||
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;
|
||||
|
||||
for (sel_iterator cur = selectedFeatures.begin(); cur != selectedFeatures.end(); ++cur) {
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "subs_grid.h"
|
||||
#include "utils.h"
|
||||
#include "video_context.h"
|
||||
|
@ -188,7 +189,7 @@ void VisualToolRotateXY::UpdateHold() {
|
|||
}
|
||||
|
||||
void VisualToolRotateXY::CommitHold() {
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
||||
SetOverride(*cur, L"\\frx",wxString::Format(L"(%0.3g)",curAngleX));
|
||||
SetOverride(*cur, L"\\fry",wxString::Format(L"(%0.3g)",curAngleY));
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "subs_grid.h"
|
||||
#include "utils.h"
|
||||
#include "video_context.h"
|
||||
|
@ -150,7 +151,7 @@ void VisualToolRotateZ::UpdateHold() {
|
|||
}
|
||||
|
||||
void VisualToolRotateZ::CommitHold() {
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
||||
SetOverride(*cur, L"\\frz",wxString::Format(L"(%0.3g)",curAngle));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#include "ass_dialogue.h"
|
||||
#include "ass_file.h"
|
||||
#include "include/aegisub/context.h"
|
||||
#include "subs_grid.h"
|
||||
#include "utils.h"
|
||||
#include "video_context.h"
|
||||
|
@ -145,7 +146,7 @@ void VisualToolScale::UpdateHold() {
|
|||
}
|
||||
|
||||
void VisualToolScale::CommitHold() {
|
||||
Selection sel = grid->GetSelectedSet();
|
||||
Selection sel = c->selectionController->GetSelectedSet();
|
||||
for (Selection::const_iterator cur = sel.begin(); cur != sel.end(); ++cur) {
|
||||
SetOverride(*cur, L"\\fscx",wxString::Format(L"(%0.3g)",curScaleX));
|
||||
SetOverride(*cur, L"\\fscy",wxString::Format(L"(%0.3g)",curScaleY));
|
||||
|
|
Loading…
Reference in a new issue