commit 647086c182afd1948111fd198b3b5f5ed0a0696d
parent 5b98b66c0f68c2e835a5c437aa56f3e945aac28b
Author: falkTX <falktx@falktx.com>
Date: Thu, 20 May 2021 20:16:17 +0100
Add idle callback to NanoSubWidgets test, for hide/show widgets
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/tests/NanoSubWidgets.cpp b/tests/NanoSubWidgets.cpp
@@ -52,14 +52,16 @@ private:
// --------------------------------------------------------------------------------------------------------------------
-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);
@@ -72,6 +74,9 @@ public:
rect3.setAbsolutePos(300, 300);
rect3.setSize(25, 25);
rect3.setColor(Color(0, 0, 255));
+
+ idleCallback();
+ addIdleCallback(this, 500);
}
protected:
@@ -86,8 +91,34 @@ protected:
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;
};
// --------------------------------------------------------------------------------------------------------------------