diff --git a/aegisub/audio_box.cpp b/aegisub/audio_box.cpp index 667266bce..dde3867e4 100644 --- a/aegisub/audio_box.cpp +++ b/aegisub/audio_box.cpp @@ -48,6 +48,7 @@ #include "options.h" #include "toggle_bitmap.h" #include "hotkeys.h" +#include "tooltip_manager.h" #ifdef __WXMAC__ #include "bevelButton.h" @@ -123,46 +124,46 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE wxSizer *ButtonSizer = new wxBoxSizer(wxHORIZONTAL); wxButton *temp; temp = new wxBitmapButton(this,Audio_Button_Prev,wxBITMAP(button_prev),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Previous line/syllable (") + Hotkeys.GetText(_T("Audio Prev Line")) + _T("/") + Hotkeys.GetText(_T("Audio Prev Line Alt")) + _T(")")); + ToolTipManager::Bind(temp,_("Previous line or syllable (%KEY%/%KEY%)"),_T("Audio Prev Line"),_T("Audio Prev Line Alt")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Next,wxBITMAP(button_next),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Next line/syllable (") + Hotkeys.GetText(_T("Audio Next Line")) + _T("/") + Hotkeys.GetText(_T("Audio Next Line Alt")) + _T(")")); + ToolTipManager::Bind(temp,_("Next line/syllable (%KEY%/%KEY%)"),_T("Audio Next Line"),_T("Audio Next Line Alt")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play,wxBITMAP(button_playsel),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play selection (") + Hotkeys.GetText(_T("Audio Play")) + _T("/") + Hotkeys.GetText(_T("Audio Play Alt")) + _T(")")); + ToolTipManager::Bind(temp,_("Play selection (%KEY%/%KEY%)"),_T("Audio Play"),_T("Audio Play Alt")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play_Row,wxBITMAP(button_playline),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play current line (") + Hotkeys.GetText(_T("Audio Play Original Line")) + _T(")")); + ToolTipManager::Bind(temp,_("Play current line (%KEY%)"),_T("Audio Play Original Line")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Stop,wxBITMAP(button_stop),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Stop (") + Hotkeys.GetText(_T("Audio Stop")) + _T(")")); + ToolTipManager::Bind(temp,_("Stop (%KEY%)"),_T("Audio Stop")); ButtonSizer->Add(temp,0,wxRIGHT,10); temp = new wxBitmapButton(this,Audio_Button_Play_500ms_Before,wxBITMAP(button_playfivehbefore),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play 500 ms before selection (") + Hotkeys.GetText(_T("Audio Play 500ms Before")) + _T(")")); + ToolTipManager::Bind(temp,_("Play 500 ms before selection (%KEY%)"),_T("Audio Play 500ms Before")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play_500ms_After,wxBITMAP(button_playfivehafter),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play 500 ms after selection (") + Hotkeys.GetText(_T("Audio Play 500ms after")) + _T(")")); + ToolTipManager::Bind(temp,_("Play 500 ms after selection (%KEY%)"),_T("Audio Play 500ms after")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play_500ms_First,wxBITMAP(button_playfirstfiveh),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play first 500ms of selection (") + Hotkeys.GetText(_T("Audio Play First 500ms")) + _T(")")); + ToolTipManager::Bind(temp,_("Play first 500ms of selection (%KEY%)"),_T("Audio Play First 500ms")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play_500ms_Last,wxBITMAP(button_playlastfiveh),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play last 500ms of selection (") + Hotkeys.GetText(_T("Audio Play Last 500ms")) + _T(")")); + ToolTipManager::Bind(temp,_("Play last 500ms of selection (%KEY%)"),_T("Audio Play Last 500ms")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Play_To_End,wxBITMAP(button_playtoend),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Play from selection start to end of file (") + Hotkeys.GetText(_T("Audio Play To End")) + _T(")")); + ToolTipManager::Bind(temp,_("Play from selection start to end of file (%KEY%)"),_T("Audio Play To End")); ButtonSizer->Add(temp,0,wxRIGHT,10); temp = new wxBitmapButton(this,Audio_Button_Leadin,wxBITMAP(button_leadin),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Add lead in (") + Hotkeys.GetText(_T("Audio Add Lead In")) + _T(")")); + ToolTipManager::Bind(temp,_("Add lead in (%KEY%)"),_T("Audio Add Lead In")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Leadout,wxBITMAP(button_leadout),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Add lead out (") + Hotkeys.GetText(_T("Audio Add Lead Out")) + _T(")")); + ToolTipManager::Bind(temp,_("Add lead out (%KEY%)"),_T("Audio Add Lead Out")); ButtonSizer->Add(temp,0,wxRIGHT,10); temp = new wxBitmapButton(this,Audio_Button_Commit,wxBITMAP(button_audio_commit),wxDefaultPosition,wxSize(30,-1)); - temp->SetToolTip(_("Commit changes (") + Hotkeys.GetText(_T("Audio Commit (Stay)")) + _T("/") + Hotkeys.GetText(_T("Audio Commit Alt")) + _T(")")); + ToolTipManager::Bind(temp,_("Commit changes (%KEY%/%KEY%)"),_T("Audio Commit (Stay)"),_T("Audio Commit Alt")); ButtonSizer->Add(temp,0,wxRIGHT,0); temp = new wxBitmapButton(this,Audio_Button_Goto,wxBITMAP(button_audio_goto),wxDefaultPosition,wxSize(30,-1)); temp->SetToolTip(_("Go to selection")); diff --git a/aegisub/dialog_options.cpp b/aegisub/dialog_options.cpp index c5345ddab..67b46b790 100644 --- a/aegisub/dialog_options.cpp +++ b/aegisub/dialog_options.cpp @@ -61,6 +61,7 @@ #include "audio_display.h" #include "video_context.h" #include "browse_button.h" +#include "tooltip_manager.h" /////// @@ -866,6 +867,9 @@ void DialogOptions::WriteToOptions(bool justApply) { // Rebuild accelerator table parent->SetAccelerators(); + + // Update tooltips + ToolTipManager::Update(); } // Save options diff --git a/aegisub/subs_edit_box.cpp b/aegisub/subs_edit_box.cpp index d125351aa..06ca5d520 100644 --- a/aegisub/subs_edit_box.cpp +++ b/aegisub/subs_edit_box.cpp @@ -59,7 +59,7 @@ #include "dialog_search_replace.h" #include "idle_field_event.h" #include "float_spin.h" - +#include "tooltip_manager.h" /////////////// @@ -133,7 +133,7 @@ SubsEditBox::SubsEditBox (wxWindow *parent,SubtitlesGrid *gridp) : wxPanel(paren Color4 = new wxBitmapButton(this,BUTTON_COLOR4,wxBITMAP(button_color_four),wxDefaultPosition,wxSize(30,20)); Color4->SetToolTip(_("Shadow color")); CommitButton = new wxButton(this,BUTTON_COMMIT,_("Commit"),wxDefaultPosition,wxSize(55,20)); - CommitButton->SetToolTip(_T("Commits the text (Enter). Hold Ctrl to stay in line (Ctrl+Enter).")); + ToolTipManager::Bind(CommitButton,_("Commits the text (Enter). Hold Ctrl to stay in line (%KEY%)."),_T("Edit Box Commit")); ByTime = new wxRadioButton(this,RADIO_TIME_BY_TIME,_("Time"),wxDefaultPosition,wxDefaultSize,wxRB_GROUP); ByTime->SetToolTip(_("Time by h:mm:ss.cs")); ByFrame = new wxRadioButton(this,RADIO_TIME_BY_FRAME,_("Frame")); diff --git a/aegisub/tooltip_manager.cpp b/aegisub/tooltip_manager.cpp index 718e6cc38..caa919d04 100644 --- a/aegisub/tooltip_manager.cpp +++ b/aegisub/tooltip_manager.cpp @@ -37,6 +37,7 @@ /////////// // Headers #include "tooltip_manager.h" +#include "hotkeys.h" /////////////////// @@ -69,6 +70,16 @@ void ToolTipManager::Bind(wxWindow *window,wxString tooltip,wxString hotkey) { } +//////////////////////// +// Two hotkeys overload +void ToolTipManager::Bind(wxWindow *window,wxString tooltip,wxString hotkey1,wxString hotkey2) { + wxArrayString hotkeys; + hotkeys.Add(hotkey1); + hotkeys.Add(hotkey2); + Bind(window,tooltip,hotkeys); +} + + /////////////////// // Static instance ToolTipManager *ToolTipManager::instance = NULL; @@ -84,7 +95,7 @@ void ToolTipBinding::Update() { wxString finalTip = toolTip; wxArrayString hotkeysLeft = hotkeys; while (hotkeysLeft.Count()) { - finalTip.Replace(_T("%KEY%"),hotkeysLeft[0],false); + finalTip.Replace(_T("%KEY%"),Hotkeys.GetText(hotkeysLeft[0]),false); hotkeysLeft.RemoveAt(0); } window->SetToolTip(finalTip); diff --git a/aegisub/tooltip_manager.h b/aegisub/tooltip_manager.h index 6f812ead4..6d11bbaa8 100644 --- a/aegisub/tooltip_manager.h +++ b/aegisub/tooltip_manager.h @@ -72,4 +72,5 @@ public: static void Update() { GetInstance()->DoUpdate(); } static void Bind(wxWindow *window,wxString tooltip,wxArrayString hotkeys) { GetInstance()->AddTips(window,tooltip,hotkeys); } static void Bind(wxWindow *window,wxString tooltip,wxString hotkey=_T("")); + static void Bind(wxWindow *window,wxString tooltip,wxString hotkey1,wxString hotkey2); };