Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
scrolling_frame.hpp
Go to the documentation of this file.
1/*
2 Copyright 2020-2021 natinusala
3 Copyright 2021 XITRIX
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/time.hpp>
21
23#include <aurore/core/box.hpp>
25
26namespace aurore
27{
28
31{
34 NATURAL,
35
38};
39
44class ScrollingFrame : public Box
45{
46 public:
50
51 void draw(NVGcontext* vg, float x, float y, float width, float height, Style style, FrameContext* ctx) override;
52 void onFocusGained() override;
53 void onChildFocusGained(View* directChild, View* focusedView) override;
54 void onChildFocusLost(View* directChild, View* focusedView) override;
55 void willAppear(bool resetState) override;
56 void addView(View* view) override;
57 void removeView(View* view, bool free = true) override;
58 void onLayout() override;
59 void setPadding(float top, float right, float bottom, float left) override;
60 void setPaddingTop(float top) override;
61 void setPaddingRight(float right) override;
62 void setPaddingBottom(float bottom) override;
63 void setPaddingLeft(float left) override;
64 View* getParentNavigationDecision(View* from, View* newFocus, FocusDirection direction) override;
65 View* getNextFocus(FocusDirection direction, View* currentView) override;
66 View* getDefaultFocus() override;
67 enum Sound getFocusSound() override;
70
75 void setContentView(View* view);
76
82
86 float getContentOffsetY() const
87 {
88 return contentOffsetY;
89 }
90
94 void setContentOffsetY(float value, bool animated);
95
98 {
100 }
101
104 {
105 showScrollingIndicator = visible;
106 }
107
109 static View* create();
110
111 protected:
112 View* contentView = nullptr;
114
116 bool childFocused = false;
125
126 float middleY = 0;
127 float bottomY = 0;
128
130
132 bool updateScrolling(bool animated);
133 void startScrolling(bool animated, float newScroll);
134 void animateScrolling(float newScroll, float time);
136
139
141
144 bool isRubberBanding = false;
146 void naturalScrollingButtonProcessing(FocusDirection focusDirection, bool* repeat);
148
151
153};
154
155} // namespace aurore
Definition animation.hpp:42
Generic FlexBox layout.
Definition box.hpp:74
CallbacksList::iterator Subscription
Definition event.hpp:45
Definition frame_context.hpp:30
Definition rectangle.hpp:28
Definition scrolling_frame.hpp:45
float getContentOffsetY() const
Definition scrolling_frame.hpp:86
bool updateScrolling(bool animated)
View * getDefaultFocus() override
void setPaddingLeft(float left) override
void onChildFocusGained(View *directChild, View *focusedView) override
void setScrollingIndicatorAutoHide(bool autoHide)
On by default: the indicator shows while scrolling, then fades.
Definition scrolling_frame.hpp:97
void onFocusGained() override
bool showScrollingIndicator
Definition scrolling_frame.hpp:117
void onChildFocusLost(View *directChild, View *focusedView) override
void setPaddingBottom(float bottom) override
void setPaddingRight(float right) override
Rectangle * scrollingIndicator
Definition scrolling_frame.hpp:113
void setPadding(float top, float right, float bottom, float left) override
void addView(View *view) override
void setContentOffsetY(float value, bool animated)
ScrollingFrame()
An empty frame, NATURAL scrolling.
bool updateScrollingOnNextFrame
Definition scrolling_frame.hpp:115
void removeView(View *view, bool free=true) override
void onLayout() override
Time lastScrollTime
Definition scrolling_frame.hpp:124
View * getParentNavigationDecision(View *from, View *newFocus, FocusDirection direction) override
static View * create()
Makes a frame for XML (<aurore:ScrollingFrame>, one child: its content).
void setContentView(View *view)
ScrollingBehavior behavior
Definition scrolling_frame.hpp:142
View * findTopMostFocusableView()
bool naturalScrollingCanScroll
Definition scrolling_frame.hpp:143
bool isRubberBanding
true while finger is dragging past a scroll boundary
Definition scrolling_frame.hpp:144
float bottomY
y + height
Definition scrolling_frame.hpp:127
View * contentView
Definition scrolling_frame.hpp:112
void startScrolling(bool animated, float newScroll)
bool autoHideScrollingIndicator
Definition scrolling_frame.hpp:120
float getScrollingAreaTopBoundary()
void setScrollingBehavior(ScrollingBehavior behavior)
void setPaddingTop(float top) override
float lastIndicatorOffset
Definition scrolling_frame.hpp:121
void animateScrolling(float newScroll, float time)
View * getNextFocus(FocusDirection direction, View *currentView) override
Event< InputType >::Subscription inputTypeSubscription
Definition scrolling_frame.hpp:152
bool indicatorShowsFocus
The focus waits on the frame itself: the indicator stands for it.
Definition scrolling_frame.hpp:123
void willAppear(bool resetState) override
void naturalScrollingButtonProcessing(FocusDirection focusDirection, bool *repeat)
Rect getVisibleFrame()
The part of the content in view: the local frame moved down by the scroll offset.
bool childFocused
Definition scrolling_frame.hpp:116
Animatable contentOffsetY
Definition scrolling_frame.hpp:129
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
enum Sound getFocusSound() override
void setScrollingIndicatorVisible(bool visible)
Whether the scroll bar on the right is drawn at all.
Definition scrolling_frame.hpp:103
float middleY
y + height/2
Definition scrolling_frame.hpp:126
Simple wrapper around StyleValues for the array operator.
Definition style.hpp:115
Definition view.hpp:232
Definition actions.hpp:25
ScrollingBehavior
How a ScrollingFrame follows the focus.
Definition scrolling_frame.hpp:31
@ CENTERED
The focused view is always in the center, inputs always change focus and scroll immediately.
FocusDirection
Focus direction when navigating.
Definition view.hpp:96
Sound
Definition audio.hpp:23
retro_time_t Time
Definition time.hpp:31
Definition geometry.hpp:70