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 iconsHideTitle = true;
38 bool iconsAllowMove = false;
39 int iconsHorizontal = 1; // 0=vertical, 1=horizontal
40 float iconsFadeDuration = 5.0f;
41 float iconsFadeDelay = 5.0f;
42
43 struct IconInfo {
44 IconInfo() = default;
45 IconInfo(TclObject expr_, std::string on_, std::string off_, bool fade_)
46 : expr(expr_), on(std::move(on_)), off(std::move(off_)), fade(fade_) {}
47 struct Icon {
48 Icon() = default;
49 explicit Icon(std::string filename_) : filename(std::move(filename_)) {}
50 std::string filename;
53 };
54 TclObject expr;
55 Icon on, off;
56 float time = 0.0f;
57 bool lastState = true;
58 bool enable = true;
59 bool fade = false;
60 };
61 std::vector<IconInfo> iconInfo;
62 gl::ivec2 iconsTotalSize;
63 gl::ivec2 iconsMaxSize;
64 int iconsNumEnabled = 0;
65 bool iconInfoDirty = true;
66
68
69 static constexpr auto persistentElements = std::tuple{
71 PersistentElement{"hideTitle", &ImGuiOsdIcons::iconsHideTitle},
72 PersistentElement{"allowMove", &ImGuiOsdIcons::iconsAllowMove},
73 PersistentElementMax{"layout", &ImGuiOsdIcons::iconsHorizontal, 2},
74 PersistentElement{"fadeDuration", &ImGuiOsdIcons::iconsFadeDuration},
75 PersistentElement{"fadeDelay", &ImGuiOsdIcons::iconsFadeDelay},
77 // manually handle "icon.xxx"
78 };
79};
80
81} // namespace openmsx
82
83#endif
Most basic/generic texture: only contains a texture ID.
Definition GLUtil.hh:39
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.