diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-17 11:20:58 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-09-17 11:20:58 (GMT) |
| commit | 6e44ebc358d1206c147f514225373da07b43c015 (patch) | |
| tree | 35e97c28991c4aff46a9e5a4182b53dedb26e7ee /src/interface | |
| parent | e52e9ce91ccca13115fec0fdb0111e7e5d39d10d (diff) | |
| download | powder-6e44ebc358d1206c147f514225373da07b43c015.zip powder-6e44ebc358d1206c147f514225373da07b43c015.tar.gz | |
Checkbox, Slider and ProgressBar components for ui API
Diffstat (limited to 'src/interface')
| -rw-r--r-- | src/interface/Checkbox.cpp | 5 | ||||
| -rw-r--r-- | src/interface/Checkbox.h | 1 | ||||
| -rw-r--r-- | src/interface/ProgressBar.cpp | 20 | ||||
| -rw-r--r-- | src/interface/ProgressBar.h | 4 | ||||
| -rw-r--r-- | src/interface/Slider.cpp | 23 | ||||
| -rw-r--r-- | src/interface/Slider.h | 2 |
6 files changed, 47 insertions, 8 deletions
diff --git a/src/interface/Checkbox.cpp b/src/interface/Checkbox.cpp index 2481b23..c0dd47b 100644 --- a/src/interface/Checkbox.cpp +++ b/src/interface/Checkbox.cpp @@ -25,6 +25,11 @@ void Checkbox::SetText(std::string text) this->text = text; } +std::string Checkbox::GetText() +{ + return text; +} + void Checkbox::OnMouseClick(int x, int y, unsigned int button) { if(checked) diff --git a/src/interface/Checkbox.h b/src/interface/Checkbox.h index ba96cc7..f9d305c 100644 --- a/src/interface/Checkbox.h +++ b/src/interface/Checkbox.h @@ -27,6 +27,7 @@ class Checkbox: public ui::Component { public: Checkbox(ui::Point position, ui::Point size, std::string text); void SetText(std::string text); + std::string GetText(); void Draw(const Point& screenPos); virtual void OnMouseEnter(int x, int y); virtual void OnMouseLeave(int x, int y); diff --git a/src/interface/ProgressBar.cpp b/src/interface/ProgressBar.cpp index a622bab..eda88f6 100644 --- a/src/interface/ProgressBar.cpp +++ b/src/interface/ProgressBar.cpp @@ -3,17 +3,26 @@ using namespace ui; -ProgressBar::ProgressBar(Point position, Point size): +ProgressBar::ProgressBar(Point position, Point size, int startProgress, std::string startStatus): Component(position, size), intermediatePos(0.0f), - progressStatus("") + progressStatus(""), + progress(0) { - progress = 0; + SetStatus(startStatus); + SetProgress(startProgress); } void ProgressBar::SetProgress(int progress) { this->progress = progress; + if(this->progress > 100) + this->progress = 100; +} + +int ProgressBar::GetProgress() +{ + return progress; } void ProgressBar::SetStatus(std::string status) @@ -21,6 +30,11 @@ void ProgressBar::SetStatus(std::string status) progressStatus = status; } +std::string ProgressBar::GetStatus() +{ + return progressStatus; +} + void ProgressBar::Draw(const Point & screenPos) { Graphics * g = ui::Engine::Ref().g; diff --git a/src/interface/ProgressBar.h b/src/interface/ProgressBar.h index 9d803cc..fc47f0c 100644 --- a/src/interface/ProgressBar.h +++ b/src/interface/ProgressBar.h @@ -10,9 +10,11 @@ namespace ui float intermediatePos; std::string progressStatus; public: - ProgressBar(Point position, Point size); + ProgressBar(Point position, Point size, int startProgress = 0, std::string startStatus = ""); virtual void SetProgress(int progress); + virtual int GetProgress(); virtual void SetStatus(std::string status); + virtual std::string GetStatus(); virtual void Draw(const Point & screenPos); virtual void Tick(float dt); }; diff --git a/src/interface/Slider.cpp b/src/interface/Slider.cpp index 652ae59..d5639cb 100644 --- a/src/interface/Slider.cpp +++ b/src/interface/Slider.cpp @@ -72,10 +72,6 @@ void Slider::OnMouseUp(int x, int y, unsigned button) } } -int Slider::GetValue() -{ - return sliderPosition; -} void Slider::SetColour(Colour col1, Colour col2) { @@ -88,6 +84,11 @@ void Slider::SetColour(Colour col1, Colour col2) bgGradient = (unsigned char*)Graphics::GenerateGradient(pix, fl, 2, Size.X-7); } +int Slider::GetValue() +{ + return sliderPosition; +} + void Slider::SetValue(int value) { if(value < 0) @@ -97,6 +98,20 @@ void Slider::SetValue(int value) sliderPosition = value; } +int Slider::GetSteps() +{ + return sliderSteps; +} + +void Slider::SetSteps(int steps) +{ + if(steps < 0) + steps = 0; + if(steps < sliderPosition) + sliderPosition = steps; + sliderSteps = steps; +} + void Slider::Draw(const Point& screenPos) { Graphics * g = Engine::Ref().g; diff --git a/src/interface/Slider.h b/src/interface/Slider.h index 21792bc..65ca0ba 100644 --- a/src/interface/Slider.h +++ b/src/interface/Slider.h @@ -38,6 +38,8 @@ public: void SetActionCallback(SliderAction * action) { actionCallback = action; } int GetValue(); void SetValue(int value); + int GetSteps(); + void SetSteps(int steps); virtual ~Slider(); }; |
