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.arsd_image_chain, 33 fluid.button, 34 fluid.checkbox, 35 fluid.children, 36 fluid.clipboard_chain, 37 fluid.code_input, 38 fluid.default_theme, 39 fluid.drag_slot, 40 fluid.file_chain, 41 fluid.file_input, 42 fluid.field_slot, 43 fluid.frame, 44 fluid.focus_chain, 45 fluid.grid, 46 fluid.hover_button, 47 fluid.hover_chain, 48 fluid.hover_transform, 49 fluid.image_view, 50 fluid.input, 51 fluid.input_map_chain, 52 fluid.io, 53 fluid.label, 54 fluid.map_frame, 55 fluid.node, 56 fluid.node_chain, 57 fluid.number_input, 58 fluid.onion_frame, 59 fluid.overlay_chain, 60 fluid.password_input, 61 fluid.popup_button, 62 fluid.popup_frame, 63 fluid.preference_chain, 64 fluid.progress_bar, 65 fluid.radiobox, 66 fluid.raylib_view, 67 fluid.resolution_override, 68 fluid.scroll, 69 fluid.scroll_input, 70 fluid.separator, 71 fluid.size_lock, 72 fluid.slider, 73 fluid.slot, 74 fluid.space, 75 fluid.structs, 76 fluid.style, 77 fluid.switch_slot, 78 fluid.test_space, 79 fluid.time_chain, 80 fluid.time_machine, 81 fluid.text, 82 fluid.text_input, 83 // Note: fluid.theme is not included 84 fluid.tree, 85 fluid.utils; 86 87 unittest { 88 89 auto root = onionFrame( 90 .layout!"fill", 91 92 vframe( 93 label("Hello, World!"), 94 button("Some input", delegate { }), 95 ), 96 97 hframe( 98 imageView("logo.png"), 99 textInput("Input text here"), 100 ), 101 102 popupButton( 103 "Click me!", 104 vspace( 105 hspace(.layout!"fill", vscrollInput()), 106 hscrollFrame(label("Hello, World!")), 107 ), 108 ), 109 ); 110 111 } 112 113 @("Legacy: readme.md example (migrated)") 114 unittest { 115 116 import std.math; 117 118 auto io = new HeadlessBackend; 119 auto root = vspace( 120 .layout!"center", 121 label(.layout!"center", "Hello World from"), 122 imageView("./logo.png", Vector2(499, 240)), 123 ); 124 125 root.io = io; 126 root.draw(); 127 128 // This should render two textures 129 auto textTexture = io.textures.front; 130 io.textures.popFront; 131 auto imageView = io.textures.front; 132 133 // Both textures should have the same bottom line 134 assert(textTexture.rectangle.end.y.isClose(imageView.rectangle.end.y)); 135 136 } 137 138 @("readme.md example") 139 unittest { 140 141 import std.math; 142 143 auto ui = vspace( 144 .layout!"center", 145 label( 146 .layout!"center", 147 "Hello World from" 148 ), 149 imageView( 150 "./logo.png", 151 Vector2(499, 240) 152 ), 153 ); 154 auto root = testSpace(ui); 155 156 root.draw(); 157 158 // This should render two textures 159 root.drawAndAssert( 160 ui.children[0].drawsImage, 161 ui.children[1].drawsImage, 162 ); 163 164 }