Refactored blesettingsmenu, ledstripselectanimationmenu, profilesmenu

This commit is contained in:
CommanderRedYT
2021-12-07 02:54:14 +01:00
parent ddf0d27137
commit 5dff47f437
7 changed files with 122 additions and 88 deletions

View File

@ -4,9 +4,8 @@
#include "textinterface.h"
#include "ble_bobby.h"
namespace {
#ifdef FEATURE_BLE
struct BleServerPeerDevicesText : public virtual TextInterface {
struct BleServerPeerDevicesText : public virtual espgui::TextInterface {
public:
std::string text() const override
{
@ -17,7 +16,7 @@ public:
}
};
struct BleCharacSubscribedText : public virtual TextInterface {
struct BleCharacSubscribedText : public virtual espgui::TextInterface {
public:
std::string text() const override
{
@ -28,4 +27,3 @@ public:
}
};
#endif
}

View File

@ -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

View File

@ -2,32 +2,16 @@
// local includes
#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"
using namespace espgui;
namespace {
#ifdef FEATURE_BLE
class BleSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_BLESETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_BLESETTINGS>
{
public:
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>>>();
}
BleSettingsMenu();
void back() override;
};
#endif
} // namespace

View File

@ -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

View File

@ -2,54 +2,21 @@
// Local includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "ledstrip.h"
#include "ledstripselectanimationmenu.h"
#include "icons/back.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
class currentSelectedAnimationText : public virtual TextInterface { public: std::string text() const override {
switch (animation_type) {
case LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW:
return TEXT_ANIMATION_DEFAULTRAINBOW;
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";
}
};
class currentSelectedAnimationText : public virtual espgui::TextInterface {
public:
std::string text() const override;
};
using namespace espgui;
namespace {
class LedstripSelectAnimationMenu :
public MenuDisplay,
public StaticText<TEXT_SELECTANIMATION>,
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
{
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
class LedstripSelectAnimationMenu :
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_SELECTANIMATION>
{
public:
LedstripSelectAnimationMenu();
void back() override;
};
#endif

View File

@ -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>();
}

View File

@ -2,27 +2,13 @@
// local includes
#include "menudisplay.h"
#include "actions/switchprofileaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "texts.h"
using namespace espgui;
namespace {
class ProfilesMenu :
public MenuDisplay,
public StaticText<TEXT_PROFILES>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_PROFILES>
{
public:
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>>>();
}
ProfilesMenu();
void back() override;
};
} // namespace