Skip to content

Commit

Permalink
Add idle callback to NanoSubWidgets test, for hide/show widgets
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed May 20, 2021
1 parent 5b98b66 commit 647086c
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions tests/NanoSubWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ class NanoRectangle : public NanoSubWidget

// --------------------------------------------------------------------------------------------------------------------

class NanoRectanglesContainer : public NanoTopLevelWidget
class NanoRectanglesContainer : public NanoTopLevelWidget,
public IdleCallback
{
public:
explicit NanoRectanglesContainer(Window& parent)
: NanoTopLevelWidget(parent),
rect1(this),
rect2(this),
rect3(this)
rect3(this),
rectToHide(1)
{
rect1.setAbsolutePos(100, 100);
rect1.setSize(25, 25);
Expand All @@ -72,6 +74,9 @@ class NanoRectanglesContainer : public NanoTopLevelWidget
rect3.setAbsolutePos(300, 300);
rect3.setSize(25, 25);
rect3.setColor(Color(0, 0, 255));

idleCallback();
addIdleCallback(this, 500);
}

protected:
Expand All @@ -86,8 +91,34 @@ class NanoRectanglesContainer : public NanoTopLevelWidget
closePath();
}

void idleCallback() override
{
switch (rectToHide)
{
case 1:
rect1.hide();
rect2.show();
rect3.show();
rectToHide = 2;
break;
case 2:
rect1.show();
rect2.hide();
rect3.show();
rectToHide = 3;
break;
case 3:
rect1.show();
rect2.show();
rect3.hide();
rectToHide = 1;
break;
}
}

private:
NanoRectangle rect1, rect2, rect3;
int rectToHide;
};

// --------------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 647086c

Please sign in to comment.