2 using Microsoft.Xna.Framework;
14 private bool isHorizontal;
18 private float barSize;
19 private float barScroll;
23 private Vector2? dragStartPos;
33 get {
return base.ToolTip; }
42 private float minValue;
45 get {
return minValue; }
48 minValue = MathHelper.Clamp(value, 0.0f, 1.0f);
49 BarScroll = Math.Max(minValue, barScroll);
53 private float maxValue = 1.0f;
56 get {
return maxValue; }
59 maxValue = MathHelper.Clamp(value, 0.0f, 1.0f);
60 BarScroll = Math.Min(maxValue, barScroll);
66 get {
return isHorizontal; }
82 Children.ForEach(c => c.Enabled = value);
99 private Vector2 range;
134 get {
return step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step); }
137 if (
float.IsNaN(value))
142 barScroll = MathHelper.Clamp(value, minValue, maxValue);
145 float newScroll = step == 0.0f ? barScroll : MathUtils.RoundTowardsClosest(barScroll, step);
169 step = MathHelper.Clamp(value, 0.0f, 1.0f);
192 get {
return barSize; }
195 barSize = Math.Min(Math.Max(value, 0.0f), 1.0f);
203 this.isHorizontal = isHorizontal ?? (
Rect.Width >
Rect.Height);
205 GUIStyle.Apply(
Frame,
IsHorizontal ?
"GUIFrameHorizontal" :
"GUIFrameVertical",
this);
206 this.barSize = barSize;
226 GUIStyle.Apply(
Bar,
IsHorizontal ?
"GUIButtonHorizontal" :
"GUIButtonVertical",
this);
237 private void UpdateRect()
240 var newSize =
new Point((
int)(
Rect.Size.X - padding.X - padding.Z), (
int)(
Rect.Size.Y - padding.Y - padding.W));
246 protected override void Update(
float deltaTime)
261 int dir = Math.Sign(barScroll - (minValue + maxValue) / 2.0f);
262 if (dir == 0) dir = 1;
263 if ((barScroll <= maxValue && dir > 0) ||
264 (barScroll > minValue && dir < 0))
272 GUI.ForceMouseOn(
this);
293 else if (GUI.MouseOn ==
Frame)
306 float barScale = 1.0f;
321 private bool SelectBar()
324 if (barSize >= 1.0f) {
return false; }
332 float newScroll = barScroll;
virtual ComponentState State
bool IsParentOf(GUIComponent component, bool recursive=true)
virtual RichString ToolTip
RectTransform RectTransform
IEnumerable< GUIComponent > Children