From 8dfc2949f2180c676d7cd7017ef87b35f12d2f83 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Wed, 7 Aug 2024 22:36:48 +0200 Subject: [PATCH 1/2] Apply Guichan's changes from 1d9590907eb3a8cc298f660c1436d0e90808d684 (Feb 9th 2008) Patch by Tobing has been applied. "Hi, just discovered that when changing the Image of an Icon, the Icon better should resize to accommodate the new Image. Patch is attached." --- TODO | 2 +- src/widgets/icon.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 3f0dc77..f2c8fd9 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* Continue rebasing from 1d9590907eb3a8cc298f660c1436d0e90808d684 +* Continue rebasing from d7ae8b130713cb4cf8653a2c577a918e5f8f314f * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 37e6cef..fe5cd07 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -109,6 +109,8 @@ namespace gcn mImage = image; mInternalImage = false; + setHeight(mImage->getHeight()); + setWidth(mImage->getWidth()); } const Image* Icon::getImage() const From fffe84c315934b0a2de44aa8b31c859e09f951bf Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Wed, 7 Aug 2024 22:48:43 +0200 Subject: [PATCH 2/2] Apply Guichan's changes from d7ae8b130713cb4cf8653a2c577a918e5f8f314f (Feb 11th 2008) Some optimizations in `gcn::Icon` by replacing `setWidth` + `setHeight` with `setSize`. --- TODO | 2 +- src/widgets/checkbox.cpp | 7 +++---- src/widgets/icon.cpp | 12 ++++-------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index f2c8fd9..44f9b7d 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,4 @@ -* Continue rebasing from d7ae8b130713cb4cf8653a2c577a918e5f8f314f +* Continue rebasing from 2f431b404983b49adfd3cca1c39a9b0a9616e70d * Add a focus listener interface. * Make focus apply synchronously. * Graphics and input objects for DirectX. diff --git a/src/widgets/checkbox.cpp b/src/widgets/checkbox.cpp index bf733e6..64e6fb5 100644 --- a/src/widgets/checkbox.cpp +++ b/src/widgets/checkbox.cpp @@ -99,16 +99,15 @@ namespace gcn else graphics->setColor(Color(128, 128, 128)); - int h = getHeight() + getHeight() / 2; + const int h = getHeight() + getHeight() / 2; graphics->drawText(getCaption(), h - 2, 0); } void CheckBox::drawBox(Graphics* graphics) { - int h = getHeight() - 2; - - int alpha = getBaseColor().a; + const int h = getHeight() - 2; + const int alpha = getBaseColor().a; Color faceColor = getBaseColor(); faceColor.a = alpha; Color highlightColor = faceColor + 0x303030; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index fe5cd07..e197bab 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -70,8 +70,7 @@ namespace gcn : mImage(0) , mInternalImage(false) { - setWidth(0); - setHeight(0); + setSize(0, 0); } Icon::Icon(const std::string& filename) @@ -80,16 +79,14 @@ namespace gcn { mImage = Image::load(filename); mInternalImage = true; - setHeight(mImage->getHeight()); - setWidth(mImage->getWidth()); + setSize(mImage->getWidth(), mImage->getHeight()); } Icon::Icon(const Image* image) : mImage(image), mInternalImage(false) { - setHeight(mImage->getHeight()); - setWidth(mImage->getWidth()); + setSize(mImage->getWidth(), mImage->getHeight()); } Icon::~Icon() @@ -109,8 +106,7 @@ namespace gcn mImage = image; mInternalImage = false; - setHeight(mImage->getHeight()); - setWidth(mImage->getWidth()); + setSize(mImage->getWidth(), mImage->getHeight()); } const Image* Icon::getImage() const