From a10a1d8812aa61865fa538ba7cef0934f7a5649f Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Thu, 7 May 2020 19:32:01 -0600 Subject: [PATCH] Fix glew, add more icons to example --- examples/common.nim | 20 ++++++++++---------- examples/demo.nim | 2 +- examples/demo_sdl2.nim | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/common.nim b/examples/common.nim index 3b6ff7b..143878b 100644 --- a/examples/common.nim +++ b/examples/common.nim @@ -8,25 +8,27 @@ type cornerRadiusBottomLeft*: float cornerRadiusBottomRight*: float -# const ICON_TRASH: cint = 0x0000f1f8 const ICON_TRASH* = "" -# const ICON_TRASH = "\uf1f8" -#const ICON_TRASH: cint = 0xE729 +const ICON_SEARCH* = "🔍" +const ICON_CIRCLED_CROSS* = "✖" +const ICON_CHEVRON_RIGHT* = "\uE75E" +const ICON_CHECK* = "✓" +const ICON_LOGIN* = "\uE740" proc currentSourceDir*(): string {.inline.} = return currentSourcePath.parentDir() # Config -proc drawLabel*(vg: Context, text: string, x, y, w, h: float) = +proc drawLabel*(vg: Context, text: string, x, y, w, h: float, font="sans") = vg.setFontSize(50.0) - vg.setFont("sans") + vg.setFont(font) vg.setFillColor(1.0, 1.0, 1.0, 1.0) vg.textAlign("left middle") vg.text(text, x, y+h*0.5) -proc drawWindow*(vg: Context, title: string, x, y, w, h: float) = +proc drawWindow*(vg: Context, title: string, x, y, w, h: float, font="sans") = let cornerRadius = 3.0 withState(vg): vg.beginPath() @@ -36,7 +38,7 @@ proc drawWindow*(vg: Context, title: string, x, y, w, h: float) = vg.pathFill() vg.setFontSize(30.0) - vg.setFont("sans") + vg.setFont(font) vg.textAlign("center middle") vg.setFontBlur(2) @@ -184,6 +186,4 @@ proc drawButton*(vg: Context, preicon: string, text: string, x, y, w, h: float, vg.setFillColor(rgba(0,0,0,160)) vg.text(text, x+w*0.5-tw*0.5+iw*0.25, y+h*0.5-1) vg.setFillColor(rgba(255,255,255,160)) - vg.text(text, x+w*0.5-tw*0.5+iw*0.25, y+h*0.5) - -proc glewInit*() {.header:"".} \ No newline at end of file + vg.text(text, x+w*0.5-tw*0.5+iw*0.25, y+h*0.5) \ No newline at end of file diff --git a/examples/demo.nim b/examples/demo.nim index bc6b3e1..652e556 100644 --- a/examples/demo.nim +++ b/examples/demo.nim @@ -22,7 +22,7 @@ proc main = swapInterval(0) setTime(0) - glewInit() + glew.init() let vg = nanovg.newContext() vg.loadFont(currentSourceDir()/"resources/Roboto-Regular.ttf", "sans") vg.loadFont(currentSourceDir()/"resources/Roboto-Bold.ttf", "sans-bold") diff --git a/examples/demo_sdl2.nim b/examples/demo_sdl2.nim index f656180..6731365 100644 --- a/examples/demo_sdl2.nim +++ b/examples/demo_sdl2.nim @@ -70,7 +70,7 @@ proc main() = var done = false var prevt: float = sdl.getTicks().float/1000.0 - glewInit() + discard glew.init() let vg = nanovg.newContext() vg.loadFont(currentSourceDir()/"resources"/"Roboto-Regular.ttf", "sans") vg.loadFont(currentSourceDir()/"resources"/"Roboto-Bold.ttf", "sans-bold")