D Paste by h3
Description: GUI test app
|
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | import testcommon; import gui.GuiRenderer; import std.string; import derelict.sdl.sdl; void main() { doGui({ cursor.load(CursorType.Arrow, `cursors/alpha/alpha-normal-select`); cursor.current = CursorType.Arrow; SDL_ShowCursor(0); }, (GuiRenderer renderer){ Window() .title(`Deadlock Game Client`) .init((Window wnd) { wnd.parentOffset = vec2i(210, 100); }) [{ int offset = Slider() .init((Slider s) { with (s) { _discrete = 0; _width = 200; _scalesHalfHeight = 4; _boxHeight = 11; _boxHalfWidth = 4; }})._position; Border().color(vec4(1, 0, 0, 0.4)).cutCorner(false) [{ Fill().padding(vec2i(1, 1)) [{ Viewport().virtualArea(vec2i(300, 400)).virtualOffset(vec2i(0, -offset/4)) [{ VBox().spacing(10) [{ HBox() [{ Label().text(`server IP: `).size.x = 100; InputBox() .init((InputBox input) { with (input) { text = `127.0.0.1`; hexpand = hfill = true; }}); }]; HBox() [{ Label().text(`server port: `).size.x = 100; InputBox() .init((InputBox input) { with (input) { text = `12340`; hexpand = hfill = true; }}); }]; HBox() [{ Label().text(`player name: `).size.x = 100; InputBox() .init((InputBox input) { with (input) { text = `Player`; hexpand = hfill = true; }}); }]; }]; }].size = vec2i(200, 40); }]; }]; RadioGroup rg; RadioButton().text(`option 1`).group(rg); RadioButton().text(`option 2`).group(rg); DefaultOption = RadioButton().text(`option 3`).group(rg); //writefln(`radio selected: %s (%s)`, rg.index, rg.text); HBox() [{ Image().source(`cursors/alpha/alpha-normal-select.png`).color(vec4(1, 1, 1, 1)); Image().source(`cursors/alpha/alpha-normal-select.png`).color(vec4(1, 1, 1, 0.67)); Image().source(`cursors/alpha/alpha-normal-select.png`).color(vec4(1, 1, 1, 0.3)); Image().source(`cursors/alpha/alpha-help-select.png`); Image().source(`cursors/alpha/alpha-unavailable.png`); Image().source(`cursors/alpha/alpha-working-in-background.png`); }]; Button().text(`Connect`).hexpand = true; static float prog = -0.2f; prog += 0.003f; if (prog > 1.2) prog = -0.2; Border() [{ Fill().padding(vec2i(3, 3)) [{ ProgressBar().progress(prog).bitmap(`icons/progress.png`).color(vec4(1, 1, 1, 0.8)).continuous(true).size.x = 144; }]; }]; with (Border() [{ with (Fill().padding(vec2i(3, 3)) [{ with (ProgressBar().progress(prog).continuous(false).color(vec4(0.8, 0.8, 0.8, 0.8)).spacing(2).barWidth(8)) { hexpand = hfill = true; size.y = 12; } }]) { hexpand = hfill = true; color = vec4(0.1, 0.1, 0.1, 0.6); } }]) { hexpand = hfill = true; } }]; }, (GuiRenderer renderer, GuiInputReader ir) { renderer.setOffset(vec2.convert((cast(SimpleInputReader)ir).curMousePos)); cursor.draw(renderer); }); } |