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();
|
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:
|
public:
|
||||||
std::list<AssStyle*> style;
|
std::list<AssStyle*> style;
|
||||||
|
|
||||||
|
wxArrayString GetNames();
|
||||||
void Clear();
|
void Clear();
|
||||||
void Save(wxString name);
|
void Save(wxString name);
|
||||||
void Load(wxString name);
|
void Load(wxString name);
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include "subs_preview.h"
|
#include "subs_preview.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "subtitles_provider.h"
|
#include "subtitles_provider.h"
|
||||||
|
#include "ass_style_storage.h"
|
||||||
|
|
||||||
|
|
||||||
///////
|
///////
|
||||||
|
@ -91,13 +92,17 @@ enum {
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// 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"))
|
: wxDialog (parent,-1,_("Style Editor"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER,_T("DialogStyleEditor"))
|
||||||
{
|
{
|
||||||
|
wxStopWatch performance_timer;
|
||||||
// Set icon
|
// Set icon
|
||||||
SetIcon(BitmapToIcon(wxBITMAP(style_toolbutton)));
|
SetIcon(BitmapToIcon(wxBITMAP(style_toolbutton)));
|
||||||
|
|
||||||
wxStopWatch performance_timer;
|
// Set variables
|
||||||
|
isLocal = local;
|
||||||
|
store = _store;
|
||||||
|
|
||||||
// Set styles
|
// Set styles
|
||||||
grid = _grid;
|
grid = _grid;
|
||||||
style = _style;
|
style = _style;
|
||||||
|
@ -371,7 +376,6 @@ BEGIN_EVENT_TABLE(DialogStyleEditor, wxDialog)
|
||||||
EVT_BUTTON(wxID_APPLY, DialogStyleEditor::OnApply)
|
EVT_BUTTON(wxID_APPLY, DialogStyleEditor::OnApply)
|
||||||
EVT_BUTTON(wxID_OK, DialogStyleEditor::OnOK)
|
EVT_BUTTON(wxID_OK, DialogStyleEditor::OnOK)
|
||||||
EVT_BUTTON(wxID_CANCEL, DialogStyleEditor::OnCancel)
|
EVT_BUTTON(wxID_CANCEL, DialogStyleEditor::OnCancel)
|
||||||
EVT_BUTTON(BUTTON_STYLE_FONT, DialogStyleEditor::OnChooseFont)
|
|
||||||
EVT_BUTTON(BUTTON_COLOR_1, DialogStyleEditor::OnSetColor1)
|
EVT_BUTTON(BUTTON_COLOR_1, DialogStyleEditor::OnSetColor1)
|
||||||
EVT_BUTTON(BUTTON_COLOR_2, DialogStyleEditor::OnSetColor2)
|
EVT_BUTTON(BUTTON_COLOR_2, DialogStyleEditor::OnSetColor2)
|
||||||
EVT_BUTTON(BUTTON_COLOR_3, DialogStyleEditor::OnSetColor3)
|
EVT_BUTTON(BUTTON_COLOR_3, DialogStyleEditor::OnSetColor3)
|
||||||
|
@ -428,8 +432,12 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
||||||
// Style name
|
// Style name
|
||||||
wxString newStyleName = StyleName->GetValue();
|
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
|
// Check if style name is unique
|
||||||
wxArrayString styles = grid->ass->GetStyles();
|
|
||||||
for (unsigned int i=0;i<styles.Count();i++) {
|
for (unsigned int i=0;i<styles.Count();i++) {
|
||||||
if (styles[i] == newStyleName) {
|
if (styles[i] == newStyleName) {
|
||||||
if (grid->ass->GetStyle(styles[i]) != style) {
|
if (grid->ass->GetStyle(styles[i]) != style) {
|
||||||
|
@ -441,7 +449,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
|
||||||
|
|
||||||
// Style name change
|
// Style name change
|
||||||
if (work->name != newStyleName) {
|
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
|
// See if user wants to update style name through script
|
||||||
int answer = wxNO;
|
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);
|
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
|
// Copy
|
||||||
*style = *work;
|
*style = *work;
|
||||||
style->UpdateData();
|
style->UpdateData();
|
||||||
AssFile::top->FlagAsModified(_("style change"));
|
if (isLocal) {
|
||||||
grid->CommitChanges();
|
AssFile::top->FlagAsModified(_("style change"));
|
||||||
|
grid->CommitChanges();
|
||||||
|
}
|
||||||
|
|
||||||
// Exit
|
// Exit
|
||||||
if (close) {
|
if (close) {
|
||||||
|
|
|
@ -50,15 +50,18 @@
|
||||||
class AssStyle;
|
class AssStyle;
|
||||||
class SubtitlesGrid;
|
class SubtitlesGrid;
|
||||||
class SubtitlesPreview;
|
class SubtitlesPreview;
|
||||||
|
class AssStyleStorage;
|
||||||
|
|
||||||
|
|
||||||
/////////
|
/////////
|
||||||
// Class
|
// Class
|
||||||
class DialogStyleEditor : public wxDialog {
|
class DialogStyleEditor : public wxDialog {
|
||||||
private:
|
private:
|
||||||
|
bool isLocal;
|
||||||
AssStyle *style;
|
AssStyle *style;
|
||||||
AssStyle *work;
|
AssStyle *work;
|
||||||
SubtitlesGrid *grid;
|
SubtitlesGrid *grid;
|
||||||
|
AssStyleStorage *store;
|
||||||
|
|
||||||
wxString FontSizeValue;
|
wxString FontSizeValue;
|
||||||
wxString AlignmentValue;
|
wxString AlignmentValue;
|
||||||
|
@ -114,7 +117,7 @@ private:
|
||||||
void OnPreviewColourChange (wxCommandEvent &event);
|
void OnPreviewColourChange (wxCommandEvent &event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid);
|
DialogStyleEditor(wxWindow *parent,AssStyle *style,SubtitlesGrid *grid,bool local,AssStyleStorage *store);
|
||||||
~DialogStyleEditor();
|
~DialogStyleEditor();
|
||||||
|
|
||||||
void Apply (bool apply,bool close);
|
void Apply (bool apply,bool close);
|
||||||
|
|
|
@ -479,7 +479,7 @@ void DialogStyleManager::OnStorageEdit (wxCommandEvent &event) {
|
||||||
AssStyle *temp;
|
AssStyle *temp;
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
temp = styleStorageMap.at(selections[0]);
|
temp = styleStorageMap.at(selections[0]);
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
//LoadStorageStyles();
|
//LoadStorageStyles();
|
||||||
|
@ -501,7 +501,7 @@ void DialogStyleManager::OnCurrentEdit (wxCommandEvent &event) {
|
||||||
AssStyle *temp;
|
AssStyle *temp;
|
||||||
if (n == 1) {
|
if (n == 1) {
|
||||||
temp = styleMap.at(selections[0]);
|
temp = styleMap.at(selections[0]);
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
CurrentList->SetString(selections[0],temp->name);
|
CurrentList->SetString(selections[0],temp->name);
|
||||||
|
@ -613,7 +613,7 @@ void DialogStyleManager::OnStorageCopy (wxCommandEvent &event) {
|
||||||
newName += temp->name;
|
newName += temp->name;
|
||||||
temp->name = newName;
|
temp->name = newName;
|
||||||
|
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
Store.style.push_back(temp);
|
Store.style.push_back(temp);
|
||||||
|
@ -637,7 +637,7 @@ void DialogStyleManager::OnCurrentCopy (wxCommandEvent &event) {
|
||||||
newName += temp->name;
|
newName += temp->name;
|
||||||
temp->name = newName;
|
temp->name = newName;
|
||||||
|
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
AssFile::top->InsertStyle(temp);
|
AssFile::top->InsertStyle(temp);
|
||||||
|
@ -725,7 +725,7 @@ void DialogStyleManager::PasteToStorage() {
|
||||||
void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
|
void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
|
||||||
AssStyle *temp = new AssStyle;
|
AssStyle *temp = new AssStyle;
|
||||||
|
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,false,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
Store.style.push_back(temp);
|
Store.style.push_back(temp);
|
||||||
|
@ -742,7 +742,7 @@ void DialogStyleManager::OnStorageNew (wxCommandEvent &event) {
|
||||||
void DialogStyleManager::OnCurrentNew (wxCommandEvent &event) {
|
void DialogStyleManager::OnCurrentNew (wxCommandEvent &event) {
|
||||||
AssStyle *temp = new AssStyle;
|
AssStyle *temp = new AssStyle;
|
||||||
|
|
||||||
DialogStyleEditor editor(this,temp,grid);
|
DialogStyleEditor editor(this,temp,grid,true,&Store);
|
||||||
int modified = editor.ShowModal();
|
int modified = editor.ShowModal();
|
||||||
if (modified) {
|
if (modified) {
|
||||||
AssFile::top->InsertStyle(temp);
|
AssFile::top->InsertStyle(temp);
|
||||||
|
|
Loading…
Reference in New Issue