1 #include "UnitTest.h"
2 #include "Gwen/Controls/RadioButtonController.h"
3 #include "Gwen/Controls/VerticalSlider.h"
4 #include "Gwen/Controls/HorizontalSlider.h"
5 
6 using namespace Gwen;
7 
8 class Slider : public GUnit
9 {
10 public:
GWEN_CONTROL_INLINE(Slider,GUnit)11 	GWEN_CONTROL_INLINE(Slider, GUnit)
12 	{
13 		{
14 			Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider(this);
15 			pSlider->SetPos(10, 10);
16 			pSlider->SetSize(150, 20);
17 			pSlider->SetRange(0, 100);
18 			pSlider->SetValue(25);
19 			pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
20 		}
21 
22 		{
23 			Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider(this);
24 			pSlider->SetPos(10, 40);
25 			pSlider->SetSize(150, 20);
26 			pSlider->SetRange(0, 100);
27 			pSlider->SetValue(25);
28 			pSlider->SetNotchCount(10);
29 			pSlider->SetClampToNotches(true);
30 			pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
31 		}
32 
33 		{
34 			Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider(this);
35 			pSlider->SetPos(160, 10);
36 			pSlider->SetSize(20, 200);
37 			pSlider->SetRange(0, 100);
38 			pSlider->SetValue(25);
39 			pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
40 		}
41 
42 		{
43 			Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider(this);
44 			pSlider->SetPos(190, 10);
45 			pSlider->SetSize(20, 200);
46 			pSlider->SetRange(0, 100);
47 			pSlider->SetValue(25);
48 			pSlider->SetNotchCount(10);
49 			pSlider->SetClampToNotches(true);
50 			pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
51 		}
52 	}
53 
SliderMoved(Base * pControl)54 	void SliderMoved(Base* pControl)
55 	{
56 		Gwen::Controls::Slider* pSlider = (Gwen::Controls::Slider*)pControl;
57 
58 		UnitPrint(Utility::Format(L"Slider Value: %.2f", pSlider->GetValue()));
59 	}
60 };
61 
62 DEFINE_UNIT_TEST(Slider, L"Slider");