1 /// Fluid is a somewhat minimalistic and declarative high-level UI library for D.
2 ///
3 /// Fluid aims to be as simple in usage as it can be making as much possible with no excess of code. It's built
4 /// empirically, making each component suitable for all the most common needs out of the box.
5 ///
6 /// ---
7 /// auto node = label("Hello, World!");
8 /// node.draw();
9 /// ---
10 module fluid;
11 
12 // Unsupported build flag; ignores checks. Do not file issue tickets if you run into problems when building with it.
13 debug (Fluid_Force) version = Fluid_Force;
14 version (Fluid_Force) { }
15 else {
16 
17     // OSX builds are not supported with DMD. LDC is required.
18     version (DigitalMars)
19     version (OSX) {
20 
21         static assert(false,
22             "Fluid: DMD is not supported under macOS because of compiler bugs. Refusing to build.\n"
23             ~ "    Please use LDC instead. When using dub, pass flag `--compiler=ldc2`.\n"
24             ~ "    To ignore this check, you can build with UNSUPPORTED version or debug version Fluid_Force.");
25 
26     }
27 }
28 
29 public import
30     fluid.backend,
31     fluid.actions,
32     fluid.button,
33     fluid.checkbox,
34     fluid.children,
35     fluid.code_input,
36     fluid.default_theme,
37     fluid.drag_slot,
38     fluid.file_input,
39     fluid.field_slot,
40     fluid.frame,
41     fluid.grid,
42     fluid.hover_button,
43     fluid.image_view,
44     fluid.input,
45     fluid.label,
46     fluid.map_frame,
47     fluid.node,
48     fluid.number_input,
49     fluid.onion_frame,
50     fluid.password_input,
51     fluid.popup_button,
52     fluid.popup_frame,
53     fluid.progress_bar,
54     fluid.radiobox,
55     fluid.scroll,
56     fluid.scroll_input,
57     fluid.separator,
58     fluid.size_lock,
59     fluid.slider,
60     fluid.slot,
61     fluid.space,
62     fluid.structs,
63     fluid.style,
64     fluid.switch_slot,
65     fluid.text,
66     fluid.text_input,
67     // Note: fluid.theme is not included
68     fluid.tree,
69     fluid.utils;
70 
71 unittest {
72 
73     auto root = onionFrame(
74         .layout!"fill",
75 
76         vframe(
77             label("Hello, World!"),
78             button("Some input", delegate { }),
79         ),
80 
81         hframe(
82             imageView("logo.png"),
83             textInput("Input text here"),
84         ),
85 
86         popupButton(
87             "Click me!",
88             vspace(
89                 hspace(.layout!"fill", vscrollInput()),
90                 hscrollFrame(label("Hello, World!")),
91             ),
92         ),
93     );
94 
95 }
96 
97 unittest {
98 
99     import std.math;
100 
101     auto io = new HeadlessBackend;
102     auto root = vspace(
103         .layout!"center",
104         label(.layout!"center", "Hello World from"),
105         imageView("./logo.png", Vector2(499, 240)),
106     );
107 
108     root.io = io;
109     root.draw();
110 
111     // This should render two textures
112     auto textTexture = io.textures.front;
113     io.textures.popFront;
114     auto imageView = io.textures.front;
115 
116     // Both textures should have the same bottom line
117     assert(textTexture.rectangle.end.y.isClose(imageView.rectangle.end.y));
118 
119 }