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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#include "debugger.hpp"
extern "C" {
#include "plat.h"
}
struct Vram_Debugger : UI::Modal {
UI::Element* enable_btn;
Vram_Debugger(UI* ui, UI::Element* parent):
UI::Modal(ui, parent, "VRAM debugger") {
}
};
struct Device_Debugger : UI::Modal {
UI::Element* enable_btn;
Device_Debugger(UI* ui, UI::Element* parent):
UI::Modal(ui, parent, "Device debugger") {
}
};
void create_vram_debugger(
UI* ui,
UI::Element* parent,
UI::Element* button
) {
auto window = ui->create_element<Vram_Debugger>(parent);
window->enable_btn = button;
window->handler = [](UI::Element* e, const UI::Message& m) {
if (m.type == UI::Message::Type::destroy) {
auto window = (Vram_Debugger*)e;
window->enable_btn->enable();
}
return 0;
};
ui->create_element<UI::Label>(window->contents, "Hello, I'm the VRAM debugger!");
}
void create_device_debugger(
UI* ui,
UI::Element* parent,
UI::Element* button
) {
auto window = ui->create_element<Device_Debugger>(parent);
window->enable_btn = button;
window->handler = [](UI::Element* e, const UI::Message& m) {
if (m.type == UI::Message::Type::destroy) {
auto window = (Device_Debugger*)e;
window->enable_btn->enable();
}
return 0;
};
ui->create_element<UI::Label>(window->contents, "Hello, I'm the device debugger!");
}
void register_debuggers(UI* ui, UI::Toolbar* toolbar) {
auto btnvram = ui->create_element<UI::Button>(toolbar, "VRAM Debugger");
btnvram->handler = [](UI::Element* e, const UI::Message& m) {
if (m.type == UI::Message::Type::click) {
e->disable();
create_vram_debugger(e->ui, e->ui->root, e);
}
return 0;
};
auto btndevice = ui->create_element<UI::Button>(toolbar, "Device Debugger");
btndevice->handler = [](UI::Element* e, const UI::Message& m) {
if (m.type == UI::Message::Type::click) {
e->disable();
create_device_debugger(e->ui, e->ui->root, e);
}
return 0;
};
}
|