Skip to content

Commit

Permalink
bugfix: Make guisan widgets active/inactive status more visible (fixes
Browse files Browse the repository at this point in the history
…#1326)

Some widgets were not greyed out when disabled
  • Loading branch information
midwan committed May 17, 2024
1 parent c0e4777 commit 540e9b8
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
5 changes: 4 additions & 1 deletion external/libguisan/src/widgets/checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ namespace gcn
graphics->setColor(backCol);
graphics->fillRectangle(Rectangle(2, 2, h - 2, h - 2));

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

if (isFocused())
{
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/src/widgets/imagetextbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ namespace gcn
if (isPressed())
{
graphics->drawImage(mImage, imageX + 1, imageY + 1);
graphics->drawText(mCaption, textX + 1, textY + 1, Graphics::LEFT);
graphics->drawText(mCaption, textX + 1, textY + 1, Graphics::LEFT, isEnabled());
}
else
{
graphics->drawImage(mImage, imageX, imageY);
graphics->drawText(mCaption, textX, textY, Graphics::LEFT);
graphics->drawText(mCaption, textX, textY, Graphics::LEFT, isEnabled());

if (isFocused())
{
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/inputbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ namespace gcn
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->pushClipArea(Rectangle(0, 0, getWidth(), getTitleBarHeight() - 1));
graphics->drawText(getCaption(), textX, textY, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
graphics->popClipArea();
}

Expand Down
10 changes: 5 additions & 5 deletions external/libguisan/src/widgets/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ namespace gcn
}

graphics->setFont(getFont());
Color color = getForegroundColor();
if (!isEnabled())
color = Color(128, 128, 128);
graphics->setColor(color);
graphics->drawText(getCaption(), textX, textY, getAlignment());
if (isEnabled())
graphics->setColor(getForegroundColor());
else
graphics->setColor(Color(128, 128, 128));
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
}

void Label::drawBorder(Graphics* graphics)
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/src/widgets/listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ namespace gcn
// draw the text with a center vertical alignment.
if (rowHeight > getFont()->getHeight())
{
graphics->drawText(mListModel->getElementAt(i), 2, y + rowHeight / 2 - getFont()->getHeight() / 2);
graphics->drawText(mListModel->getElementAt(i), 2, y + rowHeight / 2 - getFont()->getHeight() / 2, Graphics::LEFT, isEnabled());
}
else
{
graphics->drawText(mListModel->getElementAt(i), 2, y);
graphics->drawText(mListModel->getElementAt(i), 2, y, Graphics::LEFT, isEnabled());
}

y += rowHeight;
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/messagebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace gcn
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->pushClipArea(Rectangle(0, 0, getWidth(), getTitleBarHeight() - 1));
graphics->drawText(getCaption(), textX, textY, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
graphics->popClipArea();
}

Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/progressbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace gcn
if (!isEnabled())
color = color - 0x303030;
graphics->setColor(color);
graphics->drawText(getCaption(), textX, textY, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
}

void ProgressBar::drawBorder(Graphics* graphics)
Expand Down
21 changes: 12 additions & 9 deletions external/libguisan/src/widgets/radiobutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ namespace gcn
addKeyListener(this);
}

RadioButton::RadioButton(const std::string& caption,
const std::string& group,
bool selected)
RadioButton::RadioButton(const std::string& caption, const std::string& group, bool selected)
{
setCaption(caption);
setGroup(group);
Expand Down Expand Up @@ -108,9 +106,11 @@ namespace gcn
drawBox(graphics);
graphics->popClipArea();


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

if (isFocused())
{
Expand All @@ -119,16 +119,16 @@ 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::drawBorder(Graphics* graphics)
{
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
shadowColor = faceColor - 0x303030;
Expand Down Expand Up @@ -199,7 +199,10 @@ namespace gcn
graphics->drawLine(1, hh + 1, hh, h);
graphics->drawLine(hh + 1, h - 1, h, hh);

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

const int hhh = hh - 3;
if (mSelected)
Expand Down
8 changes: 1 addition & 7 deletions external/libguisan/src/widgets/slider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,9 @@ namespace gcn

void Slider::draw(gcn::Graphics* graphics)
{
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
faceColor.a = alpha;

auto backCol = getBackgroundColor();
if (isEnabled())
if (!isEnabled())
backCol = backCol - 0x303030;
else
backCol = faceColor - 0x101010;

graphics->setColor(backCol);
graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/textbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ namespace gcn
for (unsigned int i = 0; i < mTextRows.size(); i++)
{
// Move the text one pixel so we can have a caret before a letter.
graphics->drawText(mTextRows[i], 2, i * (getFont()->getHeight() + 2));
graphics->drawText(mTextRows[i], 2, i * (getFont()->getHeight() + 2), Graphics::LEFT, isEnabled());
}
}

Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/textfield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace gcn
graphics->setColor(Color(128, 128, 128));

graphics->setFont(getFont());
graphics->drawText(mText, 1 - mXScroll, 2);
graphics->drawText(mText, 1 - mXScroll, 2, Graphics::LEFT, isEnabled());
}

void TextField::drawBorder(Graphics* graphics)
Expand Down
4 changes: 2 additions & 2 deletions external/libguisan/src/widgets/togglebutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ namespace gcn

if (isPressed() || isSelected())
{
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment(), isEnabled());
}
else
{
graphics->drawText(getCaption(), textX, textY, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());

if (isFocused())
{
Expand Down
2 changes: 1 addition & 1 deletion external/libguisan/src/widgets/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ namespace gcn
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
graphics->pushClipArea(Rectangle(0, 0, getWidth(), static_cast<int>(getTitleBarHeight() - 1)));
graphics->drawText(getCaption(), textX, textY, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment(), isEnabled());
graphics->popClipArea();
}

Expand Down

0 comments on commit 540e9b8

Please sign in to comment.