-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckbox.cpp
More file actions
43 lines (36 loc) · 991 Bytes
/
Copy pathcheckbox.cpp
File metadata and controls
43 lines (36 loc) · 991 Bytes
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 "checkbox.h"
#include "debug.h"
#include <SDL2/SDL.h>
#include "joypad.h"
CheckBox::CheckBox(int32_t x, int32_t y)
: Component(x, y)
{
this->x = x;
this->y = y;
oncheck = nullptr;
}
void CheckBox::update(Debugger* debugger)
{
int32_t mousex, mousey;
SDL_GetMouseState(&mousex, &mousey);
if ((Joypad::mousedown || Joypad::mouseup) &&
(mousex > x && mousey > y && mousex <= x + 17 && mousey <= y + 18))
{
pressed = true;
if (Joypad::mouseup) {
if (check)
*check = !(*check);
if (oncheck)
oncheck(debugger);
}
} else pressed = false;
}
void CheckBox::draw(Debugger* debugger)
{
debugger->drawRect(pressed ? 0xF0F0F0 : 0x3D5C5C, x, y, 17, 18);
debugger->fillRect(pressed ? 0x090923 : 0x0F0F3B, x + 1, y + 1, 15, 16);
if (*check)
{
debugger->drawChar((char)4, 0xE6E600, x + 4, y + 2);
}
}