5#include "fifechan/widgets/button.hpp"
10#include "fifechan/exception.hpp"
11#include "fifechan/font.hpp"
12#include "fifechan/graphics.hpp"
13#include "fifechan/key.hpp"
14#include "fifechan/mouseevent.hpp"
15#include "fifechan/mouseinput.hpp"
30 Button::Button(std::string caption) :
mCaption(std::move(caption))
41 Button::~Button() =
default;
109 if (active && ((
getSelectionMode() & Widget::SelectionMode::Background) == Widget::SelectionMode::Background)) {
113 int const alpha = faceColor.
a;
116 faceColor = faceColor - 0x303030;
120 int const color =
static_cast<int>((faceColor.
r * 0.3) + (faceColor.
g * 0.59) + (faceColor.
b * 0.11));
131 if (active && (
getSelectionMode() & Widget::SelectionMode::Border) == Widget::SelectionMode::Border) {
143 case Graphics::Alignment::Left:
146 case Graphics::Alignment::Center:
150 case Graphics::Alignment::Right:
154 throwException(
"Unknown alignment.");
169 static_cast<void>(recursion);
195 if (mouseEvent.
getButton() == MouseEvent::Button::Left) {
217 }
else if (mouseEvent.
getButton() == MouseEvent::Button::Left) {
uint8_t a
Alpha color component (0-255).
uint8_t b
Blue color component (0-255).
uint8_t g
Green color component (0-255).
uint8_t r
Red color component (0-255).
Base class for all GUI event objects.
virtual int getWidth(std::string const &text) const =0
Gets the width of a string.
virtual int getHeight() const =0
Gets the height of the glyphs in the font.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Alignment
Alignments for text drawing.
void drawText(std::string const &text, int x, int y)
Draws text with a default left alignment.
virtual void setFont(Font *font)
Sets the font to use when drawing text.
virtual void setColor(Color const &color)=0
Sets the color to use when drawing.
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.
MouseEvent::Button getButton() const
Gets the button of the mouse event.
Represents a rectangular area (X, Y, Width, Height).
int width
Holds the width of the rectangle.
int y
Holds the x coordinate of the rectangle.
int x
Holds the x coordinate of the rectangle.
int height
Holds the height of the rectangle.