From fe3676087246401caf559aa096e9b131601cfd39 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 3 Apr 2012 20:40:24 +0000 Subject: [PATCH] Use 16x16 icons for dialogs rather than cropping the 24x24 icons to 16x16 Originally committed to SVN as r6650. --- aegisub/src/dialog_attachments.cpp | 2 +- aegisub/src/dialog_automation.cpp | 3 +-- aegisub/src/dialog_fonts_collector.cpp | 2 +- aegisub/src/dialog_jumpto.cpp | 3 +-- aegisub/src/dialog_kara_timing_copy.cpp | 2 +- aegisub/src/dialog_properties.cpp | 3 +-- aegisub/src/dialog_resample.cpp | 3 +-- aegisub/src/dialog_shift_times.cpp | 3 +-- aegisub/src/dialog_spellchecker.cpp | 2 +- aegisub/src/dialog_style_editor.cpp | 2 +- aegisub/src/dialog_style_manager.cpp | 3 +-- aegisub/src/dialog_styling_assistant.cpp | 3 +-- aegisub/src/dialog_timing_processor.cpp | 2 +- aegisub/src/dialog_translation.cpp | 2 +- aegisub/src/libresrc/libresrc.cpp | 14 ++++++++++---- aegisub/src/libresrc/libresrc.h | 5 ++++- aegisub/src/preferences.cpp | 2 +- aegisub/src/utils.cpp | 21 --------------------- aegisub/src/utils.h | 5 ----- 19 files changed, 29 insertions(+), 53 deletions(-) diff --git a/aegisub/src/dialog_attachments.cpp b/aegisub/src/dialog_attachments.cpp index f8603259b..fda5a871e 100644 --- a/aegisub/src/dialog_attachments.cpp +++ b/aegisub/src/dialog_attachments.cpp @@ -67,7 +67,7 @@ DialogAttachments::DialogAttachments(wxWindow *parent, AssFile *ass) : wxDialog(parent,-1,_("Attachment List"),wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE) , ass(ass) { - SetIcon(BitmapToIcon(GETIMAGE(attach_button_24))); + SetIcon(GETICON(attach_button_16)); listView = new wxListView(this,ATTACHMENT_LIST,wxDefaultPosition,wxSize(500,200)); UpdateList(); diff --git a/aegisub/src/dialog_automation.cpp b/aegisub/src/dialog_automation.cpp index 16fc9d880..9f4364412 100644 --- a/aegisub/src/dialog_automation.cpp +++ b/aegisub/src/dialog_automation.cpp @@ -56,7 +56,6 @@ #include "libresrc/libresrc.h" #include "main.h" #include "subtitle_format.h" -#include "utils.h" using std::tr1::placeholders::_1; @@ -68,7 +67,7 @@ DialogAutomation::DialogAutomation(agi::Context *c) , global_manager(wxGetApp().global_scripts) , global_scripts_changed(global_manager->AddScriptChangeListener(&DialogAutomation::RebuildList, this)) { - SetIcon(BitmapToIcon(GETIMAGE(automation_toolbutton_24))); + SetIcon(GETICON(automation_toolbutton_16)); // create main controls list = new wxListView(this, -1, wxDefaultPosition, wxSize(600, 175), wxLC_REPORT|wxLC_SINGLE_SEL); diff --git a/aegisub/src/dialog_fonts_collector.cpp b/aegisub/src/dialog_fonts_collector.cpp index 541f4bd0d..8fc9bb1ca 100644 --- a/aegisub/src/dialog_fonts_collector.cpp +++ b/aegisub/src/dialog_fonts_collector.cpp @@ -184,7 +184,7 @@ DialogFontsCollector::DialogFontsCollector(agi::Context *c) : wxDialog(c->parent, -1, _("Fonts Collector")) , subs(c->ass) { - SetIcon(BitmapToIcon(GETIMAGE(font_collector_button_24))); + SetIcon(GETICON(font_collector_button_16)); wxString modes[] = { _("Check fonts for availability"), diff --git a/aegisub/src/dialog_jumpto.cpp b/aegisub/src/dialog_jumpto.cpp index 3b8610d57..35586bacc 100644 --- a/aegisub/src/dialog_jumpto.cpp +++ b/aegisub/src/dialog_jumpto.cpp @@ -50,7 +50,6 @@ #include "ass_time.h" #include "libresrc/libresrc.h" #include "timeedit_ctrl.h" -#include "utils.h" #include "validators.h" #include "video_context.h" @@ -59,7 +58,7 @@ DialogJumpTo::DialogJumpTo(agi::Context *c) , c(c) , jumpframe(c->videoController->GetFrameN()) { - SetIcon(BitmapToIcon(GETIMAGE(jumpto_button_24))); + SetIcon(GETICON(jumpto_button_16)); // Set initial values wxString maxLength = wxString::Format("%i",c->videoController->GetLength() - 1); diff --git a/aegisub/src/dialog_kara_timing_copy.cpp b/aegisub/src/dialog_kara_timing_copy.cpp index 3655137e2..903f8223a 100644 --- a/aegisub/src/dialog_kara_timing_copy.cpp +++ b/aegisub/src/dialog_kara_timing_copy.cpp @@ -633,7 +633,7 @@ bool KaraokeLineMatchDisplay::UndoMatch() DialogKanjiTimer::DialogKanjiTimer(agi::Context *c) : wxDialog(c->parent,-1,_("Kanji timing"),wxDefaultPosition) { - SetIcon(BitmapToIcon(GETIMAGE(kara_timing_copier_24))); + SetIcon(GETICON(kara_timing_copier_16)); subs = c->ass; currentSourceLine = subs->Line.begin(); diff --git a/aegisub/src/dialog_properties.cpp b/aegisub/src/dialog_properties.cpp index 67eea8db9..991bcebf7 100644 --- a/aegisub/src/dialog_properties.cpp +++ b/aegisub/src/dialog_properties.cpp @@ -51,7 +51,6 @@ #include "help_button.h" #include "include/aegisub/context.h" #include "libresrc/libresrc.h" -#include "utils.h" #include "validators.h" #include "video_context.h" @@ -59,7 +58,7 @@ DialogProperties::DialogProperties(agi::Context *c) : wxDialog(c->parent, -1, _("Script Properties")) , c(c) { - SetIcon(BitmapToIcon(GETIMAGE(properties_toolbutton_24))); + SetIcon(GETICON(properties_toolbutton_16)); // Script details crap wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Script")); diff --git a/aegisub/src/dialog_resample.cpp b/aegisub/src/dialog_resample.cpp index 53f2f15fb..9ee4878ae 100644 --- a/aegisub/src/dialog_resample.cpp +++ b/aegisub/src/dialog_resample.cpp @@ -42,7 +42,6 @@ #include "include/aegisub/context.h" #include "help_button.h" #include "libresrc/libresrc.h" -#include "utils.h" #include "video_context.h" enum { @@ -56,7 +55,7 @@ DialogResample::DialogResample(agi::Context *c, ResampleSettings &settings) : wxDialog(c->parent, -1, _("Resample Resolution")) , c(c) { - SetIcon(BitmapToIcon(GETIMAGE(resample_toolbutton_24))); + SetIcon(GETICON(resample_toolbutton_16)); memset(&settings, 0, sizeof(settings)); c->ass->GetResolution(settings.script_x, settings.script_y); diff --git a/aegisub/src/dialog_shift_times.cpp b/aegisub/src/dialog_shift_times.cpp index bb89600e8..3e2c4a3bc 100644 --- a/aegisub/src/dialog_shift_times.cpp +++ b/aegisub/src/dialog_shift_times.cpp @@ -55,7 +55,6 @@ #include "main.h" #include "standard_paths.h" #include "timeedit_ctrl.h" -#include "utils.h" #include "video_context.h" static wxString get_history_string(json::Object &obj) { @@ -107,7 +106,7 @@ DialogShiftTimes::DialogShiftTimes(agi::Context *context) , history(new json::Array) , timecodes_loaded_slot(context->videoController->AddTimecodesListener(&DialogShiftTimes::OnTimecodesLoaded, this)) { - SetIcon(BitmapToIcon(GETIMAGE(shift_times_toolbutton_24))); + SetIcon(GETICON(shift_times_toolbutton_16)); // Create controls shift_by_time = new wxRadioButton(this, -1, _("&Time: "), wxDefaultPosition, wxDefaultSize, wxRB_GROUP); diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index b5e497bdd..57b0e28b2 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -60,7 +60,7 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) , active_line(0) , has_looped(false) { - SetIcon(BitmapToIcon(GETIMAGE(spellcheck_toolbutton_24))); + SetIcon(GETICON(spellcheck_toolbutton_16)); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); diff --git a/aegisub/src/dialog_style_editor.cpp b/aegisub/src/dialog_style_editor.cpp index 26f15158d..1b6ea54b0 100644 --- a/aegisub/src/dialog_style_editor.cpp +++ b/aegisub/src/dialog_style_editor.cpp @@ -164,7 +164,7 @@ DialogStyleEditor::DialogStyleEditor(wxWindow *parent, AssStyle *style, agi::Con work.reset(new AssStyle(*style)); - SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24))); + SetIcon(GETICON(style_toolbutton_16)); // Prepare control values wxString EncodingValue = AegiIntegerToString(style->encoding); diff --git a/aegisub/src/dialog_style_manager.cpp b/aegisub/src/dialog_style_manager.cpp index 4521b55e9..c829da674 100644 --- a/aegisub/src/dialog_style_manager.cpp +++ b/aegisub/src/dialog_style_manager.cpp @@ -64,7 +64,6 @@ #include "persist_location.h" #include "selection_controller.h" #include "standard_paths.h" -#include "utils.h" using std::tr1::placeholders::_1; @@ -168,7 +167,7 @@ DialogStyleManager::DialogStyleManager(agi::Context *context) , commit_connection(c->ass->AddCommitListener(&DialogStyleManager::LoadCurrentStyles, this)) { using std::tr1::bind; - SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24))); + SetIcon(GETICON(style_toolbutton_16)); // Catalog wxSizer *CatalogBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Catalog of available storages")); diff --git a/aegisub/src/dialog_styling_assistant.cpp b/aegisub/src/dialog_styling_assistant.cpp index 12cc949c6..bf1e39fca 100644 --- a/aegisub/src/dialog_styling_assistant.cpp +++ b/aegisub/src/dialog_styling_assistant.cpp @@ -37,7 +37,6 @@ #include "help_button.h" #include "libresrc/libresrc.h" #include "persist_location.h" -#include "utils.h" #include "video_context.h" #ifndef AGI_PRE @@ -60,7 +59,7 @@ DialogStyling::DialogStyling(agi::Context *context) , c(context) , active_line(0) { - SetIcon(BitmapToIcon(GETIMAGE(styling_toolbutton_24))); + SetIcon(GETICON(styling_toolbutton_16)); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); wxSizer *bottom_sizer = new wxBoxSizer(wxHORIZONTAL); diff --git a/aegisub/src/dialog_timing_processor.cpp b/aegisub/src/dialog_timing_processor.cpp index fa8108558..f538a355d 100644 --- a/aegisub/src/dialog_timing_processor.cpp +++ b/aegisub/src/dialog_timing_processor.cpp @@ -107,7 +107,7 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c) { using std::tr1::bind; - SetIcon(BitmapToIcon(GETIMAGE(timing_processor_toolbutton_24))); + SetIcon(GETICON(timing_processor_toolbutton_16)); // Read options leadIn = OPT_GET("Audio/Lead/IN")->GetInt(); diff --git a/aegisub/src/dialog_translation.cpp b/aegisub/src/dialog_translation.cpp index 06a80853b..fa7fba961 100644 --- a/aegisub/src/dialog_translation.cpp +++ b/aegisub/src/dialog_translation.cpp @@ -73,7 +73,7 @@ DialogTranslation::DialogTranslation(agi::Context *c) , line_number(count_if(c->ass->Line.begin(), find(c->ass->Line.begin(), c->ass->Line.end(), active_line), cast()) + 1) , switching_lines(false) { - SetIcon(BitmapToIcon(GETIMAGE(translation_toolbutton_16))); + SetIcon(GETICON(translation_toolbutton_16)); wxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); diff --git a/aegisub/src/libresrc/libresrc.cpp b/aegisub/src/libresrc/libresrc.cpp index f90fecf6d..7014f21e1 100644 --- a/aegisub/src/libresrc/libresrc.cpp +++ b/aegisub/src/libresrc/libresrc.cpp @@ -2,11 +2,17 @@ wxBitmap libresrc_getimage(const unsigned char *buff, size_t size) { wxMemoryInputStream mem(buff, size); - wxImage image(mem); - return wxBitmap(image); + return wxBitmap(wxImage(mem)); +} + +wxIcon libresrc_geticon(const unsigned char *buff, size_t size) { + wxMemoryInputStream mem(buff, size); + wxIcon icon; + icon.CopyFromBitmap(wxBitmap(wxImage(mem))); + return icon; } const std::string libresrc_getconfig(const unsigned char *config, size_t size) { - std::string str((char*)config, size); - return str.c_str(); + std::string str((char*)config, size); + return str.c_str(); } diff --git a/aegisub/src/libresrc/libresrc.h b/aegisub/src/libresrc/libresrc.h index e177cc727..c8824f07b 100644 --- a/aegisub/src/libresrc/libresrc.h +++ b/aegisub/src/libresrc/libresrc.h @@ -1,14 +1,17 @@ #include -#include #include +#include #include +#include #include "bitmap.h" #include "default_config.h" wxBitmap libresrc_getimage(const unsigned char *image, size_t size); +wxIcon libresrc_geticon(const unsigned char *image, size_t size); #define GETIMAGE(a) libresrc_getimage(a, sizeof(a)) +#define GETICON(a) libresrc_geticon(a, sizeof(a)) const std::string libresrc_getconfig(const unsigned char *config, size_t size); #define GET_DEFAULT_CONFIG(a) libresrc_getconfig(a, sizeof(a)) diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index 51ce73509..49b905749 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -658,7 +658,7 @@ static void PageChanged(wxBookCtrlEvent& evt) { } Preferences::Preferences(wxWindow *parent): wxDialog(parent, -1, _("Preferences"), wxDefaultPosition, wxSize(-1, 500)) { - // SetIcon(BitmapToIcon(GETIMAGE(options_button_24))); + // SetIcon(GETICON(options_button_16)); book = new wxTreebook(this, -1, wxDefaultPosition, wxDefaultSize); new General(book, this); diff --git a/aegisub/src/utils.cpp b/aegisub/src/utils.cpp index 5d0957db7..b5b73b730 100644 --- a/aegisub/src/utils.cpp +++ b/aegisub/src/utils.cpp @@ -271,27 +271,6 @@ int AegiStringToFix(const wxString &str,size_t decimalPlaces,int start,int end) return (major + minor)*sign; } -wxIcon BitmapToIcon(wxBitmap const& iconBmp) { - // Create the icon and background bmp - wxIcon ico; - wxBitmap bmp(16,16); - - // Blit bitmap into 16x16 one (don't remove brackets) - { - wxMemoryDC dc; - dc.SelectObject(bmp); - dc.SetBackground(wxColour(192,192,192)); - dc.Clear(); - dc.DrawBitmap(iconBmp,0,0,false); - } - - // Create mask and convert to icon - wxMask *mask = new wxMask(bmp,wxColour(192,192,192)); - bmp.SetMask(mask); - ico.CopyFromBitmap(bmp); - return ico; -} - void RestartAegisub() { #if defined(__WXMSW__) wxStandardPaths stand; diff --git a/aegisub/src/utils.h b/aegisub/src/utils.h index b8e30522e..77d2e8096 100644 --- a/aegisub/src/utils.h +++ b/aegisub/src/utils.h @@ -88,11 +88,6 @@ bool StringEmptyOrWhitespace(const wxString &str); int AegiStringToInt(const wxString &str,int start=0,int end=-1); int AegiStringToFix(const wxString &str,size_t decimalPlaces,int start=0,int end=-1); -/// @brief Convert a wxBitmap to wxIcon -/// -/// This is needed because wxIcon has to be 16x16 to work properly on win32 -wxIcon BitmapToIcon(wxBitmap const& bmp); - /// @brief Launch a new copy of Aegisub. /// /// Contrary to what the name suggests, this does not close the currently