| 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 |
|
| 13 |
namespace openmsx { |
| 14 |
|
| 15 |
class ImGuiOsdIcons final : public ImGuiPart |
| 16 |
{ |
| 17 |
public: |
| 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 |
|
| 27 |
private: |
| 28 |
void setDefaultIcons(); |
| 29 |
void loadIcons(); |
| 30 |
void paintConfigureIcons(); |
| 31 |
|
| 32 |
public: |
| 33 |
bool showIcons = true; |
| 34 |
bool showConfigureIcons = false; |
| 35 |
|
| 36 |
private: |
| 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(std::move(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; |
| 50 |
gl::Texture tex{gl::Null{}}; |
| 51 |
gl::ivec2 size; |
| 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; |
| 63 |
bool iconInfoDirty = true; |
| 64 |
|
| 65 |
AdjustWindowInMainViewPort adjust; |
| 66 |
|
| 67 |
static constexpr auto persistentElements = std::tuple{ |
| 68 |
PersistentElement{"show", &ImGuiOsdIcons::showIcons}, |
| 69 |
PersistentElement{"hideTitle", &ImGuiOsdIcons::hideTitle}, |
| 70 |
PersistentElement{"allowMove", &ImGuiOsdIcons::allowMove}, |
| 71 |
PersistentElement{"fadeDuration", &ImGuiOsdIcons::fadeDuration}, |
| 72 |
PersistentElement{"fadeDelay", &ImGuiOsdIcons::fadeDelay}, |
| 73 |
PersistentElement{"showConfig", &ImGuiOsdIcons::showConfigureIcons} |
| 74 |
|
| 75 |
}; |
| 76 |
}; |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
#endif |