Browse Source

Update for new API

pull/1/head
falkTX 11 years ago
parent
commit
9f5ad68497
5 changed files with 41 additions and 30 deletions
  1. +1
    -1
      dpf
  2. +27
    -22
      examples/demo.cpp
  3. +4
    -1
      examples/widgets/ExampleColorWidget.hpp
  4. +5
    -5
      examples/widgets/ExampleRectanglesWidget.hpp
  5. +4
    -1
      examples/widgets/ExampleShapesWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 326178f2327c60c53357b8f88779e229bf435c75
Subproject commit f187108634f98b0b7fb944dc9ab03c78ccd533e3

+ 27
- 22
examples/demo.cpp View File

@@ -106,11 +106,11 @@ protected:
img4.drawAt(pad, pad + 3 + iconSize*3); img4.drawAt(pad, pad + 3 + iconSize*3);
} }


bool onMouse(int button, bool press, int x, int y) override
bool onMouse(const MouseEvent& ev) override
{ {
if (button != 1 || ! press)
if (ev.button != 1 || ! ev.press)
return false; return false;
if (! contains(x, y))
if (! contains(ev.pos))
return false; return false;


const int iconSize = getWidth(); const int iconSize = getWidth();
@@ -119,7 +119,7 @@ protected:
{ {
bgIcon.setY(i*iconSize + i + 1); bgIcon.setY(i*iconSize + i + 1);


if (bgIcon.contains(x, y))
if (bgIcon.contains(ev.pos))
{ {
curPage = i; curPage = i;
callback->curPageChanged(i); callback->curPageChanged(i);
@@ -131,9 +131,9 @@ protected:
return true; return true;
} }


bool onMotion(int x, int y) override
bool onMotion(const MotionEvent& ev) override
{ {
if (contains(x, y))
if (contains(ev.pos))
{ {
const int iconSize = getWidth(); const int iconSize = getWidth();


@@ -141,7 +141,7 @@ protected:
{ {
bgIcon.setY(i*iconSize + i + 1); bgIcon.setY(i*iconSize + i + 1);


if (bgIcon.contains(x, y))
if (bgIcon.contains(ev.pos))
{ {
if (curHover == i) if (curHover == i)
return true; return true;
@@ -170,9 +170,12 @@ protected:
} }
} }


void onReshape(int width, int height) override
void onResize(const ResizeEvent& ev) override
{ {
bg.setSize(width, height);
const int width = ev.size.getWidth();
const int height = ev.size.getHeight();

bg.setSize(ev.size);


bgIcon.setWidth(width-2); bgIcon.setWidth(width-2);
bgIcon.setHeight(width-2); bgIcon.setHeight(width-2);
@@ -189,6 +192,7 @@ private:
Image img1, img2, img3, img4; Image img1, img2, img3, img4;
}; };


#if 0
// ------------------------------------------------------ // ------------------------------------------------------
// Resize handle // Resize handle


@@ -256,8 +260,8 @@ protected:
if (! press) if (! press)
return false; return false;


fLastX = x+getX();
fLastY = y+getY();
fLastX = x+getAbsoluteX();
fLastY = y+getAbsoluteY();
fMouseUnder = true; fMouseUnder = true;
return true; return true;
} }
@@ -267,8 +271,8 @@ protected:
if (! fMouseUnder) if (! fMouseUnder)
return false; return false;


x += getX();
y += getY();
x += getAbsoluteX();
y += getAbsoluteY();


const int movedX = x - fLastX; const int movedX = x - fLastX;
const int movedY = y - fLastY; const int movedY = y - fLastY;
@@ -291,6 +295,7 @@ protected:
int fLastX, fLastY; int fLastX, fLastY;
Line<float> fLine1, fLine2, fLine3; Line<float> fLine1, fLine2, fLine3;
}; };
#endif


// ------------------------------------------------------ // ------------------------------------------------------
// Our Demo Window // Our Demo Window
@@ -306,7 +311,7 @@ public:
wRects(*this), wRects(*this),
wShapes(*this), wShapes(*this),
wLeft(*this, this), wLeft(*this, this),
wRezHandle(*this),
//wRezHandle(*this),
curWidget(nullptr) curWidget(nullptr)
{ {
wColor.hide(); wColor.hide();
@@ -314,11 +319,11 @@ public:
wRects.hide(); wRects.hide();
wShapes.hide(); wShapes.hide();


wColor.setX(80);
wImages.setX(80);
wRects.setX(80);
wShapes.setX(80);
wLeft.setPos(2, 2);
wColor.setAbsoluteX(80);
wImages.setAbsoluteX(80);
wRects.setAbsoluteX(80);
wShapes.setAbsoluteX(80);
wLeft.setAbsolutePos(2, 2);


setSize(600, 500); setSize(600, 500);
setTitle("DGL Demo"); setTitle("DGL Demo");
@@ -335,8 +340,8 @@ public:
wShapes.setSize(size); wShapes.setSize(size);


wLeft.setSize(73, height-4); wLeft.setSize(73, height-4);
wRezHandle.setX(width-wRezHandle.getWidth());
wRezHandle.setY(height-wRezHandle.getHeight());
//wRezHandle.setAbsoluteX(width-wRezHandle.getWidth());
//wRezHandle.setAbsoluteY(height-wRezHandle.getHeight());


Window::onReshape(width, height); Window::onReshape(width, height);
} }
@@ -376,7 +381,7 @@ private:
ExampleRectanglesWidget wRects; ExampleRectanglesWidget wRects;
ExampleShapesWidget wShapes; ExampleShapesWidget wShapes;
LeftSideWidget wLeft; LeftSideWidget wLeft;
ResizeHandle wRezHandle;
//ResizeHandle wRezHandle;


Widget* curWidget; Widget* curWidget;
}; };


+ 4
- 1
examples/widgets/ExampleColorWidget.hpp View File

@@ -114,8 +114,11 @@ protected:
bgSmall.draw(); bgSmall.draw();
} }


