diff --git a/dpf b/dpf index ed0d3be..39c93d6 160000 --- a/dpf +++ b/dpf @@ -1 +1 @@ -Subproject commit ed0d3be276d8b0beaa28dc38eeb79a86db16e425 +Subproject commit 39c93d6aa2beae64e411feaef300e384196c1e64 diff --git a/examples/color.cpp b/examples/color.cpp index 04bba33..c3a3dc7 100644 --- a/examples/color.cpp +++ b/examples/color.cpp @@ -31,7 +31,7 @@ using DGL::StandaloneWindow; int main() { StandaloneWindow swin; - ExampleColorWidget widget(swin.getWindow()); + ExampleColorWidget widget(swin); swin.setSize(300, 300); swin.setTitle("Color"); diff --git a/examples/demo.cpp b/examples/demo.cpp index d720395..21ad9f4 100644 --- a/examples/demo.cpp +++ b/examples/demo.cpp @@ -34,6 +34,7 @@ using DGL::App; using DGL::ImageButton; +using DGL::Size; // ------------------------------------------------------ // Our Demo Window @@ -50,14 +51,14 @@ public: protected: void onDisplay() override { - glColor3f(0.302f, 0.337f, 0.361f); + glColor3f(0.302f/5, 0.337f/5, 0.361f/5); rect.draw(); // reset color glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } - void onReshape(int width, int height) override + void onReshape(int, int height) override { // always 100px width rect.setHeight(height); @@ -84,9 +85,9 @@ public: b1(*this, Image()), b2(*this, Image()) { - wColor.hide(); + //wColor.hide(); wImages.hide(); - //wRects.hide(); + wRects.hide(); wShapes.hide(); wColor.setX(100); @@ -100,21 +101,15 @@ public: //wLeft.toFront(); } -#if 0 - bool onMouse(int button, bool press, int x, int y) override - { - if (button != 1 || ! press) - return false; - - return true; - } -#endif - - void onReshapeAAA(int width, int height) override + void onReshape(int width, int height) override { - wRects.setSize(width-100, height); + Size size(width-100, height); + wColor.setSize(size); + wImages.setSize(size); + wRects.setSize(size); + wShapes.setSize(size); - //Window::onReshape(width, height); + Window::onReshape(width, height); } private: diff --git a/examples/images.cpp b/examples/images.cpp index 700f8bd..6bfd46f 100644 --- a/examples/images.cpp +++ b/examples/images.cpp @@ -36,7 +36,7 @@ using DGL::StandaloneWindow; int main() { StandaloneWindow swin; - ExampleImagesWidget widget(swin.getWindow(), true); + ExampleImagesWidget widget(swin, true); swin.setTitle("Images"); swin.exec(); diff --git a/examples/rectangles.cpp b/examples/rectangles.cpp index fac92d6..f7099c2 100644 --- a/examples/rectangles.cpp +++ b/examples/rectangles.cpp @@ -31,7 +31,7 @@ using DGL::StandaloneWindow; int main() { StandaloneWindow swin; - ExampleRectanglesWidget widget(swin.getWindow()); + ExampleRectanglesWidget widget(swin); swin.setSize(300, 300); swin.setTitle("Rectangles"); diff --git a/examples/shapes.cpp b/examples/shapes.cpp index 276e1f3..61ce069 100644 --- a/examples/shapes.cpp +++ b/examples/shapes.cpp @@ -31,7 +31,7 @@ using DGL::StandaloneWindow; int main() { StandaloneWindow swin; - ExampleShapesWidget widget(swin.getWindow()); + ExampleShapesWidget widget(swin); swin.setSize(300, 300); swin.setTitle("Shapes"); diff --git a/examples/widgets/ExampleColorWidget.hpp b/examples/widgets/ExampleColorWidget.hpp index 06455bb..9d8fdd3 100644 --- a/examples/widgets/ExampleColorWidget.hpp +++ b/examples/widgets/ExampleColorWidget.hpp @@ -44,6 +44,8 @@ public: reverse(false), r(0), g(0), b(0) { + setSize(300, 300); + parent.addIdleCallback(this); } @@ -112,19 +114,18 @@ protected: bgSmall.draw(); } - void onReshape(int width, int height) override + void onReshape(int, int) override { + const int cx = getX(); + const int cy = getY(); + const int width = getWidth(); + const int height = getHeight(); + // full bg - bgFull = Rectangle(0, 0, width, height); + bgFull = Rectangle(cx, cy, width, height); // small bg, centered 2/3 size - bgSmall = Rectangle(width/6, height/6, width*2/3, height*2/3); - - // make widget same size as window - setSize(width, height); - - // default reshape implementation - Widget::onReshape(width, height); + bgSmall = Rectangle(cx+width/6, cy+height/6, width*2/3, height*2/3); } char cur; diff --git a/examples/widgets/ExampleRectanglesWidget.hpp b/examples/widgets/ExampleRectanglesWidget.hpp index e6ccefd..3fd6f18 100644 --- a/examples/widgets/ExampleRectanglesWidget.hpp +++ b/examples/widgets/ExampleRectanglesWidget.hpp @@ -39,6 +39,8 @@ public: ExampleRectanglesWidget(Window& parent) : Widget(parent) { + setSize(300, 300); + for (int i=0; i<9; ++i) fClicked[i] = false; } @@ -93,13 +95,6 @@ protected: } } - void onReshape(int width, int height) override - { - // make this widget same size as window - //setSize(width, height); - Widget::onReshape(width, height); - } - bool onMouse(int button, bool press, int x, int y) override { if (button != 1 || ! press) diff --git a/examples/widgets/ExampleShapesWidget.hpp b/examples/widgets/ExampleShapesWidget.hpp index ab4f450..ef24d1d 100644 --- a/examples/widgets/ExampleShapesWidget.hpp +++ b/examples/widgets/ExampleShapesWidget.hpp @@ -39,7 +39,10 @@ class ExampleShapesWidget : public Widget { public: ExampleShapesWidget(Window& parent) - : Widget(parent) {} + : Widget(parent) + { + setSize(300, 300); + } protected: void onDisplay() override @@ -78,25 +81,24 @@ protected: cir.drawOutline(); } - void onReshape(int width, int height) override + void onReshape(int, int) override { + const int cx = getX(); + const int cy = getY(); + const int width = getWidth(); + const int height = getHeight(); + // background - bg = Rectangle(0, 0, width, height); + bg = Rectangle(cx, cy, width, height); // rectangle - rect = Rectangle(20, 10, width-40, height-20); + rect = Rectangle(cx+20, cy+10, width-40, height-20); // center triangle - tri = Triangle(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9); + tri = Triangle(cx+width*0.5, cy+height*0.1, cx+width*0.1, cy+height*0.9, cx+width*0.9, cy+height*0.9); // circle - cir = Circle(width/2, height*2/3, height/6, 300); - - // make widget same size as window - setSize(width, height); - - // default reshape implementation - Widget::onReshape(width, height); + cir = Circle(cx+width/2, cy+height*2/3, height/6, 300); } private: