diff --git a/examples/demo.cpp b/examples/demo.cpp index 21ad9f4..b54e161 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -43,8 +43,7 @@ class LeftSizeWidget : public Widget { public: LeftSizeWidget(Window& parent) - : Widget(parent), - rect(0, 0, 100, 0) + : Widget(parent) { } @@ -52,21 +51,19 @@ protected: void onDisplay() override { glColor3f(0.302f/5, 0.337f/5, 0.361f/5); - rect.draw(); + bg.draw(); // reset color glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } - void onReshape(int, int height) override + void onReshape(int, int) override { - // always 100px width - rect.setHeight(height); - setSize(100, height); + bg = getArea(); } private: - Rectangle rect; + Rectangle bg; }; // ------------------------------------------------------ @@ -85,7 +82,7 @@ public: b1(*this, Image()), b2(*this, Image()) { - //wColor.hide(); + wColor.hide(); wImages.hide(); wRects.hide(); wShapes.hide(); @@ -97,8 +94,6 @@ public: setSize(600, 500); setTitle("DGL Demo"); - - //wLeft.toFront(); } void onReshape(int width, int height) override @@ -109,6 +104,8 @@ public: wRects.setSize(size); wShapes.setSize(size); + wLeft.setSize(100, height); + Window::onReshape(width, height); } diff --git a/examples/widgets/ExampleColorWidget.hpp b/examples/widgets/ExampleColorWidget.hpp index 9d8fdd3..800dc0b 100644 --- a/examples/widgets/ExampleColorWidget.hpp +++ b/examples/widgets/ExampleColorWidget.hpp @@ -122,7 +122,7 @@ protected: const int height = getHeight(); // full bg - bgFull = Rectangle(cx, cy, width, height); + bgFull = getArea(); // small bg, centered 2/3 size bgSmall = Rectangle(cx+width/6, cy+height/6, width*2/3, height*2/3); diff --git a/examples/widgets/ExampleShapesWidget.hpp b/examples/widgets/ExampleShapesWidget.hpp index ef24d1d..d213199 100644 --- a/examples/widgets/ExampleShapesWidget.hpp +++ b/examples/widgets/ExampleShapesWidget.hpp @@ -89,7 +89,7 @@ protected: const int height = getHeight(); // background - bg = Rectangle(cx, cy, width, height); + bg = getArea(); // rectangle rect = Rectangle(cx+20, cy+10, width-40, height-20);