1 module rpui.widgets.panel.theme_loader; 2 3 import rpdl; 4 5 import rpui.theme; 6 import rpui.primitives; 7 import rpui.render.components; 8 import rpui.render.components_factory; 9 import rpui.widgets.panel.widget; 10 import rpui.widgets.panel.render_system; 11 12 import gapi.geometry; 13 14 struct PanelThemeLoader { 15 Panel.Measure createMeasureFromRpdl(RpdlNode data, in string style) { 16 Panel.Measure measure = { 17 scrollButtonMinSize: data.getNumber(style ~ ".Scroll.buttonMinSize.0"), 18 horizontalScrollRegionWidth: data.getNumber(style ~ ".Scroll.Horizontal.regionWidth.0"), 19 verticalScrollRegionWidth: data.getNumber(style ~ ".Scroll.Vertical.regionWidth.0"), 20 headerHeight: data.getNumber(style ~ ".Header.height.0"), 21 splitThickness: data.getNumber(style ~ ".Split.thickness.0"), 22 }; 23 return measure; 24 } 25 26 RenderData loadRenderData(Theme theme, in string style) { 27 RenderData renderData; 28 RpdlNode data = theme.tree.data; 29 30 with (renderData) { 31 backgroundColors = [ 32 Panel.Background.light: data.getNormColor(style ~ ".backgroundLight"), 33 Panel.Background.dark: data.getNormColor(style ~ ".backgroundDark"), 34 Panel.Background.action: data.getNormColor(style ~ ".backgroundAction"), 35 ]; 36 splitColors = [ 37 SplitColor.darkInner: data.getNormColor(style ~ ".Split.Dark.innerColor"), 38 SplitColor.darkOuter: data.getNormColor(style ~ ".Split.Dark.outerColor"), 39 SplitColor.lightInner: data.getNormColor(style ~ ".Split.Light.innerColor"), 40 SplitColor.lightOuter: data.getNormColor(style ~ ".Split.Light.outerColor"), 41 ]; 42 background = createGeometry(); 43 splitInner = createGeometry(); 44 splitOuter = createGeometry(); 45 headerBackground = createStatefulTexAtlasTextureQuadFromRdpl( 46 theme, 47 style ~ ".Header", "background", 48 [State.leave, State.enter] 49 ); 50 headerText = createStatefulUiTextFromRdpl( 51 theme, 52 style ~ ".Header", "Text", 53 [State.leave, State.enter] 54 ); 55 headerMarkSize = data.getVec2f(style ~ ".Header.Mark.size"); 56 headerMarkPosition = data.getVec2f(style ~ ".Header.Mark.position"); 57 headerMark = createUiSkinTextureQuad(theme); 58 headerOpenMarkTexCoords = createNormilizedTextureCoordsFromRdpl( 59 theme, 60 style ~ ".Header.Mark.open" 61 ); 62 headerCloseMarkTexCoords = createNormilizedTextureCoordsFromRdpl( 63 theme, 64 style ~ ".Header.Mark.close" 65 ); 66 horizontalScrollButton = createStatefulChainFromRdpl( 67 theme, 68 Orientation.horizontal, 69 style ~ ".Scroll.Horizontal.Button" 70 ); 71 verticalScrollButton = createStatefulChainFromRdpl( 72 theme, 73 Orientation.vertical, 74 style ~ ".Scroll.Vertical.Button" 75 ); 76 } 77 78 return renderData; 79 } 80 }