Browse Source

More work

pull/1/head
falkTX 11 years ago
parent
commit
c0367b6893
5 changed files with 26 additions and 26 deletions
  1. +1
    -1
      dpf
  2. +2
    -5
      examples/Makefile
  3. +17
    -3
      examples/demo.cpp
  4. +4
    -9
      examples/nanovg.cpp
  5. +2
    -8
      examples/widgets/ExampleTextWidget.hpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 568b765007958ba86bed1553b7f34dcc1bb2ed3f
Subproject commit edf7cebc93c6172d45111deb7e52b5df44652ba5

+ 2
- 5
examples/Makefile View File

@@ -16,9 +16,9 @@ WINDRES ?= windres
# -------------------------------------------------------------- # --------------------------------------------------------------


ifeq ($(WIN32),true) ifeq ($(WIN32),true)
TARGETS = app.exe color.exe demo.exe images.exe nanovg.exe rectangles.exe shapes.exe
TARGETS = app.exe color.exe demo.exe images.exe nanovg.exe rectangles.exe shapes.exe text.exe
else else
TARGETS = app color demo images nanovg rectangles shapes
TARGETS = app color demo images nanovg rectangles shapes text
endif endif


# -------------------------------------------------------------- # --------------------------------------------------------------
@@ -71,9 +71,6 @@ cairo: cairo.cpp ../dpf/dgl/*
qt-embed: qt-embed.cpp ../dpf/dgl/* qt-embed: qt-embed.cpp ../dpf/dgl/*
$(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags --libs QtCore QtGui) $(LINK_FLAGS) -o $@ $(CXX) $< $(BUILD_CXX_FLAGS) $(shell pkg-config --cflags --libs QtCore QtGui) $(LINK_FLAGS) -o $@


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

# -------------------------------------------------------------- # --------------------------------------------------------------


%.exe: %.cpp win32/distrho.o %.exe: %.cpp win32/distrho.o


+ 17
- 3
examples/demo.cpp View File

@@ -23,6 +23,7 @@
#include "widgets/ExampleImagesWidget.hpp" #include "widgets/ExampleImagesWidget.hpp"
#include "widgets/ExampleRectanglesWidget.hpp" #include "widgets/ExampleRectanglesWidget.hpp"
#include "widgets/ExampleShapesWidget.hpp" #include "widgets/ExampleShapesWidget.hpp"
#include "widgets/ExampleTextWidget.hpp"


// ------------------------------------------------------ // ------------------------------------------------------
// Images // Images
@@ -44,6 +45,8 @@ using DGL::Size;
class LeftSideWidget : public Widget class LeftSideWidget : public Widget
{ {
public: public:
static const int kPageCount = 5;

class Callback class Callback
{ {
public: public:
@@ -62,6 +65,7 @@ public:
img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR); img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR);
img3.loadFromMemory(ico3Data, ico3Width, ico2Height, GL_BGR); img3.loadFromMemory(ico3Data, ico3Width, ico2Height, GL_BGR);
img4.loadFromMemory(ico4Data, ico4Width, ico4Height, GL_BGR); img4.loadFromMemory(ico4Data, ico4Width, ico4Height, GL_BGR);
//img5.loadFromMemory(ico5Data, ico5Width, ico5Height, GL_BGR);
} }


protected: protected:
@@ -104,6 +108,7 @@ protected:
img2.drawAt(pad, pad + 1 + iconSize); img2.drawAt(pad, pad + 1 + iconSize);
img3.drawAt(pad, pad + 2 + iconSize*2); img3.drawAt(pad, pad + 2 + iconSize*2);
img4.drawAt(pad, pad + 3 + iconSize*3); img4.drawAt(pad, pad + 3 + iconSize*3);
//img5.drawAt(pad, pad + 3 + iconSize*3);
} }


bool onMouse(const MouseEvent& ev) override bool onMouse(const MouseEvent& ev) override
@@ -115,7 +120,7 @@ protected:


const int iconSize = getWidth(); const int iconSize = getWidth();


for (int i=0; i<4; ++i)
for (int i=0; i<kPageCount; ++i)
{ {
bgIcon.setY(i*iconSize + i + 1); bgIcon.setY(i*iconSize + i + 1);


@@ -137,7 +142,7 @@ protected:
{ {
const int iconSize = getWidth(); const int iconSize = getWidth();


for (int i=0; i<4; ++i)
for (int i=0; i<kPageCount; ++i)
{ {
bgIcon.setY(i*iconSize + i + 1); bgIcon.setY(i*iconSize + i + 1);


@@ -189,7 +194,7 @@ private:
int curPage, curHover; int curPage, curHover;
Rectangle<int> bg, bgIcon; Rectangle<int> bg, bgIcon;
Line<int> lineSep; Line<int> lineSep;
Image img1, img2, img3, img4;
Image img1, img2, img3, img4, img5;
}; };


#if 0 #if 0
@@ -310,6 +315,7 @@ public:
wImages(*this), wImages(*this),
wRects(*this), wRects(*this),
wShapes(*this), wShapes(*this),
wText(*this),
wLeft(*this, this), wLeft(*this, this),
//wRezHandle(*this), //wRezHandle(*this),
curWidget(nullptr) curWidget(nullptr)
@@ -318,11 +324,13 @@ public:
wImages.hide(); wImages.hide();
wRects.hide(); wRects.hide();
wShapes.hide(); wShapes.hide();
wText.hide();


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


setSize(600, 500); setSize(600, 500);
@@ -338,6 +346,7 @@ public:
wImages.setSize(size); wImages.setSize(size);
wRects.setSize(size); wRects.setSize(size);
wShapes.setSize(size); wShapes.setSize(size);
wText.setSize(size);


wLeft.setSize(73, height-4); wLeft.setSize(73, height-4);
//wRezHandle.setAbsoluteX(width-wRezHandle.getWidth()); //wRezHandle.setAbsoluteX(width-wRezHandle.getWidth());
@@ -369,6 +378,10 @@ protected:
case 3: case 3:
curWidget = &wShapes; curWidget = &wShapes;
break; break;
break;
case 4:
curWidget = &wText;
break;
} }


if (curWidget != nullptr) if (curWidget != nullptr)
@@ -380,6 +393,7 @@ private:
ExampleImagesWidget wImages; ExampleImagesWidget wImages;
ExampleRectanglesWidget wRects; ExampleRectanglesWidget wRects;
ExampleShapesWidget wShapes; ExampleShapesWidget wShapes;
ExampleTextWidget wText;
LeftSideWidget wLeft; LeftSideWidget wLeft;
//ResizeHandle wRezHandle; //ResizeHandle wRezHandle;




+ 4
- 9
examples/nanovg.cpp View File

@@ -104,13 +104,12 @@ int my = 0;


double prevt = 0; double prevt = 0;


class NanoExampleWidget : public Widget,
public IdleCallback,
public NanoVG
class NanoExampleWidget : public NanoWidget,
public IdleCallback
{ {
public: public:
NanoExampleWidget(Window& parent) NanoExampleWidget(Window& parent)
: Widget(parent),
: NanoWidget(parent),
fContext(getContext()) fContext(getContext())
{ {
parent.addIdleCallback(this); parent.addIdleCallback(this);
@@ -136,7 +135,7 @@ protected:
repaint(); repaint();
} }


void onDisplay() override
void onNanoDisplay() override
{ {
if (fContext == nullptr) if (fContext == nullptr)
return; return;
@@ -158,13 +157,9 @@ protected:


glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);


beginFrame(winWidth, winHeight, premult ? PREMULTIPLIED_ALPHA : STRAIGHT_ALPHA);

renderDemo(fContext, mx, my, winWidth, winHeight, t, blowup, &fData); renderDemo(fContext, mx, my, winWidth, winHeight, t, blowup, &fData);
renderGraph(fContext, 5, 5, &fPerf); renderGraph(fContext, 5, 5, &fPerf);


endFrame();

if (screenshot) if (screenshot)
{ {
screenshot = 0; screenshot = 0;


+ 2
- 8
examples/widgets/ExampleTextWidget.hpp View File

@@ -20,7 +20,7 @@
// ------------------------------------------------------ // ------------------------------------------------------
// DGL Stuff // DGL Stuff


#include "NanoWidget.hpp"
#include "NanoVG.hpp"


// ------------------------------------------------------ // ------------------------------------------------------
// use namespace // use namespace
@@ -42,14 +42,11 @@ public:
} }


protected: protected:
void onDisplay() override
void onNanoDisplay() override
{ {
const int width = getWidth(); const int width = getWidth();
const int height = getHeight(); const int height = getHeight();


beginFrame();
save();

fontSize(40.0f); fontSize(40.0f);
textAlign(Align(ALIGN_CENTER|ALIGN_MIDDLE)); textAlign(Align(ALIGN_CENTER|ALIGN_MIDDLE));
textLineHeight(20.0f); textLineHeight(20.0f);
@@ -61,9 +58,6 @@ protected:


fillColor(RGBA(0,0,0,220)); fillColor(RGBA(0,0,0,220));
textBox(10, height/2, width-20, "Hello World!", nullptr); textBox(10, height/2, width-20, "Hello World!", nullptr);

restore();
endFrame();
} }


private: private:


Loading…
Cancel
Save