5#include "fifechan/widgets/slider.hpp"
9#include "fifechan/graphics.hpp"
10#include "fifechan/key.hpp"
11#include "fifechan/mouseinput.hpp"
64 shadowColor.
a = alpha;
78 highlightColor = faceColor + 0x303030;
79 highlightColor.
a = alpha;
80 shadowColor = faceColor - 0x303030;
81 shadowColor.
a = alpha;
118 if (mouseEvent.
getButton() == fcn::MouseEvent::Button::Left && mouseEvent.
getX() >= 0 &&
182 }
else if (key.
getValue() == Key::Left) {
192 }
else if (key.
getValue() == Key::Down) {
219 double const pos = position / (
static_cast<double>(w) -
getMarkerLength());
uint8_t a
Alpha color component (0-255).
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
virtual void drawLine(int x1, int y1, int x2, int y2)=0
Draws a line.
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
virtual void drawRectangle(Rectangle const &rectangle)=0
Draws a simple, non-filled rectangle with a one pixel width.
virtual void fillRectangle(Rectangle const &rectangle)=0
Draws a filled rectangle.
Key const & getKey() const
Gets the key of the event.
Represents a keyboard key or character code.
int getValue() const
Gets the value of the key.
Represents a mouse event.
int getX() const
Gets the x coordinate of the mouse event.
int getY() const
Gets the y coordinate of the mouse event.
MouseEvent::Button getButton() const
Gets the button of the mouse event.
void setScale(double scaleStart, double scaleEnd)
Sets the scale of the slider.
double mValue
Holds the current selected value.
Slider(double scaleEnd=1.0)
Constructor.
virtual int getMarkerPosition() const
Gets the marker position of the current selected value.
void mousePressed(MouseEvent &mouseEvent) override
Called when a mouse button has been pressed on the widget area.
double mStepLength
Holds the step length.
double getStepLength() const
Gets the step length.
Orientation
Draw orientations for the slider.
double mScaleEnd
Holds the end value of the scale.
void mouseWheelMovedLeft(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved left on the widget area.
virtual double markerPositionToValue(int position) const
Converts a marker position to a value in the scale.
void setStepLength(double length)
Sets the step length.
Orientation mOrientation
Holds the orientation of the slider.
void setScaleStart(double scaleStart)
Sets the start value of the scale.
void keyPressed(KeyEvent &keyEvent) override
Called if a key is pressed when the widget has keyboard focus.
void setOrientation(Orientation orientation)
Sets the orientation of the slider.
double getScaleStart() const
Gets the start value of the scale.
double mScaleStart
Holds the start value of the scale.
void mouseWheelMovedUp(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved up on the widget area.
virtual void drawMarker(Graphics *graphics)
Draws the marker.
Orientation getOrientation() const
Gets the orientation of the slider.
void setScaleEnd(double scaleEnd)
Sets the end value of the scale.
int getMarkerLength() const
Gets the length of the marker.
void mouseWheelMovedDown(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved down on the widget area.
int mMarkerLength
Holds the length of the marker.
void setMarkerLength(int length)
Sets the length of the marker.
void setValue(double value)
Sets the current selected value.
double getValue() const
Gets the current selected value.
void mouseDragged(MouseEvent &mouseEvent) override
Called when the mouse has moved and the mouse has previously been pressed on the widget.
void draw(Graphics *graphics) override
Draws the widget.
virtual int valueToMarkerPosition(double value) const
Converts a value to a marker position.
void mouseWheelMovedRight(MouseEvent &mouseEvent) override
Called when the mouse wheel has moved right on the widget area.
double getScaleEnd() const
Gets the end value of the scale.