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.children, 34 fluid.default_theme, 35 fluid.file_input, 36 fluid.frame, 37 fluid.grid, 38 fluid.hover_button, 39 fluid.image_view, 40 fluid.input, 41 fluid.label, 42 fluid.map_space, 43 fluid.node, 44 fluid.onion_frame, 45 fluid.popup_button, 46 fluid.popup_frame, 47 fluid.scroll, 48 fluid.scroll_input, 49 fluid.size_lock, 50 fluid.slot, 51 fluid.space, 52 fluid.structs, 53 fluid.style, 54 fluid.text_input, 55 fluid.utils; 56 57 unittest { 58 59 auto root = onionFrame( 60 .layout!"fill", 61 62 vframe( 63 label("Hello, World!"), 64 button("Some input", delegate { }), 65 ), 66 67 hframe( 68 imageView("logo.png"), 69 textInput("Input text here"), 70 ), 71 72 popupButton( 73 "Click me!", 74 vspace( 75 hspace(.layout!"fill", vscrollInput()), 76 hscrollFrame(label("Hello, World!")), 77 ), 78 ), 79 ); 80 81 } 82 83 unittest { 84 85 import std.math; 86 87 auto io = new HeadlessBackend; 88 auto root = vspace( 89 .layout!"center", 90 label(.layout!"center", "Hello World from"), 91 imageView("./logo.png", Vector2(499, 240)), 92 ); 93 94 root.io = io; 95 root.draw(); 96 97 // This should render two textures 98 auto textTexture = io.textures.front; 99 io.textures.popFront; 100 auto imageView = io.textures.front; 101 102 // Both textures should have the same bottom line 103 assert(textTexture.rectangle.end.y.isClose(imageView.rectangle.end.y)); 104 105 }