Clean up DialogStyleManager a bit, eliminating a decent amount of duplicated code and fixing issues with the logic for enabling and disabling the buttons.

Originally committed to SVN as r6416.
This commit is contained in:
Thomas Goyne 2012-02-01 00:48:50 +00:00
parent c6ac746215
commit 98b51e2c23
2 changed files with 305 additions and 512 deletions

File diff suppressed because it is too large Load diff

View file

@ -57,19 +57,25 @@ class PersistLocation;
/// ///
/// DOCME /// DOCME
class DialogStyleManager : public wxDialog { class DialogStyleManager : public wxDialog {
agi::Context *c; agi::Context *c; ///< Project context
agi::scoped_ptr<PersistLocation> persist; agi::scoped_ptr<PersistLocation> persist;
/// DOCME /// Styles in the current subtitle file
std::vector<AssStyle*> styleMap; std::vector<AssStyle*> styleMap;
/// DOCME /// Styles in the currently selected style storage
std::vector<AssStyle*> styleStorageMap; std::vector<AssStyle*> styleStorageMap;
/// Style storage manager
AssStyleStorage Store;
wxComboBox *CatalogList; wxComboBox *CatalogList;
wxListBox *StorageList; wxListBox *StorageList;
wxListBox *CurrentList; wxListBox *CurrentList;
wxButton *MoveToLocal; wxButton *MoveToLocal;
wxButton *MoveToStorage;
wxButton *StorageNew; wxButton *StorageNew;
wxButton *StorageEdit; wxButton *StorageEdit;
wxButton *StorageCopy; wxButton *StorageCopy;
@ -79,7 +85,7 @@ class DialogStyleManager : public wxDialog {
wxButton *StorageMoveTop; wxButton *StorageMoveTop;
wxButton *StorageMoveBottom; wxButton *StorageMoveBottom;
wxButton *StorageSort; wxButton *StorageSort;
wxButton *MoveToStorage;
wxButton *CurrentNew; wxButton *CurrentNew;
wxButton *CurrentEdit; wxButton *CurrentEdit;
wxButton *CurrentCopy; wxButton *CurrentCopy;
@ -90,46 +96,35 @@ class DialogStyleManager : public wxDialog {
wxButton *CurrentMoveBottom; wxButton *CurrentMoveBottom;
wxButton *CurrentSort; wxButton *CurrentSort;
/// Enable or disable the storage buttons
/// DOCME
AssStyleStorage Store;
void StorageActions(bool state); void StorageActions(bool state);
/// Load the list of available storages
void LoadCatalog(); void LoadCatalog();
/// Load the style list from the subtitles file
void LoadCurrentStyles(AssFile *subs); void LoadCurrentStyles(AssFile *subs);
/// Load the style list from the current storage
void LoadStorageStyles(); void LoadStorageStyles();
void UpdateMoveButtons(); /// Enable/disable all of the buttons as appropriate
void UpdateButtons();
/// Move styles up or down
/// @param storage Storage or current file styles
/// @param type 0: up; 1: top; 2: down; 3: bottom; 4: sort
void MoveStyles(bool storage, int type); void MoveStyles(bool storage, int type);
/// DOCME void OnChangeCatalog();
wxSizer *MainSizer; void OnCatalogNew();
void OnCatalogDelete();
void OnChangeCatalog (wxCommandEvent &event); void OnStorageEdit();
void OnCatalogNew (wxCommandEvent &event); void OnCurrentEdit();
void OnCatalogDelete (wxCommandEvent &event); void OnCopyToStorage();
void OnStorageEdit (wxCommandEvent &event); void OnCopyToCurrent();
void OnCurrentEdit (wxCommandEvent &event); void OnStorageCopy();
void OnCurrentMoveUp (wxCommandEvent &event); void OnCurrentCopy();
void OnCurrentMoveDown (wxCommandEvent &event); void OnStorageNew();
void OnCurrentMoveTop (wxCommandEvent &event); void OnCurrentNew();
void OnCurrentMoveBottom (wxCommandEvent &event); void OnStorageDelete();
void OnCurrentSort (wxCommandEvent &event); void OnCurrentDelete();
void OnStorageChange (wxCommandEvent &event); void OnCurrentImport();
void OnCurrentChange (wxCommandEvent &event);
void OnCopyToStorage (wxCommandEvent &event);
void OnCopyToCurrent (wxCommandEvent &event);
void OnStorageCopy (wxCommandEvent &event);
void OnCurrentCopy (wxCommandEvent &event);
void OnStorageNew (wxCommandEvent &event);
void OnCurrentNew (wxCommandEvent &event);
void OnStorageMoveUp (wxCommandEvent &event);
void OnStorageMoveDown (wxCommandEvent &event);
void OnStorageMoveTop (wxCommandEvent &event);
void OnStorageMoveBottom (wxCommandEvent &event);
void OnStorageSort (wxCommandEvent &event);
void OnStorageDelete (wxCommandEvent &event);
void OnCurrentDelete (wxCommandEvent &event);
void OnCurrentImport (wxCommandEvent &event);
void OnKeyDown(wxKeyEvent &event); void OnKeyDown(wxKeyEvent &event);
void CopyToClipboard(wxListBox *list, std::vector<AssStyle*> v); void CopyToClipboard(wxListBox *list, std::vector<AssStyle*> v);
void PasteToCurrent(); void PasteToCurrent();
@ -138,6 +133,4 @@ class DialogStyleManager : public wxDialog {
public: public:
DialogStyleManager(agi::Context *context); DialogStyleManager(agi::Context *context);
~DialogStyleManager(); ~DialogStyleManager();
DECLARE_EVENT_TABLE()
}; };