diff --git a/aegisub/bitmaps/copy_disable.bmp b/aegisub/bitmaps/copy_disable.bmp deleted file mode 100644 index f6cfd8b73..000000000 Binary files a/aegisub/bitmaps/copy_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/cut_disable.bmp b/aegisub/bitmaps/cut_disable.bmp deleted file mode 100644 index 307112d6b..000000000 Binary files a/aegisub/bitmaps/cut_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/delete_disable.bmp b/aegisub/bitmaps/delete_disable.bmp deleted file mode 100644 index 29b77fd3e..000000000 Binary files a/aegisub/bitmaps/delete_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/jumpto_disable.bmp b/aegisub/bitmaps/jumpto_disable.bmp deleted file mode 100644 index 5f07fdea4..000000000 Binary files a/aegisub/bitmaps/jumpto_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/paste_disable.bmp b/aegisub/bitmaps/paste_disable.bmp deleted file mode 100644 index 48cb4f131..000000000 Binary files a/aegisub/bitmaps/paste_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/redo_disable.bmp b/aegisub/bitmaps/redo_disable.bmp deleted file mode 100644 index 8d76b4f9e..000000000 Binary files a/aegisub/bitmaps/redo_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/shift_to_frame_disable.bmp b/aegisub/bitmaps/shift_to_frame_disable.bmp deleted file mode 100644 index 7e2027a0d..000000000 Binary files a/aegisub/bitmaps/shift_to_frame_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/snap_to_scene_disable.bmp b/aegisub/bitmaps/snap_to_scene_disable.bmp deleted file mode 100644 index e3151b3e4..000000000 Binary files a/aegisub/bitmaps/snap_to_scene_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/subend_to_video_disable.bmp b/aegisub/bitmaps/subend_to_video_disable.bmp deleted file mode 100644 index 18b263fa6..000000000 Binary files a/aegisub/bitmaps/subend_to_video_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/substart_to_video_disable.bmp b/aegisub/bitmaps/substart_to_video_disable.bmp deleted file mode 100644 index d173bcf0c..000000000 Binary files a/aegisub/bitmaps/substart_to_video_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/video_to_subend_disable.bmp b/aegisub/bitmaps/video_to_subend_disable.bmp deleted file mode 100644 index 9f113df44..000000000 Binary files a/aegisub/bitmaps/video_to_subend_disable.bmp and /dev/null differ diff --git a/aegisub/bitmaps/video_to_substart_disable.bmp b/aegisub/bitmaps/video_to_substart_disable.bmp deleted file mode 100644 index 7001d365a..000000000 Binary files a/aegisub/bitmaps/video_to_substart_disable.bmp and /dev/null differ diff --git a/aegisub/frame_main.cpp b/aegisub/frame_main.cpp index 388ae1d35..62ad2acfb 100644 --- a/aegisub/frame_main.cpp +++ b/aegisub/frame_main.cpp @@ -289,8 +289,9 @@ void FrameMain::InitMenu() { // Create Edit menu editMenu = new wxMenu(); - AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, _("&Undo\t") + Hotkeys.GetText(_T("Undo")), _("Undoes last action"),wxBITMAP(undo_button)); - AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, _("&Redo\t") + Hotkeys.GetText(_T("Redo")), _("Redoes last action"),wxBITMAP(redo_button)); + wxMenuItem *item; + item = AppendBitmapMenuItem(editMenu,Menu_Edit_Undo, _("-") + wxString(_T("\t")) + Hotkeys.GetText(_T("Undo")), _("Undoes last action"),wxBITMAP(undo_button)); + item = AppendBitmapMenuItem(editMenu,Menu_Edit_Redo, _("-") + wxString(_T("\t")) + Hotkeys.GetText(_T("Redo")), _("Redoes last action"),wxBITMAP(redo_button)); editMenu->AppendSeparator(); AppendBitmapMenuItem(editMenu,Menu_Edit_Cut, _("Cut Lines\t") + Hotkeys.GetText(_T("Cut")), _("Cut subtitles"), wxBITMAP(cut_button)); AppendBitmapMenuItem(editMenu,Menu_Edit_Copy, _("Copy Lines\t") + Hotkeys.GetText(_T("Copy")), _("Copy subtitles"), wxBITMAP(copy_button)); @@ -538,55 +539,6 @@ void FrameMain::UpdateToolbar() { } -//////////////////////////// -// Menu item enable/disable -void FrameMain::MenuItemEnable (int id, bool state,wxBitmap &bmp1,wxBitmap &bmp2) { - wxMenuItem *item = MenuBar->FindItem(id); - wxBitmap bmp = item->GetBitmap(); - - // No image - if (bmp.GetWidth() == 0) { - item->Enable(state); - } - - // Has image - else { - RebuildMenuItem(item->GetMenu(),id,bmp1,bmp2,state); - } -} - - -///////////////////////////////// -// Helper to rebuild menu items -wxMenuItem *FrameMain::RebuildMenuItem(wxMenu *menu,int findId,wxBitmap bmp1,wxBitmap bmp2,bool state) { - // Find pos - wxMenuItemList &items = menu->GetMenuItems(); - int pos = -1; - for (size_t i=0;iGetId() == findId) { - pos = (int)i; - break; - } - } - if (pos == -1) return NULL; - - // Get ID and pointer - wxMenuItem *cur = items[pos]; - int id = cur->GetId(); - - // Rebuild - wxMenuItem *newItem = new wxMenuItem(menu,id,cur->GetText(),cur->GetHelp(),cur->GetKind(),cur->GetSubMenu()); - if (state) newItem->SetBitmap(bmp1); - else newItem->SetBitmap(bmp2); - - // Swap them - menu->Destroy(id); - menu->Insert(pos,newItem); - menu->Enable(id,state); - return cur; -} - - ////////////////// // Open subtitles void FrameMain::LoadSubtitles (wxString filename,wxString charset) { diff --git a/aegisub/frame_main.h b/aegisub/frame_main.h index 543582e29..3cf1682a7 100644 --- a/aegisub/frame_main.h +++ b/aegisub/frame_main.h @@ -237,8 +237,7 @@ private: bool SaveSubtitles(bool saveas=false,bool withCharset=false); int TryToCloseSubs(bool enableCancel=true); - wxMenuItem *RebuildMenuItem(wxMenu *menu,int id,wxBitmap bmp1,wxBitmap bmp2,bool state); - void MenuItemEnable(int id,bool state,wxBitmap &bmp1,wxBitmap &bmp2); + void RebuildRecentList(wxString listName,wxMenu *menu,int startID); void SynchronizeProject(bool FromSubs=false); public: diff --git a/aegisub/frame_main_events.cpp b/aegisub/frame_main_events.cpp index ecf562e43..b4940d993 100644 --- a/aegisub/frame_main_events.cpp +++ b/aegisub/frame_main_events.cpp @@ -227,34 +227,44 @@ void FrameMain::OnGridEvent (wxCommandEvent &event) { } +/////////////////////// +// Rebuild recent list +void FrameMain::RebuildRecentList(wxString listName,wxMenu *menu,int startID) { + // Wipe previous list + int count = (int)menu->GetMenuItemCount(); + for (int i=count;--i>=0;) { + menu->Destroy(menu->FindItemByPosition(i)); + } + + // Rebuild + int added = 0; + wxString n; + wxArrayString entries = Options.GetRecentList(listName); + for (size_t i=0;iAppend(startID+i,n + _T(" ") + filename); + added++; + } + + // Nothing added, add an empty placeholder + if (added == 0) menu->Append(startID,_("Empty"))->Enable(false); +} + + //////////////////////// // Menu is being opened void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Get menu - //Freeze(); + MenuBar->Freeze(); wxMenu *curMenu = event.GetMenu(); // File menu if (curMenu == fileMenu) { - // Wipe recent - int count = (int)RecentSubs->GetMenuItemCount(); - for (int i=count;--i>=0;) { - RecentSubs->Destroy(RecentSubs->FindItemByPosition(i)); - } - // Rebuild recent - int added = 0; - wxString n; - wxArrayString entries = Options.GetRecentList(_T("Recent sub")); - for (size_t i=0;iAppend(Menu_File_Recent+i,n + _T(" ") + filename); - added++; - } - if (added == 0) RecentSubs->Append(Menu_File_Recent,_T("Empty"))->Enable(false); + RebuildRecentList(_T("Recent sub"),RecentSubs,Menu_File_Recent); } // View menu @@ -279,12 +289,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { else if (curMenu == videoMenu) { bool state = VideoContext::Get()->IsLoaded(); - // Rebuild icons - RebuildMenuItem(videoMenu,Menu_Video_JumpTo,wxBITMAP(jumpto_button),wxBITMAP(jumpto_disable_button),state); - RebuildMenuItem(videoMenu,Menu_Subs_Snap_Video_To_Start,wxBITMAP(video_to_substart),wxBITMAP(video_to_substart_disable),state); - RebuildMenuItem(videoMenu,Menu_Subs_Snap_Video_To_End,wxBITMAP(video_to_subend),wxBITMAP(video_to_subend_disable),state); - // Set states + MenuBar->Enable(Menu_Video_JumpTo,state); + MenuBar->Enable(Menu_Subs_Snap_Video_To_Start,state); + MenuBar->Enable(Menu_Subs_Snap_Video_To_End,state); MenuBar->Enable(Menu_View_Zoom,state); MenuBar->Enable(Menu_View_Zoom_50,state); MenuBar->Enable(Menu_View_Zoom_100,state); @@ -316,59 +324,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { case 4: MenuBar->Check(Menu_Video_AR_Custom,true); break; } - // Wipe recent - int count = (int)RecentVids->GetMenuItemCount(); - for (int i=count;--i>=0;) { - RecentVids->Destroy(RecentVids->FindItemByPosition(i)); - } - count = (int)RecentTimecodes->GetMenuItemCount(); - for (int i=count;--i>=0;) { - RecentTimecodes->Destroy(RecentTimecodes->FindItemByPosition(i)); - } - count = (int)RecentKeyframes->GetMenuItemCount(); - for (int i=count;--i>=0;) { - RecentKeyframes->Destroy(RecentKeyframes->FindItemByPosition(i)); - } - - // Rebuild recent videos - int added = 0; - wxString n; - wxArrayString entries = Options.GetRecentList(_T("Recent vid")); - for (size_t i=0;iAppend(Menu_Video_Recent+i,n + _T(" ") + filename); - added++; - } - if (added == 0) RecentVids->Append(Menu_Video_Recent,_T("Empty"))->Enable(false); - - // Rebuild recent timecodes - added = 0; - entries = Options.GetRecentList(_T("Recent timecodes")); - for (size_t i=0;iAppend(Menu_Timecodes_Recent+i,n + _T(" ") + filename); - added++; - } - if (added == 0) RecentTimecodes->Append(Menu_Timecodes_Recent,_T("Empty"))->Enable(false); - - // Rebuild recent Keyframes - added = 0; - entries = Options.GetRecentList(_T("Recent Keyframes")); - for (size_t i=0;iAppend(Menu_Keyframes_Recent+i,n + _T(" ") + filename); - added++; - } - if (added == 0) RecentKeyframes->Append(Menu_Keyframes_Recent,_T("Empty"))->Enable(false); + // Rebuild recent lists + RebuildRecentList(_T("Recent vid"),RecentVids,Menu_Video_Recent); + RebuildRecentList(_T("Recent timecodes"),RecentTimecodes,Menu_Timecodes_Recent); + RebuildRecentList(_T("Recent Keyframes"),RecentKeyframes,Menu_Keyframes_Recent); } // Audio menu @@ -379,25 +338,8 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { MenuBar->Enable(Menu_Audio_Open_From_Video,vidstate); MenuBar->Enable(Menu_Audio_Close,state); - // Wipe recent - int count = (int)RecentAuds->GetMenuItemCount(); - for (int i=count;--i>=0;) { - RecentAuds->Destroy(RecentAuds->FindItemByPosition(i)); - } - // Rebuild recent - int added = 0; - wxString n; - wxArrayString entries = Options.GetRecentList(_T("Recent aud")); - for (size_t i=0;iAppend(Menu_Audio_Recent+i,n + _T(" ") + filename); - added++; - } - if (added == 0) RecentAuds->Append(Menu_Audio_Recent,_T("Empty"))->Enable(false); + RebuildRecentList(_T("Recent aud"),RecentAuds,Menu_Audio_Recent); } // Subtitles menu @@ -413,7 +355,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { MenuBar->Enable(MENU_INSERT_BEFORE,state); MenuBar->Enable(MENU_INSERT_AFTER,state); MenuBar->Enable(MENU_SPLIT_BY_KARAOKE,state); - RebuildMenuItem(subtitlesMenu,MENU_DELETE,wxBITMAP(delete_button),wxBITMAP(delete_disable_button),state); + MenuBar->Enable(MENU_DELETE,state); state2 = count > 0 && VideoContext::Get()->IsLoaded(); MenuBar->Enable(MENU_INSERT_BEFORE_VIDEO,state2); MenuBar->Enable(MENU_INSERT_AFTER_VIDEO,state2); @@ -442,10 +384,10 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Video related bool state = VideoContext::Get()->IsLoaded(); - RebuildMenuItem(timingMenu,Menu_Subs_Snap_Start_To_Video,wxBITMAP(substart_to_video),wxBITMAP(substart_to_video_disable),state); - RebuildMenuItem(timingMenu,Menu_Subs_Snap_End_To_Video,wxBITMAP(subend_to_video),wxBITMAP(subend_to_video_disable),state); - RebuildMenuItem(timingMenu,Menu_Video_Snap_To_Scene,wxBITMAP(snap_subs_to_scene),wxBITMAP(snap_subs_to_scene_disable),state); - RebuildMenuItem(timingMenu,Menu_Video_Shift_To_Frame,wxBITMAP(shift_to_frame),wxBITMAP(shift_to_frame_disable),state); + MenuBar->Enable(Menu_Subs_Snap_Start_To_Video,state); + MenuBar->Enable(Menu_Subs_Snap_End_To_Video,state); + MenuBar->Enable(Menu_Video_Snap_To_Scene,state); + MenuBar->Enable(Menu_Video_Shift_To_Frame,state); // Other state = count >= 2 && continuous; @@ -456,18 +398,22 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { // Edit menu else if (curMenu == editMenu) { // Undo state - curMenu->FindItemByPosition(0)->SetText(_("Undo ")+AssFile::GetUndoDescription()+_T("\t")+Hotkeys.GetText(_T("Undo"))); - curMenu->FindItemByPosition(1)->SetText(_("Redo ")+AssFile::GetRedoDescription()+_T("\t")+Hotkeys.GetText(_T("Redo"))); - RebuildMenuItem(editMenu,Menu_Edit_Undo,wxBITMAP(undo_button),wxBITMAP(undo_disable_button),!AssFile::IsUndoStackEmpty()); - RebuildMenuItem(editMenu,Menu_Edit_Redo,wxBITMAP(redo_button),wxBITMAP(redo_disable_button),!AssFile::IsRedoStackEmpty()); - + wxMenuItem *item; + item = MenuBar->FindItem(Menu_Edit_Undo); + item->SetText(_("&Undo")+wxString(_T(" "))+AssFile::GetUndoDescription()+_T("\t")+Hotkeys.GetText(_T("Undo"))); + item->SetBitmap(wxBITMAP(undo_button)); + item->Enable(!AssFile::IsUndoStackEmpty()); + item = MenuBar->FindItem(Menu_Edit_Redo); + item->SetText(_("&Redo")+wxString(_T(" "))+AssFile::GetRedoDescription()+_T("\t")+Hotkeys.GetText(_T("Redo"))); + item->SetBitmap(wxBITMAP(redo_button)); + item->Enable(!AssFile::IsRedoStackEmpty()); // Copy/cut/paste wxArrayInt sels = SubsBox->GetSelection(); bool state = (sels.Count() > 0); - RebuildMenuItem(editMenu,Menu_Edit_Cut,wxBITMAP(cut_button),wxBITMAP(cut_disable_button),state); - RebuildMenuItem(editMenu,Menu_Edit_Copy,wxBITMAP(copy_button),wxBITMAP(copy_disable_button),state); - RebuildMenuItem(editMenu,Menu_Edit_Paste,wxBITMAP(paste_button),wxBITMAP(paste_disable_button),state); + MenuBar->Enable(Menu_Edit_Cut,state); + MenuBar->Enable(Menu_Edit_Copy,state); + MenuBar->Enable(Menu_Edit_Paste,state); MenuBar->Enable(Menu_Edit_Paste_Over,state); } @@ -494,7 +440,7 @@ void FrameMain::OnMenuOpen (wxMenuEvent &event) { } } - //Thaw(); + MenuBar->Thaw(); } diff --git a/aegisub/res.rc b/aegisub/res.rc index f201134eb..9561013dc 100644 --- a/aegisub/res.rc +++ b/aegisub/res.rc @@ -50,7 +50,6 @@ resample_toolbutton BITMAP "bitmaps/resample.bmp" timing_processor_toolbutton BITMAP "bitmaps/timing_processor.bmp" shift_times_toolbutton BITMAP "bitmaps/shift_times.bmp" jumpto_button BITMAP "bitmaps/jumpto.bmp" -jumpto_disable_button BITMAP "bitmaps/jumpto_disable.bmp" contents_button BITMAP "bitmaps/contents.bmp" zoom_in_button BITMAP "bitmaps/zoom_in.bmp" zoom_out_button BITMAP "bitmaps/zoom_out.bmp" @@ -62,34 +61,22 @@ substart_to_video BITMAP "bitmaps/substart_to_video.bmp" subend_to_video BITMAP "bitmaps/subend_to_video.bmp" video_to_substart BITMAP "bitmaps/video_to_substart.bmp" video_to_subend BITMAP "bitmaps/video_to_subend.bmp" -substart_to_video_disable BITMAP "bitmaps/substart_to_video_disable.bmp" -subend_to_video_disable BITMAP "bitmaps/subend_to_video_disable.bmp" -video_to_substart_disable BITMAP "bitmaps/video_to_substart_disable.bmp" -video_to_subend_disable BITMAP "bitmaps/video_to_subend_disable.bmp" snap_subs_to_scene BITMAP "bitmaps/snap_to_scene.bmp" -snap_subs_to_scene_disable BITMAP "bitmaps/snap_to_scene_disable.bmp" copy_button BITMAP "bitmaps/copy.bmp" paste_button BITMAP "bitmaps/paste.bmp" paste_over_button BITMAP "bitmaps/paste_over.bmp" cut_button BITMAP "bitmaps/cut.bmp" undo_button BITMAP "bitmaps/undo.bmp" redo_button BITMAP "bitmaps/redo.bmp" -copy_disable_button BITMAP "bitmaps/copy_disable.bmp" -paste_disable_button BITMAP "bitmaps/paste_disable.bmp" -cut_disable_button BITMAP "bitmaps/cut_disable.bmp" -undo_disable_button BITMAP "bitmaps/undo_disable.bmp" -redo_disable_button BITMAP "bitmaps/redo_disable.bmp" irc_button BITMAP "bitmaps/irc.bmp" find_button BITMAP "bitmaps/find.bmp" find_next_button BITMAP "bitmaps/find_next.bmp" replace_button BITMAP "bitmaps/replace.bmp" delete_button BITMAP "bitmaps/delete.bmp" -delete_disable_button BITMAP "bitmaps/delete_disable.bmp" null_button BITMAP "bitmaps/null_button.bmp" select_visible_button BITMAP "bitmaps/select_visible.bmp" toggle_tag_hiding BITMAP "bitmaps/toggle_tag_hiding.bmp" shift_to_frame BITMAP "bitmaps/shift_to_frame.bmp" -shift_to_frame_disable BITMAP "bitmaps/shift_to_frame_disable.bmp" bugtracker_button BITMAP "bitmaps/bugtracker.bmp" website_button BITMAP "bitmaps/website.bmp" forums_button BITMAP "bitmaps/forums.bmp" diff --git a/aegisub/utils.cpp b/aegisub/utils.cpp index 9cacd87c6..1874e1f7b 100644 --- a/aegisub/utils.cpp +++ b/aegisub/utils.cpp @@ -190,10 +190,11 @@ wxString PrettySize(int bytes) { ////////////////////////////////// // Append a menu item with bitmap -void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp) { +wxMenuItem* AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp) { wxMenuItem *cur = new wxMenuItem(parentMenu,id,text,help); cur->SetBitmap(bmp); parentMenu->Append(cur); + return cur; } diff --git a/aegisub/utils.h b/aegisub/utils.h index 17b6babda..6f36a4be0 100644 --- a/aegisub/utils.h +++ b/aegisub/utils.h @@ -53,7 +53,7 @@ wxString PrettyFloatD(double src); wxString FloatToString(double value); wxString IntegerToString(int value); wxString PrettySize(int bytes); -void AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp); +wxMenuItem *AppendBitmapMenuItem (wxMenu* parentMenu,int id,wxString text,wxString help,wxBitmap bmp); int SmallestPowerOf2(int x);