Browse Source

Sort out demo widget resize stuff

pull/1/head
falkTX 11 years ago
parent
commit
07b070ff96
9 changed files with 43 additions and 50 deletions
  1. +1
    -1
      dpf
  2. +1
    -1
      examples/color.cpp
  3. +12
    -17
      examples/demo.cpp
  4. +1
    -1
      examples/images.cpp
  5. +1
    -1
      examples/rectangles.cpp
  6. +1
    -1
      examples/shapes.cpp
  7. +10
    -9
      examples/widgets/ExampleColorWidget.hpp
  8. +2
    -7
      examples/widgets/ExampleRectanglesWidget.hpp
  9. +14
    -12
      examples/widgets/ExampleShapesWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit ed0d3be276d8b0beaa28dc38eeb79a86db16e425
Subproject commit 39c93d6aa2beae64e411feaef300e384196c1e64

+ 1
- 1
examples/color.cpp View File

@@ -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");


+ 12
- 17
examples/demo.cpp View File

@@ -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<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:


+ 1
- 1
examples/images.cpp View File

@@ -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();


+ 1
- 1
examples/rectangles.cpp View File

@@ -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");


+ 1
- 1
examples/shapes.cpp View File

@@ -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");


+ 10
- 9
examples/widgets/ExampleColorWidget.hpp View File

@@ -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<int>(0, 0, width, height);
bgFull = Rectangle<int>(cx, cy, width, height);

// 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;


+ 2
- 7
examples/widgets/ExampleRectanglesWidget.hpp View File

@@ -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)


+ 14
- 12
examples/widgets/ExampleShapesWidget.hpp View File

@@ -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<int>(0, 0, width, height);
bg = Rectangle<int>(cx, cy, width, height);

// rectangle
rect = Rectangle<int>(20, 10, width-40, height-20);
rect = Rectangle<int>(cx+20, cy+10, width-40, height-20);

// 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
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:


Loading…
Cancel
Save