OXYGENHUB
◆ main openmsx / src / console / OSDTopWidget.cc
1.7 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "OSDTopWidget.hh"
2
3
#include "CliComm.hh"
4
#include "Display.hh"
5
#include "OutputSurface.hh"
6
7
namespace openmsx {
8
9
OSDTopWidget::OSDTopWidget(Display& display_)
10
	: OSDWidget(display_, TclObject())
11
{
12
	addName(*this);
13
}
14
15
std::string_view OSDTopWidget::getType() const
16
{
17
	return "top";
18
}
19
20
gl::vec2 OSDTopWidget::getSize(const OutputSurface& output) const
21
{
22
	return gl::vec2(output.getLogicalSize()); // int -> float
23
}
24
25
bool OSDTopWidget::isVisible() const
26
{
27
	return false;
28
}
29
30
bool OSDTopWidget::isRecursiveFading() const
31
{
32
	return false; // not fading
33
}
34
35
void OSDTopWidget::invalidateLocal()
36
{
37
	// nothing
38
}
39
40
void OSDTopWidget::paint(OutputSurface& /*output*/)
41
{
42
	// nothing
43
}
44
45
void OSDTopWidget::queueError(std::string message)
46
{
47
	errors.push_back(std::move(message));
48
}
49
50
void OSDTopWidget::showAllErrors()
51
{
52
	auto& cliComm = getDisplay().getCliComm();
53
	for (auto& message : errors) {
54
		cliComm.printWarning(std::move(message));
55
	}
56
	errors.clear();
57
}
58
59
OSDWidget* OSDTopWidget::findByName(std::string_view widgetName)
60
{
61
	auto it = widgetsByName.find(widgetName);
62
	return (it != end(widgetsByName)) ? *it : nullptr;
63
}
64
65
const OSDWidget* OSDTopWidget::findByName(std::string_view widgetName) const
66
{
67
	auto it = widgetsByName.find(widgetName);
68
	return (it != end(widgetsByName)) ? *it : nullptr;
69
}
70
71
void OSDTopWidget::addName(OSDWidget& widget)
72
{
73
	assert(!widgetsByName.contains(widget.getName()));
74
	widgetsByName.emplace_noDuplicateCheck(&widget);
75
}
76
77
void OSDTopWidget::removeName(OSDWidget& widget)
78
{
79
	auto it = widgetsByName.find(widget.getName());
80
	assert(it != end(widgetsByName));
81
	for (auto& child : (*it)->getChildren()) {
82
		removeName(*child);
83
	}
84
	widgetsByName.erase(it);
85
}
86
87
} // namespace openmsx