1 module rpui.widgets.chain_layout.renderer; 2 3 import std.container.array; 4 5 import rpui.math; 6 import rpui.theme; 7 import rpui.events; 8 import rpui.widget; 9 import rpui.widgets.chain_layout.widget; 10 import rpui.render.components; 11 import rpui.render.components_factory; 12 import rpui.render.renderer; 13 import rpui.render.transforms; 14 15 final class ChainLayoutRenderer : Renderer { 16 private ChainLayout widget; 17 private Theme theme; 18 19 private vec2 splitOffset; 20 private TexAtlasTextureQuad split; 21 private Array!QuadTransforms splitTransforms; 22 23 override void onCreate(Widget widget, in string style) { 24 this.theme = widget.view.theme; 25 this.widget = cast(ChainLayout) widget; 26 27 this.split = createTexAtlasTextureQuadFromRdpl(theme, style, "split"); 28 this.splitOffset = theme.tree.data.getVec2f(style ~ ".splitOffset"); 29 } 30 31 override void onRender() { 32 widget.renderChildren(); 33 34 foreach (const transforms; splitTransforms) { 35 renderTexAtlasQuad(theme, split, transforms); 36 } 37 } 38 39 override void onProgress(in ProgressEvent event) { 40 float splitPos = 0; 41 splitTransforms.clear(); 42 43 foreach (Widget child; widget.children) { 44 if (widget.children.back == child) 45 continue; 46 47 if (!child.associatedWidget.isVisible) 48 continue; 49 50 splitPos += child.associatedWidget.width; 51 const transforms = updateQuadTransforms( 52 widget.view.cameraView, 53 widget.absolutePosition + vec2(splitPos, 0) + splitOffset, 54 split.texCoords.originalTexCoords.size 55 ); 56 splitTransforms.insert(transforms); 57 } 58 } 59 }