1 ///
2 module glui.onion_frame;
3 
4 import raylib;
5 
6 import glui.frame;
7 import glui.utils;
8 import glui.style;
9 
10 /// Make a new onion frame
11 alias onionFrame = simpleConstructor!GluiOnionFrame;
12 
13 @safe:
14 
15 /// An onion frame places its children as layers, drawing one on top of the other, instead of on the side.
16 ///
17 /// Children are placed in order of drawing — the last child will be drawn last.
18 ///
19 /// It might be useful to use OnionFrame as the root node to enable drawing overlaying items, such as modals.
20 class GluiOnionFrame : GluiFrame {
21 
22     mixin DefineStyles;
23 
24     this(T...)(T args) {
25 
26         super(args);
27 
28     }
29 
30     protected override void resizeImpl(Vector2 available) {
31 
32         import std.algorithm : max;
33 
34         minSize = Vector2(0, 0);
35 
36         // Check each child
37         foreach (child; children) {
38 
39             // Resize the child
40             child.resize(tree, theme, available);
41 
42             // Update minSize
43             minSize.x = max(minSize.x, child.minSize.x);
44             minSize.y = max(minSize.y, child.minSize.y);
45 
46         }
47 
48     }
49 
50     protected override void drawImpl(Rectangle outer, Rectangle inner) {
51 
52         const style = pickStyle();
53         style.drawBackground(outer);
54 
55         drawChildren(child => child.draw(inner));
56 
57     }
58 
59 }