v2 / vlib / gg / gg_ui.c.v
27 lines · 21 sloc · 907 bytes · e2e5cf8db56f3562c7baa735061690be936bdf3e
Raw
1module gg
2
3import sokol.sgl
4
5// Stuff for ui from now for screenshot (that would be interesting for gg if screenshot is implemented also for gg)
6
7// required for ui.DrawDevice interface (with &gg.Context as an instance)
8pub fn (ctx &Context) scissor_rect(x int, y int, w int, h int) {
9 sgl.scissor_rect(int(ctx.scale * x), int(ctx.scale * y), int(ctx.scale * w),
10 int(ctx.scale * h), true)
11}
12
13// empty function
14pub fn (ctx &Context) has_text_style() bool {
15 return false
16}
17
18// empty function
19pub fn (ctx &Context) set_text_style(font_name string, font_path string, size int, color Color, align int,
20 vertical_align int) {
21}
22
23// default draw_text (draw_text_def but without set_text_cfg)
24pub fn (ctx &Context) draw_text_default(x int, y int, text string) {
25 scale := if ctx.ft.scale == 0 { f32(1) } else { ctx.ft.scale }
26 ctx.ft.fons.draw_text(x * scale, y * scale, text) // TODO: check offsets/alignment
27}
28