void DialogStyleEditor::OnCommandPreviewUpdate(wxCommandEvent &event) { UpdateWorkStyle(); SubsPreview->SetStyle(*work); event.Skip(); }
void DialogStyleEditor::Apply(bool apply, bool close) { if (apply) { std::string new_name = from_wx(StyleName->GetValue()); // Get list of existing styles std::vector<std::string> styles = store ? store->GetNames() : c->ass->GetStyles(); // Check if style name is unique AssStyle *existing = store ? store->GetStyle(new_name) : c->ass->GetStyle(new_name); if (existing && existing != style) { wxMessageBox(_("There is already a style with this name. Please choose another name."), _("Style name conflict"), wxOK | wxICON_ERROR | wxCENTER); return; } // Style name change bool did_rename = false; if (work->name != new_name) { if (!store && !is_new) { StyleRenamer renamer(c, work->name, new_name); if (renamer.NeedsReplace()) { // See if user wants to update style name through script int answer = wxMessageBox( _("Do you want to change all instances of this style in the script to this new name?"), _("Update script?"), wxYES_NO | wxCANCEL); if (answer == wxCANCEL) return; if (answer == wxYES) { did_rename = true; renamer.Replace(); } } } work->name = new_name; } UpdateWorkStyle(); *style = *work; style->UpdateData(); if (is_new) { if (store) store->push_back(std::unique_ptr<AssStyle>(style)); else c->ass->Styles.push_back(*style); is_new = false; } if (!store) c->ass->Commit(_("style change"), AssFile::COMMIT_STYLES | (did_rename ? AssFile::COMMIT_DIAG_FULL : 0)); // Update preview if (!close) SubsPreview->SetStyle(*style); } if (close) { EndModal(apply); if (PreviewText) OPT_SET("Tool/Style Editor/Preview Text")->SetString(from_wx(PreviewText->GetValue())); } }
void DialogStyleEditor::OnChildFocus(wxChildFocusEvent &event) { UpdateWorkStyle(); SubsPreview->SetStyle(*work); event.Skip(); }
/// @brief Command event to update preview void DialogStyleEditor::OnCommandPreviewUpdate (wxCommandEvent &event) { if (!IsShownOnScreen()) return; UpdateWorkStyle(); SubsPreview->SetStyle(*work); event.Skip(); }