24 #include "sdl_button.hpp"
26 static const SDL_Color buttonbackgroundcolor = { 0x69, 0x66, 0x63, 0xff };
27 static const SDL_Color buttonhighlightcolor = { 0xcd, 0xca, 0x35, 0x60 };
28 static const SDL_Color buttonmouseovercolor = { 0x66, 0xff, 0x66, 0x60 };
29 static const SDL_Color buttonfontcolor = { 0xd1, 0xcf, 0xcd, 0xff };
31 SdlButton::SdlButton(SDL_Renderer* renderer, std::string label,
int id,
const SDL_FRect& rect)
32 :
SdlWidget(renderer, rect, false), _name(std::move(label)), _id(id)
36 update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
39 SdlButton::SdlButton(
SdlButton&& other) noexcept =
default;
41 SdlButton::~SdlButton() =
default;
43 bool 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);
53 bool 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);
61 bool SdlButton::update(SDL_Renderer* renderer)
65 return update_text(renderer, _name, buttonfontcolor, buttonbackgroundcolor);
68 int SdlButton::id()
const