Skip to content

Commit 73cd82a

Browse files
committed
Merge branch 'feature/scroll_view_default_shrink' into next
2 parents bf19b67 + 612e900 commit 73cd82a

File tree

3 files changed

+39
-29
lines changed

3 files changed

+39
-29
lines changed

Assets/Example/Runtime/Categories/LayoutExample.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ Element CreateElement_ScrollView()
154154
{
155155
// ReSharper disable once ConvertToConstant.Local
156156
var scrollViewItemCount = 50;
157-
const float width = 700f;
158-
const float height = 300f;
157+
const float maxWidth = 500f;
158+
const float maxHeight = 200f;
159159

160160
return ExampleTemplate.UIFunctionColumn(nameof(UI.ScrollView),
161161
UI.Slider(() => scrollViewItemCount),
162162
ExampleTemplate.BlankLine(),
163163
UI.Box(
164164
UI.Tabs(
165165
("Vertical",
166-
() => UI.ScrollViewVertical(height,
166+
() => UI.ScrollViewVertical(maxHeight,
167167
UI.DynamicElementOnStatusChanged(
168168
() => scrollViewItemCount,
169169
count => UI.Column(
@@ -178,7 +178,7 @@ Element CreateElement_ScrollView()
178178
)
179179
),
180180
("Horizontal",
181-
() => UI.ScrollViewHorizontal(null,
181+
() => UI.ScrollViewHorizontal(maxWidth,
182182
UI.DynamicElementOnStatusChanged(
183183
() => scrollViewItemCount,
184184
count => UI.Row(
@@ -196,7 +196,7 @@ Element CreateElement_ScrollView()
196196
)
197197
),
198198
("VerticalAndHorizontal",
199-
() => UI.ScrollViewVerticalAndHorizontal(null, height,
199+
() => UI.ScrollViewVerticalAndHorizontal(maxWidth, maxHeight,
200200
UI.DynamicElementOnStatusChanged(
201201
() => scrollViewItemCount,
202202
count =>
@@ -215,21 +215,21 @@ Element CreateElement_ScrollView()
215215
var idx = i++;
216216
var str = idx.ToString();
217217
return UI.Field(
218-
UI.Label("Item" + idx, LabelType.Standard),
218+
UI.Label($"Item{idx}", LabelType.Standard),
219219
() => str).SetWidth(200f);
220220
})
221221
)
222222
);
223223
}
224-
224+
225225
return UI.Column(rows);
226226
}
227227
}
228228
)
229229
)
230230
)
231231
)
232-
).SetWidth(width)
232+
)
233233
);
234234
}
235235

Packages/ga.fuquna.rosettaui.uitoolkit/Runtime/Builder/UIToolkitBuilder.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,26 @@ protected override void OnElementStyleChanged(Element element, VisualElement ve,
169169
veStyle.backgroundColor = ToStyleColor(style.BackgroundColor);
170170

171171
// width or height has value
172-
var isFixedSize = (veStyle.width.keyword == StyleKeyword.Undefined ||
173-
veStyle.height.keyword == StyleKeyword.Undefined);
174-
if (isFixedSize)
172+
// WidthかHeightが定義されていた場合はその値になるように、Min,MaxとFlexの値をAutoにする
173+
var isFixedWidth = (veStyle.width.keyword == StyleKeyword.Undefined);
174+
var isFixedHeight = (veStyle.height.keyword == StyleKeyword.Undefined);
175+
176+
if (isFixedWidth)
177+
{
178+
veStyle.minWidth = StyleKeyword.Auto;
179+
veStyle.maxWidth = StyleKeyword.Auto;
180+
}
181+
182+
if (isFixedHeight)
183+
{
184+
veStyle.minHeight = StyleKeyword.Auto;
185+
veStyle.maxHeight = StyleKeyword.Auto;
186+
}
187+
188+
if(isFixedWidth || isFixedHeight)
175189
{
176-
veStyle.flexGrow = 0;
177-
veStyle.flexShrink = 0;
178-
veStyle.minWidth = StyleKeyword.Auto;
179-
veStyle.maxWidth = StyleKeyword.Auto;
180-
veStyle.minHeight = StyleKeyword.Auto;
181-
veStyle.maxHeight = StyleKeyword.Auto;
190+
veStyle.flexGrow = 0;
191+
veStyle.flexShrink = 0;
182192
}
183193
else
184194
{

Packages/ga.fuquna.rosettaui/Runtime/UI/UI_ScrollView.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ namespace RosettaUI
55
{
66
public static partial class UI
77
{
8-
public static ScrollViewElement ScrollViewVertical(float? height, params Element[] elements)
9-
=> ScrollViewVertical(height, elements.AsEnumerable());
8+
public static ScrollViewElement ScrollViewVertical(float? maxHeight, params Element[] elements)
9+
=> ScrollViewVertical(maxHeight, elements.AsEnumerable());
1010

11-
public static ScrollViewElement ScrollViewVertical(float? height, IEnumerable<Element> elements)
12-
=> ScrollView(ScrollViewType.Vertical, elements).SetHeight(height);
11+
public static ScrollViewElement ScrollViewVertical(float? maxHeight, IEnumerable<Element> elements)
12+
=> ScrollView(ScrollViewType.Vertical, elements).SetMaxHeight(maxHeight);
1313

14-
public static ScrollViewElement ScrollViewHorizontal(float? width, params Element[] elements)
15-
=> ScrollViewHorizontal(width, elements.AsEnumerable());
14+
public static ScrollViewElement ScrollViewHorizontal(float? maxWidth, params Element[] elements)
15+
=> ScrollViewHorizontal(maxWidth, elements.AsEnumerable());
1616

17-
public static ScrollViewElement ScrollViewHorizontal(float? width, IEnumerable<Element> elements)
18-
=> ScrollView(ScrollViewType.Horizontal, elements).SetWidth(width);
17+
public static ScrollViewElement ScrollViewHorizontal(float? maxWidth, IEnumerable<Element> elements)
18+
=> ScrollView(ScrollViewType.Horizontal, elements).SetMaxWidth(maxWidth);
1919

20-
public static ScrollViewElement ScrollViewVerticalAndHorizontal(float? width, float? height, params Element[] elements)
21-
=> ScrollViewVerticalAndHorizontal(width, height, elements.AsEnumerable());
20+
public static ScrollViewElement ScrollViewVerticalAndHorizontal(float? maxWidth, float? maxHeight, params Element[] elements)
21+
=> ScrollViewVerticalAndHorizontal(maxWidth, maxHeight, elements.AsEnumerable());
2222

23-
public static ScrollViewElement ScrollViewVerticalAndHorizontal(float? width, float? height, IEnumerable<Element> elements)
24-
=> ScrollView(ScrollViewType.VerticalAndHorizontal, elements).SetWidth(width).SetHeight(height);
23+
public static ScrollViewElement ScrollViewVerticalAndHorizontal(float? maxWidth, float? maxHeight, IEnumerable<Element> elements)
24+
=> ScrollView(ScrollViewType.VerticalAndHorizontal, elements).SetMaxWidth(maxWidth).SetMaxHeight(maxHeight);
2525

2626

2727
public static ScrollViewElement ScrollView(ScrollViewType scrollViewType, IEnumerable<Element> elements)

0 commit comments

Comments
 (0)