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
45{
46 // nothing
47}
48
49void OSDTopWidget::queueError(std::string message)
50{
51 errors.push_back(std::move(message));
52}
53
55{
56 auto& cliComm = getDisplay().getCliComm();
57 for (auto& message : errors) {
58 cliComm.printWarning(std::move(message));
59 }
60 errors.clear();
61}
62
63OSDWidget* OSDTopWidget::findByName(std::string_view widgetName)
64{
65 auto it = widgetsByName.find(widgetName);
66 return (it != end(widgetsByName)) ? *it : nullptr;
67}
68
69const OSDWidget* OSDTopWidget::findByName(std::string_view widgetName) const
70{
71 return const_cast<OSDTopWidget*>(this)->findByName(widgetName);
72}
73
75{
76 assert(!widgetsByName.contains(widget.getName()));
77 widgetsByName.emplace_noDuplicateCheck(&widget);
78}
79
81{
82 auto it = widgetsByName.find(widget.getName());
83 assert(it != end(widgetsByName));
84 for (auto& child : (*it)->getChildren()) {
85 removeName(*child);
86 }
87 widgetsByName.erase(it);
88}
89
90} // namespace openmsx
void printWarning(std::string_view message)
Definition: CliComm.cc:10
Represents the output window/screen of openMSX.
Definition: Display.hh:33
CliComm & getCliComm() const
Definition: Display.cc:126
std::string_view getType() const override
Definition: OSDTopWidget.cc:14
OSDWidget * findByName(std::string_view name)
Definition: OSDTopWidget.cc:63
bool isRecursiveFading() const override
Definition: OSDTopWidget.cc:29
void addName(OSDWidget &widget)
Definition: OSDTopWidget.cc:74
void queueError(std::string message)
Definition: OSDTopWidget.cc:49
gl::vec2 getSize(const OutputSurface &output) const override
Definition: OSDTopWidget.cc:19
void removeName(OSDWidget &widget)
Definition: OSDTopWidget.cc:80
void paintGL(OutputSurface &output) override
Definition: OSDTopWidget.cc:44
bool isVisible() const override
Definition: OSDTopWidget.cc:24
void invalidateLocal() override
Definition: OSDTopWidget.cc:34
OSDTopWidget(Display &display)
Definition: OSDTopWidget.cc:8
void paintSDL(OutputSurface &output) override
Definition: OSDTopWidget.cc:39
Display & getDisplay() const
Definition: OSDWidget.hh:69
std::string_view getName() const
Definition: OSDWidget.hh:34
A frame buffer where pixels can be written to.
gl::ivec2 getLogicalSize() const
vecN< 2, float > vec2
Definition: gl_vec.hh:150
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr auto end(const zstring_view &x)