-
Notifications
You must be signed in to change notification settings - Fork 57
/
cppwindows.cpp
43 lines (36 loc) · 1.27 KB
/
cppwindows.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "cppwindows.h"
namespace eternal_lands
{
namespace window_static_handlers
{
int button_click(widget_list *widget, int mx, int my, std::uint32_t flags, void* cb_ptr)
{
auto callback = reinterpret_cast<const std::function<bool()>*>(cb_ptr);
return (*callback)();
}
int delete_button_callback(widget_list *widget, void* cb_ptr)
{
auto callback = reinterpret_cast<const std::function<bool()>*>(cb_ptr);
delete callback;
return 1;
}
int scrollbar_click(widget_list *widget, int mx, int my, std::uint32_t flags, void* cb_ptr)
{
const vscrollbar *scrollbar = reinterpret_cast<const vscrollbar*>(widget->widget_info);
auto callback = reinterpret_cast<const std::function<bool(int)>*>(cb_ptr);
return (*callback)(scrollbar->pos);
}
int scrollbar_drag(widget_list *widget, int mx, int my, std::uint32_t flags, int dx, int dy, void* cb_ptr)
{
const vscrollbar *scrollbar = reinterpret_cast<const vscrollbar*>(widget->widget_info);
auto callback = reinterpret_cast<const std::function<bool(int)>*>(cb_ptr);
return (*callback)(scrollbar->pos);
}
int delete_scrollbar_callback(widget_list *widget, void* cb_ptr)
{
auto callback = reinterpret_cast<const std::function<bool(int)>*>(cb_ptr);
delete callback;
return 1;
}
} // namespace window_static_handlers
} // namespace eternal_lands