1.10
sideboard.h
1/*
2 * Copyright (C) 2018 Microchip Technology Inc. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#ifndef EGT_SIDEBOARD_H
7#define EGT_SIDEBOARD_H
8
14#include <chrono>
15#include <egt/animation.h>
16#include <egt/detail/meta.h>
17#include <egt/easing.h>
18#include <egt/window.h>
19#include <iosfwd>
20
21namespace egt
22{
23inline namespace v1
24{
25
33class EGT_API SideBoard : public Window
34{
35public:
36
38 constexpr static const int HANDLE_WIDTH = 50;
39
41 enum class PositionFlag : uint32_t
42 {
44 left,
46 right,
48 top,
50 bottom,
51 };
52
63 explicit SideBoard(PositionFlag position = PositionFlag::left,
64 std::chrono::milliseconds open_duration = std::chrono::milliseconds(1000),
65 EasingFunc open_func = easing_cubic_easeinout,
66 std::chrono::milliseconds close_duration = std::chrono::milliseconds(1000),
67 EasingFunc close_func = easing_circular_easeinout,
68 WindowHint hint = WindowHint::automatic);
69
77
81 explicit SideBoard(Serializer::Properties& props) noexcept
82 : SideBoard(props, false)
83 {
84 }
85
86protected:
87
88 explicit SideBoard(Serializer::Properties& props, bool is_derived) noexcept;
89
90public:
91
92 void handle(Event& event) override;
93
99 void position(PositionFlag position);
100
102 EGT_NODISCARD PositionFlag position() const { return m_position; }
103
105 void close();
106
108 void open();
109
110 void serialize(Serializer& serializer) const override;
111
112protected:
113
116
118 PositionFlag m_position{PositionFlag::left};
119
122
125
127 bool m_dir{false};
128
129private:
130 void initialize();
131
132 void deserialize(Serializer::Properties& props);
133};
134
136EGT_API std::ostream& operator<<(std::ostream& os, const SideBoard::PositionFlag& flag);
137
138}
139}
140
141#endif
Abstract base serializer class.
Definition serialize.h:34
std::list< std::tuple< std::string, std::string, Serializer::Attributes > > Properties
Definition serialize.h:47
SideBoard Window for a sliding board that slides on and off the screen.
Definition sideboard.h:34
void reset_animations()
Reset animation start/end values.
PropertyAnimator m_oanim
Open animation.
Definition sideboard.h:121
void position(PositionFlag position)
Set the position of the SideBoard.
void close()
Move to a closed state.
SideBoard(PositionFlag position, WindowHint hint)
void serialize(Serializer &serializer) const override
Serialize the widget to the specified serializer.
SideBoard(Serializer::Properties &props) noexcept
Definition sideboard.h:81
void open()
Move to an open state.
PositionFlag
Position flag of the SideBoard.
Definition sideboard.h:42
SideBoard(PositionFlag position=PositionFlag::left, std::chrono::milliseconds open_duration=std::chrono::milliseconds(1000), EasingFunc open_func=easing_cubic_easeinout, std::chrono::milliseconds close_duration=std::chrono::milliseconds(1000), EasingFunc close_func=easing_circular_easeinout, WindowHint hint=WindowHint::automatic)
void handle(Event &event) override
Handle an event.
EGT_NODISCARD PositionFlag position() const
Get the position of the SideBoard.
Definition sideboard.h:102
SideBoard(Serializer::Properties &props, bool is_derived) noexcept
PropertyAnimator m_canim
Close animation.
Definition sideboard.h:124
A Window is a Widget that handles drawing to a Screen.
Definition window.h:47
std::function< EasingScalar(EasingScalar percent)> EasingFunc
Easing function type.
Definition animation.h:41
WindowHint
Hint used for configuring Window backends.
Definition widgetflags.h:683
T & top(T &widget)
Helper to set alignment of a widget.
Definition widgetflags.h:494
T & right(T &widget)
Helper to set alignment of a widget.
Definition widgetflags.h:468
T & left(T &widget)
Helper to set alignment of a widget.
Definition widgetflags.h:442
EGT_API std::ostream & operator<<(std::ostream &os, const Color &color)
Overloaded std::ostream insertion operator.
T & bottom(T &widget)
Helper to set alignment of a widget.
Definition widgetflags.h:520
EGT framework namespace.
Definition animation.h:24
A single event that has information about the event and state for the event.
Definition event.h:255