From 22afbcee741a3c8503b8dfb1091e21776ad06dcc Mon Sep 17 00:00:00 2001 From: dassjosh Date: Tue, 30 Apr 2024 16:30:40 -0500 Subject: [PATCH] Initial Work on scroll view component --- src/Rust.UIFramework.sln | 5 - .../Builder/BaseUiBuilder.Components.cs | 12 +- src/Rust.UIFramework/Builder/UI/UiBuilder.cs | 4 +- src/Rust.UIFramework/Colors/UiColor.cs | 5 +- .../Components/BasePoolableComponent.cs | 25 ++++ .../Components/RectTransformComponent.cs | 19 +++ .../Components/ScrollViewComponent.cs | 64 ++++++++++ .../ScrollViewContentTransformComponent.cs | 30 +++++ .../Components/ScrollbarComponent.cs | 47 +++++++ src/Rust.UIFramework/Json/JsonDefaults.cs | 40 ++++++ .../Json/JsonFrameworkWriter.cs | 39 ++++++ .../UiElements/UiReference.cs | 2 + .../UiElements/UiScrollView.cs | 118 ++++++++++++++++++ 13 files changed, 398 insertions(+), 12 deletions(-) create mode 100644 src/Rust.UIFramework/Components/BasePoolableComponent.cs create mode 100644 src/Rust.UIFramework/Components/RectTransformComponent.cs create mode 100644 src/Rust.UIFramework/Components/ScrollViewComponent.cs create mode 100644 src/Rust.UIFramework/Components/ScrollViewContentTransformComponent.cs create mode 100644 src/Rust.UIFramework/Components/ScrollbarComponent.cs create mode 100644 src/Rust.UIFramework/UiElements/UiScrollView.cs diff --git a/src/Rust.UIFramework.sln b/src/Rust.UIFramework.sln index 451f04f..b6c71b2 100644 --- a/src/Rust.UIFramework.sln +++ b/src/Rust.UIFramework.sln @@ -10,7 +10,6 @@ Global Release|Carbon = Release|Carbon Debug|Carbon = Debug|Carbon Debug|Oxide = Debug|Oxide - Benchmarks|Oxide = Benchmarks|Oxide EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Debug|Carbon.ActiveCfg = Debug|Carbon @@ -19,12 +18,8 @@ Global {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Debug|Oxide.Build.0 = Debug|Oxide {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Release|Carbon.ActiveCfg = Release|Carbon {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Release|Carbon.Build.0 = Release|Carbon - {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Benchmarks|Oxide.ActiveCfg = Benchmarks|Oxide - {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Benchmarks|Oxide.Build.0 = Benchmarks|Oxide {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Release|Oxide.ActiveCfg = Release|Oxide {2CEE08B1-A5BD-4F64-A1A9-5242440758D0}.Release|Oxide.Build.0 = Release|Oxide - {6C18B22C-7319-4C3F-B7F9-F9B87B6B244C}.Benchmarks|Oxide.ActiveCfg = Benchmarks|Oxide - {6C18B22C-7319-4C3F-B7F9-F9B87B6B244C}.Benchmarks|Oxide.Build.0 = Benchmarks|Oxide {6C18B22C-7319-4C3F-B7F9-F9B87B6B244C}.Release|Oxide.ActiveCfg = Release|Oxide {6C18B22C-7319-4C3F-B7F9-F9B87B6B244C}.Release|Oxide.Build.0 = Release|Oxide EndGlobalSection diff --git a/src/Rust.UIFramework/Builder/BaseUiBuilder.Components.cs b/src/Rust.UIFramework/Builder/BaseUiBuilder.Components.cs index da96fec..ff6e0b5 100644 --- a/src/Rust.UIFramework/Builder/BaseUiBuilder.Components.cs +++ b/src/Rust.UIFramework/Builder/BaseUiBuilder.Components.cs @@ -1,7 +1,6 @@ using Oxide.Ext.UiFramework.Colors; using Oxide.Ext.UiFramework.Controls; using Oxide.Ext.UiFramework.Enums; -using Oxide.Ext.UiFramework.Exceptions; using Oxide.Ext.UiFramework.Offsets; using Oxide.Ext.UiFramework.Positions; using Oxide.Ext.UiFramework.UiElements; @@ -199,5 +198,16 @@ public UiSection Anchor(in UiReference parent, in UiPosition pos, in UiOffset of return section; } #endregion + + #region ScrollView + + public UiScrollView ScrollView(in UiReference parent, in UiPosition pos, in UiOffset offset, bool horizontal = false, bool vertical = false, ScrollRect.MovementType movementType = ScrollRect.MovementType.Clamped, float elasticity = 0.1f, + bool inertia = false, float decelerationRate = 0.135f, float scrollSensitivity = 1f) + { + UiScrollView scroll = UiScrollView.Create(pos, offset, horizontal, vertical, movementType, elasticity, inertia, decelerationRate, scrollSensitivity); + AddComponent(scroll, parent); + return scroll; + } + #endregion } } \ No newline at end of file diff --git a/src/Rust.UIFramework/Builder/UI/UiBuilder.cs b/src/Rust.UIFramework/Builder/UI/UiBuilder.cs index ec76ffb..3b568bc 100644 --- a/src/Rust.UIFramework/Builder/UI/UiBuilder.cs +++ b/src/Rust.UIFramework/Builder/UI/UiBuilder.cs @@ -78,14 +78,14 @@ public CachedUiBuilder ToCachedBuilder() public override void AddComponent(BaseUiComponent component, in UiReference parent) { UiReferenceException.ThrowIfInvalidParent(parent); - component.Reference = new UiReference(parent.Name, UiNameCache.GetComponentName(RootName, Components.Count)); + component.Reference = parent.WithChild(UiNameCache.GetComponentName(RootName, Components.Count)); Components.Add(component); } protected override void AddAnchor(BaseUiComponent component, in UiReference parent) { UiReferenceException.ThrowIfInvalidParent(parent); - component.Reference = new UiReference(parent.Name, UiNameCache.GetAnchorName(RootName, Anchors.Count)); + component.Reference = parent.WithChild(UiNameCache.GetAnchorName(RootName, Anchors.Count)); Anchors.Add(component); } #endregion diff --git a/src/Rust.UIFramework/Colors/UiColor.cs b/src/Rust.UIFramework/Colors/UiColor.cs index d438695..5a07130 100644 --- a/src/Rust.UIFramework/Colors/UiColor.cs +++ b/src/Rust.UIFramework/Colors/UiColor.cs @@ -69,10 +69,7 @@ public UiColor(float red, float green, float blue, float alpha = 1f) : this(Math private static float ToFloat(byte value) => value / 255f; - public bool Equals(UiColor other) - { - return this == other; - } + public bool Equals(UiColor other) => this == other; public override bool Equals(object obj) { diff --git a/src/Rust.UIFramework/Components/BasePoolableComponent.cs b/src/Rust.UIFramework/Components/BasePoolableComponent.cs new file mode 100644 index 0000000..e4d4225 --- /dev/null +++ b/src/Rust.UIFramework/Components/BasePoolableComponent.cs @@ -0,0 +1,25 @@ +using Oxide.Ext.UiFramework.Json; +using Oxide.Ext.UiFramework.Pooling; + +namespace Oxide.Ext.UiFramework.Components +{ + public abstract class BasePoolableComponent : BasePoolable, IComponent + { + public bool Enabled = true; + + public virtual void WriteComponent(JsonFrameworkWriter writer) + { + writer.AddField(JsonDefaults.Common.EnabledName, Enabled, true); + } + + protected override void EnterPool() + { + Reset(); + } + + public virtual void Reset() + { + Enabled = true; + } + } +} \ No newline at end of file diff --git a/src/Rust.UIFramework/Components/RectTransformComponent.cs b/src/Rust.UIFramework/Components/RectTransformComponent.cs new file mode 100644 index 0000000..ba387dc --- /dev/null +++ b/src/Rust.UIFramework/Components/RectTransformComponent.cs @@ -0,0 +1,19 @@ +using Oxide.Ext.UiFramework.Json; +using Oxide.Ext.UiFramework.Offsets; +using Oxide.Ext.UiFramework.Positions; + +namespace Oxide.Ext.UiFramework.Components; + +public abstract class RectTransformComponent : IComponent +{ + public UiPosition Position; + public UiOffset Offset; + + public abstract void WriteComponent(JsonFrameworkWriter writer); + + public virtual void Reset() + { + Position = default; + Offset = default; + } +} \ No newline at end of file diff --git a/src/Rust.UIFramework/Components/ScrollViewComponent.cs b/src/Rust.UIFramework/Components/ScrollViewComponent.cs new file mode 100644 index 0000000..b89642e --- /dev/null +++ b/src/Rust.UIFramework/Components/ScrollViewComponent.cs @@ -0,0 +1,64 @@ +using Oxide.Ext.UiFramework.Json; +using UnityEngine.UI; + +namespace Oxide.Ext.UiFramework.Components; + +public class ScrollViewComponent : IComponent +{ + private const string Type = "UnityEngine.UI.ScrollView"; + + public ScrollViewContentTransformComponent ContentTransform = new(); + public bool Horizontal; + public bool Vertical; + public ScrollRect.MovementType MovementType = ScrollRect.MovementType.Clamped; + public float Elasticity = JsonDefaults.ScrollView.Elasticity; + public bool Inertia; + public float DecelerationRate = JsonDefaults.ScrollView.DecelerationRate; + public float ScrollSensitivity = JsonDefaults.ScrollView.ScrollSensitivity; + public ScrollbarComponent HorizontalScrollbar; + public ScrollbarComponent VerticalScrollbar; + + public void WriteComponent(JsonFrameworkWriter writer) + { + writer.WriteStartObject(); + writer.AddFieldRaw(JsonDefaults.Common.ComponentTypeName, Type); + writer.AddField(JsonDefaults.ScrollView.Horizontal, Horizontal, false); + writer.AddField(JsonDefaults.ScrollView.Vertical, Vertical, false); + writer.AddField(JsonDefaults.ScrollView.MovementType, MovementType); + writer.AddField(JsonDefaults.ScrollView.ElasticityName, Elasticity, JsonDefaults.ScrollView.Elasticity); + writer.AddField(JsonDefaults.ScrollView.Inertia, Inertia, false); + writer.AddField(JsonDefaults.ScrollView.DecelerationRateName, DecelerationRate, JsonDefaults.ScrollView.DecelerationRate); + writer.AddField(JsonDefaults.ScrollView.ScrollSensitivityName, ScrollSensitivity, JsonDefaults.ScrollView.ScrollSensitivity); + + if (Horizontal) + { + writer.AddComponent(JsonDefaults.ScrollView.HorizontalScrollbar, HorizontalScrollbar); + } + + if (Vertical) + { + writer.AddComponent(JsonDefaults.ScrollView.VerticalScrollbar, VerticalScrollbar); + } + + if (ContentTransform != null) + { + writer.AddComponent(JsonDefaults.ScrollView.ContentTransform, ContentTransform); + } + + writer.WriteEndObject(); + } + + public void Reset() + { + ContentTransform.Reset(); + Horizontal = false; + Vertical = false; + MovementType = ScrollRect.MovementType.Clamped; + Elasticity = JsonDefaults.ScrollView.Elasticity; + Inertia = false; + DecelerationRate = JsonDefaults.ScrollView.DecelerationRate; + ScrollSensitivity = JsonDefaults.ScrollView.ScrollSensitivity; + HorizontalScrollbar = null; + VerticalScrollbar = null; + } +} \ No newline at end of file diff --git a/src/Rust.UIFramework/Components/ScrollViewContentTransformComponent.cs b/src/Rust.UIFramework/Components/ScrollViewContentTransformComponent.cs new file mode 100644 index 0000000..d10360e --- /dev/null +++ b/src/Rust.UIFramework/Components/ScrollViewContentTransformComponent.cs @@ -0,0 +1,30 @@ +using Oxide.Ext.UiFramework.Json; +using Oxide.Ext.UiFramework.Offsets; +using Oxide.Ext.UiFramework.Positions; + +namespace Oxide.Ext.UiFramework.Components; + +public class ScrollViewContentTransformComponent : RectTransformComponent +{ + public ScrollViewContentTransformComponent() + { + Position = new UiPosition(0, 0, 1, 1); + Offset = new UiOffset(0, 0, 0, 0); + } + + public override void WriteComponent(JsonFrameworkWriter writer) + { + writer.WriteStartObject(); + writer.AddPosition(JsonDefaults.Position.AnchorMinName, Position.Min, JsonDefaults.ScrollView.Min); + writer.AddPosition(JsonDefaults.Position.AnchorMaxName, Position.Max, JsonDefaults.ScrollView.AnchorMax); + writer.AddOffset(JsonDefaults.Offset.OffsetMinName, Offset.Min, JsonDefaults.ScrollView.Min); + writer.AddOffset(JsonDefaults.Offset.OffsetMaxName, Offset.Max, JsonDefaults.ScrollView.OffsetMax); + writer.WriteEndObject(); + } + + public override void Reset() + { + Position = new UiPosition(0, 0, 1, 1); + Offset = new UiOffset(0, 0, 0, 0); + } +} \ No newline at end of file diff --git a/src/Rust.UIFramework/Components/ScrollbarComponent.cs b/src/Rust.UIFramework/Components/ScrollbarComponent.cs new file mode 100644 index 0000000..4600476 --- /dev/null +++ b/src/Rust.UIFramework/Components/ScrollbarComponent.cs @@ -0,0 +1,47 @@ +using Oxide.Ext.UiFramework.Colors; +using Oxide.Ext.UiFramework.Json; + +namespace Oxide.Ext.UiFramework.Components; + +public class ScrollbarComponent : BasePoolableComponent +{ + public bool Invert; + public bool AutoHide; + public string HandleSprite; + public string TrackSprite; + public float Size = JsonDefaults.ScrollBar.Size; + public UiColor HandleColor = JsonDefaults.ScrollBar.HandleColor; + public UiColor HighlightColor = JsonDefaults.ScrollBar.HighlightColor; + public UiColor PressedColor = JsonDefaults.ScrollBar.PressedColor; + public UiColor TrackColor = JsonDefaults.ScrollBar.TrackColor; + + public override void WriteComponent(JsonFrameworkWriter writer) + { + writer.WriteStartObject(); + base.WriteComponent(writer); + writer.AddField(JsonDefaults.ScrollBar.Invert, Invert, false); + writer.AddField(JsonDefaults.ScrollBar.AutoHide, AutoHide, false); + writer.AddField(JsonDefaults.ScrollBar.HandleSprite, HandleSprite, null); + writer.AddField(JsonDefaults.ScrollBar.TrackSprite, TrackSprite, null); + writer.AddField(JsonDefaults.ScrollBar.SizeName, Size, JsonDefaults.ScrollBar.Size); + writer.AddField(JsonDefaults.ScrollBar.HandleColorName, HandleColor, JsonDefaults.ScrollBar.HandleColor); + writer.AddField(JsonDefaults.ScrollBar.HighlightColorName, HighlightColor, JsonDefaults.ScrollBar.HighlightColor); + writer.AddField(JsonDefaults.ScrollBar.PressedColorName, PressedColor, JsonDefaults.ScrollBar.PressedColor); + writer.AddField(JsonDefaults.ScrollBar.TrackColorName, TrackColor, JsonDefaults.ScrollBar.TrackColor); + writer.WriteEndObject(); + } + + public override void Reset() + { + base.Reset(); + Invert = false; + AutoHide = false; + HandleSprite = null; + TrackSprite = null; + Size = JsonDefaults.ScrollBar.Size; + HandleColor = JsonDefaults.ScrollBar.HandleColor; + HighlightColor = JsonDefaults.ScrollBar.HighlightColor; + PressedColor = JsonDefaults.ScrollBar.PressedColor; + TrackColor = JsonDefaults.ScrollBar.TrackColor; + } +} \ No newline at end of file diff --git a/src/Rust.UIFramework/Json/JsonDefaults.cs b/src/Rust.UIFramework/Json/JsonDefaults.cs index 63e4f26..ec4ec8d 100644 --- a/src/Rust.UIFramework/Json/JsonDefaults.cs +++ b/src/Rust.UIFramework/Json/JsonDefaults.cs @@ -116,5 +116,45 @@ public static class Countdown public const int StepValue = 1; public const string CountdownCommandName = "command"; } + + public static class ScrollView + { + public const string Horizontal = "horizontal"; + public const string Vertical = "vertical"; + public const string MovementType = "movementType"; + public const string ElasticityName = "elasticity"; + public const string Inertia = "inertia"; + public const string DecelerationRateName = "decelerationRate"; + public const string ScrollSensitivityName = "scrollSensitivity"; + public const string HorizontalScrollbar = "horizontalScrollbar"; + public const string VerticalScrollbar = "verticalScrollbar"; + public const string ContentTransform = "contentTransform"; + + public static readonly float Elasticity = 0.1f; + public static readonly float DecelerationRate = 0.135f; + public static readonly float ScrollSensitivity = 1f; + + public static readonly Vector2 Min = new(0, 0); + public static readonly Vector2 AnchorMax = new(1, 1); + public static readonly Vector2 OffsetMax = new(0, 0); + } + + public static class ScrollBar + { + public const string Invert = "invert"; + public const string AutoHide = "autoHide"; + public const string HandleSprite = "handleSprite"; + public const string TrackSprite = "trackSprite"; + public const string SizeName = "size"; + public const float Size = 20f; + public const string HandleColorName = "handleColor"; + public const string HighlightColorName = "highlightColor"; + public const string PressedColorName = "pressedColor"; + public const string TrackColorName = "trackColor"; + public static readonly UiColor HandleColor = UiColor.ParseHexColor("#262626"); + public static readonly UiColor HighlightColor = UiColor.ParseHexColor("#2B2B2B"); + public static readonly UiColor PressedColor = UiColor.ParseHexColor("#333333"); + public static readonly UiColor TrackColor = UiColor.ParseHexColor("#171717"); + } } } \ No newline at end of file diff --git a/src/Rust.UIFramework/Json/JsonFrameworkWriter.cs b/src/Rust.UIFramework/Json/JsonFrameworkWriter.cs index 29a423b..2fe539c 100644 --- a/src/Rust.UIFramework/Json/JsonFrameworkWriter.cs +++ b/src/Rust.UIFramework/Json/JsonFrameworkWriter.cs @@ -1,6 +1,7 @@ using Network; using Oxide.Ext.UiFramework.Cache; using Oxide.Ext.UiFramework.Colors; +using Oxide.Ext.UiFramework.Components; using Oxide.Ext.UiFramework.Pooling; using UnityEngine; using UnityEngine.UI; @@ -147,6 +148,15 @@ public void AddField(string name, VerticalWrapMode value) WriteValue(EnumCache.ToString(value)); } } + + public void AddField(string name, ScrollRect.MovementType value) + { + if (value != ScrollRect.MovementType.Clamped) + { + WritePropertyName(name); + WriteValue(EnumCache.ToString(value)); + } + } public void AddField(string name, int value, int defaultValue) { @@ -193,6 +203,35 @@ public void AddField(string name, UiColor color) } } + public void AddField(string name, UiColor color, UiColor defaultColor) + { + if (color != defaultColor) + { + WritePropertyName(name); + WriteValue(color); + } + } + + public void AddComponent(string name, IComponent component) + { + WritePropertyName(name); + bool objectComma = _objectComma; + bool propertyComma = _propertyComma; + _objectComma = false; + _propertyComma = false; + if (component != null) + { + component.WriteComponent(this); + } + else + { + WriteStartObject(); + WriteEndObject(); + } + _objectComma = objectComma; + _propertyComma = propertyComma; + } + public void AddKeyField(string name) { WritePropertyName(name); diff --git a/src/Rust.UIFramework/UiElements/UiReference.cs b/src/Rust.UIFramework/UiElements/UiReference.cs index cca0325..6b2b807 100644 --- a/src/Rust.UIFramework/UiElements/UiReference.cs +++ b/src/Rust.UIFramework/UiElements/UiReference.cs @@ -11,6 +11,8 @@ public UiReference(string parent, string name) Name = name; } + public UiReference WithChild(string name) => new(Name, name); + public bool IsValidParent() => !string.IsNullOrEmpty(Parent); public bool IsValidReference() => IsValidParent() && !string.IsNullOrEmpty(Name); } diff --git a/src/Rust.UIFramework/UiElements/UiScrollView.cs b/src/Rust.UIFramework/UiElements/UiScrollView.cs new file mode 100644 index 0000000..df7491a --- /dev/null +++ b/src/Rust.UIFramework/UiElements/UiScrollView.cs @@ -0,0 +1,118 @@ +using Oxide.Ext.UiFramework.Colors; +using Oxide.Ext.UiFramework.Components; +using Oxide.Ext.UiFramework.Json; +using Oxide.Ext.UiFramework.Offsets; +using Oxide.Ext.UiFramework.Pooling; +using Oxide.Ext.UiFramework.Positions; +using UnityEngine.UI; + +namespace Oxide.Ext.UiFramework.UiElements; + +public class UiScrollView : BaseUiComponent +{ + public readonly ScrollViewComponent ScrollView = new(); + + public UiReference ViewPort => _viewPort ??= Reference.WithChild($"{Reference.Name}___Viewport"); + public UiReference Content => _content ??= Reference.WithChild($"{Reference.Name}___Content"); + + private UiReference? _viewPort; + private UiReference? _content; + + public static UiScrollView Create(in UiPosition pos, in UiOffset offset, bool horizontal, bool vertical, ScrollRect.MovementType movementType, float elasticity, + bool inertia, float decelerationRate, float scrollSensitivity) + { + UiScrollView scroll = CreateBase(pos, offset); + ScrollViewComponent comp = scroll.ScrollView; + comp.Horizontal = horizontal; + comp.Vertical = vertical; + comp.MovementType = movementType; + comp.Elasticity = elasticity; + comp.Inertia = inertia; + comp.DecelerationRate = decelerationRate; + comp.ScrollSensitivity = scrollSensitivity; + return scroll; + } + + public void UpdateContentTransform(in UiPosition? position, in UiOffset? offset) + { + if (position.HasValue) + { + ScrollView.ContentTransform.Position = position.Value; + } + + if (offset.HasValue) + { + ScrollView.ContentTransform.Offset = offset.Value; + } + } + + public void AddScrollBars(bool invert = false, bool autoHide = false, string handleSprite = null, string trackSprite = null, float size = 20f, + UiColor? handleColor = null, UiColor? highlightColor = null, UiColor? pressedColor = null, UiColor? trackColor = null) + { + AddHorizontalScrollBar(invert, autoHide, handleSprite, trackSprite, size, handleColor, highlightColor, pressedColor, trackColor); + AddVerticalScrollBar(invert, autoHide, handleSprite, trackSprite, size, handleColor, highlightColor, pressedColor, trackColor); + } + + public ScrollbarComponent AddHorizontalScrollBar(bool invert = false, bool autoHide = false, string handleSprite = null, string trackSprite = null, float size = 20f, + UiColor? handleColor = null, UiColor? highlightColor = null, UiColor? pressedColor = null, UiColor? trackColor = null) + { + ScrollView.Horizontal = true; + ScrollbarComponent bar = CreateScrollBar(invert, autoHide, handleSprite, trackSprite, size, handleColor, highlightColor, pressedColor, trackColor); + ScrollView.HorizontalScrollbar = bar; + return bar; + } + + public ScrollbarComponent AddVerticalScrollBar(bool invert = false, bool autoHide = false, string handleSprite = null, string trackSprite = null, float size = 20f, + UiColor? handleColor = null, UiColor? highlightColor = null, UiColor? pressedColor = null, UiColor? trackColor = null) + { + ScrollView.Vertical = true; + ScrollbarComponent bar = CreateScrollBar(invert, autoHide, handleSprite, trackSprite, size, handleColor, highlightColor, pressedColor, trackColor); + ScrollView.VerticalScrollbar = bar; + return bar; + } + + private ScrollbarComponent CreateScrollBar(bool invert = false, bool autoHide = false, string handleSprite = null, string trackSprite = null, float size = 20f, + UiColor? handleColor = null, UiColor? highlightColor = null, UiColor? pressedColor = null, UiColor? trackColor = null) + { + ScrollbarComponent comp = UiFrameworkPool.Get(); + comp.Invert = invert; + comp.AutoHide = autoHide; + comp.HandleSprite = handleSprite; + comp.TrackSprite = trackSprite; + comp.Size = size; + if (handleColor.HasValue) + { + comp.HandleColor = handleColor.Value; + } + if (highlightColor.HasValue) + { + comp.HighlightColor = highlightColor.Value; + } + if (pressedColor.HasValue) + { + comp.PressedColor = pressedColor.Value; + } + if (trackColor.HasValue) + { + comp.TrackColor = trackColor.Value; + } + return comp; + } + + protected override void WriteComponents(JsonFrameworkWriter writer) + { + ScrollView.WriteComponent(writer); + base.WriteComponents(writer); + } + + protected override void EnterPool() + { + base.EnterPool(); + ScrollView.HorizontalScrollbar?.Dispose(); + ScrollView.HorizontalScrollbar = null; + ScrollView.VerticalScrollbar?.Dispose(); + ScrollView.VerticalScrollbar = null; + _viewPort = null; + _content = null; + } +} \ No newline at end of file