replace Range with MinimumValue/MaximumValue

This commit is contained in:
Chris Forbes
2011-07-17 16:22:01 +12:00
parent a52e5a92ae
commit 74b894b69f
5 changed files with 20 additions and 13 deletions

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Widgets
public int Ticks = 0; public int Ticks = 0;
public int TrackHeight = 5; public int TrackHeight = 5;
public float2 Range = new float2(0f, 1f); public float MinimumValue = 0;
public float MaximumValue = 1;
public float Value = 0; public float Value = 0;
protected bool isMoving = false; protected bool isMoving = false;
@@ -33,14 +34,15 @@ namespace OpenRA.Widgets
{ {
OnChange = other.OnChange; OnChange = other.OnChange;
Ticks = other.Ticks; Ticks = other.Ticks;
Range = other.Range; MinimumValue = other.MinimumValue;
MaximumValue = other.MaximumValue;
Value = other.Value; Value = other.Value;
TrackHeight = other.TrackHeight; TrackHeight = other.TrackHeight;
} }
void UpdateValue(float newValue) void UpdateValue(float newValue)
{ {
Value = newValue.Clamp(Range.X, Range.Y); Value = newValue.Clamp(MinimumValue, MaximumValue);
OnChange(Value); OnChange(Value);
} }
@@ -74,8 +76,8 @@ namespace OpenRA.Widgets
return ThumbRect.Contains(mi.Location); return ThumbRect.Contains(mi.Location);
} }
float ValueFromPx(int x) { return Range.X + (Range.Y - Range.X) * (1f * x / RenderBounds.Width); } float ValueFromPx(int x) { return MinimumValue + (MaximumValue - MinimumValue) * (1f * x / RenderBounds.Width); }
int PxFromValue(float x) { return (int)(RenderBounds.Width * (x - Range.X) / (Range.Y - Range.X)); } int PxFromValue(float x) { return (int)(RenderBounds.Width * (x - MinimumValue) / (MaximumValue - MinimumValue)); }
public override Widget Clone() { return new SliderWidget(this); } public override Widget Clone() { return new SliderWidget(this); }

View File

@@ -71,7 +71,8 @@ Background@COLOR_CHOOSER:
Width:160 Width:160
Height:20 Height:20
Ticks:5 Ticks:5
Range:0.2,1 MinimumValue: 0.2
MaximumValue: 1
ScrollPanel@LABEL_DROPDOWN_TEMPLATE: ScrollPanel@LABEL_DROPDOWN_TEMPLATE:
Id:LABEL_DROPDOWN_TEMPLATE Id:LABEL_DROPDOWN_TEMPLATE
@@ -135,4 +136,4 @@ ScrollPanel@TEAM_DROPDOWN_TEMPLATE:
X:0 X:0
Width:PARENT_RIGHT Width:PARENT_RIGHT
Height:25 Height:25
Align:Center Align:Center

View File

@@ -240,7 +240,8 @@ Container@SETTINGS_PANEL:
Width:240 Width:240
Height:20 Height:20
Ticks:5 Ticks:5
Range:10,50 MinimumValue: 10
MaximumValue: 50
Checkbox@EDGESCROLL_CHECKBOX: Checkbox@EDGESCROLL_CHECKBOX:
Id:EDGESCROLL_CHECKBOX Id:EDGESCROLL_CHECKBOX
X:15 X:15
@@ -338,4 +339,4 @@ Container@SETTINGS_PANEL:
Y:249 Y:249
Width:140 Width:140
Height:35 Height:35
Text:Back Text:Back

View File

@@ -493,7 +493,8 @@ Background@COLOR_CHOOSER:
Width:160 Width:160
Height:20 Height:20
Ticks:5 Ticks:5
Range:0.2,1 MinimumValue: 0.2
MaximumValue: 1
Label@RANGE_LABEL: Label@RANGE_LABEL:
X:0 X:0
Y:80 Y:80
@@ -508,7 +509,8 @@ Background@COLOR_CHOOSER:
Width:160 Width:160
Height:20 Height:20
Ticks:5 Ticks:5
Range:0,0.25 MinimumValue: 0
MaximumValue: 0.25
Background@MAP_CHOOSER: Background@MAP_CHOOSER:
Id:MAP_CHOOSER Id:MAP_CHOOSER
X:(WINDOW_RIGHT - WIDTH)/2 X:(WINDOW_RIGHT - WIDTH)/2
@@ -714,4 +716,4 @@ Background@MAP_CHOOSER:
Width:120 Width:120
Height:25 Height:25
Text:Cancel Text:Cancel
Font:Bold Font:Bold

View File

@@ -102,7 +102,8 @@ Background@SETTINGS_MENU:
Width:250 Width:250
Height:20 Height:20
Ticks:5 Ticks:5
Range:10,50 MinimumValue: 10
MaximumValue: 50
Checkbox@INVERSE_SCROLL: Checkbox@INVERSE_SCROLL:
Id:INVERSE_SCROLL Id:INVERSE_SCROLL
X:0 X:0