From 5d02ab43ff6d3e328a3b02479c033609023edec2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 20 Oct 2012 01:25:19 +0300 Subject: Add palette inheritance to icon class. --- src/gui/itemamountwindow.cpp | 2 +- src/gui/itempopup.cpp | 2 +- src/gui/widgets/icon.cpp | 7 ++++--- src/gui/widgets/icon.h | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/itemamountwindow.cpp b/src/gui/itemamountwindow.cpp index dbbe2d50f..a11740f5b 100644 --- a/src/gui/itemamountwindow.cpp +++ b/src/gui/itemamountwindow.cpp @@ -144,7 +144,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItemPriceTextField(nullptr), mGPLabel(nullptr), mItem(item), - mItemIcon(new Icon(item->getImage())), + mItemIcon(new Icon(this, item ? item->getImage() : 0)), mMax(maxRange), mUsage(usage), mItemPopup(new ItemPopup), diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp index cd2663079..3c4241022 100644 --- a/src/gui/itempopup.cpp +++ b/src/gui/itempopup.cpp @@ -51,7 +51,7 @@ ItemPopup::ItemPopup() : mItemDesc(new TextBox), mItemEffect(new TextBox), mItemWeight(new TextBox), - mIcon(new Icon(nullptr)), + mIcon(new Icon(this, nullptr)), mLastName(""), mLastColor(1) { diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 4b7ab9b98..9781e978f 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -29,17 +29,18 @@ #include "debug.h" -Icon::Icon(const std::string &file) : +Icon::Icon(const Widget2 *const widget, const std::string &file) : gcn::Widget(), - Widget2(), + Widget2(widget), mImage(ResourceManager::getInstance()->getImage(file)) { if (mImage) setSize(mImage->mBounds.w, mImage->mBounds.h); } -Icon::Icon(Image *const image) : +Icon::Icon(const Widget2 *const widget, Image *const image) : gcn::Widget(), + Widget2(widget), mImage(image) { if (mImage) diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index e0cabf3d9..761bbe584 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -43,12 +43,12 @@ class Icon final : public gcn::Widget, /** * Constructor. */ - Icon(const std::string &filename); + Icon(const Widget2 *const widget, const std::string &filename); /** * Constructor, uses an existing Image. */ - Icon(Image *const image); + Icon(const Widget2 *const widget, Image *const image); A_DELETE_COPY(Icon) -- cgit v1.2.3-70-g09d2