Tweaked the layout of Subtitles Edit area.

Originally committed to SVN as r632.
This commit is contained in:
Rodrigo Braz Monteiro 2006-12-27 00:00:41 +00:00
parent ccabf8ec15
commit 15e70fa194
4 changed files with 72 additions and 10 deletions

View File

@ -49,6 +49,7 @@ Please visit http://aegisub.net to download latest version
- Added an "Import from script..." button to Styles Manager, to import styles directly from other subtitle files. (AMZ)
- Added buttons to Styles Manager to move styles up, down, to top or to bottom, on both storage and current script. (AMZ)
- Added sorting functionality to Styles Manager, for both storage and current script. (AMZ)
- Tweaked the layout of Subtitles Edit area. (AMZ)
= 1.10 beta - 2006.08.07 ===========================

View File

@ -703,6 +703,7 @@ void FrameMain::SetDisplayMode(int mode) {
// Update
curMode = mode;
UpdateToolbar();
EditBox->SetSplitLineMode();
MainSizer->CalcMin();
MainSizer->RecalcSizes();
videoBox->VideoSizer->Layout();

View File

@ -72,6 +72,7 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
enabled = false;
textEditReady = true;
controlState = true;
setupDone = false;
linen = -2;
// Top controls
@ -131,14 +132,15 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
ByFrame->SetToolTip(_("Time by frame number"));
// Top sizer
wxSizer *TopSizer = new wxBoxSizer(wxHORIZONTAL);
TopSizer = new wxBoxSizer(wxHORIZONTAL);
TopSizer->Add(CommentBox,0,wxRIGHT | wxALIGN_CENTER,5);
TopSizer->Add(StyleBox,0,wxRIGHT,5);
TopSizer->Add(ActorBox,0,wxRIGHT,5);
TopSizer->Add(Effect,0,0,0);
TopSizer->Add(StyleBox,1,wxRIGHT,5);
TopSizer->Add(ActorBox,1,wxRIGHT,5);
TopSizer->Add(Effect,1,0,0);
// Middle sizer
wxSizer *MiddleSizer = new wxBoxSizer(wxHORIZONTAL);
splitLineMode = true;
MiddleSizer = new wxBoxSizer(wxHORIZONTAL);
MiddleSizer->Add(Layer,0,wxRIGHT,5);
MiddleSizer->Add(StartTime,0,wxRIGHT,0);
MiddleSizer->Add(EndTime,0,wxRIGHT,5);
@ -146,10 +148,10 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
MiddleSizer->Add(MarginL,0,0,0);
MiddleSizer->Add(MarginR,0,0,0);
MiddleSizer->Add(MarginV,0,0,0);
//MiddleSizer->Add(SyntaxHighlight,0,wxRIGHT | wxALIGN_CENTER,5);
MiddleSizer->AddSpacer(5);
// Middle-bottom sizer
wxSizer *MiddleBotSizer = new wxBoxSizer(wxHORIZONTAL);
MiddleBotSizer = new wxBoxSizer(wxHORIZONTAL);
MiddleBotSizer->Add(Bold);
MiddleBotSizer->Add(Italics);
MiddleBotSizer->Add(Underline);
@ -164,14 +166,14 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
MiddleBotSizer->Add(ByFrame,0,wxRIGHT | wxALIGN_CENTER,5);
// Text editor
TextEdit = new SubsTextEditCtrl(this,EDIT_BOX,_T(""),wxDefaultPosition,wxSize(300,50),wxTE_MULTILINE | wxTE_RICH2 | wxTE_NOHIDESEL);
TextEdit = new SubsTextEditCtrl(this,EDIT_BOX,_T(""),wxDefaultPosition,wxSize(300,50));
TextEdit->PushEventHandler(new SubsEditBoxEvent(this));
TextEdit->control = this;
wxSizer *BottomSizer = new wxBoxSizer(wxHORIZONTAL);
BottomSizer = new wxBoxSizer(wxHORIZONTAL);
BottomSizer->Add(TextEdit,1,wxEXPAND,0);
// Main sizer
wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer = new wxBoxSizer(wxVERTICAL);
MainSizer->Add(TopSizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxTOP,3);
MainSizer->Add(MiddleSizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
MainSizer->Add(MiddleBotSizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
@ -184,10 +186,47 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren
// HACK: Fix colour of bg of editbox
origBgColour = TextEdit->GetBackgroundColour();
disabledBgColour = GetBackgroundColour();
// Set split mode
setupDone = true;
SetSplitLineMode();
Update();
}
/////////////////////////////////
// Set split or single line mode
void SubsEditBox::SetSplitLineMode(wxSize newSize) {
// Widths
int topWidth;
if (newSize.GetWidth() == -1) topWidth = TopSizer->GetSize().GetWidth();
else topWidth = newSize.GetWidth()-GetSize().GetWidth()+GetClientSize().GetWidth();
int midMin = MiddleSizer->GetMinSize().GetWidth();
int botMin = MiddleBotSizer->GetMinSize().GetWidth();
// Currently split
if (splitLineMode) {
if (topWidth >= midMin + botMin) {
MainSizer->Detach(MiddleBotSizer);
MiddleSizer->Add(MiddleBotSizer);
Layout();
splitLineMode = false;
}
}
// Currently joined
else {
if (topWidth < midMin) {
MiddleSizer->Detach(MiddleBotSizer);
MainSizer->Insert(2,MiddleBotSizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
Layout();
splitLineMode = true;
}
}
}
///////////////////
// Update function
void SubsEditBox::Update (bool timeOnly) {
@ -324,9 +363,19 @@ BEGIN_EVENT_TABLE(SubsEditBox, wxPanel)
EVT_BUTTON(BUTTON_ITALICS,SubsEditBox::OnButtonItalics)
EVT_BUTTON(BUTTON_UNDERLINE,SubsEditBox::OnButtonUnderline)
EVT_BUTTON(BUTTON_STRIKEOUT,SubsEditBox::OnButtonStrikeout)
EVT_SIZE(SubsEditBox::OnSize)
END_EVENT_TABLE()
///////////
// On size
void SubsEditBox::OnSize(wxSizeEvent &event) {
if (setupDone) SetSplitLineMode(event.GetSize());
event.Skip();
}
/////////////////////
// Text edited event
void SubsEditBox::OnEditText(wxScintillaEvent &event) {

View File

@ -61,6 +61,8 @@ class SubsEditBox : public wxPanel {
friend class SubsTextEditCtrl;
private:
bool splitLineMode;
bool setupDone;
bool enabled;
bool textEditReady;
bool controlState;
@ -93,6 +95,13 @@ private:
wxButton *Color3;
wxButton *Color4;
wxSizer *TopSizer;
wxSizer *MiddleBotSizer;
wxSizer *MiddleSizer;
wxSizer *MainSizer;
wxSizer *DummySizer;
wxSizer *BottomSizer;
void SetControlsState(bool state);
void CommitTimes(bool start,bool end,bool fromStart);
@ -126,6 +135,7 @@ private:
void OnMarginVChange(wxCommandEvent &event);
void OnCommentChange(wxCommandEvent &event);
void OnEffectChange(wxCommandEvent &event);
void OnSize(wxSizeEvent &event);
public:
int linen;
@ -138,6 +148,7 @@ public:
void SetOverride (wxString tag,wxString preValue=_T(""),int pos=-1);
void SetStyleFlag (wxString tag,wxString preValue=_T(""),int pos=-1);
void SetSplitLineMode(wxSize size=wxSize(-1,-1));
void CommitText();
void Update(bool timeOnly=false);
void UpdateGlobals();