1 module nodes.resolution_override; 2 3 import fluid; 4 5 @safe: 6 7 @("ResolutionOverride uses fixed size for its marginBox") 8 unittest { 9 10 auto child = vspace( 11 .layout!(1, "fill") 12 ); 13 auto node = resolutionOverride!vspace( 14 Vector2(1920, 1080), 15 child, 16 ); 17 auto root = sizeLock!testSpace( 18 .nullTheme, 19 .sizeLimit(600, 600), 20 node 21 ); 22 23 root.drawAndAssert( 24 node.isDrawn().at(0, 0, 600, 1080), 25 child.isDrawn().at(0, 0, 1920, 1080), 26 ); 27 assert(node.paddingBoxForSpace(Rectangle(0, 0, 800, 600)) == Rectangle(0, 0, 1920, 1080)); 28 29 } 30 31 @("ResolutionOverride sets its own DPI") 32 unittest { 33 34 auto contentInner = label("Hello"); 35 auto contentOuter = label("Hello"); 36 auto node = resolutionOverride!vspace( 37 .layout!"fill", 38 Vector2(100, 100), 39 contentInner, 40 ); 41 auto root = testSpace( 42 .nullTheme, 43 node, 44 contentOuter, 45 ); 46 root.dpi = Vector2(120, 120); 47 48 root.drawAndAssert( 49 node.isDrawn().at(0, 0, 80, 80), 50 ); 51 52 assert(contentInner.text.texture.dpi == Vector2(96, 96)); 53 assert(contentOuter.text.texture.dpi == Vector2(120, 120)); 54 55 }