Aurore
A Switch-like interface for your app, on every screen
Loading...
Searching...
No Matches
hint.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 XITRIX
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
20#include <aurore/core/bind.hpp>
21#include <aurore/core/box.hpp>
24
25namespace aurore
26{
27
28// The footer's hints and clock with a larger text (Label::setFontScale):
29// drawn at most `max` times their size (1 by default: they keep theirs),
30// smaller again when the footer has no room for them.
31void setHintsFontScaleMax(float max);
33
34class Hint : public Box
35{
36 public:
37 Hint(std::shared_ptr<Action> action, bool allowAButtonTouch = false);
38 static std::string getKeyIcon(ControllerButton button, bool ignoreKeysSwap = false);
39
40 // Its width with its key and text at their full size.
41 float fullWidth();
42
43 private:
44 std::shared_ptr<Action> action;
45
46 AURORE_BIND(Label, icon, "icon");
47 AURORE_BIND(Label, hint, "hint");
48};
49
50class Hints : public Box
51{
52 public:
55
57 {
58 addUnableAButtonAction = value;
59 }
60
62 {
63 return addUnableAButtonAction;
64 }
65
66 void setAllowAButtonTouch(bool value)
67 {
68 allowAButtonTouch = value;
69 }
70
72 {
73 return allowAButtonTouch;
74 }
75
76 static View* create();
77
78 void onLayout() override;
79
80 private:
81 void refillHints(View* focusView);
82 float room();
83 bool roomUnknown = false;
84 bool addUnableAButtonAction = true;
85 bool allowAButtonTouch = false;
86 bool forceShown = false;
87
88 VoidEvent::Subscription hintSubscription;
89};
90
91// Draws the hints as they are once a screen has opened or closed: greyed
92// only for an action that is not available, not while the input is blocked
93// by the screen's fade. So a screenshot does not depend on when it was taken.
94void setHintsSteady(bool steady);
95
96// The actions of `owner` (but A and B) are the footer's optional hints: keys
97// that work from any screen, which a screen with its own keys may need the
98// room of. When the hints do not all fit at their full size, the optional
99// ones are left out, the last one first. nullptr (the default): none.
102
103} // namespace aurore
#define AURORE_BIND(type, name, id)
Definition bind.hpp:39
Generic FlexBox layout.
Definition box.hpp:74
CallbacksList::iterator Subscription
Definition event.hpp:45
Definition hint.hpp:35
Hint(std::shared_ptr< Action > action, bool allowAButtonTouch=false)
float fullWidth()
static std::string getKeyIcon(ControllerButton button, bool ignoreKeysSwap=false)
Definition hint.hpp:51
void setAddUnableAButtonAction(bool value)
Definition hint.hpp:56
void onLayout() override
static View * create()
void setAllowAButtonTouch(bool value)
Definition hint.hpp:66
bool getAddUnableAButtonAction() const
Definition hint.hpp:61
bool getAllowAButtonTouch() const
Definition hint.hpp:71
Definition label.hpp:65
Definition view.hpp:232
Definition actions.hpp:25
View * getHintsOptionalOwner()
ControllerButton
Definition input.hpp:179
void setHintsOptionalOwner(View *owner)
void setHintsFontScaleMax(float max)
void setHintsSteady(bool steady)
float getHintsFontScaleMax()