-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcatgl_ui_editbox.h
47 lines (39 loc) · 1.32 KB
/
catgl_ui_editbox.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
void caDrawEditBoxBase(NVGcontext* vg, float x, float y, float w, float h)
{
NVGpaint bg;
// Edit
bg = nvgBoxGradient(vg, x+1,y+1+1.5f, w-2,h-2, 3,4, nvgRGBA(255,255,255,32), nvgRGBA(32,32,32,32));
nvgBeginPath(vg);
nvgRoundedRect(vg, x+1,y+1, w-2,h-2, 4-1);
nvgFillPaint(vg, bg);
nvgFill(vg);
nvgBeginPath(vg);
nvgRoundedRect(vg, x+0.5f,y+0.5f, w-1,h-1, 4-0.5f);
nvgStrokeColor(vg, nvgRGBA(0,0,0,48));
nvgStroke(vg);
}
void caDrawEditBox(NVGcontext* vg, const char* text, float x, float y, float w, float h)
{
caDrawEditBoxBase(vg, x,y, w,h);
nvgFontSize(vg, 20.0f);
nvgFontFace(vg, "sans");
nvgFillColor(vg, nvgRGBA(255,255,255,64));
nvgTextAlign(vg,NVG_ALIGN_LEFT|NVG_ALIGN_MIDDLE);
nvgText(vg, x+h*0.3f,y+h*0.5f,text, NULL);
}
void caDrawEditBoxNum(NVGcontext* vg, const char* text, const char* units, float x, float y, float w, float h)
{
float uw;
caDrawEditBoxBase(vg, x,y, w,h);
uw = nvgTextBounds(vg, 0,0, units, NULL, NULL);
nvgFontSize(vg, 18.0f);
nvgFontFace(vg, "sans");
nvgFillColor(vg, nvgRGBA(255,255,255,64));
nvgTextAlign(vg,NVG_ALIGN_RIGHT|NVG_ALIGN_MIDDLE);
nvgText(vg, x+w-h*0.3f,y+h*0.5f,units, NULL);
nvgFontSize(vg, 20.0f);
nvgFontFace(vg, "sans");
nvgFillColor(vg, nvgRGBA(255,255,255,128));
nvgTextAlign(vg,NVG_ALIGN_RIGHT|NVG_ALIGN_MIDDLE);
nvgText(vg, x+w-uw-h*0.5f,y+h*0.5f,text, NULL);
}