Added a commit button to the subtitles edit box for the shortcut-impaired.

Originally committed to SVN as r1319.
This commit is contained in:
Rodrigo Braz Monteiro 2007-06-30 20:00:07 +00:00
parent 3e411f1eed
commit 6f283a819e
4 changed files with 55 additions and 33 deletions

View File

@ -118,6 +118,7 @@ Please visit http://aegisub.net to download latest version
o Fixed glitches related to the Duration time edit box. (AMZ)
o Tweaked the behavior of the margin boxes, now they no longer show padding zeros. (AMZ)
o Actor and Effect fields now show a "ghosted" caption saying their name when they are not focused on and blank. (AMZ)
o Added a "Commit" button that duplicates the Enter/Ctrl+Enter functionality, since those shortcuts were not obvious to everyone. (AMZ)
- Changes to Fonts Collector:
o Changed the font searching engine to something slower, but far more reliable. (jfs/AMZ)
o Added option to just verify if you have the fonts. (AMZ)

View File

@ -75,8 +75,8 @@
// FrameMain constructor
FrameMain::FrameMain (wxArrayString args)
// FIXME: 800x600 default window size is tiny on high-res monitors, but maximised is not always desirable either
: wxFrame ((wxFrame*)NULL,-1,_T(""),wxDefaultPosition,wxSize(800,600),wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
// FIXME: 860x600 default window size is tiny on high-res monitors, but maximised is not always desirable either
: wxFrame ((wxFrame*)NULL,-1,_T(""),wxDefaultPosition,wxSize(860,600),wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN)
{
#ifdef __WXGTK__
/* XXX HACK XXX

View File

@ -132,6 +132,8 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
Color3->SetToolTip(_("Outline color"));
Color4 = new wxBitmapButton(this,BUTTON_COLOR4,wxBITMAP(button_color_four),wxDefaultPosition,wxSize(30,20));
Color4->SetToolTip(_("Shadow color"));
CommitButton = new wxButton(this,BUTTON_COMMIT,_("Commit"),wxDefaultPosition,wxSize(55,20));
CommitButton->SetToolTip(_T("Commits the text (Enter). Hold Ctrl to stay in line (Ctrl+Enter)."));
ByTime = new wxRadioButton(this,RADIO_TIME_BY_TIME,_("Time"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP);
ByTime->SetToolTip(_("Time by h:mm:ss.cs"));
ByFrame = new wxRadioButton(this,RADIO_TIME_BY_FRAME,_("Frame"));
@ -168,7 +170,8 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
MiddleBotSizer->Add(Color1);
MiddleBotSizer->Add(Color2);
MiddleBotSizer->Add(Color3);
MiddleBotSizer->Add(Color4,0,wxRIGHT,10);
MiddleBotSizer->Add(Color4,0,wxRIGHT,5);
MiddleBotSizer->Add(CommitButton,0,wxRIGHT,10);
MiddleBotSizer->Add(ByTime,0,wxRIGHT | wxALIGN_CENTER,5);
MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER,5);
@ -379,6 +382,7 @@ BEGIN_EVENT_TABLE(SubsEditBox, wxPanel)
EVT_BUTTON(BUTTON_ITALICS,SubsEditBox::OnButtonItalics)
EVT_BUTTON(BUTTON_UNDERLINE,SubsEditBox::OnButtonUnderline)
EVT_BUTTON(BUTTON_STRIKEOUT,SubsEditBox::OnButtonStrikeout)
EVT_BUTTON(BUTTON_COMMIT,SubsEditBox::OnButtonCommit)
EVT_SIZE(SubsEditBox::OnSize)
END_EVENT_TABLE()
@ -819,35 +823,7 @@ void SubsEditBox::DoKeyPress(wxKeyEvent &event) {
if (key == WXK_RETURN || key == WXK_NUMPAD_ENTER) {
if (enabled) {
// Update line
CommitText();
// Next line if control is not held down
bool updated = false;
if (!event.m_controlDown) {
AssDialogue *cur = grid->GetDialogue(linen);
int nrows = grid->GetRows();
int next = linen+1;
if (next >= nrows) {
AssDialogue *newline = new AssDialogue;
newline->Start = cur->End;
newline->End.SetMS(cur->End.GetMS()+5000);
newline->Style = cur->Style;
newline->UpdateData();
grid->InsertLine(newline,next-1,true,true);
updated = true;
}
grid->SelectRow(next);
grid->MakeCellVisible(next,0);
SetToLine(next);
if (next >= nrows) return;
}
// Update file
if (!updated) {
grid->ass->FlagAsModified(_("editing"));
grid->CommitChanges();
}
Commit(event.m_controlDown);
return;
}
}
@ -856,6 +832,41 @@ void SubsEditBox::DoKeyPress(wxKeyEvent &event) {
}
//////////
// Commit
void SubsEditBox::Commit(bool stay) {
// Update line
CommitText();
// Next line if control is not held down
bool updated = false;
if (!stay) {
AssDialogue *cur = grid->GetDialogue(linen);
int nrows = grid->GetRows();
int next = linen+1;
if (next >= nrows) {
AssDialogue *newline = new AssDialogue;
newline->Start = cur->End;
newline->End.SetMS(cur->End.GetMS()+5000);
newline->Style = cur->Style;
newline->UpdateData();
grid->InsertLine(newline,next-1,true,true);
updated = true;
}
grid->SelectRow(next);
grid->MakeCellVisible(next,0);
SetToLine(next);
if (next >= nrows) return;
}
// Update file
if (!updated) {
grid->ass->FlagAsModified(_("editing"));
grid->CommitChanges();
}
}
///////////////
// Commit text
void SubsEditBox::CommitText(bool weak) {
@ -1276,3 +1287,9 @@ void SubsEditBox::OnButtonStrikeout(wxCommandEvent &event) {
}
//////////
// Commit
void SubsEditBox::OnButtonCommit(wxCommandEvent &event) {
Commit(wxGetMouseState().ControlDown());
}

View File

@ -95,6 +95,7 @@ private:
wxButton *Color2;
wxButton *Color3;
wxButton *Color4;
wxButton *CommitButton;
wxSizer *TopSizer;
wxSizer *MiddleBotSizer;
@ -122,6 +123,7 @@ private:
void OnButtonItalics(wxCommandEvent &event);
void OnButtonUnderline(wxCommandEvent &event);
void OnButtonStrikeout(wxCommandEvent &event);
void OnButtonCommit(wxCommandEvent &event);
void OnSyntaxBox(wxCommandEvent &event);
void OnFrameRadio(wxCommandEvent &event);
@ -157,6 +159,7 @@ public:
void SetToLine(int n,bool weak=false);
void UpdateFrameTiming();
void DoKeyPress(wxKeyEvent &event);
void Commit(bool stay);
DECLARE_EVENT_TABLE()
};
@ -202,5 +205,6 @@ enum {
BUTTON_COLOR1,
BUTTON_COLOR2,
BUTTON_COLOR3,
BUTTON_COLOR4
BUTTON_COLOR4,
BUTTON_COMMIT
};