From ad7d7c2be3064fd6c7386c49457c4c03dbe27cee Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 20 Feb 2012 05:41:54 +0000 Subject: [PATCH] Don't return a dummy icon when no icon is found for a command The hotkey editor initially required this, but now that we've using fully custom renderers they're no longer needed, and the blank icons didn't work correctly on wxGTK. Originally committed to SVN as r6490. --- aegisub/src/command/icon.cpp | 15 ++------------- aegisub/src/preferences.cpp | 20 ++++++-------------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/aegisub/src/command/icon.cpp b/aegisub/src/command/icon.cpp index b1c5a907a..30d969a54 100644 --- a/aegisub/src/command/icon.cpp +++ b/aegisub/src/command/icon.cpp @@ -53,19 +53,8 @@ wxBitmap const& get(std::string const& name, const int size) { LOG_W("icon/get") << "Icon not found: " << name << " " << size; - 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; + static wxBitmap bad; + return bad; } diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index 39b0557ab..8f3a7cdad 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -271,6 +271,7 @@ Interface_Colours::Interface_Colours(wxTreebook *book, Preferences *parent): Opt class CommandRenderer : public wxDataViewCustomRenderer { wxArrayString autocomplete; wxDataViewIconText value; + static const int icon_width = 20; public: CommandRenderer() @@ -288,11 +289,8 @@ public: wxString text = iconText.GetText(); // adjust the label rect to take the width of the icon into account - if (iconText.GetIcon().IsOk()) { - int w = iconText.GetIcon().GetWidth() + 4; - label_rect.x += w; - label_rect.width -= w; - } + label_rect.x += icon_width; + label_rect.width -= icon_width; wxTextCtrl* ctrl = new wxTextCtrl(parent, -1, text, label_rect.GetPosition(), label_rect.GetSize(), wxTE_PROCESS_ENTER); ctrl->SetInsertionPointEnd(); @@ -307,15 +305,11 @@ public: } bool Render(wxRect rect, wxDC *dc, int state) { - int xoffset = 0; - wxIcon const& icon = value.GetIcon(); - if (icon.IsOk()) { + if (icon.IsOk()) dc->DrawIcon(icon, rect.x, rect.y + (rect.height - icon.GetHeight()) / 2); - xoffset = icon.GetWidth() + 4; - } - RenderText(value.GetText(), xoffset, rect, dc, state); + RenderText(value.GetText(), icon_width, rect, dc, state); return true; } @@ -323,9 +317,7 @@ public: wxSize GetSize() const { if (!value.GetText().empty()) { wxSize size = GetTextExtent(value.GetText()); - - if (value.GetIcon().IsOk()) - size.x += value.GetIcon().GetWidth() + 4; + size.x += icon_width; return size; } return wxSize(80,20);