mirror of https://github.com/odrling/Aegisub
Fixed #458, along with other style manager/editor related issues.
Originally committed to SVN as r1444.
This commit is contained in:
parent
1bd5869ac6
commit
fcd9974772
|
@ -90,3 +90,15 @@ void AssStyleStorage::Clear () {
|
|||
}
|
||||
style.clear();
|
||||
}
|
||||
|
||||
|
||||
/////////////
|
||||
// Get names
|
||||
wxArrayString AssStyleStorage::GetNames() {
|
||||
using std::list;
|
||||
wxArrayString names;
|
||||
for (list<AssStyle*>::iterator cur=style.begin();cur!=style.end();cur++) {
|
||||
names.Add((*cur)->name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ class AssStyleStorage {
|
|||
public:
|
||||
std::list<AssStyle*> style;
|
||||
|
||||
wxArrayString GetNames();
|
||||
void Clear();
|
||||
void Save(wxString name);
|
||||
void Load(wxString name);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "subs_preview.h"
|
||||
#include "options.h"
|
||||
#include "subtitles_provider.h"
|
||||
#include "ass_style_storage.h"
|
||||
|
||||
|
||||
///////
|
||||
|
@ -91,13 +92,17 @@ enum {
|
|||
|
||||
///////////////
|
||||
// Constructor
|
||||
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, SubtitlesGrid *_grid)
|
||||
DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, SubtitlesGrid *_grid,bool local,AssStyleStorage *_store)
|
||||
: wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor"))
|
||||
{
|
||||
wxStopWatch performance_timer;
|
||||
// Set icon
|
||||
SetIcon(BitmapToIcon(wxBITMAP(style_toolbutton)));
|
||||
|
||||
wxStopWatch performance_timer;
|
||||
// Set variables
|
||||
isLocal = local;
|
||||
store = _store;
|
||||
|
||||
// Set styles
|
||||
grid = _grid;
|
||||
style = _style;
|
||||
|
@ -371,7 +376,6 @@ BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog)
|
|||
EVT_BUTTON(wxID_APPLY, DialogStyleEditor::OnApply)
|
||||
EVT_BUTTON(wxID_OK, DialogStyleEditor::OnOK)
|
||||
EVT_BUTTON(wxID_CANCEL, DialogStyleEditor::OnCancel)
|
||||
EVT_BUTTON(BUTTON_STYLE_FONT, DialogStyleEditor::OnChooseFont)
|
||||
EVT_BUTTON(BUTTON_COLOR_1, DialogStyleEditor::OnSetColor1)
|
||||
EVT_BUTTON(BUTTON_COLOR_2, DialogStyleEditor::OnSetColor2)
|
||||
EVT_BUTTON(BUTTON_COLOR_3, DialogStyleEditor::OnSetColor3)
|
||||
|
@ -428,8 +432,12 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
|||
// Style name
|
||||
wxString newStyleName = StyleName->GetValue();
|
||||
|
||||
// Get list of existing styles
|
||||
wxArrayString styles;
|
||||
if (isLocal) styles = grid->ass->GetStyles();
|
||||
else if (store) styles = store->GetNames();
|
||||
|
||||
// Check if style name is unique
|
||||
wxArrayString styles = grid->ass->GetStyles();
|
||||
for (unsigned int i=0;i<styles.Count();i++) {
|
||||
if (styles[i] == newStyleName) {
|
||||
if (grid->ass->GetStyle(styles[i]) != style) {
|
||||
|
@ -441,7 +449,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
|||
|
||||
// Style name change
|
||||
if (work->name != newStyleName) {
|
||||
if (!work->name.StartsWith(_("Copy of "))) {
|
||||
if (!work->name.StartsWith(_("Copy of ")) && isLocal) {
|
||||
// See if user wants to update style name through script
|
||||
int answer = wxNO;
|
||||
if (work->name != _T("Default")) answer = wxMessageBox(_("Do you want to change all instances of this style in the script to this new name?"),_("Update script?"),wxYES_NO | wxCANCEL);
|
||||
|
@ -477,8 +485,10 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
|||
// Copy
|
||||
*style = *work;
|
||||
style->UpdateData();
|
||||
AssFile::top->FlagAsModified(_("style change"));
|
||||
grid->CommitChanges();
|
||||
if (isLocal) {
|
||||
AssFile::top->FlagAsModified(_("style change"));
|
||||
grid->CommitChanges();
|
||||
}
|
||||
|
||||
// Exit
|
||||
if (close) {
|
||||
|
|
|
@ -50,15 +50,18 @@
|
|||
class AssStyle;
|
||||
class SubtitlesGrid;
|
||||
class SubtitlesPreview;
|
||||
class AssStyleStorage;
|
||||
|
||||
|
||||
/////////
|
||||
// Class
|
||||
class DialogStyleEditor : public wxDialog {
|
||||
private:
|
||||
bool isLocal;
|
||||
AssStyle *style;
|
||||
AssStyle *work;
|
||||
SubtitlesGrid *grid;
|
||||
AssStyleStorage *store;
|
||||
|
||||
wxString FontSizeValue;
|
||||
wxString AlignmentValue;
|
||||
|
@ -114,7 +117,7 @@ private:
|
|||
void OnPreviewColourChange (wxCommandEvent &event);
|
||||
|
||||
public:
|
||||
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid);
|
||||
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid,bool local,AssStyleStorage *store);
|
||||
~DialogStyleEditor();
|
||||
|
||||
void Apply (bool apply,bool close);
|
||||
|
|
|
@ -479,7 +479,7 @@ void DialogStyleManager::OnStorageEdit (wxCommandEvent &event) {
|
|||
AssStyle *temp;
|
||||
if (n == 1) {
|
||||
temp = styleStorageMap.at(selections[0]);
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
//LoadStorageStyles();
|
||||
|
@ -501,7 +501,7 @@ void DialogStyleManager::OnCurrentEdit (wxCommandEvent &event) {
|
|||
AssStyle *temp;
|
||||
if (n == 1) {
|
||||
temp = styleMap.at(selections[0]);
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
CurrentList->SetString(selections[0],temp->name);
|
||||
|
@ -613,7 +613,7 @@ void DialogStyleManager::OnStorageCopy (wxCommandEvent &event) {
|
|||
newName += temp->name;
|
||||
temp->name = newName;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
Store.style.push_back(temp);
|
||||
|
@ -637,7 +637,7 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &event) {
|
|||
newName += temp->name;
|
||||
temp->name = newName;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
AssFile::top->InsertStyle(temp);
|
||||
|
@ -725,7 +725,7 @@ void DialogStyleManager::PasteToStorage() {
|
|||
void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
|
||||
AssStyle *temp = new AssStyle;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
Store.style.push_back(temp);
|
||||
|
@ -742,7 +742,7 @@ void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
|
|||
void DialogStyleManager::OnCurrentNew (wxCommandEvent &event) {
|
||||
AssStyle *temp = new AssStyle;
|
||||
|
||||
DialogStyleEditor editor(this,temp,grid);
|
||||
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||
int modified = editor.ShowModal();
|
||||
if (modified) {
|
||||
AssFile::top->InsertStyle(temp);
|
||||
|
|
Loading…
Reference in New Issue