Expand all widgets in SubsEditBox to get a consistent height

This commit is contained in:
wangqr 2020-04-10 00:24:49 -04:00
parent c1dca9cb1f
commit b92a2593cb

View file

@ -117,7 +117,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"));
@ -129,17 +129,17 @@ 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);
#if wxCHECK_VERSION(3, 1, 3)
@ -148,7 +148,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
char_count->SetInitialSize(char_count->GetSizeFromTextSize(GetTextExtent(wxS("000"))));
#endif
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);
@ -164,7 +164,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);
@ -201,13 +201,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);
@ -220,8 +220,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);
@ -273,7 +273,7 @@ wxTextCtrl *SubsEditBox::MakeMarginCtrl(wxString const& tooltip, int margin, wxS
#endif
ctrl->SetMaxLength(4);
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(0, atoi(ctrl->GetValue().utf8_str()), 9999);
@ -294,7 +294,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;
}
@ -324,7 +324,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;
}