Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
sidebar.hpp
Go to the documentation of this file.
1
/*
2
Copyright 2019-2021 natinusala
3
Copyright 2019 p-sam
4
5
Licensed under the Apache License, Version 2.0 (the "License");
6
you may not use this file except in compliance with the License.
7
You may obtain a copy of the License at
8
9
http://www.apache.org/licenses/LICENSE-2.0
10
11
Unless required by applicable law or agreed to in writing, software
12
distributed under the License is distributed on an "AS IS" BASIS,
13
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
See the License for the specific language governing permissions and
15
limitations under the License.
16
*/
17
18
#pragma once
19
20
#include <
aurore/core/bind.hpp
>
21
#include <
aurore/core/box.hpp
>
22
#include <
aurore/views/label.hpp
>
23
#include <
aurore/views/rectangle.hpp
>
24
#include <
aurore/views/scrolling_frame.hpp
>
25
26
namespace
aurore
27
{
28
29
class
SidebarItem;
30
31
class
SidebarSeparator
:
public
View
32
{
33
public
:
34
SidebarSeparator
();
35
36
void
draw
(NVGcontext* vg,
float
x,
float
y,
float
width,
float
height,
Style
style,
FrameContext
* ctx)
override
;
37
};
38
39
class
SidebarItemGroup
40
{
41
public
:
42
void
add
(
SidebarItem
* item);
43
void
setActive
(
SidebarItem
* item);
44
void
clear
();
45
46
private
:
47
std::vector<SidebarItem*> items;
48
};
49
50
class
SidebarItem
:
public
Box
51
{
52
public
:
53
SidebarItem
();
54
55
void
onFocusGained
()
override
;
56
void
onFocusLost
()
override
;
57
58
void
setGroup
(
SidebarItemGroup
* group);
59
60
void
setLabel
(std::string label);
61
62
void
setActive
(
bool
active);
63
bool
isActive
()
const
{
return
this->active; }
64
65
GenericEvent
*
getActiveEvent
();
66
67
protected
:
68
AccessibilityRole
getDefaultAccessibilityRole
()
override
{
return
AccessibilityRole::TAB
; }
69
std::string
getDefaultAccessibilityLabel
()
override
{
return
this->label->
getFullText
(); }
70
bool
getDefaultAccessibilitySelected
()
override
{
return
this->active; }
71
72
private
:
73
AURORE_BIND
(
Rectangle
, accent,
"aurore/sidebar/item_accent"
);
74
AURORE_BIND
(
Label
, label,
"aurore/sidebar/item_label"
);
75
76
GenericEvent
activeEvent;
77
78
SidebarItemGroup
* group;
79
80
bool
active =
false
;
81
};
82
83
class
Sidebar
:
public
ScrollingFrame
84
{
85
public
:
86
Sidebar
();
87
92
void
addItem
(std::string label,
GenericEvent::Callback
focusCallback);
93
94
SidebarItem
*
getItem
(
int
position);
95
99
void
addSeparator
();
100
104
void
clearItems
();
105
106
static
View
*
create
();
107
108
private
:
109
SidebarItemGroup
group;
110
111
Box
* contentBox;
112
};
113
114
}
// namespace aurore
bind.hpp
AURORE_BIND
#define AURORE_BIND(type, name, id)
Definition
bind.hpp:39
box.hpp
aurore::Box
Generic FlexBox layout.
Definition
box.hpp:74
aurore::Event< View * >
aurore::Event< View * >::Callback
std::function< void(Ts...)> Callback
Definition
event.hpp:43
aurore::FrameContext
Definition
frame_context.hpp:30
aurore::Label
Definition
label.hpp:65
aurore::Label::getFullText
std::string getFullText()
The whole text, as set (not cut to fit).
aurore::Rectangle
Definition
rectangle.hpp:28
aurore::ScrollingFrame
Definition
scrolling_frame.hpp:45
aurore::SidebarItemGroup
Definition
sidebar.hpp:40
aurore::SidebarItemGroup::clear
void clear()
aurore::SidebarItemGroup::add
void add(SidebarItem *item)
aurore::SidebarItemGroup::setActive
void setActive(SidebarItem *item)
aurore::SidebarItem
Definition
sidebar.hpp:51
aurore::SidebarItem::setActive
void setActive(bool active)
aurore::SidebarItem::setGroup
void setGroup(SidebarItemGroup *group)
aurore::SidebarItem::isActive
bool isActive() const
Definition
sidebar.hpp:63
aurore::SidebarItem::getActiveEvent
GenericEvent * getActiveEvent()
aurore::SidebarItem::getDefaultAccessibilityLabel
std::string getDefaultAccessibilityLabel() override
A focusable box says the texts shown in it (getAccessibilityText).
Definition
sidebar.hpp:69
aurore::SidebarItem::SidebarItem
SidebarItem()
aurore::SidebarItem::getDefaultAccessibilitySelected
bool getDefaultAccessibilitySelected() override
Definition
sidebar.hpp:70
aurore::SidebarItem::setLabel
void setLabel(std::string label)
aurore::SidebarItem::getDefaultAccessibilityRole
AccessibilityRole getDefaultAccessibilityRole() override
Definition
sidebar.hpp:68
aurore::SidebarItem::onFocusLost
void onFocusLost() override
aurore::SidebarItem::onFocusGained
void onFocusGained() override
aurore::SidebarSeparator
Definition
sidebar.hpp:32
aurore::SidebarSeparator::SidebarSeparator
SidebarSeparator()
aurore::SidebarSeparator::draw
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
aurore::Sidebar
Definition
sidebar.hpp:84
aurore::Sidebar::addItem
void addItem(std::string label, GenericEvent::Callback focusCallback)
aurore::Sidebar::create
static View * create()
aurore::Sidebar::Sidebar
Sidebar()
aurore::Sidebar::getItem
SidebarItem * getItem(int position)
aurore::Sidebar::addSeparator
void addSeparator()
aurore::Sidebar::clearItems
void clearItems()
aurore::Style
Simple wrapper around StyleValues for the array operator.
Definition
style.hpp:115
aurore::View
Definition
view.hpp:232
label.hpp
aurore
Definition
actions.hpp:25
aurore::AccessibilityRole
AccessibilityRole
Definition
view_style.hpp:78
aurore::AccessibilityRole::TAB
@ TAB
rectangle.hpp
scrolling_frame.hpp
aurore
views
sidebar.hpp
Generated by
1.9.8