diff --git a/package.json b/package.json index 3af4f60..1e0192d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@rbxts/zenui-core", - "version": "0.8.0", + "version": "0.8.1", "description": "", "main": "out/init.lua", "scripts": { diff --git a/src/Layouts/RowView.tsx b/src/Layouts/RowView.tsx index 4e61ce9..bb24e82 100644 --- a/src/Layouts/RowView.tsx +++ b/src/Layouts/RowView.tsx @@ -14,10 +14,10 @@ export interface RowProps { */ readonly MaxHeight?: number; - // /** - // * Automatic Height - // */ - // readonly AutomaticHeight?: boolean; + /** + * Automatic Height + */ + readonly AutomaticHeight?: boolean; /** * The minimum height of this row @@ -68,6 +68,11 @@ interface RowViewDefaultProps { */ readonly RowWidth: UDim; + /** + * Automatic sizing rules + */ + readonly AutomaticSize?: Enum.AutomaticSize | InferEnumNames; + /** * Whether or not this `RowView` scrols */ @@ -174,27 +179,38 @@ export class RowView extends Roact.Component { if (child.component === Row) { const props = child.props as RowProps; + let height: UDim2; + let automaticSize: Enum.AutomaticSize = Enum.AutomaticSize.None; + const shouldAutoX = this.props.RowWidth === new UDim(); + const shouldAutoY = props.AutomaticHeight === true; + + if (props.Height) { + height = new UDim2( + this.props.RowWidth.Scale, + this.props.RowWidth.Offset, + props.Height.Scale, + props.Height.Offset, + ); + } else { + height = new UDim2( + this.props.RowWidth.Scale, + this.props.RowWidth.Offset, + props.AutomaticHeight ? 0 : (1 + scaleOffset) * (1 / autoSizeCount), + widthOffset / autoSizeCount, + ); + } + + if (shouldAutoX && shouldAutoY) { + automaticSize = Enum.AutomaticSize.XY; + } else if (shouldAutoY) { + automaticSize = Enum.AutomaticSize.Y; + } else if (shouldAutoX) { + automaticSize = Enum.AutomaticSize.X; + } + containerMap.set( key, - + {(props.MaxHeight !== undefined || props.MinHeight !== undefined) && ( { BackgroundTransparency={1} Size={this.props.Size} {...properties} - AutomaticSize={this.props.RowWidth !== new UDim() ? "None" : "X"} + AutomaticSize={this.props.AutomaticSize ?? (this.props.RowWidth !== new UDim() ? "None" : "X")} CanvasSize={this.contentsSize.map((size) => new UDim2(0, size.X, 0, size.Y))} > { SortOrder="LayoutOrder" FillDirection="Vertical" Padding={colPadding} - VerticalAlignment={this.props.VerticalAlignment ?? "Center"} + VerticalAlignment={this.props.VerticalAlignment ?? "Top"} /> {(this.props.MinSize !== undefined || this.props.MaxSize !== undefined) && ( { ); } else { return ( - +