libwtk-sdl2
0.0.1
include
button.hpp
1
#ifndef LIBWTK_SDL2_BUTTON_HPP
2
#define LIBWTK_SDL2_BUTTON_HPP
3
4
#include <functional>
5
6
#include "selectable.hpp"
7
8
struct
button
:
selectable
9
{
10
button
(std::string text, std::function<
void
()> callback);
11
12
void
on_draw
(
draw_context
& dc,
selection_context
const
& sc)
const override
;
13
void
on_mouse_up_event(
mouse_up_event
const
& e)
override
;
14
void
on_mouse_down_event(
mouse_down_event
const
& e)
override
;
15
void
on_key_event(
key_event
const
& e)
override
;
16
void
on_activate
()
override
;
17
size_hint
get_size_hint
(
int
width,
int
height)
const override
;
18
19
~
button
()
override
;
20
26
void
set_label(std::string text);
27
30
private
:
31
32
bool
_pressed;
33
std::string _text;
34
std::function<void()> _callback;
35
};
36
37
38
#endif
39
button::get_size_hint
size_hint get_size_hint(int width, int height) const override
mouse_up_event
Definition:
mouse_event.hpp:19
mouse_down_event
Definition:
mouse_event.hpp:8
button::on_draw
void on_draw(draw_context &dc, selection_context const &sc) const override
selectable
Definition:
selectable.hpp:6
draw_context
Definition:
draw_context.hpp:126
button
Definition:
button.hpp:8
button::on_activate
void on_activate() override
key_event
Definition:
key_event.hpp:4
selection_context
Definition:
selection_context.hpp:18
size_hint
Definition:
widget.hpp:35
Generated by
1.8.14