1 module w95.window;
2 
3 import fluid;
4 import raylib;
5 
6 import w95.theme;
7 import w95.titlebar;
8 import w95.image_button;
9 
10 @safe:
11 
12 alias window95 = simpleConstructor!Window95;
13 
14 /// Displays a Windows 95-like window.
15 class Window95 : DragSlot {
16 
17     public {
18 
19         Titlebar titlebar;
20         Node content;
21 
22     }
23 
24     alias close = remove;
25 
26     this(Titlebar titlebar, Node content) {
27 
28         super(
29             this.content = content,
30         );
31         this.titlebar = titlebar;
32         super.handle = new WindowDragHandle(titlebar);
33         super.handle.layout = .layout!"fill";
34         super.theme = w95Theme;
35 
36         // Set custom default onClose handler
37         if (titlebar.onClose is null) {
38 
39             titlebar.onClose = delegate {
40                 remove();
41             };
42 
43         }
44 
45     }
46 
47     static Selector selector() {
48 
49         return Selector(typeid(Window95));
50 
51     }
52 
53 }
54 
55 private class WindowDragHandle : DragHandle {
56 
57     public {
58 
59         Node titlebar;
60 
61     }
62 
63     this(Node titlebar) {
64 
65         this.titlebar = titlebar;
66 
67     }
68 
69     override void resizeImpl(Vector2 space) {
70 
71         titlebar.resize(tree, theme, space);
72         minSize = titlebar.minSize;
73 
74     }
75 
76     override void drawImpl(Rectangle outer, Rectangle inner) {
77 
78         titlebar.draw(outer);
79         
80     }
81 
82 }