Browse Source

Rename some files; more demo work

pull/1/head
falkTX 11 years ago
parent
commit
43815cf6e1
12 changed files with 114 additions and 27 deletions
  1. +1
    -1
      dpf
  2. +1
    -1
      examples/Makefile
  3. +81
    -5
      examples/demo.cpp
  4. +1
    -1
      examples/images.cpp
  5. +0
    -0
      examples/images_res/CREDITS.txt
  6. +0
    -0
      examples/images_res/CatPics.cpp
  7. +0
    -0
      examples/images_res/CatPics.hpp
  8. +0
    -0
      examples/images_res/cat1.png
  9. +0
    -0
      examples/images_res/cat2.png
  10. +0
    -0
      examples/images_res/cat3.png
  11. +13
    -10
      examples/widgets/ExampleImagesWidget.hpp
  12. +17
    -9
      examples/widgets/ExampleRectanglesWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 142af3edcb598e0293f3637b0bad8f4af4158f24
Subproject commit ed0d3be276d8b0beaa28dc38eeb79a86db16e425

+ 1
- 1
examples/Makefile View File

@@ -48,7 +48,7 @@ color: color.cpp ../dpf/dgl/*
demo: demo.cpp ../dpf/dgl/*
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@

images: images.cpp images_src/* ../dpf/dgl/*
images: images.cpp images_res/* ../dpf/dgl/*
$(CXX) $< $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $@

rectangles: rectangles.cpp ../dpf/dgl/*


+ 81
- 5
examples/demo.cpp View File

@@ -17,6 +17,7 @@
// ------------------------------------------------------
// DGL Stuff

#include "ImageButton.hpp"
#include "StandaloneWindow.hpp"
#include "widgets/ExampleColorWidget.hpp"
#include "widgets/ExampleImagesWidget.hpp"
@@ -26,12 +27,46 @@
// ------------------------------------------------------
// Images

#include "images_src/CatPics.cpp"
#include "images_res/CatPics.cpp"

// ------------------------------------------------------
// use namespace

using DGL::App;
using DGL::ImageButton;

// ------------------------------------------------------
// Our Demo Window

class LeftSizeWidget : public Widget
{
public:
LeftSizeWidget(Window& parent)
: Widget(parent),
rect(0, 0, 100, 0)
{
}

protected:
void onDisplay() override
{
glColor3f(0.302f, 0.337f, 0.361f);
rect.draw();

// reset color
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}

void onReshape(int width, int height) override
{
// always 100px width
rect.setHeight(height);
setSize(100, height);
}

private:
Rectangle<int> rect;
};

// ------------------------------------------------------
// Our Demo Window
@@ -40,15 +75,56 @@ class DemoWindow : public Window
{
public:
DemoWindow(App& app)
: Window(app)//,
//w1(*this)
: Window(app),
wColor(*this),
wImages(*this),
wRects(*this),
wShapes(*this),
wLeft(*this),
b1(*this, Image()),
b2(*this, Image())
{
setSize(300, 300);
wColor.hide();
wImages.hide();
//wRects.hide();
wShapes.hide();

wColor.setX(100);
wImages.setX(100);
wRects.setX(100);
wShapes.setX(100);

setSize(600, 500);
setTitle("DGL Demo");

//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
{
wRects.setSize(width-100, height);

//Window::onReshape(width, height);
}

private:
//DummyWidget w1;
ExampleColorWidget wColor;
ExampleImagesWidget wImages;
ExampleRectanglesWidget wRects;
ExampleShapesWidget wShapes;
LeftSizeWidget wLeft;

ImageButton b1, b2;
};

// ------------------------------------------------------


+ 1
- 1
examples/images.cpp View File

@@ -23,7 +23,7 @@
// ------------------------------------------------------
// Images

#include "images_src/CatPics.cpp"
#include "images_res/CatPics.cpp"

// ------------------------------------------------------
// use namespace


examples/images_src/CREDITS.txt → examples/images_res/CREDITS.txt View File


examples/images_src/CatPics.cpp → examples/images_res/CatPics.cpp View File


examples/images_src/CatPics.hpp → examples/images_res/CatPics.hpp View File


examples/images_src/cat1.png → examples/images_res/cat1.png View File


examples/images_src/cat2.png → examples/images_res/cat2.png View File


examples/images_src/cat3.png → examples/images_res/cat3.png View File


+ 13
- 10
examples/widgets/ExampleImagesWidget.hpp View File

@@ -27,7 +27,7 @@
// ------------------------------------------------------
// Images

#include "../images_src/CatPics.hpp"
#include "../images_res/CatPics.hpp"

// ------------------------------------------------------
// use namespace
@@ -144,42 +144,45 @@ private:

void onDisplay() override
{
const int cx = getX();
const int cy = getY();

switch (fImgTop3rd)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
fImg1.drawAt(fImg1x+cx, kImg1y+cy);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
fImg2.drawAt(fImg2x+cx, kImg2y+cy);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
fImg3.drawAt(kImg3x+cx, fImg3y+cy);
break;
};

switch (fImgTop2nd)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
fImg1.drawAt(fImg1x+cx, kImg1y+cy);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
fImg2.drawAt(fImg2x+cx, kImg2y+cy);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
fImg3.drawAt(kImg3x+cx, fImg3y+cy);
break;
};

switch (fImgTop1st)
{
case 1:
fImg1.drawAt(fImg1x, kImg1y);
fImg1.drawAt(fImg1x+cx, kImg1y+cy);
break;
case 2:
fImg2.drawAt(fImg2x, kImg2y);
fImg2.drawAt(fImg2x+cx, kImg2y+cy);
break;
case 3:
fImg3.drawAt(kImg3x, fImg3y);
fImg3.drawAt(kImg3x+cx, fImg3y+cy);
break;
};
}


+ 17
- 9
examples/widgets/ExampleRectanglesWidget.hpp View File

@@ -46,6 +46,8 @@ public:
protected:
void onDisplay() override
{
const int cx = getX();
const int cy = getY();
const int width = getWidth();
const int height = getHeight();

@@ -57,10 +59,10 @@ protected:
// draw a 3x3 grid
for (int i=0; i<3; ++i)
{
r.setX(3 + i*width/3);
r.setX(cx + 3 + i*width/3);

// 1st
r.setY(3);
r.setY(cy + 3);

if (fClicked[0+i])
glColor3f(0.8f, 0.5f, 0.3f);
@@ -70,7 +72,7 @@ protected:
r.draw();

// 2nd
r.setY(3 + height/3);
r.setY(cy + 3 + height/3);

if (fClicked[3+i])
glColor3f(0.8f, 0.5f, 0.3f);
@@ -80,7 +82,7 @@ protected:
r.draw();

// 3rd
r.setY(3 + height*2/3);
r.setY(cy + 3 + height*2/3);

if (fClicked[6+i])
glColor3f(0.8f, 0.5f, 0.3f);
@@ -94,7 +96,7 @@ protected:
void onReshape(int width, int height) override
{
// make this widget same size as window
setSize(width, height);
//setSize(width, height);
Widget::onReshape(width, height);
}

@@ -103,6 +105,8 @@ protected:
if (button != 1 || ! press)
return false;

const int cx = getX();
const int cy = getY();
const int width = getWidth();
const int height = getHeight();

@@ -114,8 +118,10 @@ protected:
// draw a 3x3 grid
for (int i=0; i<3; ++i)
{
r.setX(3 + i*width/3);
r.setY(3);
r.setX(cx + 3 + i*width/3);

// 1st
r.setY(cy + 3);

if (r.contains(x, y))
{
@@ -124,7 +130,8 @@ protected:
break;
}

r.setY(3 + height/3);
// 2nd
r.setY(cy + 3 + height/3);

if (r.contains(x, y))
{
@@ -133,7 +140,8 @@ protected:
break;
}

r.setY(3 + height*2/3);
// 3rd
r.setY(cy + 3 + height*2/3);

if (r.contains(x, y))
{


Loading…
Cancel
Save