diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/slider.cpp | 91 | ||||
-rw-r--r-- | src/gui/widgets/slider.h | 14 |
2 files changed, 49 insertions, 56 deletions
diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index ee649947a..86089fb9a 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -166,8 +166,8 @@ void Slider::init() mInstances++; - if (buttons[0].grid[HGRIP]) - setMarkerLength(buttons[0].grid[HGRIP]->getWidth()); + if (buttons[0].grid[SliderGrid::HGRIP]) + setMarkerLength(buttons[0].grid[SliderGrid::HGRIP]->getWidth()); } void Slider::updateAlpha() @@ -180,7 +180,7 @@ void Slider::updateAlpha() mAlpha = alpha; for (int f = 0; f < 2; f ++) { - for (int d = 0; d < SLIDER_MAX; d ++) + for (int d = 0; d < SliderGrid::SLIDER_MAX; d ++) { if (buttons[f].grid[d]) buttons[f].grid[d]->setAlpha(mAlpha); @@ -192,8 +192,9 @@ void Slider::updateAlpha() void Slider::draw(Graphics *const graphics) { BLOCK_START("Slider::draw") - if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART] - || !buttons[0].grid[HEND]) + if (!buttons[0].grid[SliderGrid::HSTART] || + !buttons[1].grid[SliderGrid::HSTART] || + !buttons[0].grid[SliderGrid::HEND]) { BLOCK_END("Slider::draw") return; @@ -201,8 +202,9 @@ void Slider::draw(Graphics *const graphics) int w = getWidth(); const int h = getHeight(); - const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : - (h - buttons[0].grid[HSTART]->getHeight()) / 2; + const int y = mHasMouse ? + (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 : + (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2; updateAlpha(); @@ -214,15 +216,16 @@ void Slider::draw(Graphics *const graphics) if (!mHasMouse) { graphics->calcTileCollection(mVertexes, - buttons[0].grid[HSTART], x, y); + buttons[0].grid[SliderGrid::HSTART], + x, y); - const int width = buttons[0].grid[HSTART]->getWidth(); - w -= width + buttons[0].grid[HEND]->getWidth(); + const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth(); + w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth(); x += width; - if (buttons[0].grid[HMID]) + if (buttons[0].grid[SliderGrid::HMID]) { - const Image *const hMid = buttons[0].grid[HMID]; + const Image *const hMid = buttons[0].grid[SliderGrid::HMID]; graphics->calcPattern(mVertexes, hMid, x, y, @@ -231,10 +234,10 @@ void Slider::draw(Graphics *const graphics) x += w; graphics->calcTileCollection(mVertexes, - buttons[0].grid[HEND], + buttons[0].grid[SliderGrid::HEND], x, y); - const Image *const img = buttons[0].grid[HGRIP]; + const Image *const img = buttons[0].grid[SliderGrid::HGRIP]; if (img) { graphics->calcTileCollection(mVertexes, @@ -246,18 +249,18 @@ void Slider::draw(Graphics *const graphics) else { graphics->calcTileCollection(mVertexes, - buttons[1].grid[HSTART], + buttons[1].grid[SliderGrid::HSTART], x, y); - const int width = buttons[1].grid[HSTART]->getWidth(); + const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth(); w -= width; - if (buttons[1].grid[HEND]) - w -= buttons[1].grid[HEND]->getWidth(); + if (buttons[1].grid[SliderGrid::HEND]) + w -= buttons[1].grid[SliderGrid::HEND]->getWidth(); x += width; - if (buttons[1].grid[HMID]) + if (buttons[1].grid[SliderGrid::HMID]) { - const Image *const hMid = buttons[1].grid[HMID]; + const Image *const hMid = buttons[1].grid[SliderGrid::HMID]; graphics->calcPattern(mVertexes, hMid, x, y, @@ -265,13 +268,13 @@ void Slider::draw(Graphics *const graphics) } x += w; - if (buttons[1].grid[HEND]) + if (buttons[1].grid[SliderGrid::HEND]) { graphics->calcTileCollection(mVertexes, - buttons[1].grid[HEND], x, y); + buttons[1].grid[SliderGrid::HEND], x, y); } - const Image *const img = buttons[1].grid[HGRIP]; + const Image *const img = buttons[1].grid[SliderGrid::HGRIP]; if (img) { graphics->calcTileCollection(mVertexes, @@ -290,8 +293,9 @@ void Slider::draw(Graphics *const graphics) void Slider::safeDraw(Graphics *const graphics) { BLOCK_START("Slider::draw") - if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART] - || !buttons[0].grid[HEND]) + if (!buttons[0].grid[SliderGrid::HSTART] || + !buttons[1].grid[SliderGrid::HSTART] || + !buttons[0].grid[SliderGrid::HEND]) { BLOCK_END("Slider::draw") return; @@ -300,28 +304,29 @@ void Slider::safeDraw(Graphics *const graphics) int w = getWidth(); const int h = getHeight(); int x = 0; - const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : - (h - buttons[0].grid[HSTART]->getHeight()) / 2; + const int y = mHasMouse ? + (h - buttons[1].grid[SliderGrid::HSTART]->getHeight()) / 2 : + (h - buttons[0].grid[SliderGrid::HSTART]->getHeight()) / 2; updateAlpha(); if (!mHasMouse) { - graphics->drawImage(buttons[0].grid[HSTART], x, y); - const int width = buttons[0].grid[HSTART]->getWidth(); - w -= width + buttons[0].grid[HEND]->getWidth(); + graphics->drawImage(buttons[0].grid[SliderGrid::HSTART], x, y); + const int width = buttons[0].grid[SliderGrid::HSTART]->getWidth(); + w -= width + buttons[0].grid[SliderGrid::HEND]->getWidth(); x += width; - if (buttons[0].grid[HMID]) + if (buttons[0].grid[SliderGrid::HMID]) { - const Image *const hMid = buttons[0].grid[HMID]; + const Image *const hMid = buttons[0].grid[SliderGrid::HMID]; graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; - graphics->drawImage(buttons[0].grid[HEND], x, y); + graphics->drawImage(buttons[0].grid[SliderGrid::HEND], x, y); - const Image *const img = buttons[0].grid[HGRIP]; + const Image *const img = buttons[0].grid[SliderGrid::HGRIP]; if (img) { graphics->drawImage(img, getMarkerPosition(), @@ -330,25 +335,25 @@ void Slider::safeDraw(Graphics *const graphics) } else { - graphics->drawImage(buttons[1].grid[HSTART], x, y); + graphics->drawImage(buttons[1].grid[SliderGrid::HSTART], x, y); - const int width = buttons[1].grid[HSTART]->getWidth(); + const int width = buttons[1].grid[SliderGrid::HSTART]->getWidth(); w -= width; - if (buttons[1].grid[HEND]) - w -= buttons[1].grid[HEND]->getWidth(); + if (buttons[1].grid[SliderGrid::HEND]) + w -= buttons[1].grid[SliderGrid::HEND]->getWidth(); x += width; - if (buttons[1].grid[HMID]) + if (buttons[1].grid[SliderGrid::HMID]) { - const Image *const hMid = buttons[1].grid[HMID]; + const Image *const hMid = buttons[1].grid[SliderGrid::HMID]; graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; - if (buttons[1].grid[HEND]) - graphics->drawImage(buttons[1].grid[HEND], x, y); + if (buttons[1].grid[SliderGrid::HEND]) + graphics->drawImage(buttons[1].grid[SliderGrid::HEND], x, y); - const Image *const img = buttons[1].grid[HGRIP]; + const Image *const img = buttons[1].grid[SliderGrid::HGRIP]; if (img) { graphics->drawImage(img, getMarkerPosition(), diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index b70f3f000..450eddcac 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -67,6 +67,7 @@ #define GUI_WIDGETS_SLIDER_H #include "enums/gui/orientation.h" +#include "enums/gui/slidergrid.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" @@ -261,19 +262,6 @@ class Slider final : public Widget, double getStepLength() const { return mStepLength; } - enum SLIDER_ENUM - { - HSTART = 0, - HMID, - HEND, - HGRIP, - VSTART, - VMID, - VEND, - VGRIP, - SLIDER_MAX - }; - private: /** * Used to initialize instances. |