Work on examples
This commit is contained in:
parent
de15812872
commit
86fa492323
3 changed files with 48 additions and 5 deletions
|
|
@ -2,12 +2,52 @@ import os
|
|||
import nanovg
|
||||
|
||||
type
|
||||
StyleConfig* = ref object
|
||||
cornerRadiusTopLeft*: float
|
||||
cornerRadiusTopRight*: float
|
||||
cornerRadiusBottomLeft*: float
|
||||
cornerRadiusBottomRight*: float
|
||||
|
||||
fontBlur*: float
|
||||
font*: string
|
||||
fontSize*: float
|
||||
fontColor*: Color
|
||||
fontShadowColor*: Color
|
||||
fontShadowXOffset*: float
|
||||
fontShadowYOffset*: float
|
||||
textAlignments*: seq[Alignment]
|
||||
|
||||
hasShadow*: bool
|
||||
shadowColor*: Color
|
||||
shadowXOffset*: float
|
||||
shadowYOffset*: float
|
||||
|
||||
highlightColor*: Color
|
||||
highlightWidth*: float
|
||||
|
||||
fillColor*: Color
|
||||
fillOverlay*: Paint
|
||||
|
||||
|
||||
WindowConfig* = object
|
||||
cornerRadiusTopLeft*: float
|
||||
cornerRadiusTopRight*: float
|
||||
cornerRadiusBottomLeft*: float
|
||||
cornerRadiusBottomRight*: float
|
||||
|
||||
let DEFAULT_BUTTON_STYLE = StyleConfig(
|
||||
cornerRadiusTopLeft: 3.0,
|
||||
cornerRadiusTopRight: 3.0,
|
||||
cornerRadiusBottomLeft: 3.0,
|
||||
cornerRadiusBottomRight: 3.0,
|
||||
fontBlur: 0.0,
|
||||
font: "sans",
|
||||
fontSize: 20.0,
|
||||
fontColor: rgba(255, 255, 255, 160),
|
||||
fontShadowColor: rgba(0, 0, 0, 60)
|
||||
)
|
||||
|
||||
|
||||
# To see icons in code, use a nerd font
|
||||
const ICON_TRASH* = ""
|
||||
const ICON_SEARCH* = "🔍"
|
||||
|
|
@ -42,7 +82,7 @@ proc drawWindow*(vg: Context, title: string, x, y, w, h: float, font="sans") =
|
|||
vg.setFont(font)
|
||||
vg.textAlign("center middle")
|
||||
|
||||
vg.setFontBlur(2)
|
||||
vg.setFontBlur(0)
|
||||
vg.setFillColor(rgba(0,0,0,128))
|
||||
vg.text(title, x+w/2, y+16+1)
|
||||
|
||||
|
|
@ -215,4 +255,4 @@ proc drawSearchBox*(vg: Context, text: string, x, y, w, h: float) =
|
|||
vg.setFont("icons")
|
||||
vg.setFillColor(rgba(255,255,255,32))
|
||||
vg.textAlign("center middle")
|
||||
vg.text(ICON_CIRCLED_CROSS, x+w-h*0.55f, y+h*0.55f)
|
||||
vg.text(ICON_CIRCLED_CROSS, x+w-h*0.55f, y+h*0.55f)
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ proc setFallbackFont*(context: Context, baseFont, fallbackFont: Font): Font =
|
|||
proc `font=`*(context: Context, font: Font) =
|
||||
context.fontFaceId(font)
|
||||
|
||||
proc `font=`*(context: Context, name: string) =
|
||||
context.fontFace(name)
|
||||
|
||||
proc setFont*(context: Context, name: string) =
|
||||
context.fontFace(name)
|
||||
|
||||
|
|
@ -578,8 +581,8 @@ proc pathRect*(context: Context, x, y, width, height: float) =
|
|||
proc pathRoundedRect*(context: Context, x, y, width, height, radius: float) =
|
||||
context.roundedRect(x, y, width, height, radius)
|
||||
|
||||
proc pathRoundedRectVarying*(context: Context, x, y, width, height, radiusTopLeft, radiusTopRight,
|
||||
radiusBottomRight, radiusBottomLeft: float) =
|
||||
proc pathRoundedRect*(context: Context, x, y, width, height, radiusTopLeft, radiusTopRight,
|
||||
radiusBottomRight, radiusBottomLeft: float) =
|
||||
context.roundedRectVarying(
|
||||
x, y, width, height,
|
||||
radiusTopLeft, radiusTopRight, radiusBottomRight, radiusBottomLeft
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ elif defined(unix):
|
|||
when defined(useGlfw):
|
||||
{.passL: "-lGL -lGLU -lGLEW -lm -lglfw".}
|
||||
else:
|
||||
{.passL: "-lGL -lGLU -lGLEW -lm -lpthread -lglfw".}
|
||||
{.passL: "-lGL -lGLU -lGLEW -lm -lpthread".}
|
||||
elif defined(windows):
|
||||
const inclPath = baseDir/"lib"/"include"
|
||||
when defined(amd64):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue