openMSX
ImGuiOsdIcons.hh
Go to the documentation of this file.
1#ifndef IMGUI_OSD_ICONS_HH
2#define IMGUI_OSD_ICONS_HH
3
4#include "ImGuiAdjust.hh"
5#include "ImGuiPart.hh"
6
7#include "GLUtil.hh"
8#include "TclObject.hh"
9#include "gl_vec.hh"
10
11#include <vector>
12
13namespace openmsx {
14
15class ImGuiOsdIcons final : public ImGuiPart
16{
17public:
18 explicit ImGuiOsdIcons(ImGuiManager& manager_);
19
20 [[nodiscard]] zstring_view iniName() const override { return "OSD icons"; }
21 void save(ImGuiTextBuffer& buf) override;
22 void loadStart() override;
23 void loadLine(std::string_view name, zstring_view value) override;
24 void loadEnd() override;
25 void paint(MSXMotherBoard* motherBoard) override;
26
27private:
28 void setDefaultIcons();
29 void loadIcons();
30 void paintConfigureIcons();
31
32public:
33 bool showIcons = true;
34 bool showConfigureIcons = false;
35
36private:
37 bool hideTitle = true;
38 bool allowMove = false;
39 float fadeDuration = 5.0f;
40 float fadeDelay = 5.0f;
41
42 struct IconInfo {
43 IconInfo() = default;
44 IconInfo(TclObject expr_, std::string on_, std::string off_, bool fade_)
45 : expr(expr_), on(std::move(on_)), off(std::move(off_)), fade(fade_) {}
46 struct Icon {
47 Icon() = default;
48 explicit Icon(std::string filename_) : filename(std::move(filename_)) {}
49 std::string filename;
52 };
53 TclObject expr;
54 Icon on, off;
55 float time = 0.0f;
56 bool lastState = true;
57 bool enable = true;
58 bool fade = false;
59 };
60 std::vector<IconInfo> iconInfo;
61 gl::vec2 maxIconSize;
62 int numIcons = 0; // number of enabled icons
63 bool iconInfoDirty = true;
64
66
67 static constexpr auto persistentElements = std::tuple{
69 PersistentElement{"hideTitle", &ImGuiOsdIcons::hideTitle},
70 PersistentElement{"allowMove", &ImGuiOsdIcons::allowMove},
71 PersistentElement{"fadeDuration", &ImGuiOsdIcons::fadeDuration},
72 PersistentElement{"fadeDelay", &ImGuiOsdIcons::fadeDelay},
74 // manually handle "icon.xxx", "adjust"
75 };
76};
77
78} // namespace openmsx
79
80#endif
Most basic/generic texture: only contains a texture ID.
Definition GLUtil.hh:40
void save(ImGuiTextBuffer &buf) override
void loadEnd() override
void loadLine(std::string_view name, zstring_view value) override
void paint(MSXMotherBoard *motherBoard) override
zstring_view iniName() const override
void loadStart() override
Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.
This file implemented 3 utility functions:
Definition Autofire.cc:11
PersistentElement(zstring_view, T C::*) -> PersistentElement< C, T >
STL namespace.