Aegisub/src/dialog_style_manager.h

154 lines
4.6 KiB
C
Raw Normal View History

2006-01-16 22:02:54 +01:00
// Copyright (c) 2005, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Aegisub Project http://www.aegisub.org/
/// @file dialog_style_manager.h
/// @see dialog_style_manager.cpp
/// @ingroup style_editor
///
2006-01-16 22:02:54 +01:00
#include <future>
2013-06-10 15:58:13 +02:00
#include <memory>
#include <vector>
#include <wx/button.h>
#include <wx/combobox.h>
#include <wx/dialog.h>
#include <wx/listbox.h>
#include <libaegisub/signal.h>
2006-01-16 22:02:54 +01:00
#include "ass_style_storage.h"
namespace agi { struct Context; }
class AssDialogue;
2006-01-16 22:02:54 +01:00
class AssFile;
class AssStyle;
class DialogStyleEditor;
class PersistLocation;
class DialogStyleManager : public wxDialog {
agi::Context *c; ///< Project context
2013-06-10 15:58:13 +02:00
std::unique_ptr<PersistLocation> persist;
agi::signal::Connection commit_connection;
agi::signal::Connection active_line_connection;
std::shared_future<wxArrayString> font_list;
/// Styles in the current subtitle file
2006-01-16 22:02:54 +01:00
std::vector<AssStyle*> styleMap;
/// Style storage manager
AssStyleStorage Store;
2006-01-16 22:02:54 +01:00
wxComboBox *CatalogList;
wxListBox *StorageList;
wxListBox *CurrentList;
wxButton *CatalogDelete;
2006-01-16 22:02:54 +01:00
wxButton *MoveToLocal;
wxButton *MoveToStorage;
2006-01-16 22:02:54 +01:00
wxButton *StorageNew;
wxButton *StorageEdit;
2006-01-16 22:02:54 +01:00
wxButton *StorageCopy;
wxButton *StorageDelete;
wxButton *StorageMoveUp;
wxButton *StorageMoveDown;
wxButton *StorageMoveTop;
wxButton *StorageMoveBottom;
wxButton *StorageSort;
2006-01-16 22:02:54 +01:00
wxButton *CurrentNew;
wxButton *CurrentEdit;
2006-01-16 22:02:54 +01:00
wxButton *CurrentCopy;
wxButton *CurrentDelete;
wxButton *CurrentMoveUp;
wxButton *CurrentMoveDown;
wxButton *CurrentMoveTop;
wxButton *CurrentMoveBottom;
wxButton *CurrentSort;
2006-01-16 22:02:54 +01:00
/// Load the list of available storages
void LoadCatalog();
/// Load the style list from the subtitles file
void LoadCurrentStyles(int commit_type);
/// 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);
/// Open the style editor for the given style on the script
2012-11-13 17:51:01 +01:00
/// @param style Style to edit, or nullptr for new
/// @param new_name Default new name for copies
2012-12-30 01:32:36 +01:00
void ShowCurrentEditor(AssStyle *style, std::string const& new_name = "");
/// Open the style editor for the given style in the storage
2012-11-13 17:51:01 +01:00
/// @param style Style to edit, or nullptr for new
/// @param new_name Default new name for copies
2012-12-30 01:32:36 +01:00
void ShowStorageEditor(AssStyle *style, std::string const& new_name = "");
/// Save the storage and update the view after a change
void UpdateStorage();
void OnChangeCatalog();
void OnCatalogNew();
void OnCatalogDelete();
void OnCopyToCurrent();
void OnCopyToStorage();
void OnCurrentCopy();
void OnCurrentDelete();
void OnCurrentEdit();
void OnCurrentImport();
void OnCurrentNew();
void OnStorageCopy();
void OnStorageDelete();
void OnStorageEdit();
void OnStorageNew();
void OnKeyDown(wxKeyEvent &event);
void PasteToCurrent();
void PasteToStorage();
template<class T>
void CopyToClipboard(wxListBox *list, T const& v);
void OnActiveLineChanged(AssDialogue *new_line);
public:
DialogStyleManager(agi::Context *context);
~DialogStyleManager();
};