6#include "fifechan/widgets/button.hpp"
13#include "fifechan/events/mouseevent.hpp"
14#include "fifechan/exception.hpp"
15#include "fifechan/font.hpp"
16#include "fifechan/graphics.hpp"
17#include "fifechan/key.hpp"
18#include "fifechan/mouseinput.hpp"
33 Button::Button(std::string caption) :
mCaption(std::move(caption))
44 Button::~Button() =
default;
112 if (active && ((
getSelectionMode() & Widget::SelectionMode::Background) == Widget::SelectionMode::Background)) {
116 int const alpha = faceColor.
a;
119 faceColor = faceColor - 0x303030;
123 int const color =
static_cast<int>((faceColor.
r * 0.3) + (faceColor.
g * 0.59) + (faceColor.
b * 0.11));
134 if (active && (
getSelectionMode() & Widget::SelectionMode::Border) == Widget::SelectionMode::Border) {
146 case Graphics::Alignment::Left:
149 case Graphics::Alignment::Center:
153 case Graphics::Alignment::Right:
172 static_cast<void>(recursion);
198 if (mouseEvent.
getButton() == MouseEvent::Button::Left) {
222 }
else if (mouseEvent.
getButton() == MouseEvent::Button::Left) {
235 Key
const key = keyEvent.
getKey();
237 if (key.getValue() == fcn::Key::KEY_RETURN || key.getValue() == fcn::Key::SPACE) {
245 Key
const key = keyEvent.
getKey();
247 if ((key.getValue() == fcn::Key::KEY_RETURN || key.getValue() == fcn::Key::SPACE) &&
mKeyPressed) {
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
Horizontal 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 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.
Used replacement tokens by configure_file():
void throwException(std::string const &message, std::source_location location=std::source_location::current())
Throw an Exception capturing the current source location.