Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
slider.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/application.hpp
>
21
#include <
aurore/core/bind.hpp
>
22
#include <
aurore/core/box.hpp
>
23
#include <
aurore/views/label.hpp
>
24
#include <
aurore/views/rectangle.hpp
>
25
26
namespace
aurore
27
{
28
29
class
Slider
:
public
Box
30
{
31
public
:
32
Slider
();
33
34
void
onLayout
()
override
;
35
View
*
getDefaultFocus
()
override
;
36
void
draw
(NVGcontext* vg,
float
x,
float
y,
float
width,
float
height,
Style
style,
FrameContext
* ctx)
override
;
37
38
void
setProgress
(
float
progress);
39
40
float
getProgress
();
41
42
Event<float>
*
getProgressEvent
();
43
44
void
setStep
(
float
step);
45
51
void
setDiscreteStep
(
float
step);
52
58
Event<float>
*
getInputProgressEvent
();
59
60
// Whether the user is moving it now (D-pad held, finger down)
61
bool
isProgressing
();
62
63
void
setPointerSize
(
float
size);
64
65
static
View
*
create
();
66
67
protected
:
68
// The knob takes the focus and says these: a slider, its cell's title,
69
// its value as "40%".
70
AccessibilityRole
getDefaultAccessibilityRole
()
override
{
return
AccessibilityRole::SLIDER
; }
71
std::string
getDefaultAccessibilityLabel
()
override
;
72
std::string
getDefaultAccessibilityValue
()
override
;
73
74
private
:
75
int
announced = -1;
// the value last said, in percent
76
void
announceValue();
77
78
Rectangle
* line;
79
Rectangle
* lineEmpty;
80
Rectangle
* pointer;
81
82
Event<float>
progressEvent;
83
Event<float>
inputProgressEvent;
84
float
discreteStep = 0;
85
bool
progressing =
false
;
86
87
float
progress = 1;
88
float
step = 0.5f;
89
90
void
buttonsProcessing();
91
void
moveByStep(
int
direction);
92
void
updateUI();
93
};
94
95
}
// namespace aurore
application.hpp
bind.hpp
box.hpp
aurore::Box
Generic FlexBox layout.
Definition
box.hpp:74
aurore::Event
Definition
event.hpp:41
aurore::FrameContext
Definition
frame_context.hpp:30
aurore::Rectangle
Definition
rectangle.hpp:28
aurore::Slider
Definition
slider.hpp:30
aurore::Slider::setDiscreteStep
void setDiscreteStep(float step)
aurore::Slider::setStep
void setStep(float step)
aurore::Slider::getDefaultAccessibilityLabel
std::string getDefaultAccessibilityLabel() override
A focusable box says the texts shown in it (getAccessibilityText).
aurore::Slider::setPointerSize
void setPointerSize(float size)
aurore::Slider::create
static View * create()
aurore::Slider::getDefaultAccessibilityRole
AccessibilityRole getDefaultAccessibilityRole() override
Definition
slider.hpp:70
aurore::Slider::onLayout
void onLayout() override
aurore::Slider::getProgress
float getProgress()
aurore::Slider::getDefaultFocus
View * getDefaultFocus() override
aurore::Slider::Slider
Slider()
aurore::Slider::draw
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
aurore::Slider::isProgressing
bool isProgressing()
aurore::Slider::getProgressEvent
Event< float > * getProgressEvent()
aurore::Slider::getInputProgressEvent
Event< float > * getInputProgressEvent()
aurore::Slider::getDefaultAccessibilityValue
std::string getDefaultAccessibilityValue() override
aurore::Slider::setProgress
void setProgress(float progress)
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::SLIDER
@ SLIDER
rectangle.hpp
aurore
views
slider.hpp
Generated by
1.9.8