egra: YesNoWindow cosmetix
[iv.d.git] / skeletons / sdpynano.d
bloba9ec51e7cd5a92f367ba4eb910f3d017a7756df2
1 import arsd.color;
2 import arsd.simpledisplay;
4 import iv.cmdcon;
5 import iv.cmdcongl;
6 import iv.nanovg;
9 // ////////////////////////////////////////////////////////////////////////// //
10 __gshared string optEditorFont = "~/ttf/ms/arial.ttf:noaa";
11 __gshared int optEditorFontSize = 14;
12 __gshared NVGContext nvg = null;
15 // ////////////////////////////////////////////////////////////////////////// //
16 void main (string[] args) {
17 glconShowKey = "M-Grave";
19 conRegVar!optEditorFont("ed_font_path", "path to TTF font");
20 conRegVar!optEditorFontSize(6, 72, "ed_font_size", "editor font size");
22 conProcessQueue(); // load config
23 conProcessArgs!true(args);
26 // first time setup
27 oglSetupDG = delegate () {
28 // create and upload texture, rebuild screen
29 nvg = createGL2NVG(NVG_FONT_NOAA|NVG_ANTIALIAS|NVG_STENCIL_STROKES/*|NVG_DEBUG*/);
30 if (nvg is null) assert(0, "Could not init nanovg.");
31 nvg.createFont("sans", optEditorFont);
35 resizeEventDG = delegate (int wdt, int hgt) {
39 // draw main screen
40 redrawFrameDG = delegate () {
41 // draw main screen
42 glClearColor(0, 0, 0, 0);
43 glClear(glNVGClearFlags|GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);
44 glViewport(0, 0, glconCtlWindow.width, glconCtlWindow.height);
46 if (nvg !is null) {
47 nvg.beginFrame(glconCtlWindow.width, glconCtlWindow.height, 1);
49 nvg.beginPath();
50 nvg.roundedRect(0, 0, glconCtlWindow.width, glconCtlWindow.height, 3);
51 nvg.fillColor(nvgRGB(255, 127, 0));
52 nvg.fill();
54 nvg.fontSize(optEditorFontSize);
55 nvg.fontFace("sans");
56 nvg.textAlign(NVGTextAlign.H.Center, NVGTextAlign.V.Middle);
57 nvg.fillColor(nvgRGB(0, 0, 255));
58 nvg.text(glconCtlWindow.width/2, glconCtlWindow.height/2, "Hello! Двощер молодых");
60 nvg.endFrame();
65 // rebuild main screen (do any calculations we might need)
66 nextFrameDG = delegate () {
70 keyEventDG = delegate (KeyEvent event) {
71 if (!event.pressed) return;
72 switch (event.key) {
73 case Key.Escape: concmd("quit"); break;
74 default:
78 mouseEventDG = delegate (MouseEvent event) {
81 charEventDG = delegate (dchar ch) {
82 if (ch == 'q') { concmd("quit"); return; }
86 glconRunGLWindowResizeable(800, 600, "My D App", "SDPY WINDOW");
87 if (nvg !is null) { nvg.deleteGL2(); nvg = null; }