Improved hotkeys manager, and tweaked style manager.

Originally committed to SVN as r1617.
This commit is contained in:
Rodrigo Braz Monteiro 2007-10-20 23:04:06 +00:00
parent c4347d9e8a
commit 045583c190
3 changed files with 80 additions and 24 deletions

View File

@ -69,7 +69,10 @@
// IDs
enum {
BUTTON_DEFAULTS = 2500,
HOTKEY_LIST
HOTKEY_LIST,
BUTTON_HOTKEY_SET,
BUTTON_HOTKEY_CLEAR,
BUTTON_HOTKEY_DEFAULT
};
@ -576,9 +579,6 @@ DialogOptions::DialogOptions(wxWindow *parent)
hotkeysModified = false;
origKeys = Hotkeys.key;
// Description
wxStaticText *text = new wxStaticText(hotkeysPage,-1,_("List of all hotkeys (shortcuts) available in Aegisub.\nDouble click on any item to reassign it."),wxDefaultPosition,wxSize(150,-1));
// List of shortcuts
Shortcuts = new wxListView(hotkeysPage,HOTKEY_LIST,wxDefaultPosition,wxSize(250,150),wxLC_REPORT | wxLC_SINGLE_SEL);
Shortcuts->InsertColumn(0,_("Function"),wxLIST_FORMAT_LEFT,200);
@ -594,10 +594,16 @@ DialogOptions::DialogOptions(wxWindow *parent)
Shortcuts->SetItem(pos,1,cur->second.GetText());
}
// Create buttons
wxSizer *buttons = new wxBoxSizer(wxHORIZONTAL);
buttons->Add(new wxButton(hotkeysPage,BUTTON_HOTKEY_SET,_("Set Hotkey...")),1,wxEXPAND|wxRIGHT,5);
buttons->Add(new wxButton(hotkeysPage,BUTTON_HOTKEY_CLEAR,_("Clear Hotkey")),1,wxEXPAND|wxRIGHT,5);
buttons->Add(new wxButton(hotkeysPage,BUTTON_HOTKEY_DEFAULT,_("Default")),1,wxEXPAND|wxRIGHT,0);
// Main sizer
wxSizer *hotkeysSizer = new wxBoxSizer(wxVERTICAL);
hotkeysSizer->Add(text,0,wxALL|wxEXPAND,5);
hotkeysSizer->Add(Shortcuts,1,wxLEFT|wxRIGHT|wxTOP|wxEXPAND,5);
hotkeysSizer->Add(buttons,0,wxALL|wxEXPAND,5);
hotkeysSizer->Fit(hotkeysPage);
hotkeysPage->SetSizer(hotkeysSizer);
}
@ -695,7 +701,9 @@ BEGIN_EVENT_TABLE(DialogOptions,wxDialog)
EVT_BUTTON(wxID_CANCEL,DialogOptions::OnCancel)
EVT_BUTTON(wxID_APPLY,DialogOptions::OnApply)
EVT_BUTTON(BUTTON_DEFAULTS,DialogOptions::OnDefaults)
EVT_LIST_ITEM_ACTIVATED (HOTKEY_LIST,DialogOptions::OnEditHotkey)
EVT_BUTTON(BUTTON_HOTKEY_SET,DialogOptions::OnEditHotkey)
EVT_BUTTON(BUTTON_HOTKEY_CLEAR,DialogOptions::OnClearHotkey)
EVT_BUTTON(BUTTON_HOTKEY_DEFAULT,DialogOptions::OnDefaultHotkey)
END_EVENT_TABLE()
@ -984,24 +992,70 @@ void DialogOptions::ReadFromOptions() {
/////////////////
// Edit a hotkey
void DialogOptions::OnEditHotkey(wxListEvent &event) {
void DialogOptions::OnEditHotkey(wxCommandEvent &event) {
// Get selection
int sel = Shortcuts->GetFirstSelected();
if (sel == wxNOT_FOUND) return;
// Get key and store old
HotkeyType *curKey = (HotkeyType *)event.GetData();
HotkeyType *curKey = (HotkeyType *) Shortcuts->GetItemData(sel);
int oldKeycode = curKey->keycode;
int oldFlags = curKey->flags;
// Open dialog
DialogInputHotkey input(curKey,event.GetText());
DialogInputHotkey input(curKey,Shortcuts->GetItemText(sel));
input.ShowModal();
// Update stuff if it changed
if (oldKeycode != curKey->keycode || oldFlags != curKey->flags) {
Shortcuts->SetItem(event.GetIndex(),1,curKey->GetText());
Shortcuts->SetItem(sel,1,curKey->GetText());
hotkeysModified = true;
}
}
//////////////////
// Clear a hotkey
void DialogOptions::OnClearHotkey(wxCommandEvent &event) {
for (int item=-1;true;) {
item = Shortcuts->GetNextItem(item,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED);
if (item == -1) break;
HotkeyType *curKey = (HotkeyType *) Shortcuts->GetItemData(item);
if (curKey->keycode != 0 || curKey->flags != 0) {
hotkeysModified = true;
curKey->keycode = 0;
curKey->flags = 0;
Shortcuts->SetItem(item,1,curKey->GetText());
}
}
}
///////////////////////////
// Reset hotkey to default
void DialogOptions::OnDefaultHotkey(wxCommandEvent &event) {
// Load defaults
HotkeyManager defs;
defs.LoadDefaults();
// Replace
for (int item=-1;true;) {
item = Shortcuts->GetNextItem(item,wxLIST_NEXT_ALL,wxLIST_STATE_SELECTED);
if (item == -1) break;
HotkeyType *curKey = (HotkeyType *) Shortcuts->GetItemData(item);
HotkeyType *origKey = &defs.key[curKey->origName.Lower()];
if (origKey->keycode != curKey->keycode || origKey->flags != curKey->flags) {
hotkeysModified = true;
curKey->keycode = origKey->keycode;
curKey->flags = origKey->flags;
Shortcuts->SetItem(item,1,curKey->GetText());
}
}
}
/////////////////////
// Input constructor
DialogInputHotkey::DialogInputHotkey(HotkeyType *_key,wxString name)

View File

@ -80,7 +80,6 @@ enum TextType {
TEXT_TYPE_FONT
};
////////////////////////
// Options screen class
class DialogOptions: public wxDialog {
@ -107,7 +106,10 @@ private:
void OnCancel(wxCommandEvent &event);
void OnApply(wxCommandEvent &event);
void OnDefaults(wxCommandEvent &event);
void OnEditHotkey(wxListEvent &event);
void OnEditHotkey(wxCommandEvent &event);
void OnClearHotkey(wxCommandEvent &event);
void OnDefaultHotkey(wxCommandEvent &event);
public:
DialogOptions(wxWindow *parent);

View File

@ -67,9 +67,9 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
// Catalog
wxSizer *CatalogBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Catalog of available storages"));
CatalogList = new wxComboBox(this,LIST_CATALOG, _T(""), wxDefaultPosition, wxSize(180,20), 0, NULL, wxCB_READONLY | wxCB_READONLY, wxDefaultValidator, _T("Catalog List"));
wxButton *CatalogNew = new wxButton(this, BUTTON_CATALOG_NEW, _("New"), wxDefaultPosition, wxSize(60,20));
wxButton *CatalogDelete = new wxButton(this, BUTTON_CATALOG_DELETE, _("Delete"), wxDefaultPosition, wxSize(60,20));
CatalogList = new wxComboBox(this,LIST_CATALOG, _T(""), wxDefaultPosition, wxSize(-1,-1), 0, NULL, wxCB_READONLY | wxCB_READONLY, wxDefaultValidator, _T("Catalog List"));
wxButton *CatalogNew = new wxButton(this, BUTTON_CATALOG_NEW, _("New"), wxDefaultPosition, wxSize(-1,-1));
wxButton *CatalogDelete = new wxButton(this, BUTTON_CATALOG_DELETE, _("Delete"), wxDefaultPosition, wxSize(-1,-1));
CatalogBox->Add(CatalogList,1,wxEXPAND | wxRIGHT | wxALIGN_RIGHT,5);
CatalogBox->Add(CatalogNew,0,wxRIGHT,5);
CatalogBox->Add(CatalogDelete,0,0,0);
@ -80,11 +80,11 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
wxSizer *StorageButtons = new wxBoxSizer(wxHORIZONTAL);
wxSizer *StorageButtonsLow = new wxBoxSizer(wxVERTICAL);
wxSizer *StorageListSizer = new wxBoxSizer(wxHORIZONTAL);
MoveToLocal = new wxButton(this, BUTTON_STORAGE_COPYTO, _("Copy to current script ->"), wxDefaultPosition, wxSize(205,25));
StorageNew = new wxButton(this, BUTTON_STORAGE_NEW, _("New"), wxDefaultPosition, wxSize(40,25));
StorageEdit = new wxButton(this, BUTTON_STORAGE_EDIT, _("Edit"), wxDefaultPosition, wxSize(40,25));
StorageCopy = new wxButton(this, BUTTON_STORAGE_COPY, _("Copy"), wxDefaultPosition, wxSize(40,25));
StorageDelete = new wxButton(this, BUTTON_STORAGE_DELETE, _("Delete"), wxDefaultPosition, wxSize(40,25));
MoveToLocal = new wxButton(this, BUTTON_STORAGE_COPYTO, _("Copy to current script ->"), wxDefaultPosition, wxSize(205,-1));
StorageNew = new wxButton(this, BUTTON_STORAGE_NEW, _("New"), wxDefaultPosition, wxSize(40,-1));
StorageEdit = new wxButton(this, BUTTON_STORAGE_EDIT, _("Edit"), wxDefaultPosition, wxSize(40,-1));
StorageCopy = new wxButton(this, BUTTON_STORAGE_COPY, _("Copy"), wxDefaultPosition, wxSize(40,-1));
StorageDelete = new wxButton(this, BUTTON_STORAGE_DELETE, _("Delete"), wxDefaultPosition, wxSize(40,-1));
StorageButtons->Add(StorageNew,1,wxEXPAND | wxRIGHT,5);
StorageButtons->Add(StorageEdit,1,wxEXPAND | wxRIGHT,5);
StorageButtons->Add(StorageCopy,1,wxEXPAND | wxRIGHT,5);
@ -126,10 +126,10 @@ DialogStyleManager::DialogStyleManager (wxWindow *parent,SubtitlesGrid *_grid)
MoveToStorage = new wxButton(this, BUTTON_CURRENT_COPYTO, _("<- Copy to storage"), wxDefaultPosition, wxSize(-1,25));
MoveImportSizer->Add(MoveToStorage,1,wxEXPAND | wxRIGHT,5);
MoveImportSizer->Add(new wxButton(this, BUTTON_CURRENT_IMPORT, _("Import from script...")),1,wxEXPAND,0);
CurrentNew = new wxButton(this, BUTTON_CURRENT_NEW, _("New"), wxDefaultPosition, wxSize(40,25));
CurrentEdit = new wxButton(this, BUTTON_CURRENT_EDIT, _("Edit"), wxDefaultPosition, wxSize(40,25));
CurrentCopy = new wxButton(this, BUTTON_CURRENT_COPY, _("Copy"), wxDefaultPosition, wxSize(40,25));
CurrentDelete = new wxButton(this, BUTTON_CURRENT_DELETE, _("Delete"), wxDefaultPosition, wxSize(40,25));
CurrentNew = new wxButton(this, BUTTON_CURRENT_NEW, _("New"), wxDefaultPosition, wxSize(40,-1));
CurrentEdit = new wxButton(this, BUTTON_CURRENT_EDIT, _("Edit"), wxDefaultPosition, wxSize(40,-1));
CurrentCopy = new wxButton(this, BUTTON_CURRENT_COPY, _("Copy"), wxDefaultPosition, wxSize(40,-1));
CurrentDelete = new wxButton(this, BUTTON_CURRENT_DELETE, _("Delete"), wxDefaultPosition, wxSize(40,-1));
CurrentButtons->Add(CurrentNew,1,wxEXPAND | wxRIGHT,5);
CurrentButtons->Add(CurrentEdit,1,wxEXPAND | wxRIGHT,5);
CurrentButtons->Add(CurrentCopy,1,wxEXPAND | wxRIGHT,5);