Added changeable icons

This commit is contained in:
CommanderRedYT
2023-02-15 17:19:33 +01:00
parent 6d3002c87b
commit 7a6dd2afac

View File

@ -41,6 +41,38 @@ public:
virtual const Icon<width, height> *selectedIcon() const override { return T; }
};
template<uint16_t width, uint16_t height>
class ChangeableSelectableIcon : public virtual SelectableIconInterface<width, height>
{
public:
virtual const Icon<width, height> *icon(bool selected) const override { return selected ? m_selectedIcon : m_icon; }
void setIcon(const Icon<width, height> *icon, const Icon<width, height> *selectedIcon)
{
m_icon = icon;
m_selectedIcon = selectedIcon;
}
void setIcon(const Icon<width, height> *icon) { m_icon = icon; }
void setSelectedIcon(const Icon<width, height> *selectedIcon) { m_selectedIcon = selectedIcon; }
private:
const Icon<width, height> *m_icon = nullptr;
const Icon<width, height> *m_selectedIcon = nullptr;
};
template<uint16_t width, uint16_t height>
class ChangeableSelectedIcon : public virtual SelectedIconInterface<width, height>
{
public:
virtual const Icon<width, height> *selectedIcon() const override { return m_selectedIcon; }
void setSelectedIcon(const Icon<width, height> *selectedIcon) { m_selectedIcon = selectedIcon; }
private:
const Icon<width, height> *m_selectedIcon = nullptr;
};
using MenuItemIconInterface = SelectableIconInterface<24, 24>;
using MenuItemSelectedIconInterface = SelectedIconInterface<24, 24>;
@ -51,6 +83,10 @@ using StaticMenuItemIcon = StaticSelectableIcon<24, 24, T, Tselected>;
template<const MenuItemIcon *T>
using StaticMenuItemSelectedIcon = StaticSelectedIcon<24, 24, T>;
using ChangeableMenuItemIcon = ChangeableSelectableIcon<24, 24>;
using ChangeableMenuItemSelectedIcon = ChangeableSelectedIcon<24, 24>;
class MenuItem :
public virtual ActionInterface,
public virtual TextInterface,