Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// Copyright (c) 2010, Amar Takhar <verm@aegisub.org>
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
/// @file icon.h
|
|
|
|
/// @brief Icon for commands.
|
|
|
|
/// @ingroup command
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef AGI_PRE
|
2011-01-08 13:10:40 +01:00
|
|
|
#include <map>
|
|
|
|
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
#include <wx/bitmap.h>
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/mstream.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <libaegisub/log.h>
|
|
|
|
|
|
|
|
#include "icon.h"
|
|
|
|
#include "../libresrc/bitmap.h"
|
|
|
|
|
|
|
|
namespace icon {
|
2011-07-15 19:24:05 +02:00
|
|
|
typedef std::map<std::string, wxBitmap> iconMap;
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
iconMap icon16;
|
|
|
|
iconMap icon24;
|
|
|
|
|
2011-07-15 19:24:05 +02:00
|
|
|
wxBitmap const& get(std::string const& name, const int size) {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// XXX: This code will go away with dynamic icon generation so I'm not
|
|
|
|
// concerned about it.
|
2011-10-18 02:10:02 +02:00
|
|
|
iconMap::iterator index;
|
2011-07-15 06:06:29 +02:00
|
|
|
if (size != 24) {
|
2011-10-18 02:09:51 +02:00
|
|
|
if ((index = icon16.find(name)) != icon16.end())
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
return index->second;
|
2011-07-15 06:06:29 +02:00
|
|
|
}
|
|
|
|
else {
|
2011-10-18 02:09:51 +02:00
|
|
|
if ((index = icon24.find(name)) != icon24.end())
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
return index->second;
|
|
|
|
}
|
2011-10-18 02:09:51 +02:00
|
|
|
|
|
|
|
LOG_W("icon/get") << "Icon not found: " << name << " " << size;
|
|
|
|
|
2011-10-18 02:10:02 +02:00
|
|
|
static wxBitmap empty16(16, 16, 1);
|
|
|
|
static wxBitmap empty24(24, 24, 1);
|
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
empty16.SetMask(new wxMask(empty16));
|
|
|
|
empty24.SetMask(new wxMask(empty24));
|
|
|
|
initialized = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size != 24)
|
|
|
|
return empty16;
|
|
|
|
return empty24;
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-15 19:24:05 +02:00
|
|
|
wxBitmap getimage(const unsigned char *buff, size_t size) {
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
wxMemoryInputStream mem(buff, size);
|
|
|
|
wxImage img(mem);
|
2011-07-15 19:24:05 +02:00
|
|
|
return wxBitmap(img);
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define INSERT_ICON(a, b) \
|
2011-07-15 19:24:05 +02:00
|
|
|
icon16.insert(std::make_pair(a, getimage(b##_16, sizeof(b##_16)))); \
|
|
|
|
icon24.insert(std::make_pair(a, getimage(b##_24, sizeof(b##_24))));
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
|
|
|
|
|
|
|
|
void icon_init() {
|
|
|
|
// Seems that WX doesn't install the handlers early enough for our use.
|
|
|
|
wxPNGHandler *handler = new wxPNGHandler();
|
|
|
|
wxImage::AddHandler(handler);
|
|
|
|
wxString handler_name(handler->GetName());
|
|
|
|
|
|
|
|
LOG_D("icon/init") << "Generating 24x24, 16x16 icons";
|
|
|
|
|
|
|
|
INSERT_ICON("am/manager", automation_toolbutton)
|
|
|
|
INSERT_ICON("app/about", about_menu)
|
|
|
|
INSERT_ICON("app/exit", exit_button)
|
|
|
|
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)
|
2011-08-27 08:30:42 +02:00
|
|
|
INSERT_ICON("app/toggle/global_hotkeys", toggle_audio_medusa)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
INSERT_ICON("app/updates", blank_button)
|
|
|
|
INSERT_ICON("audio/close", close_audio_menu)
|
2011-01-18 00:54:05 +01:00
|
|
|
INSERT_ICON("audio/commit", button_audio_commit)
|
2011-08-27 08:30:42 +02:00
|
|
|
INSERT_ICON("audio/go_to", button_audio_goto)
|
2011-09-28 21:44:07 +02:00
|
|
|
INSERT_ICON("audio/karaoke", kara_mode)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
INSERT_ICON("audio/open", open_audio_menu)
|
|
|
|
INSERT_ICON("audio/open/video", open_audio_from_video_menu)
|
2011-01-18 00:54:05 +01:00
|
|
|
INSERT_ICON("audio/opt/autocommit", toggle_audio_autocommit)
|
|
|
|
INSERT_ICON("audio/opt/autonext", toggle_audio_nextcommit)
|
|
|
|
INSERT_ICON("audio/opt/autoscroll", toggle_audio_autoscroll)
|
2011-08-27 08:30:42 +02:00
|
|
|
INSERT_ICON("audio/opt/spectrum", toggle_audio_spectrum)
|
2011-01-18 00:54:05 +01:00
|
|
|
INSERT_ICON("audio/opt/vertical_link", toggle_audio_link)
|
|
|
|
INSERT_ICON("audio/play/selection", button_playsel)
|
|
|
|
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)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
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/duplicate", blank_button)
|
|
|
|
INSERT_ICON("edit/line/duplicate/shift", blank_button)
|
|
|
|
INSERT_ICON("edit/line/join/as_karaoke", blank_button)
|
|
|
|
INSERT_ICON("edit/line/join/concatenate", blank_button)
|
|
|
|
INSERT_ICON("edit/line/join/keep_first", blank_button)
|
|
|
|
INSERT_ICON("edit/line/paste", paste_button)
|
|
|
|
INSERT_ICON("edit/line/paste/over", paste_over_button)
|
|
|
|
INSERT_ICON("edit/line/recombine", blank_button)
|
|
|
|
INSERT_ICON("edit/line/split/by_karaoke", blank_button)
|
|
|
|
INSERT_ICON("edit/line/swap", arrow_sort)
|
|
|
|
INSERT_ICON("edit/redo", redo_button)
|
|
|
|
INSERT_ICON("edit/search_replace", find_replace_menu)
|
|
|
|
INSERT_ICON("edit/undo", undo_button)
|
|
|
|
INSERT_ICON("grid/tag/cycle_hiding", toggle_tag_hiding)
|
|
|
|
INSERT_ICON("help/bugs", bugtracker_button)
|
|
|
|
INSERT_ICON("help/contents", contents_button)
|
|
|
|
INSERT_ICON("help/files", contents_button)
|
|
|
|
INSERT_ICON("help/forums", forums_button)
|
|
|
|
INSERT_ICON("help/irc", irc_button)
|
2011-01-20 06:58:01 +01:00
|
|
|
INSERT_ICON("help/video", visual_help)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
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/insert/after", blank_button)
|
|
|
|
INSERT_ICON("subtitle/insert/after/videotime", blank_button)
|
|
|
|
INSERT_ICON("subtitle/insert/before", blank_button)
|
|
|
|
INSERT_ICON("subtitle/insert/before/videotime", blank_button)
|
|
|
|
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/continous/end", blank_button)
|
|
|
|
INSERT_ICON("time/continous/start", blank_button)
|
|
|
|
INSERT_ICON("time/frame/current", shift_to_frame)
|
2011-01-18 00:54:05 +01:00
|
|
|
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)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
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("time/sort/end", blank_button)
|
|
|
|
INSERT_ICON("time/sort/start", blank_button)
|
|
|
|
INSERT_ICON("time/sort/style", blank_button)
|
|
|
|
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)
|
2011-01-20 06:58:01 +01:00
|
|
|
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)
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
INSERT_ICON("video/zoom/in", zoom_in_button)
|
|
|
|
INSERT_ICON("video/zoom/out", zoom_out_button)
|
|
|
|
|
2011-01-18 00:54:05 +01:00
|
|
|
// Remove the handler to avoid "Duplicate handler" warnings from WX since
|
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
|
|
|
// it will attempt to install all the handlers later on.
|
|
|
|
wxImage::RemoveHandler(handler_name);
|
|
|
|
}
|
|
|
|
} // namespace icon
|