using RosettaUI.Reactive; namespace RosettaUI { public abstract class RangeFieldElement : FieldBaseElement { private readonly IGetter _minGetter; private readonly IGetter _maxGetter; public readonly ReactiveProperty minRx; public readonly ReactiveProperty maxRx; protected RangeFieldElement(LabelElement label, IBinder binder, IGetter minGetter, IGetter maxGetter, in FieldOption option = default) : base(label, binder, option) { _minGetter = minGetter; _maxGetter = maxGetter; minRx = new ReactiveProperty(_minGetter.Get()); maxRx = new ReactiveProperty(_maxGetter.Get()); } public TRange Min => minRx.Value; public TRange Max => maxRx.Value; public bool IsMinConst => _minGetter.IsConst; public bool IsMaxConst => _maxGetter.IsConst; protected override void UpdateInternal() { base.UpdateInternal(); if (!IsMinConst) minRx.Value = _minGetter.Get(); if (!IsMaxConst) maxRx.Value = _maxGetter.Get(); } } }