More button improvements
This commit is contained in:
@ -2,6 +2,7 @@ set(headers
|
||||
src/accessorinterface.h
|
||||
src/actioninterface.h
|
||||
src/backinterface.h
|
||||
src/buttonsinterface.h
|
||||
src/changevaluedisplay.h
|
||||
src/changevaluedisplay_bool.h
|
||||
src/changevaluedisplay_daylightsavingmode.h
|
||||
|
27
src/buttonsinterface.h
Normal file
27
src/buttonsinterface.h
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
//system includes
|
||||
#include <cstdint>
|
||||
|
||||
namespace espgui {
|
||||
|
||||
enum Button
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
ButtonMax = Down
|
||||
};
|
||||
|
||||
class ButtonsInterface
|
||||
{
|
||||
public:
|
||||
virtual void rawButtonPressed(uint8_t button) = 0;
|
||||
virtual void rawButtonReleased(uint8_t button) = 0;
|
||||
|
||||
virtual void buttonPressed(Button button) = 0;
|
||||
virtual void buttonReleased(Button button) = 0;
|
||||
};
|
||||
|
||||
} // namespace espgui
|
@ -10,6 +10,7 @@
|
||||
#include "backinterface.h"
|
||||
|
||||
namespace espgui {
|
||||
|
||||
class ChangeValueDisplayInterface :
|
||||
public DisplayWithTitle,
|
||||
public virtual ActionInterface
|
||||
@ -115,7 +116,7 @@ void ChangeValueDisplay<float>::redraw();
|
||||
template<typename Tvalue>
|
||||
void ChangeValueDisplay<Tvalue>::buttonPressed(Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
//Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
@ -125,4 +126,5 @@ void ChangeValueDisplay<Tvalue>::buttonPressed(Button button)
|
||||
case Button::Down: m_rotateOffset++; break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace espgui
|
||||
|
@ -4,6 +4,9 @@
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
// local includes
|
||||
#include "buttonsinterface.h"
|
||||
|
||||
// forward declares
|
||||
namespace espgui {
|
||||
class TextInterface;
|
||||
@ -27,16 +30,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
enum Button
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
ButtonMax = Down
|
||||
};
|
||||
|
||||
class Display
|
||||
class Display : public virtual ButtonsInterface
|
||||
{
|
||||
public:
|
||||
virtual ~Display() = default;
|
||||
@ -56,12 +50,6 @@ public:
|
||||
//! Display goes out of existance, is not shown anymore
|
||||
virtual void stop() {}
|
||||
|
||||
virtual void rawButtonPressed(uint8_t button) = 0;
|
||||
virtual void rawButtonReleased(uint8_t button) = 0;
|
||||
|
||||
virtual void buttonPressed(Button button) = 0;
|
||||
virtual void buttonReleased(Button button) = 0;
|
||||
|
||||
virtual TextInterface *asTextInterface() { return nullptr; }
|
||||
virtual const TextInterface *asTextInterface() const { return nullptr; }
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "backinterface.h"
|
||||
|
||||
namespace espgui {
|
||||
|
||||
template<size_t COUNT>
|
||||
class GraphAccessorInterface
|
||||
{
|
||||
@ -81,7 +82,7 @@ void GraphDisplay<COUNT>::redraw()
|
||||
template<size_t COUNT>
|
||||
void GraphDisplay<COUNT>::buttonPressed(Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
//Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
@ -90,4 +91,5 @@ void GraphDisplay<COUNT>::buttonPressed(Button button)
|
||||
default:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace espgui
|
||||
|
@ -174,7 +174,7 @@ void MenuDisplay::stop()
|
||||
|
||||
void MenuDisplay::buttonPressed(Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
//Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
|
@ -17,7 +17,9 @@
|
||||
#include "backinterface.h"
|
||||
|
||||
namespace espgui {
|
||||
class MenuDisplay : public DisplayWithTitle, public virtual BackInterface
|
||||
class MenuDisplay :
|
||||
public DisplayWithTitle,
|
||||
public virtual BackInterface
|
||||
{
|
||||
using Base = DisplayWithTitle;
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
// local includes
|
||||
#include "display.h"
|
||||
#include "textinterface.h"
|
||||
#include "widgets/label.h"
|
||||
#include "widgets/graph.h"
|
||||
#include "confirminterface.h"
|
||||
#include "backinterface.h"
|
||||
|
||||
namespace espgui {
|
||||
|
||||
template<std::size_t COUNT>
|
||||
class TopGraphAccessorInterface
|
||||
{
|
||||
@ -42,15 +46,19 @@ public:
|
||||
|
||||
template<std::size_t COUNT0, std::size_t COUNT1>
|
||||
class SplitGraphDisplay :
|
||||
public Display,
|
||||
public virtual TextInterface,
|
||||
public virtual TopGraphAccessorInterface<COUNT0>,
|
||||
public virtual BottomGraphAccessorInterface<COUNT1>
|
||||
public Display,
|
||||
public virtual TextInterface,
|
||||
public virtual TopGraphAccessorInterface<COUNT0>,
|
||||
public virtual BottomGraphAccessorInterface<COUNT1>,
|
||||
public virtual ConfirmInterface,
|
||||
public virtual BackInterface
|
||||
{
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
||||
void buttonPressed(Button button) override;
|
||||
|
||||
private:
|
||||
Label m_titleLabel{5, 5}; // 230, 25
|
||||
|
||||
@ -80,4 +88,18 @@ void SplitGraphDisplay<COUNT0, COUNT1>::redraw()
|
||||
m_graph0.redraw(static_cast<const TopGraphAccessorInterface<COUNT0>&>(*this).getTopBuffers());
|
||||
m_graph1.redraw(static_cast<const BottomGraphAccessorInterface<COUNT1>&>(*this).getBottomBuffers());
|
||||
}
|
||||
|
||||
template<std::size_t COUNT0, std::size_t COUNT1>
|
||||
void SplitGraphDisplay<COUNT0, COUNT1>::buttonPressed(Button button)
|
||||
{
|
||||
//Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
case Button::Left: back(); break;
|
||||
case Button::Right: confirm(); break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace espgui
|
||||
|
Reference in New Issue
Block a user