Expand all widgets in SubsEditBox to get a consistent height

This commit is contained in:
wangqr 2020-04-10 00:24:49 -04:00 committed by arch1t3cht
parent 53cc316e6f
commit e69c4e9a86
1 changed files with 15 additions and 15 deletions

View File

@ -120,7 +120,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
// Only supported in wxgtk
comment_box->SetCanFocus(false);
#endif
top_sizer->Add(comment_box, 0, wxRIGHT | wxALIGN_CENTER, 5);
top_sizer->Add(comment_box, wxSizerFlags().Expand().Border(wxRIGHT, 5));
style_box = MakeComboBox("Default", wxCB_READONLY, &SubsEditBox::OnStyleChange, _("Style for this line"));
@ -132,22 +132,22 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
DialogStyleEditor(this, active_style, c, nullptr, "", font_list).ShowModal();
}
});
top_sizer->Add(style_edit_button, wxSizerFlags().Center().Border(wxRIGHT));
top_sizer->Add(style_edit_button, wxSizerFlags().Expand().Border(wxRIGHT));
actor_box = new Placeholder<wxComboBox>(this, _("Actor"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Actor name for this speech. This is only for reference, and is mainly useless."));
Bind(wxEVT_TEXT, &SubsEditBox::OnActorChange, this, actor_box->GetId());
Bind(wxEVT_COMBOBOX, &SubsEditBox::OnActorChange, this, actor_box->GetId());
top_sizer->Add(actor_box, wxSizerFlags(2).Center().Border(wxRIGHT));
top_sizer->Add(actor_box, wxSizerFlags(2).Expand().Border(wxRIGHT));
effect_box = new Placeholder<wxComboBox>(this, _("Effect"), wxDefaultSize, wxCB_DROPDOWN | wxTE_PROCESS_ENTER, _("Effect for this line. This can be used to store extra information for karaoke scripts, or for the effects supported by the renderer."));
Bind(wxEVT_TEXT, &SubsEditBox::OnEffectChange, this, effect_box->GetId());
Bind(wxEVT_COMBOBOX, &SubsEditBox::OnEffectChange, this, effect_box->GetId());
top_sizer->Add(effect_box, 3, wxALIGN_CENTER, 5);
top_sizer->Add(effect_box, wxSizerFlags(3).Expand());
char_count = new wxTextCtrl(this, -1, "0", wxDefaultPosition, wxDefaultSize, wxTE_READONLY | wxTE_CENTER);
char_count->SetInitialSize(char_count->GetSizeFromTextSize(GetTextExtent(wxS("000"))));
char_count->SetToolTip(_("Number of characters in the longest line of this subtitle."));
top_sizer->Add(char_count, 0, wxALIGN_CENTER, 5);
top_sizer->Add(char_count, wxSizerFlags().Expand());
// Middle controls
middle_left_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -160,7 +160,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
layer->SetInitialSize(layer->GetSizeFromTextSize(GetTextExtent(wxS("00"))));
#endif
layer->SetToolTip(_("Layer number"));
middle_left_sizer->Add(layer, wxSizerFlags().Center());
middle_left_sizer->Add(layer, wxSizerFlags().Expand());
middle_left_sizer->AddSpacer(5);
start_time = MakeTimeCtrl(_("Start time"), TIME_START);
@ -197,13 +197,13 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
split_box = new wxCheckBox(this,-1,_("Show Original"));
split_box->SetToolTip(_("Show the contents of the subtitle line when it was first selected above the edit box. This is sometimes useful when editing subtitles or translating subtitles into another language."));
split_box->Bind(wxEVT_CHECKBOX, &SubsEditBox::OnSplit, this);
middle_right_sizer->Add(split_box, wxSizerFlags().Center().Left());
middle_right_sizer->Add(split_box, wxSizerFlags().Expand());
// Main sizer
wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);
main_sizer->Add(top_sizer,0,wxEXPAND | wxALL,3);
main_sizer->Add(middle_left_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
main_sizer->Add(top_sizer, wxSizerFlags().Expand().Border(wxALL, 3));
main_sizer->Add(middle_left_sizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3));
main_sizer->Add(middle_right_sizer, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3));
// Text editor
edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c);
@ -216,8 +216,8 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
// https://github.com/wangqr/Aegisub/issues/4
edit_ctrl->SetInitialSize(secondary_editor->GetSize());
main_sizer->Add(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
main_sizer->Add(secondary_editor, wxSizerFlags(1).Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3));
main_sizer->Add(edit_ctrl, wxSizerFlags(1).Expand().Border(wxLEFT | wxRIGHT | wxBOTTOM, 3));
main_sizer->Hide(secondary_editor);
bottom_sizer = new wxBoxSizer(wxHORIZONTAL);
@ -265,7 +265,7 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS
ctrl->SetInitialSize(ctrl->GetSizeFromTextSize(GetTextExtent(wxS("0000"))));
ctrl->SetMaxLength(5);
ctrl->SetToolTip(tooltip);
middle_left_sizer->Add(ctrl, wxSizerFlags().Center());
middle_left_sizer->Add(ctrl, wxSizerFlags().Expand());
Bind(wxEVT_TEXT, [=](wxCommandEvent&) {
int value = agi::util::mid(-9999, atoi(ctrl->GetValue().utf8_str()), 99999);
@ -282,7 +282,7 @@ TimeEdit *SubsEditBox::MakeTimeCtrl(wxString const& tooltip, TimeField field) {
ctrl->SetToolTip(tooltip);
Bind(wxEVT_TEXT, [=](wxCommandEvent&) { CommitTimes(field); }, ctrl->GetId());
ctrl->Bind(wxEVT_CHAR_HOOK, time_edit_char_hook);
middle_left_sizer->Add(ctrl, wxSizerFlags().Center());
middle_left_sizer->Add(ctrl, wxSizerFlags().Expand());
return ctrl;
}
@ -308,7 +308,7 @@ wxComboBox *SubsEditBox::MakeComboBox(wxString const& initial_text, int style, v
wxString styles[] = { "Default" };
wxComboBox *ctrl = new wxComboBox(this, -1, initial_text, wxDefaultPosition, wxDefaultSize, 1, styles, style | wxTE_PROCESS_ENTER);
ctrl->SetToolTip(tooltip);
top_sizer->Add(ctrl, wxSizerFlags(2).Center().Border(wxRIGHT));
top_sizer->Add(ctrl, wxSizerFlags(2).Expand().Border(wxRIGHT));
Bind(wxEVT_COMBOBOX, handler, this, ctrl->GetId());
return ctrl;
}