void onReshape(int width, int height) override
void onResize(const ResizeEvent& ev) override
{ {
const int width = ev.size.getWidth();
const int height = ev.size.getHeight();

// full bg // full bg
bgFull = Rectangle<int>(0, 0, width, height); bgFull = Rectangle<int>(0, 0, width, height);




+ 5
- 5
examples/widgets/ExampleRectanglesWidget.hpp View File

@@ -93,9 +93,9 @@ protected:
} }
} }


bool onMouse(int button, bool press, int x, int y) override
bool onMouse(const MouseEvent& ev) override
{ {
if (button != 1 || ! press)
if (ev.button != 1 || ! ev.press)
return false; return false;


const int width = getWidth(); const int width = getWidth();
@@ -114,7 +114,7 @@ protected:
// 1st // 1st
r.setY(3); r.setY(3);


if (r.contains(x, y))
if (r.contains(ev.pos))
{ {
fClicked[0+i] = !fClicked[0+i]; fClicked[0+i] = !fClicked[0+i];
repaint(); repaint();
@@ -124,7 +124,7 @@ protected:
// 2nd // 2nd
r.setY(3 + height/3); r.setY(3 + height/3);


if (r.contains(x, y))
if (r.contains(ev.pos))
{ {
fClicked[3+i] = !fClicked[3+i]; fClicked[3+i] = !fClicked[3+i];
repaint(); repaint();
@@ -134,7 +134,7 @@ protected:
// 3rd // 3rd
r.setY(3 + height*2/3); r.setY(3 + height*2/3);


if (r.contains(x, y))
if (r.contains(ev.pos))
{ {
fClicked[6+i] = !fClicked[6+i]; fClicked[6+i] = !fClicked[6+i];
repaint(); repaint();


+ 4
- 1
examples/widgets/ExampleShapesWidget.hpp View File

@@ -81,8 +81,11 @@ protected:
cir.drawOutline(); cir.drawOutline();
} }


void onReshape(int width, int height) override
void onResize(const ResizeEvent& ev) override
{ {
const int width = ev.size.getWidth();
const int height = ev.size.getHeight();

// background // background
bg = Rectangle<int>(0, 0, width, height); bg = Rectangle<int>(0, 0, width, height);




Loading…
Cancel
Save