Refactored blesettingsmenu, ledstripselectanimationmenu, profilesmenu
This commit is contained in:
@ -4,9 +4,8 @@
|
|||||||
#include "textinterface.h"
|
#include "textinterface.h"
|
||||||
#include "ble_bobby.h"
|
#include "ble_bobby.h"
|
||||||
|
|
||||||
namespace {
|
|
||||||
#ifdef FEATURE_BLE
|
#ifdef FEATURE_BLE
|
||||||
struct BleServerPeerDevicesText : public virtual TextInterface {
|
struct BleServerPeerDevicesText : public virtual espgui::TextInterface {
|
||||||
public:
|
public:
|
||||||
std::string text() const override
|
std::string text() const override
|
||||||
{
|
{
|
||||||
@ -17,7 +16,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BleCharacSubscribedText : public virtual TextInterface {
|
struct BleCharacSubscribedText : public virtual espgui::TextInterface {
|
||||||
public:
|
public:
|
||||||
std::string text() const override
|
std::string text() const override
|
||||||
{
|
{
|
||||||
@ -28,4 +27,3 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
#include "blesettingsmenu.h"
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "accessors/settingsaccessors.h"
|
||||||
|
#include "actions/dummyaction.h"
|
||||||
|
#include "actions/switchscreenaction.h"
|
||||||
|
#include "actions/toggleboolaction.h"
|
||||||
|
#include "bletexthelpers.h"
|
||||||
|
#include "checkboxicon.h"
|
||||||
|
#include "displays/menus/settingsmenu.h"
|
||||||
|
#include "icons/back.h"
|
||||||
|
#include "texts.h"
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLE
|
||||||
|
|
||||||
|
using namespace espgui;
|
||||||
|
|
||||||
|
BleSettingsMenu::BleSettingsMenu()
|
||||||
|
{
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLEENABLED>, ToggleBoolAction, CheckboxIcon, BleEnabledAccessor>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, BleServerPeerDevicesText, DisabledColor, DummyAction>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, BleCharacSubscribedText, DisabledColor, DummyAction>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BleSettingsMenu::back()
|
||||||
|
{
|
||||||
|
switchScreen<SettingsMenu>();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -2,32 +2,16 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "menudisplay.h"
|
#include "menudisplay.h"
|
||||||
#include "menuitem.h"
|
|
||||||
#include "actions/switchscreenaction.h"
|
|
||||||
#include "actions/toggleboolaction.h"
|
|
||||||
#include "checkboxicon.h"
|
|
||||||
#include "bletexthelpers.h"
|
|
||||||
#include "accessors/settingsaccessors.h"
|
|
||||||
#include "icons/back.h"
|
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
|
|
||||||
using namespace espgui;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
#ifdef FEATURE_BLE
|
#ifdef FEATURE_BLE
|
||||||
|
|
||||||
class BleSettingsMenu :
|
class BleSettingsMenu :
|
||||||
public MenuDisplay,
|
public espgui::MenuDisplay,
|
||||||
public StaticText<TEXT_BLESETTINGS>,
|
public espgui::StaticText<TEXT_BLESETTINGS>
|
||||||
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BleSettingsMenu()
|
BleSettingsMenu();
|
||||||
{
|
void back() override;
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLEENABLED>, ToggleBoolAction, CheckboxIcon, BleEnabledAccessor>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, BleServerPeerDevicesText, DisabledColor, DummyAction>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, BleCharacSubscribedText, DisabledColor, DummyAction>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
} // namespace
|
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
#include "ledstripselectanimationmenu.h"
|
||||||
|
|
||||||
|
// Local includes
|
||||||
|
#include "actions/dummyaction.h"
|
||||||
|
#include "actions/ledstripanimationactions.h"
|
||||||
|
#include "actions/switchscreenaction.h"
|
||||||
|
#include "icons/back.h"
|
||||||
|
#include "ledstripdefines.h"
|
||||||
|
#include "ledstripmenu.h"
|
||||||
|
|
||||||
|
using namespace espgui;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef FEATURE_LEDSTRIP
|
||||||
|
std::string currentSelectedAnimationText::text() const
|
||||||
|
{
|
||||||
|
switch (animation_type) {
|
||||||
|
case LedstripAnimation::DefaultRainbow:
|
||||||
|
return TEXT_ANIMATION_DEFAULTRAINBOW;
|
||||||
|
case LedstripAnimation::BetterRainbow:
|
||||||
|
return TEXT_ANIMATION_BETTERRAINBOW;
|
||||||
|
case LedstripAnimation::SpeedSync:
|
||||||
|
return TEXT_ANIMATION_SPEEDSYNCANIMATION;
|
||||||
|
case LedstripAnimation::CustomColor:
|
||||||
|
return TEXT_ANIMATION_CUSTOMCOLOR;
|
||||||
|
default:
|
||||||
|
return "Animation Unkown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LedstripSelectAnimationMenu::LedstripSelectAnimationMenu()
|
||||||
|
{
|
||||||
|
constructMenuItem<makeComponent<MenuItem, currentSelectedAnimationText, DisabledColor, DummyAction>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedStripSetAnimationAction<LedstripAnimation::DefaultRainbow>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BETTERRAINBOW>, LedStripSetAnimationAction<LedstripAnimation::BetterRainbow>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_SPEEDSYNCANIMATION>, LedStripSetAnimationAction<LedstripAnimation::SpeedSync>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_CUSTOMCOLOR>, LedStripSetAnimationAction<LedstripAnimation::CustomColor>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LedstripSelectAnimationMenu::back()
|
||||||
|
{
|
||||||
|
switchScreen<LedstripMenu>();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -2,54 +2,21 @@
|
|||||||
|
|
||||||
// Local includes
|
// Local includes
|
||||||
#include "menudisplay.h"
|
#include "menudisplay.h"
|
||||||
#include "utils.h"
|
|
||||||
#include "menuitem.h"
|
|
||||||
#include "ledstrip.h"
|
|
||||||
#include "ledstripselectanimationmenu.h"
|
|
||||||
#include "icons/back.h"
|
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
#include "actions/dummyaction.h"
|
|
||||||
#include "actions/ledstripanimationactions.h"
|
|
||||||
#include "actions/switchscreenaction.h"
|
|
||||||
#include "ledstrip.h"
|
|
||||||
#include "ledstripdefines.h"
|
|
||||||
|
|
||||||
#ifdef FEATURE_LEDSTRIP
|
#ifdef FEATURE_LEDSTRIP
|
||||||
class currentSelectedAnimationText : public virtual TextInterface { public: std::string text() const override {
|
|
||||||
switch (animation_type) {
|
class currentSelectedAnimationText : public virtual espgui::TextInterface {
|
||||||
case LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW:
|
public:
|
||||||
return TEXT_ANIMATION_DEFAULTRAINBOW;
|
std::string text() const override;
|
||||||
case LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW:
|
|
||||||
return TEXT_ANIMATION_BETTERRAINBOW;
|
|
||||||
case LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION:
|
|
||||||
return TEXT_ANIMATION_SPEEDSYNCANIMATION;
|
|
||||||
case LEDSTRIP_ANIMATION_TYPE_CUSTOMCOLOR:
|
|
||||||
return TEXT_ANIMATION_CUSTOMCOLOR;
|
|
||||||
default:
|
|
||||||
return "Animation Unkown";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
using namespace espgui;
|
class LedstripSelectAnimationMenu :
|
||||||
|
public espgui::MenuDisplay,
|
||||||
namespace {
|
public espgui::StaticText<TEXT_SELECTANIMATION>
|
||||||
class LedstripSelectAnimationMenu :
|
{
|
||||||
public MenuDisplay,
|
public:
|
||||||
public StaticText<TEXT_SELECTANIMATION>,
|
LedstripSelectAnimationMenu();
|
||||||
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
|
void back() override;
|
||||||
{
|
};
|
||||||
public:
|
|
||||||
LedstripSelectAnimationMenu()
|
|
||||||
{
|
|
||||||
constructMenuItem<makeComponent<MenuItem, currentSelectedAnimationText, DisabledColor, DummyAction>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedStripSetAnimationAction<LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BETTERRAINBOW>, LedStripSetAnimationAction<LEDSTRIP_ANIMATION_TYPE_BETTERRAINBOW>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_SPEEDSYNCANIMATION>, LedStripSetAnimationAction<LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_CUSTOMCOLOR>, LedStripSetAnimationAction<LEDSTRIP_ANIMATION_TYPE_CUSTOMCOLOR>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // Namespace
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
#include "profilesmenu.h"
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "actions/switchprofileaction.h"
|
||||||
|
#include "actions/switchscreenaction.h"
|
||||||
|
#include "displays/menus/mainmenu.h"
|
||||||
|
#include "icons/back.h"
|
||||||
|
#include "menudisplay.h"
|
||||||
|
#include "texts.h"
|
||||||
|
|
||||||
|
ProfilesMenu::ProfilesMenu()
|
||||||
|
{
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE0>, SwitchProfileAction<0>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE1>, SwitchProfileAction<1>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE2>, SwitchProfileAction<2>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE3>, SwitchProfileAction<3>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProfilesMenu::back()
|
||||||
|
{
|
||||||
|
switchScreen<MainMenu>();
|
||||||
|
}
|
||||||
|
@ -2,27 +2,13 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "menudisplay.h"
|
#include "menudisplay.h"
|
||||||
#include "actions/switchprofileaction.h"
|
|
||||||
#include "actions/switchscreenaction.h"
|
|
||||||
#include "icons/back.h"
|
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
|
|
||||||
using namespace espgui;
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
class ProfilesMenu :
|
class ProfilesMenu :
|
||||||
public MenuDisplay,
|
public espgui::MenuDisplay,
|
||||||
public StaticText<TEXT_PROFILES>,
|
public espgui::StaticText<TEXT_PROFILES>
|
||||||
public BackActionInterface<SwitchScreenAction<MainMenu>>
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProfilesMenu()
|
ProfilesMenu();
|
||||||
{
|
void back() override;
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE0>, SwitchProfileAction<0>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE1>, SwitchProfileAction<1>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE2>, SwitchProfileAction<2>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILE3>, SwitchProfileAction<3>>>();
|
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
} // namespace
|
|
||||||
|
Reference in New Issue
Block a user