Skip to content

Commit 4256354

Browse files
committed
Common: dont apply grey-out effect on Button without action
1 parent 8924328 commit 4256354

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Common/gui/guibutton.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ bool GUIButton::IsClippingImage() const
154154
return (_flags & kGUICtrl_Clip) != 0;
155155
}
156156

157+
bool GUIButton::HasAction() const
158+
{
159+
return _clickAction[kGUIClickLeft] != kGUIAction_None || _clickAction[kGUIClickRight] != kGUIAction_None;
160+
}
161+
157162
GUIClickAction GUIButton::GetClickAction(GUIClickMouseButton button) const
158163
{
159164
if (button < kGUIClickLeft || button >= kNumGUIClicks)
@@ -255,7 +260,12 @@ Rect GUIButton::CalcGraphicRect(bool clipped)
255260

256261
void GUIButton::Draw(Bitmap *ds, int x, int y)
257262
{
258-
const bool draw_disabled = GUI::ShouldDrawDisabled(this);
263+
// A non-clickable button is, in effect, just a label.
264+
// When the GUI is disabled, the user should not get the message that
265+
// the button is now unclickable since it had never been in the first place.
266+
bool const has_interaction = IsClickable() || HasAction();
267+
const bool draw_disabled = GUI::ShouldDrawDisabled(this)
268+
&& has_interaction;
259269
// TODO: should only change properties in reaction to particular events
260270
if (_currentImage <= 0 || draw_disabled)
261271
_currentImage = _image;

Common/gui/guibutton.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class GUIButton : public GUIObject
9393
const String &GetText() const;
9494
bool IsImageButton() const;
9595
bool IsClippingImage() const;
96+
bool HasAction() const;
9697

9798
GUIClickAction GetClickAction(GUIClickMouseButton button) const;
9899
int GetClickData(GUIClickMouseButton button) const;

0 commit comments

Comments
 (0)