D Paste by h3r3tic
Description: None
Hide line numbers

Create new paste
Post a reply
View replies

Paste:
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  
import testcommon;



void main() {
    doGui({}, {
        Window(`title = 'the window'`)
        [{
            HBox(`spacing=20`)
            [{
                VBox(`vexpand`)
                [{
                    Button(`text = 'Hello world!'`);
        
                    VBox()
                    [{
                        int curRes;
                        
                        HBox()
                        [{
                            curRes = Slider()
                                .init((Slider s) { with (s) {
                                    _discrete = 4;
                                    _width = 150;
                                    _scalesHalfHeight = 4;
                                    _boxHeight = 11;
                                    _boxHalfWidth = 4;
                                }})
                                ._position;
                        }];
                        
                        Label(`hexpand, vexpand`)
                            .text([`400x300`[], `640x480`, `800x600`, `1024x768`][curRes]);
                    }];
                }];

                VBox()
                [{
                    if (Checkbox(`text='show nested window', checked=true`).checked) {
                        Window(`title = 'nested window'`)
                        [{
                            Button().text(`oh hai`);
                            Label().text(`some random label`);

                            InputBox(`text = 'woah, an input :o', hexpand, vexpand`);
        
                            if (Button().text(`click me!`).clicked) {
                                writefln(`Button clicked ! :D`);
                            }
                        }];
                    }
                    
                    Label().text(`Label omg`);
                }];
            }];

            
            Label().text(`Yet Another Label`);
            
            static int foobie = 0;
            if (++foobie % 2) {
                Label().text(`A label!`);
            } else {
                Button().text(`A button!`);
            }
            
            Slider();
            
            Slider()
                .init((Slider s) { with (s) {
                    _discrete = 0;
                    _width = 150;
                    _scalesHalfHeight = 4;
                    _boxHeight = 11;
                    _boxHalfWidth = 4;
                }});
                
            InputBox(`text='look ma, i\'ve got an input box! mwhahah :P', hexpand, hfill`);
        }];
    });
}

Replies:
No replies posted yet