This commit is contained in:
Wojtek Figat
2024-02-18 00:03:54 +01:00
parent fcfde1e964
commit e165c87e5a

View File

@@ -1,4 +1,6 @@
using System;
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine.GUI;
@@ -138,14 +140,10 @@ public class Slider : ContainerControl
{
switch (Direction)
{
case SliderDirection.HorizontalRight:
return new Float2(_thumbSize.X / 2, Height / 2);
case SliderDirection.HorizontalLeft:
return new Float2(Width - _thumbSize.X / 2, Height / 2);
case SliderDirection.VerticalUp:
return new Float2(Width / 2, Height - _thumbSize.Y / 2);
case SliderDirection.VerticalDown:
return new Float2(Width / 2, _thumbSize.Y / 2);
case SliderDirection.HorizontalRight: return new Float2(_thumbSize.X / 2, Height / 2);
case SliderDirection.HorizontalLeft: return new Float2(Width - _thumbSize.X / 2, Height / 2);
case SliderDirection.VerticalUp: return new Float2(Width / 2, Height - _thumbSize.Y / 2);
case SliderDirection.VerticalDown: return new Float2(Width / 2, _thumbSize.Y / 2);
default: break;
}
return Float2.Zero;
@@ -162,14 +160,10 @@ public class Slider : ContainerControl
{
switch (Direction)
{
case SliderDirection.HorizontalRight:
return new Float2(Width - _thumbSize.X / 2, Height / 2);
case SliderDirection.HorizontalLeft:
return new Float2(_thumbSize.X / 2, Height / 2);
case SliderDirection.VerticalUp:
return new Float2(Width / 2, _thumbSize.Y / 2);
case SliderDirection.VerticalDown:
return new Float2(Width / 2, Height - _thumbSize.Y / 2);
case SliderDirection.HorizontalRight: return new Float2(Width - _thumbSize.X / 2, Height / 2);
case SliderDirection.HorizontalLeft: return new Float2(_thumbSize.X / 2, Height / 2);
case SliderDirection.VerticalUp: return new Float2(Width / 2, _thumbSize.Y / 2);
case SliderDirection.VerticalDown: return new Float2(Width / 2, Height - _thumbSize.Y / 2);
default: break;
}
return Float2.Zero;
@@ -186,7 +180,8 @@ public class Slider : ContainerControl
/// The thumb size.
/// </summary>
[EditorOrder(41), Tooltip("The size of the thumb.")]
public Float2 ThumbSize {
public Float2 ThumbSize
{
get => _thumbSize;
set
{
@@ -359,17 +354,16 @@ public class Slider : ContainerControl
var fillLineRect = new Rectangle(_thumbSize.X / 2 - 1, (Height - TrackThickness - 2) / 2, Width - (Width - _thumbCenter) - _thumbSize.X / 2 + 1, TrackThickness + 2);
switch (Direction)
{
case SliderDirection.HorizontalRight:
break;
case SliderDirection.HorizontalRight: break;
case SliderDirection.VerticalDown:
lineRect = new Rectangle((Width - TrackThickness) / 2 , _thumbSize.Y / 2, TrackThickness, Height - _thumbSize.Y);
lineRect = new Rectangle((Width - TrackThickness) / 2, _thumbSize.Y / 2, TrackThickness, Height - _thumbSize.Y);
fillLineRect = new Rectangle((Width - TrackThickness - 2) / 2, _thumbSize.Y / 2 - 1, TrackThickness + 2, Height - (Height - _thumbCenter) - _thumbSize.Y / 2 + 1);
break;
case SliderDirection.HorizontalLeft:
fillLineRect = new Rectangle(Width - (Width - _thumbCenter) - 1, (Height - TrackThickness - 2) / 2, Width - _thumbCenter + 1, TrackThickness + 2);
break;
case SliderDirection.VerticalUp:
lineRect = new Rectangle((Width - TrackThickness) / 2 , _thumbSize.Y / 2, TrackThickness, Height - _thumbSize.Y);
lineRect = new Rectangle((Width - TrackThickness) / 2, _thumbSize.Y / 2, TrackThickness, Height - _thumbSize.Y);
fillLineRect = new Rectangle((Width - TrackThickness - 2) / 2, Height - (Height - _thumbCenter) - 1, TrackThickness + 2, Height - _thumbCenter + 1);
break;
default: break;