@@ -1 +1 @@ | |||||
Subproject commit ed0d3be276d8b0beaa28dc38eeb79a86db16e425 | |||||
Subproject commit 39c93d6aa2beae64e411feaef300e384196c1e64 |
@@ -31,7 +31,7 @@ using DGL::StandaloneWindow; | |||||
int main() | int main() | ||||
{ | { | ||||
StandaloneWindow swin; | StandaloneWindow swin; | ||||
ExampleColorWidget widget(swin.getWindow()); | |||||
ExampleColorWidget widget(swin); | |||||
swin.setSize(300, 300); | swin.setSize(300, 300); | ||||
swin.setTitle("Color"); | swin.setTitle("Color"); | ||||
@@ -34,6 +34,7 @@ | |||||
using DGL::App; | using DGL::App; | ||||
using DGL::ImageButton; | using DGL::ImageButton; | ||||
using DGL::Size; | |||||
// ------------------------------------------------------ | // ------------------------------------------------------ | ||||
// Our Demo Window | // Our Demo Window | ||||
@@ -50,14 +51,14 @@ public: | |||||
protected: | protected: | ||||
void onDisplay() override | void onDisplay() override | ||||
{ | { | ||||
glColor3f(0.302f, 0.337f, 0.361f); | |||||
glColor3f(0.302f/5, 0.337f/5, 0.361f/5); | |||||
rect.draw(); | rect.draw(); | ||||
// reset color | // reset color | ||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 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 | // always 100px width | ||||
rect.setHeight(height); | rect.setHeight(height); | ||||
@@ -84,9 +85,9 @@ public: | |||||
b1(*this, Image()), | b1(*this, Image()), | ||||
b2(*this, Image()) | b2(*this, Image()) | ||||
{ | { | ||||
wColor.hide(); | |||||
//wColor.hide(); | |||||
wImages.hide(); | wImages.hide(); | ||||
//wRects.hide(); | |||||
wRects.hide(); | |||||
wShapes.hide(); | wShapes.hide(); | ||||
wColor.setX(100); | wColor.setX(100); | ||||
@@ -100,21 +101,15 @@ public: | |||||
//wLeft.toFront(); | //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<int> 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: | private: | ||||
@@ -36,7 +36,7 @@ using DGL::StandaloneWindow; | |||||
int main() | int main() | ||||
{ | { | ||||
StandaloneWindow swin; | StandaloneWindow swin; | ||||
ExampleImagesWidget widget(swin.getWindow(), true); | |||||
ExampleImagesWidget widget(swin, true); | |||||
swin.setTitle("Images"); | swin.setTitle("Images"); | ||||
swin.exec(); | swin.exec(); | ||||
@@ -31,7 +31,7 @@ using DGL::StandaloneWindow; | |||||
int main() | int main() | ||||
{ | { | ||||
StandaloneWindow swin; | StandaloneWindow swin; | ||||
ExampleRectanglesWidget widget(swin.getWindow()); | |||||
ExampleRectanglesWidget widget(swin); | |||||
swin.setSize(300, 300); | swin.setSize(300, 300); | ||||
swin.setTitle("Rectangles"); | swin.setTitle("Rectangles"); | ||||
@@ -31,7 +31,7 @@ using DGL::StandaloneWindow; | |||||
int main() | int main() | ||||
{ | { | ||||
StandaloneWindow swin; | StandaloneWindow swin; | ||||
ExampleShapesWidget widget(swin.getWindow()); | |||||
ExampleShapesWidget widget(swin); | |||||
swin.setSize(300, 300); | swin.setSize(300, 300); | ||||
swin.setTitle("Shapes"); | swin.setTitle("Shapes"); | ||||
@@ -44,6 +44,8 @@ public: | |||||
reverse(false), | reverse(false), | ||||
r(0), g(0), b(0) | r(0), g(0), b(0) | ||||
{ | { | ||||
setSize(300, 300); | |||||
parent.addIdleCallback(this); | parent.addIdleCallback(this); | ||||
} | } | ||||
@@ -112,19 +114,18 @@ protected: | |||||
bgSmall.draw(); | 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 | // full bg | ||||
bgFull = Rectangle<int>(0, 0, width, height); | |||||
bgFull = Rectangle<int>(cx, cy, width, height); | |||||
// small bg, centered 2/3 size | // small bg, centered 2/3 size | ||||
bgSmall = Rectangle<int>(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<int>(cx+width/6, cy+height/6, width*2/3, height*2/3); | |||||
} | } | ||||
char cur; | char cur; | ||||
@@ -39,6 +39,8 @@ public: | |||||
ExampleRectanglesWidget(Window& parent) | ExampleRectanglesWidget(Window& parent) | ||||
: Widget(parent) | : Widget(parent) | ||||
{ | { | ||||
setSize(300, 300); | |||||
for (int i=0; i<9; ++i) | for (int i=0; i<9; ++i) | ||||
fClicked[i] = false; | 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 | bool onMouse(int button, bool press, int x, int y) override | ||||
{ | { | ||||
if (button != 1 || ! press) | if (button != 1 || ! press) | ||||
@@ -39,7 +39,10 @@ class ExampleShapesWidget : public Widget | |||||
{ | { | ||||
public: | public: | ||||
ExampleShapesWidget(Window& parent) | ExampleShapesWidget(Window& parent) | ||||
: Widget(parent) {} | |||||
: Widget(parent) | |||||
{ | |||||
setSize(300, 300); | |||||
} | |||||
protected: | protected: | ||||
void onDisplay() override | void onDisplay() override | ||||
@@ -78,25 +81,24 @@ protected: | |||||
cir.drawOutline(); | 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 | // background | ||||
bg = Rectangle<int>(0, 0, width, height); | |||||
bg = Rectangle<int>(cx, cy, width, height); | |||||
// rectangle | // rectangle | ||||
rect = Rectangle<int>(20, 10, width-40, height-20); | |||||
rect = Rectangle<int>(cx+20, cy+10, width-40, height-20); | |||||
// center triangle | // center triangle | ||||
tri = Triangle<int>(width*0.5, height*0.1, width*0.1, height*0.9, width*0.9, height*0.9); | |||||
tri = Triangle<int>(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 | // circle | ||||
cir = Circle<int>(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<int>(cx+width/2, cy+height*2/3, height/6, 300); | |||||
} | } | ||||
private: | private: | ||||