/
catgl_ui_window.h
51 lines (43 loc) · 1.35 KB
/
catgl_ui_window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
void caDrawWindow(NVGcontext* vg, const char* title, float x, float y, float w, float h)
{
float cornerRadius = 3.0f;
NVGpaint shadowPaint;
NVGpaint headerPaint;
nvgSave(vg);
// nvgClearState(vg);
// Window
nvgBeginPath(vg);
nvgRoundedRect(vg, x,y, w,h, cornerRadius);
nvgFillColor(vg, nvgRGBA(28,30,34,192));
// nvgFillColor(vg, nvgRGBA(0,0,0,128));
nvgFill(vg);
// Drop shadow
shadowPaint = nvgBoxGradient(vg, x,y+2, w,h, cornerRadius*2, 10, nvgRGBA(0,0,0,128), nvgRGBA(0,0,0,0));
nvgBeginPath(vg);
nvgRect(vg, x-10,y-10, w+20,h+30);
nvgRoundedRect(vg, x,y, w,h, cornerRadius);
nvgPathWinding(vg, NVG_HOLE);
nvgFillPaint(vg, shadowPaint);
nvgFill(vg);
// Header
headerPaint = nvgLinearGradient(vg, x,y,x,y+15, nvgRGBA(255,255,255,8), nvgRGBA(0,0,0,16));
nvgBeginPath(vg);
nvgRoundedRect(vg, x+1,y+1, w-2,30, cornerRadius-1);
nvgFillPaint(vg, headerPaint);
nvgFill(vg);
nvgBeginPath(vg);
nvgMoveTo(vg, x+0.5f, y+0.5f+30);
nvgLineTo(vg, x+0.5f+w-1, y+0.5f+30);
nvgStrokeColor(vg, nvgRGBA(0,0,0,32));
nvgStroke(vg);
nvgFontSize(vg, 18.0f);
nvgFontFace(vg, "sans-bold");
nvgTextAlign(vg,NVG_ALIGN_CENTER|NVG_ALIGN_MIDDLE);
nvgFontBlur(vg,2);
nvgFillColor(vg, nvgRGBA(0,0,0,128));
nvgText(vg, x+w/2,y+16+1, title, NULL);
nvgFontBlur(vg,0);
nvgFillColor(vg, nvgRGBA(220,220,220,160));
nvgText(vg, x+w/2,y+16, title, NULL);
nvgRestore(vg);
}