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
21#include <aurore/core/bind.hpp>
22#include <aurore/core/box.hpp>
25
26namespace aurore
27{
28
29class Slider : public Box
30{
31 public:
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
43
44 void setStep(float step);
45
51 void setDiscreteStep(float step);
52
59
60 // Whether the user is moving it now (D-pad held, finger down)
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%".
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
Generic FlexBox layout.
Definition box.hpp:74
Definition event.hpp:41
Definition frame_context.hpp:30
Definition rectangle.hpp:28
Definition slider.hpp:30
void setDiscreteStep(float step)
void setStep(float step)
std::string getDefaultAccessibilityLabel() override
A focusable box says the texts shown in it (getAccessibilityText).
void setPointerSize(float size)
static View * create()
AccessibilityRole getDefaultAccessibilityRole() override
Definition slider.hpp:70
void onLayout() override
float getProgress()
View * getDefaultFocus() override
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
bool isProgressing()
Event< float > * getProgressEvent()
Event< float > * getInputProgressEvent()
std::string getDefaultAccessibilityValue() override
void setProgress(float progress)
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition view.hpp:232
Definition actions.hpp:25
AccessibilityRole
Definition view_style.hpp:78