| 1 |
#ifndef OSDTOPWIDGET_HH |
| 2 |
#define OSDTOPWIDGET_HH |
| 3 |
|
| 4 |
#include "OSDWidget.hh" |
| 5 |
|
| 6 |
#include "TclObject.hh" |
| 7 |
#include "hash_set.hh" |
| 8 |
|
| 9 |
#include <ranges> |
| 10 |
#include <string> |
| 11 |
#include <vector> |
| 12 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class OSDTopWidget final : public OSDWidget |
| 16 |
{ |
| 17 |
public: |
| 18 |
explicit OSDTopWidget(Display& display); |
| 19 |
[[nodiscard]] std::string_view getType() const override; |
| 20 |
[[nodiscard]] gl::vec2 getSize(const OutputSurface& output) const override; |
| 21 |
[[nodiscard]] bool isVisible() const override; |
| 22 |
[[nodiscard]] bool isRecursiveFading() const override; |
| 23 |
|
| 24 |
void queueError(std::string message); |
| 25 |
void showAllErrors(); |
| 26 |
|
| 27 |
[[nodiscard]] OSDWidget* findByName(std::string_view name); |
| 28 |
[[nodiscard]] const OSDWidget* findByName(std::string_view name) const; |
| 29 |
void addName(OSDWidget& widget); |
| 30 |
void removeName(OSDWidget& widget); |
| 31 |
[[nodiscard]] auto getAllWidgetNames() const { |
| 32 |
return std::views::transform(widgetsByName, |
| 33 |
[](auto* p) -> std::string_view { return p->getName(); }); |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
protected: |
| 38 |
void invalidateLocal() override; |
| 39 |
void paint(OutputSurface& output) override; |
| 40 |
|
| 41 |
private: |
| 42 |
std::vector<std::string> errors; |
| 43 |
|
| 44 |
struct NameFromWidget { |
| 45 |
[[nodiscard]] std::string_view operator()(const OSDWidget* w) const { |
| 46 |
return w->getName(); |
| 47 |
} |
| 48 |
}; |
| 49 |
hash_set<OSDWidget*, NameFromWidget, XXTclHasher> widgetsByName; |
| 50 |
}; |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
#endif |