openMSX
OSDTopWidget.cc
Go to the documentation of this file.
1#include "OSDTopWidget.hh"
2#include "OutputSurface.hh"
3#include "Display.hh"
4#include "CliComm.hh"
5
6namespace openmsx {
7
9 : OSDWidget(display_, TclObject())
10{
11 addName(*this);
12}
13
14std::string_view OSDTopWidget::getType() const
15{
16 return "top";
17}
18
20{
21 return gl::vec2(output.getLogicalSize()); // int -> float
22}
23
25{
26 return false;
27}
28
30{
31 return false; // not fading
32}
33
35{
36 // nothing
37}
38
40{
41 // nothing
42}
43
44void OSDTopWidget::queueError(std::string message)
45{
46 errors.push_back(std::move(message));
47}
48
50{
51 auto& cliComm = getDisplay().getCliComm();
52 for (auto& message : errors) {
53 cliComm.printWarning(std::move(message));
54 }
55 errors.clear();
56}
57
58OSDWidget* OSDTopWidget::findByName(std::string_view widgetName)
59{
60 auto it = widgetsByName.find(widgetName);
61 return (it != end(widgetsByName)) ? *it : nullptr;
62}
63
64const OSDWidget* OSDTopWidget::findByName(std::string_view widgetName) const
65{
66 return const_cast<OSDTopWidget*>(this)->findByName(widgetName);
67}
68
70{
71 assert(!widgetsByName.contains(widget.getName()));
72 widgetsByName.emplace_noDuplicateCheck(&widget);
73}
74
76{
77 auto it = widgetsByName.find(widget.getName());
78 assert(it != end(widgetsByName));
79 for (auto& child : (*it)->getChildren()) {
80 removeName(*child);
81 }
82 widgetsByName.erase(it);
83}
84
85} // namespace openmsx
void printWarning(std::string_view message)
Definition CliComm.cc:12
Represents the output window/screen of openMSX.
Definition Display.hh:31
CliComm & getCliComm() const
Definition Display.cc:110
std::string_view getType() const override
OSDWidget * findByName(std::string_view name)
bool isRecursiveFading() const override
void addName(OSDWidget &widget)
void queueError(std::string message)
gl::vec2 getSize(const OutputSurface &output) const override
void paint(OutputSurface &output) override
void removeName(OSDWidget &widget)
bool isVisible() const override
void invalidateLocal() override
OSDTopWidget(Display &display)
Display & getDisplay() const
Definition OSDWidget.hh:70
std::string_view getName() const
Definition OSDWidget.hh:36
A frame buffer where pixels can be written to.
gl::ivec2 getLogicalSize() const
vecN< 2, float > vec2
Definition gl_vec.hh:382
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr auto end(const zstring_view &x)