Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
h_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
21
22namespace aurore
23{
24
25// A vertical-only frame that can scroll if its content overflows.
26// This frame can only contain one child view.
27// The content view is detached from the rest of the tree
28// so that its height can grow as much as possible.
29class HScrollingFrame : public Box
30{
31 public:
34
35 void draw(NVGcontext* vg, float x, float y, float width, float height, Style style, FrameContext* ctx) override;
36 void onFocusGained() override;
37 void onChildFocusGained(View* directChild, View* focusedView) override;
38 void onChildFocusLost(View* directChild, View* focusedView) override;
39 void willAppear(bool resetState) override;
40 void addView(View* view) override;
41 void removeView(View* view, bool free = true) override;
42 void onLayout() override;
43 void setPadding(float top, float right, float bottom, float left) override;
44 void setPaddingTop(float top) override;
45 void setPaddingRight(float right) override;
46 void setPaddingBottom(float bottom) override;
47 void setPaddingLeft(float left) override;
48 View* getParentNavigationDecision(View* from, View* newFocus, FocusDirection direction) override;
49 View* getNextFocus(FocusDirection direction, View* currentView) override;
50 View* getDefaultFocus() override;
51 enum Sound getFocusSound() override;
53
58 void setContentView(View* view);
59
65
69 float getContentOffsetX() const
70 {
71 return contentOffsetX;
72 }
73
77 void setContentOffsetX(float value, bool animated);
78
80 {
81 showScrollingIndicator = visible;
82 }
83
84 static View* create();
85
86 private:
87 View* contentView = nullptr;
88 Rectangle* scrollingIndicator = nullptr;
89
90 bool updateScrollingOnNextFrame = false;
91 bool childFocused = false;
92 bool showScrollingIndicator = true;
93
94 float middleX = 0; // y + height/2
95 float rightX = 0; // y + height
96
97 Animatable contentOffsetX = 0.0f;
98
99 void prebakeScrolling();
100 bool updateScrolling(bool animated);
101 void startScrolling(bool animated, float newScroll);
102 void animateScrolling(float newScroll, float time);
103 void scrollAnimationTick();
104
105 float getScrollingAreaLeftBoundary();
106 float getScrollingAreaWidth();
107
108 float getContentWidth();
109
111 bool naturalScrollingCanScroll = false;
112 bool isRubberBanding = false;
113 void naturalScrollingBehaviour();
114 void naturalScrollingButtonProcessing(FocusDirection focusDirection, bool* repeat);
115 View* findLeftMostFocusableView();
116
117 void setupScrollingIndicator();
118 void updateScrollingIndicatior();
119
120 Event<InputType>::Subscription inputTypeSubscription;
121};
122
123} // 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 h_scrolling_frame.hpp:30
void onChildFocusLost(View *directChild, View *focusedView) override
void willAppear(bool resetState) override
void draw(NVGcontext *vg, float x, float y, float width, float height, Style style, FrameContext *ctx) override
void onFocusGained() override
void setScrollingBehavior(ScrollingBehavior behavior)
float getContentOffsetX() const
Definition h_scrolling_frame.hpp:69
void setPaddingBottom(float bottom) override
void setPaddingLeft(float left) override
void addView(View *view) override
void setPaddingTop(float top) override
View * getDefaultFocus() override
void onChildFocusGained(View *directChild, View *focusedView) override
void setContentOffsetX(float value, bool animated)
void setContentView(View *view)
void setScrollingIndicatorVisible(bool visible)
Definition h_scrolling_frame.hpp:79
void setPadding(float top, float right, float bottom, float left) override
void onLayout() override
View * getNextFocus(FocusDirection direction, View *currentView) override
static View * create()
void removeView(View *view, bool free=true) override
void setPaddingRight(float right) override
View * getParentNavigationDecision(View *from, View *newFocus, FocusDirection direction) override
enum Sound getFocusSound() override
Definition rectangle.hpp:28
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
FocusDirection
Focus direction when navigating.
Definition view.hpp:96
Sound
Definition audio.hpp:23
Definition geometry.hpp:70