Skip to content

Commit

Permalink
Added hidden feature for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhard Stein committed Mar 15, 2024
1 parent 51888aa commit f66446c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion GsKit/widgets/GsButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void GsButton::processLogic()
}

void GsButton::drawNoStyle(const SDL_Rect& lRect)
{
{
if(lRect.h == 0 || lRect.w == 0)
return;

Expand Down Expand Up @@ -306,6 +306,9 @@ void GsButton::drawEnabledButton(GsWeakSurface &,

void GsButton::processRender(const GsRect<float> &RectDispCoordFloat)
{
if(mHidden)
return;

// Transform to the display coordinates
auto displayRect = getRect();

Expand All @@ -323,6 +326,9 @@ void GsButton::processRender(const GsRect<float> &RectDispCoordFloat)
void GsButton::processRender(const GsRect<float> &backRect,
const GsRect<float> &frontRect)
{
if(mHidden)
return;

// Transform this object display coordinates
auto objBackRect = backRect.transformed(getRect());
auto objFrontRect = objBackRect.clipped(frontRect);
Expand Down
7 changes: 7 additions & 0 deletions GsKit/widgets/GsButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ class GsButton : public GsControl
mRounded = rounded;
}

void hide(const bool val = true)
{
mHidden = val;
}


protected:

Expand Down Expand Up @@ -195,6 +200,8 @@ class GsButton : public GsControl
// if hovered or selected

bool mRounded = false;

bool mHidden = false;
};

std::shared_ptr<GsButton> createButtonFrom(const GsKit::ptree &node);
Expand Down

0 comments on commit f66446c

Please sign in to comment.