Skip to content

Commit

Permalink
Use SubsTextEditCtrl for secondary_editor
Browse files Browse the repository at this point in the history
  • Loading branch information
wangqr committed Apr 4, 2021
1 parent 99fee26 commit a715e54
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
11 changes: 1 addition & 10 deletions src/subs_edit_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
}
#endif

secondary_editor = new wxTextCtrl(this, -1, "", wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY);
secondary_editor = new SubsTextEditCtrl(this, wxDefaultSize, wxBORDER_SUNKEN | wxTE_MULTILINE | wxTE_READONLY, nullptr);
#ifdef WITH_WXSTC
if (use_stc) {
// Here we use the height of secondary_editor as the initial size of edit_ctrl_stc,
Expand Down Expand Up @@ -308,15 +308,6 @@ SubsEditBox::SubsEditBox(wxWindow *parent, agi::Context *context)
}
#endif

// Set the font of edit boxes. See also SubsTextEditCtrl::SetStyles
// TODO: This only sets the font once. We should use OPT_SUB("Subtitle/Edit Box/Font Face") OPT_SUB("Subtitle/Edit Box/Font Size") instead
wxFont font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
font.SetEncoding(wxFONTENCODING_DEFAULT); // this solves problems with some fonts not working properly
wxString fontname = FontFace("Subtitle/Edit Box");
if (!fontname.empty()) font.SetFaceName(fontname);
font.SetPointSize(OPT_GET("Subtitle/Edit Box/Font Size")->GetInt());
secondary_editor->SetFont(font);

bool show_original = OPT_GET("Subtitle/Show Original")->GetBool();
if (show_original) {
split_box->SetValue(true);
Expand Down
3 changes: 1 addition & 2 deletions src/subs_edit_ctrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, a
Bind(wxEVT_MENU, bind(&cmd::call, "edit/line/split/preserve", context), EDIT_MENU_SPLIT_PRESERVE);
Bind(wxEVT_MENU, bind(&cmd::call, "edit/line/split/estimate", context), EDIT_MENU_SPLIT_ESTIMATE);
Bind(wxEVT_MENU, bind(&cmd::call, "edit/line/split/video", context), EDIT_MENU_SPLIT_VIDEO);
Bind(wxEVT_CONTEXT_MENU, &SubsTextEditCtrl::OnContextMenu, this);
}

Bind(wxEVT_CONTEXT_MENU, &SubsTextEditCtrl::OnContextMenu, this);

OPT_SUB("Subtitle/Edit Box/Font Face", &SubsTextEditCtrl::SetStyles, this);
OPT_SUB("Subtitle/Edit Box/Font Size", &SubsTextEditCtrl::SetStyles, this);
OPT_SUB("Colour/Subtitle/Background", &SubsTextEditCtrl::SetStyles, this);
Expand Down

0 comments on commit a715e54

Please sign in to comment.