Set the height of sub box to the same as secondary_editor

The secondary_editor is a wxTextCtrl, whose height is calculated from 2 rows of text. Using this height gives better consistency on screens with different DPIs, instead of using hard coded value like 50px
This commit is contained in:
wangqr 2019-08-24 01:12:16 -04:00 committed by arch1t3cht
parent 0e0e04c943
commit af7cbb7730
1 changed files with 7 additions and 2 deletions

View File

@ -201,10 +201,15 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); main_sizer->Add(middle_right_sizer,0,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
// Text editor // Text editor
edit_ctrl = new SubsTextEditCtrl(this, wxSize(-1, 50), wxBORDER_SUNKEN, c); edit_ctrl = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN, c);
edit_ctrl->Bind(wxEVT_CHAR_HOOK, &SubsEditBox::OnKeyDown, this); edit_ctrl->Bind(wxEVT_CHAR_HOOK, &SubsEditBox::OnKeyDown, this);
secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxSize(-1, 50), wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY); secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY);
// Here we use the height of secondary_editor as the initial size of edit_ctrl,
// which is more reasonable than the default given by wxWidgets.
// See: https://trac.wxwidgets.org/ticket/18471#ticket
// 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(secondary_editor,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);
main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3); main_sizer->Add(edit_ctrl,1,wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM,3);