From 6ca0349fc82b0c41b05a8983b624bf2ed3f73f1f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 25 Dec 2013 13:36:37 -0800 Subject: [PATCH] Simplify icon handling Eliminate the pointless runtime command name -> icon map and just make commands responsible for their icons. Don't bother predecoding and caching icons since it wastes some RAM (~10 MB) and decoding icons takes a trivial amount of time. Fix a few places where icons were being set for the wrong command names. --- aegisub/build/Aegisub/Aegisub.vcxproj | 2 - aegisub/build/Aegisub/Aegisub.vcxproj.filters | 6 - aegisub/src/command/Makefile.inc | 3 - aegisub/src/command/app.cpp | 7 + aegisub/src/command/audio.cpp | 20 ++ aegisub/src/command/automation.cpp | 3 + aegisub/src/command/command.cpp | 5 - aegisub/src/command/command.h | 8 +- aegisub/src/command/edit.cpp | 17 ++ aegisub/src/command/grid.cpp | 4 + aegisub/src/command/help.cpp | 7 + aegisub/src/command/icon.cpp | 182 ------------------ aegisub/src/command/icon.h | 29 --- aegisub/src/command/keyframe.cpp | 4 + aegisub/src/command/recent.cpp | 1 + aegisub/src/command/subtitle.cpp | 12 ++ aegisub/src/command/time.cpp | 10 + aegisub/src/command/timecode.cpp | 4 + aegisub/src/command/tool.cpp | 11 ++ aegisub/src/command/video.cpp | 15 ++ aegisub/src/command/vis_tool.cpp | 8 + aegisub/src/hotkey_data_view_model.cpp | 3 +- aegisub/src/main.cpp | 4 - 23 files changed, 131 insertions(+), 234 deletions(-) delete mode 100644 aegisub/src/command/icon.cpp delete mode 100644 aegisub/src/command/icon.h diff --git a/aegisub/build/Aegisub/Aegisub.vcxproj b/aegisub/build/Aegisub/Aegisub.vcxproj index 92a653fd8..11f7bb8d2 100644 --- a/aegisub/build/Aegisub/Aegisub.vcxproj +++ b/aegisub/build/Aegisub/Aegisub.vcxproj @@ -142,7 +142,6 @@ - @@ -339,7 +338,6 @@ - diff --git a/aegisub/build/Aegisub/Aegisub.vcxproj.filters b/aegisub/build/Aegisub/Aegisub.vcxproj.filters index cb309864e..269bde845 100644 --- a/aegisub/build/Aegisub/Aegisub.vcxproj.filters +++ b/aegisub/build/Aegisub/Aegisub.vcxproj.filters @@ -561,9 +561,6 @@ Video\Providers - - Utilities - Utilities @@ -1088,9 +1085,6 @@ Main UI - - Utilities - Main UI diff --git a/aegisub/src/command/Makefile.inc b/aegisub/src/command/Makefile.inc index 28e1bccb5..49e77d5b1 100644 --- a/aegisub/src/command/Makefile.inc +++ b/aegisub/src/command/Makefile.inc @@ -1,5 +1,3 @@ -command/icon.o: CXXFLAGS += -fno-var-tracking - SRC += \ command/app.cpp \ command/audio.cpp \ @@ -17,7 +15,6 @@ SRC += \ command/vis_tool.cpp SRC += \ - command/icon.cpp \ command/command.cpp HEADER += *.h diff --git a/aegisub/src/command/app.cpp b/aegisub/src/command/app.cpp index 78a931821..988d0efce 100644 --- a/aegisub/src/command/app.cpp +++ b/aegisub/src/command/app.cpp @@ -47,6 +47,7 @@ #include "../dialog_version_check.h" #include "../frame_main.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../main.h" #include "../options.h" #include "../preferences.h" @@ -58,6 +59,7 @@ namespace { struct app_about : public Command { CMD_NAME("app/about") + CMD_ICON(about_menu) STR_MENU("&About") STR_DISP("About") STR_HELP("About Aegisub") @@ -156,6 +158,7 @@ struct app_exit : public Command { struct app_language : public Command { CMD_NAME("app/language") + CMD_ICON(languages_menu) STR_MENU("&Language...") STR_DISP("Language") STR_HELP("Select Aegisub interface language") @@ -180,6 +183,7 @@ struct app_language : public Command { struct app_log : public Command { CMD_NAME("app/log") + CMD_ICON(about_menu) STR_MENU("&Log window") STR_DISP("Log window") STR_HELP("View the event log") @@ -191,6 +195,7 @@ struct app_log : public Command { struct app_new_window : public Command { CMD_NAME("app/new_window") + CMD_ICON(new_window_menu) STR_MENU("New &Window") STR_DISP("New Window") STR_HELP("Open a new application window") @@ -202,6 +207,7 @@ struct app_new_window : public Command { struct app_options : public Command { CMD_NAME("app/options") + CMD_ICON(options_button) STR_MENU("&Options...") STR_DISP("Options") STR_HELP("Configure Aegisub") @@ -217,6 +223,7 @@ struct app_options : public Command { struct app_toggle_global_hotkeys : public Command { CMD_NAME("app/toggle/global_hotkeys") + CMD_ICON(toggle_audio_medusa) STR_MENU("Toggle global hotkey overrides") STR_DISP("Toggle global hotkey overrides") STR_HELP("Toggle global hotkey overrides (Medusa Mode)") diff --git a/aegisub/src/command/audio.cpp b/aegisub/src/command/audio.cpp index 827b70cc2..9e784444d 100644 --- a/aegisub/src/command/audio.cpp +++ b/aegisub/src/command/audio.cpp @@ -40,6 +40,7 @@ #include "../audio_timing.h" #include "../compat.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../selection_controller.h" #include "../utils.h" @@ -61,6 +62,7 @@ namespace { struct audio_close : public validate_audio_open { CMD_NAME("audio/close") + CMD_ICON(close_audio_menu) STR_MENU("&Close Audio") STR_DISP("Close Audio") STR_HELP("Close the currently open audio file") @@ -72,6 +74,7 @@ struct audio_close : public validate_audio_open { struct audio_open : public Command { CMD_NAME("audio/open") + CMD_ICON(open_audio_menu) STR_MENU("&Open Audio File...") STR_DISP("Open Audio File") STR_HELP("Open an audio file") @@ -127,6 +130,7 @@ struct audio_open_noise : public Command { struct audio_open_video : public Command { CMD_NAME("audio/open/video") + CMD_ICON(open_audio_from_video_menu) STR_MENU("Open Audio from &Video") STR_DISP("Open Audio from Video") STR_HELP("Open the audio from the current video file") @@ -220,6 +224,7 @@ struct audio_play_current_selection : public validate_audio_open { struct audio_play_current_line : public validate_audio_open { CMD_NAME("audio/play/line") + CMD_ICON(button_playline) STR_MENU("Play current line") STR_DISP("Play current line") STR_HELP("Play the audio for the current line") @@ -234,6 +239,7 @@ struct audio_play_current_line : public validate_audio_open { struct audio_play_selection : public validate_audio_open { CMD_NAME("audio/play/selection") + CMD_ICON(button_playsel) STR_MENU("Play audio selection") STR_DISP("Play audio selection") STR_HELP("Play audio until the end of the selection is reached") @@ -262,6 +268,7 @@ struct audio_play_toggle : public validate_audio_open { struct audio_stop : public Command { CMD_NAME("audio/stop") + CMD_ICON(button_stop) STR_MENU("Stop playing") STR_DISP("Stop playing") STR_HELP("Stop audio and video playback") @@ -279,6 +286,7 @@ struct audio_stop : public Command { struct audio_play_before : public validate_audio_open { CMD_NAME("audio/play/selection/before") + CMD_ICON(button_playfivehbefore) STR_MENU("Play 500 ms before selection") STR_DISP("Play 500 ms before selection") STR_HELP("Play 500 ms before selection") @@ -292,6 +300,7 @@ struct audio_play_before : public validate_audio_open { struct audio_play_after : public validate_audio_open { CMD_NAME("audio/play/selection/after") + CMD_ICON(button_playfivehafter) STR_MENU("Play 500 ms after selection") STR_DISP("Play 500 ms after selection") STR_HELP("Play 500 ms after selection") @@ -305,6 +314,7 @@ struct audio_play_after : public validate_audio_open { struct audio_play_end : public validate_audio_open { CMD_NAME("audio/play/selection/end") + CMD_ICON(button_playlastfiveh) STR_MENU("Play last 500 ms of selection") STR_DISP("Play last 500 ms of selection") STR_HELP("Play last 500 ms of selection") @@ -318,6 +328,7 @@ struct audio_play_end : public validate_audio_open { struct audio_play_begin : public validate_audio_open { CMD_NAME("audio/play/selection/begin") + CMD_ICON(button_playfirstfiveh) STR_MENU("Play first 500 ms of selection") STR_DISP("Play first 500 ms of selection") STR_HELP("Play first 500 ms of selection") @@ -333,6 +344,7 @@ struct audio_play_begin : public validate_audio_open { struct audio_play_to_end : public validate_audio_open { CMD_NAME("audio/play/to_end") + CMD_ICON(button_playtoend) STR_MENU("Play from selection start to end of file") STR_DISP("Play from selection start to end of file") STR_HELP("Play from selection start to end of file") @@ -345,6 +357,7 @@ struct audio_play_to_end : public validate_audio_open { struct audio_commit : public validate_audio_open { CMD_NAME("audio/commit") + CMD_ICON(button_audio_commit) STR_MENU("Commit") STR_DISP("Commit") STR_HELP("Commit any pending audio timing changes") @@ -403,6 +416,7 @@ struct audio_commit_stay : public validate_audio_open { struct audio_go_to : public validate_audio_open { CMD_NAME("audio/go_to") + CMD_ICON(button_audio_goto) STR_MENU("Go to selection") STR_DISP("Go to selection") STR_HELP("Scroll the audio display to center on the current audio selection") @@ -440,6 +454,7 @@ static inline void toggle(const char *opt) { struct audio_autoscroll : public Command { CMD_NAME("audio/opt/autoscroll") + CMD_ICON(toggle_audio_autoscroll) STR_MENU("Auto scroll audio display to selected line") STR_DISP("Auto scroll audio display to selected line") STR_HELP("Auto scroll audio display to selected line") @@ -456,6 +471,7 @@ struct audio_autoscroll : public Command { struct audio_autocommit : public Command { CMD_NAME("audio/opt/autocommit") + CMD_ICON(toggle_audio_autocommit) STR_MENU("Automatically commit all changes") STR_DISP("Automatically commit all changes") STR_HELP("Automatically commit all changes") @@ -472,6 +488,7 @@ struct audio_autocommit : public Command { struct audio_autonext : public Command { CMD_NAME("audio/opt/autonext") + CMD_ICON(toggle_audio_nextcommit) STR_MENU("Auto go to next line on commit") STR_DISP("Auto go to next line on commit") STR_HELP("Automatically go to next line on commit") @@ -488,6 +505,7 @@ struct audio_autonext : public Command { struct audio_toggle_spectrum : public Command { CMD_NAME("audio/opt/spectrum") + CMD_ICON(toggle_audio_spectrum) STR_MENU("Spectrum analyzer mode") STR_DISP("Spectrum analyzer mode") STR_HELP("Spectrum analyzer mode") @@ -504,6 +522,7 @@ struct audio_toggle_spectrum : public Command { struct audio_vertical_link : public Command { CMD_NAME("audio/opt/vertical_link") + CMD_ICON(toggle_audio_link) STR_MENU("Link vertical zoom and volume sliders") STR_DISP("Link vertical zoom and volume sliders") STR_HELP("Link vertical zoom and volume sliders") @@ -520,6 +539,7 @@ struct audio_vertical_link : public Command { struct audio_karaoke : public Command { CMD_NAME("audio/karaoke") + CMD_ICON(kara_mode) STR_MENU("Toggle karaoke mode") STR_DISP("Toggle karaoke mode") STR_HELP("Toggle karaoke mode") diff --git a/aegisub/src/command/automation.cpp b/aegisub/src/command/automation.cpp index 9055338d1..8ad1ee2f3 100644 --- a/aegisub/src/command/automation.cpp +++ b/aegisub/src/command/automation.cpp @@ -38,6 +38,7 @@ #include "../dialog_manager.h" #include "../frame_main.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../main.h" #include "../options.h" #include "../utils.h" @@ -75,6 +76,7 @@ struct reload_autoload : public Command { struct open_manager : public Command { CMD_NAME("am/manager") + CMD_ICON(automation_toolbutton) STR_MENU("&Automation...") STR_DISP("Automation") STR_HELP("Open automation manager") @@ -86,6 +88,7 @@ struct open_manager : public Command { struct meta : public Command { CMD_NAME("am/meta") + CMD_ICON(automation_toolbutton) STR_MENU("&Automation...") STR_DISP("Automation") STR_HELP("Open automation manager. Ctrl: Rescan autoload folder. Ctrl+Shift: Rescan autoload folder and reload all automation scripts") diff --git a/aegisub/src/command/command.cpp b/aegisub/src/command/command.cpp index 41f9987a6..2feaaf60e 100644 --- a/aegisub/src/command/command.cpp +++ b/aegisub/src/command/command.cpp @@ -14,7 +14,6 @@ #include "command.h" -#include "icon.h" #include "../compat.h" #include @@ -50,10 +49,6 @@ namespace cmd { cmd(c); } - wxBitmap const& Command::Icon(int size) const { - return icon::get(name(), size); - } - std::vector get_registered_commands() { std::vector ret; ret.reserve(cmd_map.size()); diff --git a/aegisub/src/command/command.h b/aegisub/src/command/command.h index a67cade0c..d073bf55c 100644 --- a/aegisub/src/command/command.h +++ b/aegisub/src/command/command.h @@ -39,6 +39,12 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandIconInvalid, CommandError, "command/icon/ #define STR_HELP(a) wxString StrHelp() const { return _(a); } #define CMD_TYPE(a) int Type() const { using namespace cmd; return a; } +#define CMD_ICON(icon) wxBitmap Icon(int size) const override { \ + if (size == 32) return GETIMAGE(icon##_32); \ + if (size == 24) return GETIMAGE(icon##_24); \ + return GETIMAGE(icon##_16); \ +} + #define COMMAND_GROUP(cname, cmdname, menu, disp, help) \ struct cname : public Command { \ CMD_NAME(cmdname) \ @@ -101,7 +107,7 @@ namespace cmd { /// Request icon. /// @param size Icon size. - wxBitmap const& Icon(int size) const; + virtual wxBitmap Icon(int size) const { return wxBitmap{}; } /// Command function virtual void operator()(agi::Context *c)=0; diff --git a/aegisub/src/command/edit.cpp b/aegisub/src/command/edit.cpp index 204a672d6..cdbd65130 100644 --- a/aegisub/src/command/edit.cpp +++ b/aegisub/src/command/edit.cpp @@ -43,6 +43,7 @@ #include "../dialog_search_replace.h" #include "../include/aegisub/context.h" #include "../initial_line_state.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../search_replace_engine.h" #include "../selection_controller.h" @@ -331,6 +332,7 @@ void show_color_picker(const agi::Context *c, agi::Color (AssStyle::*field), con struct edit_color_primary : public Command { CMD_NAME("edit/color/primary") + CMD_ICON(button_color_one) STR_MENU("Primary Color...") STR_DISP("Primary Color") STR_HELP("Set the primary fill color (\\c) at the cursor position") @@ -342,6 +344,7 @@ struct edit_color_primary : public Command { struct edit_color_secondary : public Command { CMD_NAME("edit/color/secondary") + CMD_ICON(button_color_two) STR_MENU("Secondary Color...") STR_DISP("Secondary Color") STR_HELP("Set the secondary (karaoke) fill color (\\2c) at the cursor position") @@ -353,6 +356,7 @@ struct edit_color_secondary : public Command { struct edit_color_outline : public Command { CMD_NAME("edit/color/outline") + CMD_ICON(button_color_three) STR_MENU("Outline Color...") STR_DISP("Outline Color") STR_HELP("Set the outline color (\\3c) at the cursor position") @@ -364,6 +368,7 @@ struct edit_color_outline : public Command { struct edit_color_shadow : public Command { CMD_NAME("edit/color/shadow") + CMD_ICON(button_color_four) STR_MENU("Shadow Color...") STR_DISP("Shadow Color") STR_HELP("Set the shadow color (\\4c) at the cursor position") @@ -375,6 +380,7 @@ struct edit_color_shadow : public Command { struct edit_style_bold : public Command { CMD_NAME("edit/style/bold") + CMD_ICON(button_bold) STR_MENU("Toggle Bold") STR_DISP("Toggle Bold") STR_HELP("Toggle bold (\\b) for the current selection or at the current cursor position") @@ -386,6 +392,7 @@ struct edit_style_bold : public Command { struct edit_style_italic : public Command { CMD_NAME("edit/style/italic") + CMD_ICON(button_italics) STR_MENU("Toggle Italics") STR_DISP("Toggle Italics") STR_HELP("Toggle italics (\\i) for the current selection or at the current cursor position") @@ -397,6 +404,7 @@ struct edit_style_italic : public Command { struct edit_style_underline : public Command { CMD_NAME("edit/style/underline") + CMD_ICON(button_underline) STR_MENU("Toggle Underline") STR_DISP("Toggle Underline") STR_HELP("Toggle underline (\\u) for the current selection or at the current cursor position") @@ -408,6 +416,7 @@ struct edit_style_underline : public Command { struct edit_style_strikeout : public Command { CMD_NAME("edit/style/strikeout") + CMD_ICON(button_strikeout) STR_MENU("Toggle Strikeout") STR_DISP("Toggle Strikeout") STR_HELP("Toggle strikeout (\\s) for the current selection or at the current cursor position") @@ -419,6 +428,7 @@ struct edit_style_strikeout : public Command { struct edit_font : public Command { CMD_NAME("edit/font") + CMD_ICON(button_fontname) STR_MENU("Font Face...") STR_DISP("Font Face") STR_HELP("Select a font face and size") @@ -464,6 +474,7 @@ struct edit_font : public Command { struct edit_find_replace : public Command { CMD_NAME("edit/find_replace") + CMD_ICON(find_replace_menu) STR_MENU("Find and R&eplace...") STR_DISP("Find and Replace") STR_HELP("Find and replace words in subtitles") @@ -530,6 +541,7 @@ static void delete_lines(agi::Context *c, wxString const& commit_message) { struct edit_line_copy : public validate_sel_nonempty { CMD_NAME("edit/line/copy") + CMD_ICON(copy_button) STR_MENU("&Copy Lines") STR_DISP("Copy Lines") STR_HELP("Copy subtitles to the clipboard") @@ -552,6 +564,7 @@ struct edit_line_copy : public validate_sel_nonempty { struct edit_line_cut: public validate_sel_nonempty { CMD_NAME("edit/line/cut") + CMD_ICON(cut_button) STR_MENU("Cu&t Lines") STR_DISP("Cut Lines") STR_HELP("Cut subtitles") @@ -568,6 +581,7 @@ struct edit_line_cut: public validate_sel_nonempty { struct edit_line_delete : public validate_sel_nonempty { CMD_NAME("edit/line/delete") + CMD_ICON(delete_button) STR_MENU("De&lete Lines") STR_DISP("Delete Lines") STR_HELP("Delete currently selected lines") @@ -786,6 +800,7 @@ static bool try_paste_lines(agi::Context *c) { struct edit_line_paste : public Command { CMD_NAME("edit/line/paste") + CMD_ICON(paste_button) STR_MENU("&Paste Lines") STR_DISP("Paste Lines") STR_HELP("Paste subtitles") @@ -1057,6 +1072,7 @@ struct edit_line_split_video : public validate_video_and_sel_nonempty { struct edit_redo : public Command { CMD_NAME("edit/redo") + CMD_ICON(redo_button) STR_HELP("Redo last undone action") CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME) @@ -1082,6 +1098,7 @@ struct edit_redo : public Command { struct edit_undo : public Command { CMD_NAME("edit/undo") + CMD_ICON(undo_button) STR_HELP("Undo last action") CMD_TYPE(COMMAND_VALIDATE | COMMAND_DYNAMIC_NAME) diff --git a/aegisub/src/command/grid.cpp b/aegisub/src/command/grid.cpp index cd6985e06..2378718c6 100644 --- a/aegisub/src/command/grid.cpp +++ b/aegisub/src/command/grid.cpp @@ -38,6 +38,7 @@ #include "../audio_controller.h" #include "../audio_timing.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../selection_controller.h" #include "../utils.h" @@ -60,6 +61,7 @@ struct grid_line_next : public Command { struct grid_line_next_create : public Command { CMD_NAME("grid/line/next/create") + CMD_ICON(button_audio_commit) STR_MENU("Next Line") STR_DISP("Next Line") STR_HELP("Move to the next subtitle line, creating a new one if needed") @@ -250,6 +252,7 @@ struct grid_sort_style_selected : public validate_sel_multiple { struct grid_tag_cycle_hiding : public Command { CMD_NAME("grid/tag/cycle_hiding") + CMD_ICON(toggle_tag_hiding) STR_MENU("Cycle Tag Hiding Mode") STR_DISP("Cycle Tag Hiding Mode") STR_HELP("Cycle through tag hiding modes") @@ -377,6 +380,7 @@ struct grid_move_down : public Command { struct grid_swap : public Command { CMD_NAME("grid/swap") + CMD_ICON(arrow_sort) STR_MENU("Swap Lines") STR_DISP("Swap Lines") STR_HELP("Swap the two selected lines") diff --git a/aegisub/src/command/help.cpp b/aegisub/src/command/help.cpp index d645225d3..9d5fc33f5 100644 --- a/aegisub/src/command/help.cpp +++ b/aegisub/src/command/help.cpp @@ -35,6 +35,7 @@ #include "../help_button.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include @@ -46,6 +47,7 @@ namespace { struct help_bugs : public Command { CMD_NAME("help/bugs") + CMD_ICON(bugtracker_button) STR_MENU("&Bug Tracker...") STR_DISP("Bug Tracker") STR_HELP("Visit Aegisub's bug tracker to report bugs and request new features") @@ -66,6 +68,7 @@ struct help_bugs : public Command { struct help_contents : public Command { CMD_NAME("help/contents") + CMD_ICON(contents_button) STR_MENU("&Contents") STR_DISP("Contents") STR_HELP("Help topics") @@ -77,6 +80,7 @@ struct help_contents : public Command { struct help_forums : public Command { CMD_NAME("help/forums") + CMD_ICON(forums_button) STR_MENU("&Forums") STR_DISP("Forums") STR_HELP("Visit Aegisub's forums") @@ -88,6 +92,7 @@ struct help_forums : public Command { struct help_irc : public Command { CMD_NAME("help/irc") + CMD_ICON(irc_button) STR_MENU("&IRC Channel") STR_DISP("IRC Channel") STR_HELP("Visit Aegisub's official IRC channel") @@ -99,6 +104,7 @@ struct help_irc : public Command { struct help_video : public Command { CMD_NAME("help/video") + CMD_ICON(visual_help) STR_MENU("&Visual Typesetting") STR_DISP("Visual Typesetting") STR_HELP("Open the manual page for Visual Typesetting") @@ -110,6 +116,7 @@ struct help_video : public Command { struct help_website : public Command { CMD_NAME("help/website") + CMD_ICON(website_button) STR_MENU("&Website") STR_DISP("Website") STR_HELP("Visit Aegisub's official website") diff --git a/aegisub/src/command/icon.cpp b/aegisub/src/command/icon.cpp deleted file mode 100644 index 552e5954e..000000000 --- a/aegisub/src/command/icon.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright (c) 2010, Amar Takhar -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -#include "../config.h" - -#include "icon.h" - -#include - -#include - -#include "../libresrc/libresrc.h" - -namespace icon { -typedef std::map iconMap; - -iconMap icon16; -iconMap icon24; -iconMap icon32; - -wxBitmap const& get(std::string const& name, const int size) { - // XXX: This code will go away with dynamic icon generation so I'm not - // concerned about it. - iconMap::iterator index; - if (size == 32) { - if ((index = icon32.find(name)) != icon32.end()) - return index->second; - } - else if (size == 24) { - if ((index = icon24.find(name)) != icon24.end()) - return index->second; - } - else { - if ((index = icon16.find(name)) != icon16.end()) - return index->second; - } - - LOG_W("icon/get") << "Icon not found: " << name << " " << size; - - static wxBitmap bad; - return bad; -} - -#define INSERT_ICON(a, b) \ - icon16.insert(std::make_pair(a, GETIMAGE(b##_16))); \ - icon24.insert(std::make_pair(a, GETIMAGE(b##_24))); \ - icon32.insert(std::make_pair(a, GETIMAGE(b##_32))); - -void icon_init() { - // Seems that WX doesn't install the handlers early enough for our use. - auto handler = new wxPNGHandler(); - wxImage::AddHandler(handler); - - LOG_D("icon/init") << "Generating 24x24, 16x16 icons"; - -INSERT_ICON("am/manager", automation_toolbutton) -INSERT_ICON("am/meta", automation_toolbutton) -INSERT_ICON("app/about", about_menu) -INSERT_ICON("app/language", languages_menu) -INSERT_ICON("app/log", about_menu) -INSERT_ICON("app/new_window", new_window_menu) -INSERT_ICON("app/options", options_button) -INSERT_ICON("app/toggle/global_hotkeys", toggle_audio_medusa) -INSERT_ICON("audio/close", close_audio_menu) -INSERT_ICON("audio/commit", button_audio_commit) -INSERT_ICON("audio/go_to", button_audio_goto) -INSERT_ICON("audio/karaoke", kara_mode) -INSERT_ICON("audio/open", open_audio_menu) -INSERT_ICON("audio/open/video", open_audio_from_video_menu) -INSERT_ICON("audio/opt/autocommit", toggle_audio_autocommit) -INSERT_ICON("audio/opt/autonext", toggle_audio_nextcommit) -INSERT_ICON("audio/opt/autoscroll", toggle_audio_autoscroll) -INSERT_ICON("audio/opt/spectrum", toggle_audio_spectrum) -INSERT_ICON("audio/opt/vertical_link", toggle_audio_link) -INSERT_ICON("audio/play/selection", button_playsel) -INSERT_ICON("audio/play/line", button_playline) -INSERT_ICON("audio/play/selection/after", button_playfivehafter) -INSERT_ICON("audio/play/selection/before", button_playfivehbefore) -INSERT_ICON("audio/play/selection/begin", button_playfirstfiveh) -INSERT_ICON("audio/play/selection/end", button_playlastfiveh) -INSERT_ICON("audio/play/to_end", button_playtoend) -INSERT_ICON("audio/stop", button_stop) -INSERT_ICON("edit/color/primary", button_color_one); -INSERT_ICON("edit/color/secondary", button_color_two); -INSERT_ICON("edit/color/outline", button_color_three); -INSERT_ICON("edit/color/shadow", button_color_four); -INSERT_ICON("edit/font", button_fontname); -INSERT_ICON("edit/line/copy", copy_button) -INSERT_ICON("edit/line/cut", cut_button) -INSERT_ICON("edit/line/delete", delete_button) -INSERT_ICON("edit/line/paste", paste_button) -INSERT_ICON("edit/line/swap", arrow_sort) -INSERT_ICON("edit/style/bold", button_bold) -INSERT_ICON("edit/style/italic", button_italics) -INSERT_ICON("edit/style/strikeout", button_strikeout) -INSERT_ICON("edit/style/underline", button_underline) -INSERT_ICON("edit/redo", redo_button) -INSERT_ICON("edit/search_replace", find_replace_menu) -INSERT_ICON("edit/undo", undo_button) -INSERT_ICON("grid/line/next/create", button_audio_commit) -INSERT_ICON("grid/tag/cycle_hiding", toggle_tag_hiding) -INSERT_ICON("help/bugs", bugtracker_button) -INSERT_ICON("help/contents", contents_button) -INSERT_ICON("help/forums", forums_button) -INSERT_ICON("help/irc", irc_button) -INSERT_ICON("help/video", visual_help) -INSERT_ICON("help/website", website_button) -INSERT_ICON("keyframe/close", close_keyframes_menu) -INSERT_ICON("keyframe/open", open_keyframes_menu) -INSERT_ICON("keyframe/save", save_keyframes_menu) -INSERT_ICON("subtitle/attachment", attach_button) -INSERT_ICON("subtitle/find", find_button) -INSERT_ICON("subtitle/find/next", find_next_menu) -INSERT_ICON("subtitle/new", new_toolbutton) -INSERT_ICON("subtitle/open", open_toolbutton) -INSERT_ICON("subtitle/open/charset", open_with_toolbutton) -INSERT_ICON("subtitle/properties", properties_toolbutton) -INSERT_ICON("subtitle/save", save_toolbutton) -INSERT_ICON("subtitle/save/as", save_as_toolbutton) -INSERT_ICON("subtitle/select/visible", select_visible_button) -INSERT_ICON("subtitle/spellcheck", spellcheck_toolbutton) -INSERT_ICON("time/frame/current", shift_to_frame) -INSERT_ICON("time/lead/in", button_leadin) -INSERT_ICON("time/lead/out", button_leadout) -INSERT_ICON("time/next", button_next) -INSERT_ICON("time/prev", button_prev) -INSERT_ICON("time/shift", shift_times_toolbutton) -INSERT_ICON("time/snap/end_video", subend_to_video) -INSERT_ICON("time/snap/scene", snap_subs_to_scene) -INSERT_ICON("time/snap/start_video", substart_to_video) -INSERT_ICON("timecode/close", close_timecodes_menu) -INSERT_ICON("timecode/open", open_timecodes_menu) -INSERT_ICON("timecode/save", save_timecodes_menu) -INSERT_ICON("tool/assdraw", assdraw) -INSERT_ICON("tool/export", export_menu) -INSERT_ICON("tool/font_collector", font_collector_button) -INSERT_ICON("tool/line/select", select_lines_button) -INSERT_ICON("tool/resampleres", resample_toolbutton) -INSERT_ICON("tool/style/assistant", styling_toolbutton) -INSERT_ICON("tool/style/manager", style_toolbutton) -INSERT_ICON("tool/time/kanji", kara_timing_copier) -INSERT_ICON("tool/time/kanji", spellcheck_toolbutton) -INSERT_ICON("tool/time/postprocess", timing_processor_toolbutton) -INSERT_ICON("tool/translation_assistant", translation_toolbutton) -INSERT_ICON("video/close", close_video_menu) -INSERT_ICON("video/detach", detach_video_menu) -INSERT_ICON("video/details", show_video_details_menu) -INSERT_ICON("video/jump", jumpto_button) -INSERT_ICON("video/jump/end", video_to_subend) -INSERT_ICON("video/jump/start", video_to_substart) -INSERT_ICON("video/open", open_video_menu) -INSERT_ICON("video/open/dummy", use_dummy_video_menu) -INSERT_ICON("video/opt/autoscroll", toggle_video_autoscroll) -INSERT_ICON("video/play", button_play) -INSERT_ICON("video/play/line", button_playline) -INSERT_ICON("video/stop", button_pause) -INSERT_ICON("video/tool/clip", visual_clip) -INSERT_ICON("video/tool/cross", visual_standard) -INSERT_ICON("video/tool/drag", visual_move) -INSERT_ICON("video/tool/rotate/xy", visual_rotatexy) -INSERT_ICON("video/tool/rotate/z", visual_rotatez) -INSERT_ICON("video/tool/scale", visual_scale) -INSERT_ICON("video/tool/vector_clip", visual_vector_clip) -INSERT_ICON("video/zoom/in", zoom_in_button) -INSERT_ICON("video/zoom/out", zoom_out_button) - - // Remove the handler to avoid "Duplicate handler" warnings from WX since - // it will attempt to install all the handlers later on. - wxImage::RemoveHandler(handler->GetName()); -} -} // namespace icon diff --git a/aegisub/src/command/icon.h b/aegisub/src/command/icon.h deleted file mode 100644 index 8a3d441a6..000000000 --- a/aegisub/src/command/icon.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2010, Amar Takhar -// -// Permission to use, copy, modify, and distribute this software for any -// purpose with or without fee is hereby granted, provided that the above -// copyright notice and this permission notice appear in all copies. -// -// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -/// @file icon.h -/// @brief Icon for commands. -/// @ingroup command - -#include - -#include - -DEFINE_BASE_EXCEPTION_NOINNER(IconError, agi::Exception) -DEFINE_SIMPLE_EXCEPTION_NOINNER(IconInvalid, IconError, "icon/invalid") - -namespace icon { - void icon_init(); - wxBitmap const& get(std::string const& name, int size); -} diff --git a/aegisub/src/command/keyframe.cpp b/aegisub/src/command/keyframe.cpp index 523c306cf..219ee968b 100644 --- a/aegisub/src/command/keyframe.cpp +++ b/aegisub/src/command/keyframe.cpp @@ -34,6 +34,7 @@ #include "command.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../utils.h" #include "../video_context.h" @@ -45,6 +46,7 @@ namespace { struct keyframe_close : public Command { CMD_NAME("keyframe/close") + CMD_ICON(close_keyframes_menu) STR_MENU("Close Keyframes") STR_DISP("Close Keyframes") STR_HELP("Discard the currently loaded keyframes and use those from the video, if any") @@ -61,6 +63,7 @@ struct keyframe_close : public Command { struct keyframe_open : public Command { CMD_NAME("keyframe/open") + CMD_ICON(open_keyframes_menu) STR_MENU("Open Keyframes...") STR_DISP("Open Keyframes") STR_HELP("Open a keyframe list file") @@ -79,6 +82,7 @@ struct keyframe_open : public Command { struct keyframe_save : public Command { CMD_NAME("keyframe/save") + CMD_ICON(save_keyframes_menu) STR_MENU("Save Keyframes...") STR_DISP("Save Keyframes") STR_HELP("Save the current list of keyframes to a file") diff --git a/aegisub/src/command/recent.cpp b/aegisub/src/command/recent.cpp index 5690a404f..98616a710 100644 --- a/aegisub/src/command/recent.cpp +++ b/aegisub/src/command/recent.cpp @@ -34,6 +34,7 @@ #include "../audio_controller.h" #include "../compat.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../main.h" #include "../options.h" #include "../subs_controller.h" diff --git a/aegisub/src/command/subtitle.cpp b/aegisub/src/command/subtitle.cpp index 879671cd5..a91f1bece 100644 --- a/aegisub/src/command/subtitle.cpp +++ b/aegisub/src/command/subtitle.cpp @@ -43,6 +43,7 @@ #include "../dialog_search_replace.h" #include "../dialog_spellchecker.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../main.h" #include "../options.h" #include "../search_replace_engine.h" @@ -77,6 +78,7 @@ struct validate_nonempty_selection_video_loaded : public Command { struct subtitle_attachment : public Command { CMD_NAME("subtitle/attachment") + CMD_ICON(attach_button) STR_MENU("A&ttachments...") STR_DISP("Attachments") STR_HELP("Open the attachment manager dialog") @@ -89,6 +91,7 @@ struct subtitle_attachment : public Command { struct subtitle_find : public Command { CMD_NAME("subtitle/find") + CMD_ICON(find_button) STR_MENU("&Find...") STR_DISP("Find") STR_HELP("Search for text the in subtitles") @@ -101,6 +104,7 @@ struct subtitle_find : public Command { struct subtitle_find_next : public Command { CMD_NAME("subtitle/find/next") + CMD_ICON(find_next_menu) STR_MENU("Find &Next") STR_DISP("Find Next") STR_HELP("Find next match of last search") @@ -217,6 +221,7 @@ struct subtitle_insert_before_videotime : public validate_nonempty_selection_vid struct subtitle_new : public Command { CMD_NAME("subtitle/new") + CMD_ICON(new_toolbutton) STR_MENU("&New Subtitles") STR_DISP("New Subtitles") STR_HELP("New subtitles") @@ -229,6 +234,7 @@ struct subtitle_new : public Command { struct subtitle_open : public Command { CMD_NAME("subtitle/open") + CMD_ICON(open_toolbutton) STR_MENU("&Open Subtitles...") STR_DISP("Open Subtitles") STR_HELP("Open a subtitles file") @@ -257,6 +263,7 @@ struct subtitle_open_autosave : public Command { struct subtitle_open_charset : public Command { CMD_NAME("subtitle/open/charset") + CMD_ICON(open_with_toolbutton) STR_MENU("Open Subtitles with &Charset...") STR_DISP("Open Subtitles with Charset") STR_HELP("Open a subtitles file with a specific file encoding") @@ -293,6 +300,7 @@ struct subtitle_open_video : public Command { struct subtitle_properties : public Command { CMD_NAME("subtitle/properties") + CMD_ICON(properties_toolbutton) STR_MENU("&Properties...") STR_DISP("Properties") STR_HELP("Open script properties window") @@ -328,6 +336,7 @@ static void save_subtitles(agi::Context *c, agi::fs::path filename) { struct subtitle_save : public Command { CMD_NAME("subtitle/save") + CMD_ICON(save_toolbutton) STR_MENU("&Save Subtitles") STR_DISP("Save Subtitles") STR_HELP("Save the current subtitles") @@ -344,6 +353,7 @@ struct subtitle_save : public Command { struct subtitle_save_as : public Command { CMD_NAME("subtitle/save/as") + CMD_ICON(save_as_toolbutton) STR_MENU("Save Subtitles &as...") STR_DISP("Save Subtitles as") STR_HELP("Save subtitles with another name") @@ -370,6 +380,7 @@ struct subtitle_select_all : public Command { struct subtitle_select_visible : public Command { CMD_NAME("subtitle/select/visible") + CMD_ICON(select_visible_button) STR_MENU("Select Visible") STR_DISP("Select Visible") STR_HELP("Select all dialogue lines that visible on the current video frame") @@ -404,6 +415,7 @@ struct subtitle_select_visible : public Command { struct subtitle_spellcheck : public Command { CMD_NAME("subtitle/spellcheck") + CMD_ICON(spellcheck_toolbutton) STR_MENU("Spell &Checker...") STR_DISP("Spell Checker") STR_HELP("Open spell checker") diff --git a/aegisub/src/command/time.cpp b/aegisub/src/command/time.cpp index 747634aa4..cdd2b423f 100644 --- a/aegisub/src/command/time.cpp +++ b/aegisub/src/command/time.cpp @@ -40,6 +40,7 @@ #include "../dialog_manager.h" #include "../dialog_shift_times.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../selection_controller.h" #include "../video_context.h" @@ -130,6 +131,7 @@ struct time_continuous_start : public validate_adjoinable { struct time_frame_current : public validate_video_loaded { CMD_NAME("time/frame/current") + CMD_ICON(shift_to_frame) STR_MENU("Shift to &Current Frame") STR_DISP("Shift to Current Frame") STR_HELP("Shift selection so that the active line starts at current frame") @@ -156,6 +158,7 @@ struct time_frame_current : public validate_video_loaded { struct time_shift : public Command { CMD_NAME("time/shift") + CMD_ICON(shift_times_toolbutton) STR_MENU("S&hift Times...") STR_DISP("Shift Times") STR_HELP("Shift subtitles by time or frames") @@ -185,6 +188,7 @@ static void snap_subs_video(agi::Context *c, bool set_start) { struct time_snap_end_video : public validate_video_loaded { CMD_NAME("time/snap/end_video") + CMD_ICON(subend_to_video) STR_MENU("Snap &End to Video") STR_DISP("Snap End to Video") STR_HELP("Set end of selected subtitles to current video frame") @@ -196,6 +200,7 @@ struct time_snap_end_video : public validate_video_loaded { struct time_snap_scene : public validate_video_loaded { CMD_NAME("time/snap/scene") + CMD_ICON(snap_subs_to_scene) STR_MENU("Snap to S&cene") STR_DISP("Snap to Scene") STR_HELP("Set start and end of subtitles to the keyframes around current video frame") @@ -254,6 +259,7 @@ struct time_add_lead_both : public Command { struct time_add_lead_in : public Command { CMD_NAME("time/lead/in") + CMD_ICON(button_leadin) STR_MENU("Add lead in") STR_DISP("Add lead in") STR_HELP("Add the lead in time to the selected lines") @@ -265,6 +271,7 @@ struct time_add_lead_in : public Command { struct time_add_lead_out : public Command { CMD_NAME("time/lead/out") + CMD_ICON(button_leadout) STR_MENU("Add lead out") STR_DISP("Add lead out") STR_HELP("Add the lead out time to the selected lines") @@ -342,6 +349,7 @@ struct time_start_decrease : public Command { struct time_snap_start_video : public validate_video_loaded { CMD_NAME("time/snap/start_video") + CMD_ICON(substart_to_video) STR_MENU("Snap &Start to Video") STR_DISP("Snap Start to Video") STR_HELP("Set start of selected subtitles to current video frame") @@ -353,6 +361,7 @@ struct time_snap_start_video : public validate_video_loaded { struct time_next : public Command { CMD_NAME("time/next") + CMD_ICON(button_next) STR_MENU("Next Line") STR_DISP("Next Line") STR_HELP("Next line or syllable") @@ -364,6 +373,7 @@ struct time_next : public Command { struct time_prev : public Command { CMD_NAME("time/prev") + CMD_ICON(button_prev) STR_MENU("Previous Line") STR_DISP("Previous Line") STR_HELP("Previous line or syllable") diff --git a/aegisub/src/command/timecode.cpp b/aegisub/src/command/timecode.cpp index b45ef053d..653dc201e 100644 --- a/aegisub/src/command/timecode.cpp +++ b/aegisub/src/command/timecode.cpp @@ -34,6 +34,7 @@ #include "command.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../utils.h" #include "../video_context.h" @@ -45,6 +46,7 @@ namespace { struct timecode_close : public Command { CMD_NAME("timecode/close") + CMD_ICON(close_timecodes_menu) STR_MENU("Close Timecodes File") STR_DISP("Close Timecodes File") STR_HELP("Close the currently open timecodes file") @@ -61,6 +63,7 @@ struct timecode_close : public Command { struct timecode_open : public Command { CMD_NAME("timecode/open") + CMD_ICON(open_timecodes_menu) STR_MENU("Open Timecodes File...") STR_DISP("Open Timecodes File") STR_HELP("Open a VFR timecodes v1 or v2 file") @@ -75,6 +78,7 @@ struct timecode_open : public Command { struct timecode_save : public Command { CMD_NAME("timecode/save") + CMD_ICON(save_timecodes_menu) STR_MENU("Save Timecodes File...") STR_DISP("Save Timecodes File") STR_HELP("Save a VFR timecodes v2 file") diff --git a/aegisub/src/command/tool.cpp b/aegisub/src/command/tool.cpp index 96a097e15..b6cecc8bf 100644 --- a/aegisub/src/command/tool.cpp +++ b/aegisub/src/command/tool.cpp @@ -45,6 +45,7 @@ #include "../dialog_timing_processor.h" #include "../dialog_translation.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../options.h" #include "../resolution_resampler.h" #include "../video_context.h" @@ -61,6 +62,7 @@ namespace { struct tool_assdraw : public Command { CMD_NAME("tool/assdraw") + CMD_ICON(assdraw) STR_MENU("ASSDraw3...") STR_DISP("ASSDraw3") STR_HELP("Launch the ASSDraw3 tool for vector drawing") @@ -72,6 +74,7 @@ struct tool_assdraw : public Command { struct tool_export : public Command { CMD_NAME("tool/export") + CMD_ICON(export_menu) STR_MENU("&Export Subtitles...") STR_DISP("Export Subtitles") STR_HELP("Save a copy of subtitles in a different format or with processing applied to it") @@ -84,6 +87,7 @@ struct tool_export : public Command { struct tool_font_collector : public Command { CMD_NAME("tool/font_collector") + CMD_ICON(font_collector_button) STR_MENU("&Fonts Collector...") STR_DISP("Fonts Collector") STR_HELP("Open fonts collector") @@ -95,6 +99,7 @@ struct tool_font_collector : public Command { struct tool_line_select : public Command { CMD_NAME("tool/line/select") + CMD_ICON(select_lines_button) STR_MENU("S&elect Lines...") STR_DISP("Select Lines") STR_HELP("Select lines based on defined criteria") @@ -106,6 +111,7 @@ struct tool_line_select : public Command { struct tool_resampleres : public Command { CMD_NAME("tool/resampleres") + CMD_ICON(resample_toolbutton) STR_MENU("&Resample Resolution...") STR_DISP("Resample Resolution") STR_HELP("Resample subtitles to maintain their current appearance at a different script resolution") @@ -120,6 +126,7 @@ struct tool_resampleres : public Command { struct tool_style_assistant : public Command { CMD_NAME("tool/style/assistant") + CMD_ICON(styling_toolbutton) STR_MENU("St&yling Assistant...") STR_DISP("Styling Assistant") STR_HELP("Open styling assistant") @@ -161,6 +168,7 @@ struct tool_styling_assistant_preview : public tool_styling_assistant_validator struct tool_style_manager : public Command { CMD_NAME("tool/style/manager") + CMD_ICON(style_toolbutton) STR_MENU("&Styles Manager...") STR_DISP("Styles Manager") STR_HELP("Open the styles manager") @@ -172,6 +180,7 @@ struct tool_style_manager : public Command { struct tool_time_kanji : public Command { CMD_NAME("tool/time/kanji") + CMD_ICON(kara_timing_copier) STR_MENU("&Kanji Timer...") STR_DISP("Kanji Timer") STR_HELP("Open the Kanji timer copier") @@ -183,6 +192,7 @@ struct tool_time_kanji : public Command { struct tool_time_postprocess : public Command { CMD_NAME("tool/time/postprocess") + CMD_ICON(timing_processor_toolbutton) STR_MENU("&Timing Post-Processor...") STR_DISP("Timing Post-Processor") STR_HELP("Post-process the subtitle timing to add lead-ins and lead-outs, snap timing to scene changes, etc.") @@ -194,6 +204,7 @@ struct tool_time_postprocess : public Command { struct tool_translation_assistant : public Command { CMD_NAME("tool/translation_assistant") + CMD_ICON(translation_toolbutton) STR_MENU("&Translation Assistant...") STR_DISP("Translation Assistant") STR_HELP("Open translation assistant") diff --git a/aegisub/src/command/video.cpp b/aegisub/src/command/video.cpp index 07715f5c9..010da906f 100644 --- a/aegisub/src/command/video.cpp +++ b/aegisub/src/command/video.cpp @@ -44,6 +44,7 @@ #include "../frame_main.h" #include "../include/aegisub/context.h" #include "../include/aegisub/subtitles_provider.h" +#include "../libresrc/libresrc.h" #include "../main.h" #include "../options.h" #include "../selection_controller.h" @@ -201,6 +202,7 @@ struct video_aspect_wide : public validator_video_loaded { struct video_close : public validator_video_loaded { CMD_NAME("video/close") + CMD_ICON(close_video_menu) STR_MENU("&Close Video") STR_DISP("Close Video") STR_HELP("Close the currently open video file") @@ -242,6 +244,7 @@ struct video_cycle_subtitles_provider : public cmd::Command { struct video_detach : public validator_video_loaded { CMD_NAME("video/detach") + CMD_ICON(detach_video_menu) STR_MENU("&Detach Video") STR_DISP("Detach Video") STR_HELP("Detach the video display from the main window, displaying it in a separate Window") @@ -261,6 +264,7 @@ struct video_detach : public validator_video_loaded { struct video_details : public validator_video_loaded { CMD_NAME("video/details") + CMD_ICON(show_video_details_menu) STR_MENU("Show &Video Details") STR_DISP("Show Video Details") STR_HELP("Show video details") @@ -515,6 +519,7 @@ struct video_frame_save_raw : public validator_video_loaded { struct video_jump : public validator_video_loaded { CMD_NAME("video/jump") + CMD_ICON(jumpto_button) STR_MENU("&Jump to...") STR_DISP("Jump to") STR_HELP("Jump to frame or time") @@ -530,6 +535,7 @@ struct video_jump : public validator_video_loaded { struct video_jump_end : public validator_video_loaded { CMD_NAME("video/jump/end") + CMD_ICON(video_to_subend) STR_MENU("Jump Video to &End") STR_DISP("Jump Video to End") STR_HELP("Jump the video to the end frame of current subtitle") @@ -543,6 +549,7 @@ struct video_jump_end : public validator_video_loaded { struct video_jump_start : public validator_video_loaded { CMD_NAME("video/jump/start") + CMD_ICON(video_to_substart) STR_MENU("Jump Video to &Start") STR_DISP("Jump Video to Start") STR_HELP("Jump the video to the start frame of current subtitle") @@ -555,6 +562,7 @@ struct video_jump_start : public validator_video_loaded { struct video_open : public Command { CMD_NAME("video/open") + CMD_ICON(open_video_menu) STR_MENU("&Open Video...") STR_DISP("Open Video") STR_HELP("Open a video file") @@ -570,6 +578,7 @@ struct video_open : public Command { struct video_open_dummy : public Command { CMD_NAME("video/open/dummy") + CMD_ICON(use_dummy_video_menu) STR_MENU("&Use Dummy Video...") STR_DISP("Use Dummy Video") STR_HELP("Open a placeholder video clip with solid color") @@ -583,6 +592,7 @@ struct video_open_dummy : public Command { struct video_opt_autoscroll : public Command { CMD_NAME("video/opt/autoscroll") + CMD_ICON(toggle_video_autoscroll) STR_MENU("Toggle autoscroll of video") STR_DISP("Toggle autoscroll of video") STR_HELP("Toggle automatically seeking video to the start time of selected lines") @@ -599,6 +609,7 @@ struct video_opt_autoscroll : public Command { struct video_play : public validator_video_loaded { CMD_NAME("video/play") + CMD_ICON(button_play) STR_MENU("Play") STR_DISP("Play") STR_HELP("Play video starting on this position") @@ -610,6 +621,7 @@ struct video_play : public validator_video_loaded { struct video_play_line : public validator_video_loaded { CMD_NAME("video/play/line") + CMD_ICON(button_playline) STR_MENU("Play line") STR_DISP("Play line") STR_HELP("Play current line") @@ -657,6 +669,7 @@ public: class video_stop: public validator_video_loaded { public: CMD_NAME("video/stop") + CMD_ICON(button_pause) STR_MENU("Stop video") STR_DISP("Stop video") STR_HELP("Stop video playback") @@ -704,6 +717,7 @@ public: struct video_zoom_in : public validator_video_attached { CMD_NAME("video/zoom/in") + CMD_ICON(zoom_in_button) STR_MENU("Zoom In") STR_DISP("Zoom In") STR_HELP("Zoom video in") @@ -715,6 +729,7 @@ struct video_zoom_in : public validator_video_attached { struct video_zoom_out : public validator_video_attached { CMD_NAME("video/zoom/out") + CMD_ICON(zoom_out_button) STR_MENU("Zoom Out") STR_DISP("Zoom Out") STR_HELP("Zoom video out") diff --git a/aegisub/src/command/vis_tool.cpp b/aegisub/src/command/vis_tool.cpp index b50c9bbf4..af6999f29 100644 --- a/aegisub/src/command/vis_tool.cpp +++ b/aegisub/src/command/vis_tool.cpp @@ -19,6 +19,7 @@ #include "command.h" #include "../include/aegisub/context.h" +#include "../libresrc/libresrc.h" #include "../video_box.h" #include "../video_context.h" #include "../video_display.h" @@ -54,6 +55,7 @@ namespace { struct visual_mode_cross : public visual_tool_command { CMD_NAME("video/tool/cross") + CMD_ICON(visual_standard) STR_MENU("Standard") STR_DISP("Standard") STR_HELP("Standard mode, double click sets position") @@ -61,6 +63,7 @@ namespace { struct visual_mode_drag : public visual_tool_command { CMD_NAME("video/tool/drag") + CMD_ICON(visual_move) STR_MENU("Drag") STR_DISP("Drag") STR_HELP("Drag subtitles") @@ -68,6 +71,7 @@ namespace { struct visual_mode_rotate_z : public visual_tool_command { CMD_NAME("video/tool/rotate/z") + CMD_ICON(visual_rotatez) STR_MENU("Rotate Z") STR_DISP("Rotate Z") STR_HELP("Rotate subtitles on their Z axis") @@ -75,6 +79,7 @@ namespace { struct visual_mode_rotate_xy : public visual_tool_command { CMD_NAME("video/tool/rotate/xy") + CMD_ICON(visual_rotatexy) STR_MENU("Rotate XY") STR_DISP("Rotate XY") STR_HELP("Rotate subtitles on their X and Y axes") @@ -82,6 +87,7 @@ namespace { struct visual_mode_scale : public visual_tool_command { CMD_NAME("video/tool/scale") + CMD_ICON(visual_scale) STR_MENU("Scale") STR_DISP("Scale") STR_HELP("Scale subtitles on X and Y axes") @@ -89,6 +95,7 @@ namespace { struct visual_mode_clip : public visual_tool_command { CMD_NAME("video/tool/clip") + CMD_ICON(visual_clip) STR_MENU("Clip") STR_DISP("Clip") STR_HELP("Clip subtitles to a rectangle") @@ -96,6 +103,7 @@ namespace { struct visual_mode_vector_clip : public visual_tool_command { CMD_NAME("video/tool/vector_clip") + CMD_ICON(visual_vector_clip) STR_MENU("Vector Clip") STR_DISP("Vector Clip") STR_HELP("Clip subtitles to a vectorial area") diff --git a/aegisub/src/hotkey_data_view_model.cpp b/aegisub/src/hotkey_data_view_model.cpp index 8ef05da47..b39bb06b3 100644 --- a/aegisub/src/hotkey_data_view_model.cpp +++ b/aegisub/src/hotkey_data_view_model.cpp @@ -28,7 +28,6 @@ #include #include "command/command.h" -#include "command/icon.h" #include "compat.h" #include "include/aegisub/hotkey.h" #include "preferences.h" @@ -92,7 +91,7 @@ public: if (col == 0) variant = to_wx(combo.Str()); else if (col == 1) { - wxBitmap icon_bmp(icon::get(combo.CmdName(), 16)); + auto icon_bmp = cmd::get(combo.CmdName())->Icon(16); wxIcon icon; if (icon_bmp.IsOk()) icon.CopyFromBitmap(icon_bmp); diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index 3f4517f3a..f0fc378a9 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -35,7 +35,6 @@ #include "config.h" #include "command/command.h" -#include "command/icon.h" #include "include/aegisub/hotkey.h" #include "ass_dialogue.h" @@ -185,9 +184,6 @@ bool AegisubApp::OnInit() { // Init hotkeys hotkey::init(); - // Init icons. - icon::icon_init(); - StartupLog("Load MRU"); config::mru = new agi::MRUManager(config::path->Decode("?user/mru.json"), GET_DEFAULT_CONFIG(default_mru), config::opt);