24#include "sdl_button.hpp"
26static const SDL_Color buttonbackgroundcolor = { 0x69, 0x66, 0x63, 0xff };
27static const SDL_Color buttonhighlightcolor = { 0xcd, 0xca, 0x35, 0x60 };
28static const SDL_Color buttonmouseovercolor = { 0x66, 0xff, 0x66, 0x60 };
29static const SDL_Color buttonfontcolor = { 0xd1, 0xcf, 0xcd, 0xff };
31SdlButton::SdlButton(SDL_Renderer* renderer, std::string label,
int id, SDL_Rect rect)
32 :
SdlWidget(renderer, rect, false), _name(std::move(label)), _id(id)
36 update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
39SdlButton::SdlButton(
SdlButton&& other)
noexcept =
default;
41SdlButton::~SdlButton() =
default;
43bool SdlButton::highlight(SDL_Renderer* renderer)
47 std::vector<SDL_Color> colors = { buttonbackgroundcolor, buttonhighlightcolor };
48 if (!fill(renderer, colors))
50 return update_text(renderer, _name, buttonfontcolor);
53bool SdlButton::mouseover(SDL_Renderer* renderer)
55 std::vector<SDL_Color> colors = { buttonbackgroundcolor, buttonmouseovercolor };
56 if (!fill(renderer, colors))
58 return update_text(renderer, _name, buttonfontcolor);
61bool SdlButton::update(SDL_Renderer* renderer)
65 return update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
68int SdlButton::id()
const