Browse Source

Add some text to demo app

pull/1/head
falkTX 11 years ago
parent
commit
7cd22a02b7
2 changed files with 21 additions and 1 deletions
  1. +1
    -1
      dpf
  2. +20
    -0
      examples/demo.cpp

+ 1
- 1
dpf

@@ -1 +1 @@
Subproject commit 3bebc57983052ffc2ba578eeeb6d811f0b278da9
Subproject commit 8d8af85953661c305c96610b7106bb87112357dd

+ 20
- 0
examples/demo.cpp View File

@@ -61,6 +61,9 @@ public:
curPage(0), curPage(0),
curHover(-1) curHover(-1)
{ {
// for text
font = nvg.createFont("sans", "./nanovg_res/Roboto-Regular.ttf");

using namespace DemoArtwork; using namespace DemoArtwork;
img1.loadFromMemory(ico1Data, ico1Width, ico1Height, GL_BGR); img1.loadFromMemory(ico1Data, ico1Width, ico1Height, GL_BGR);
img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR); img2.loadFromMemory(ico2Data, ico2Width, ico2Height, GL_BGR);
@@ -110,6 +113,19 @@ protected:
img3.drawAt(pad, pad + 6 + iconSize*2); img3.drawAt(pad, pad + 6 + iconSize*2);
img4.drawAt(pad, pad + 9 + iconSize*3); img4.drawAt(pad, pad + 9 + iconSize*3);
img5.drawAt(pad, pad + 12 + iconSize*4); img5.drawAt(pad, pad + 12 + iconSize*4);

// draw some text
nvg.beginFrame(this);

nvg.fontSize(23.0f);
nvg.textAlign(NanoVG::ALIGN_LEFT|NanoVG::ALIGN_TOP);
//nvg.textLineHeight(20.0f);

nvg.fillColor(nvg.RGBA(220,220,220,220));
nvg.textBox(10, 420, iconSize, "Haha,", nullptr);
nvg.textBox(15, 440, iconSize, "Look!", nullptr);

nvg.endFrame();
} }


bool onMouse(const MouseEvent& ev) override bool onMouse(const MouseEvent& ev) override
@@ -194,6 +210,10 @@ private:
Rectangle<int> bgIcon; Rectangle<int> bgIcon;
Line<int> lineSep; Line<int> lineSep;
Image img1, img2, img3, img4, img5; Image img1, img2, img3, img4, img5;

// for text
NanoVG nvg;
NanoVG::FontId font;
}; };


#if 0 #if 0


Loading…
Cancel
Save