Skip to content

Commit

Permalink
Merge pull request #87 from kallisti5/fix-widgets-disabled-color
Browse files Browse the repository at this point in the history
Fix some widgets who didn't use the right color when disabled
  • Loading branch information
midwan authored Sep 13, 2024
2 parents cfbe6eb + 58be71b commit ebe8376
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/widgets/imagebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ namespace gcn
graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1);
graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1);

graphics->setColor(getForegroundColor());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));

const int textX = getWidth() / 2 - (mImage ? mImage->getWidth() : 0) / 2;
const int textY = getHeight() / 2 - (mImage ? mImage->getHeight() : 0) / 2;
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/imagetextbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,10 @@ namespace gcn
graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1);
graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1);

graphics->setColor(getForegroundColor());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));

int imageX, imageY;
int textX, textY;
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/inputbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ namespace gcn
throw GCN_EXCEPTION("Unknown alignment.");
}

graphics->setColor(getForegroundColor());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));
graphics->setFont(getFont());
graphics->pushClipArea(Rectangle(0, 0, getWidth(), getTitleBarHeight() - 1));
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
Expand Down
7 changes: 5 additions & 2 deletions src/widgets/radiobutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ namespace gcn


graphics->setFont(getFont());
graphics->setColor(getForegroundColor());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));

if (isFocused())
{
Expand All @@ -119,7 +122,7 @@ namespace gcn

const int h = getHeight() + getHeight() / 2;

graphics->drawText(getCaption(), h - 2, 0);
graphics->drawText(getCaption(), h - 2, 0, Graphics::Left, isEnabled());
}

void RadioButton::drawBox(Graphics* graphics)
Expand Down
5 changes: 4 additions & 1 deletion src/widgets/togglebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ namespace gcn
graphics->drawLine(getWidth() - 1, 1, getWidth() - 1, getHeight() - 1);
graphics->drawLine(1, getHeight() - 1, getWidth() - 1, getHeight() - 1);

graphics->setColor(getForegroundColor());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));

int textX;
const int textY = getHeight() / 2 - getFont()->getHeight() / 2;
Expand Down

0 comments on commit ebe8376

Please sign in to comment.