LeviLamina
Loading...
Searching...
No Matches
ScreenView.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/gui/CardinalDirection.h"
7#include "mc/client/gui/DirtyFlag.h"
8#include "mc/client/gui/controls/TextCharEventResult.h"
9#include "mc/client/gui/screens/ControlCollectionChange.h"
10#include "mc/client/gui/screens/GamepadCursorData.h"
11#include "mc/client/gui/screens/ScreenEvent.h"
12#include "mc/client/gui/screens/TextEditFocusedListener.h"
13#include "mc/deps/core/utility/NonOwnerPointer.h"
14#include "mc/deps/core/utility/pub_sub/Publisher.h"
15#include "mc/deps/core/utility/pub_sub/Subscription.h"
16#include "mc/deps/input/InputMode.h"
17#include "mc/deps/input/enums/ButtonState.h"
18#include "mc/deps/input/enums/DirectionId.h"
19#include "mc/deps/input/enums/FocusImpact.h"
20
21// auto generated forward declare list
22// clang-format off
24class FocusManager;
26class InputComponent;
27class KeyboardManager;
28class LayoutManager;
29class RectangleArea;
34class ScreenSettings;
35class ScreenViewProxy;
38class UIControl;
41class UIPropertyBag;
42class UIRenderContext;
43class VisualTree;
44namespace Bedrock::PubSub::ThreadModel { struct MultiThreaded; }
45// clang-format on
46
47class ScreenView {
48public:
49 // ScreenView inner types declare
50 // clang-format off
51 struct DelayedCommand;
52 struct TouchPadData;
53 // clang-format on
54
55 // ScreenView inner types define
56 enum class DelayedCommandLocation : int {
57 DirtyVisualTree = 0,
58 PostLayout = 1,
59 };
60
61 struct DelayedCommand {
62 public:
63 // DelayedCommand inner types define
64 using Result = ::std::pair<::ui::DirtyFlag, bool>;
65
66 public:
67 // member variables
68 // NOLINTBEGIN
69 ::ll::TypedStorage<8, 64, ::std::function<::std::pair<::ui::DirtyFlag, bool>()>> mAction;
70 ::ll::TypedStorage<4, 4, ::ScreenView::DelayedCommandLocation> location;
71 // NOLINTEND
72 };
73
74 struct TouchPadData {
75 public:
76 // member variables
77 // NOLINTBEGIN
78 ::ll::TypedStorage<4, 4, int> mTouchId;
79 ::ll::TypedStorage<4, 8, ::glm::vec2> mPreviousPosition;
80 ::ll::TypedStorage<4, 8, ::glm::vec2> mCurrentPosition;
81 // NOLINTEND
82 };
83
84 using clock_type = ::std::chrono::steady_clock;
85
86 using duration_sec = ::std::chrono::duration<float, ::std::ratio<1, 1>>;
87
88public:
89 // member variables
90 // NOLINTBEGIN
91 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastTime;
92 ::ll::TypedStorage<4, 4, float> mTickTime;
93 ::ll::TypedStorage<8, 8, double> mLastRawJoystickEventTime;
94 ::ll::TypedStorage<4, 8, ::glm::vec2> mSize;
95 ::ll::TypedStorage<4, 4, int> mMenuUpButtonId;
96 ::ll::TypedStorage<4, 4, int> mMenuDownButtonId;
97 ::ll::TypedStorage<4, 4, int> mMenuLeftButtonId;
98 ::ll::TypedStorage<4, 4, int> mMenuRightButtonId;
99 ::ll::TypedStorage<4, 4, int> mMenuTabLeftButtonId;
100 ::ll::TypedStorage<4, 4, int> mMenuTabRightButtonId;
101 ::ll::TypedStorage<4, 8, ::std::array<uint, 2>> mPointerButtonIds;
102 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScreenController>> mController;
103 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::VisualTree>> mVisualTree;
104 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysBindControls;
105 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mInputControls;
106 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mScrollViewControls;
107 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mOutOfModalScopeScrollViewControls;
108 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAnimationControls;
109 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFactoryControls;
110 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mTextEditBoxControls;
111 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysListeningInputControls;
112 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mRenderableControls;
113 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFlyingItemRendererControls;
114 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mSliderControls;
115 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomRendererControls;
116 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomFrameUpdateControls;
117 ::ll::TypedStorage<
118 8,
119 16,
120 ::std::map<::std::vector<::std::shared_ptr<::UIControl>>*, ::std::vector<::std::shared_ptr<::UIControl>>>>
121 mControlsToRemove;
122 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenRenderBatch>> mRootRenderBatch;
123 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIAnimationController>> mAnimationController;
124 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint, ::std::vector<::std::weak_ptr<::UIControl>>>>
125 mReservedButtonUpEvents;
126 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mSelectedControl;
127 ::ll::TypedStorage<4, 4, ::InputMode> mInputMode;
128 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LayoutManager>> mLayoutManager;
129 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FocusManager>> mFocusManager;
130 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ITTSEventManager>> mTTSEventManager;
131 ::ll::TypedStorage<1, 1, bool> mTextToSpeechEnabled;
132 ::ll::TypedStorage<8, 32, ::std::string> mTTSSectionHeader;
133 ::ll::TypedStorage<4, 4, float> mCurrentSliderValue;
134 ::ll::TypedStorage<1, 1, bool> mIsGUIScaleSlider;
135 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::ui::CardinalDirection>> mControllerStickDirections;
136 ::ll::TypedStorage<4, 4, int> mControllerLastMoved;
137 ::ll::TypedStorage<4, 4, int> mCursorTick;
138 ::ll::TypedStorage<4, 4, float const> mControllerXThreshold;
139 ::ll::TypedStorage<4, 4, float const> mControllerYThreshold;
140 ::ll::TypedStorage<4, 72, ::glm::vec2[9]> mControllerStickValues;
141 ::ll::TypedStorage<4, 8, ::GamepadCursorData> mGamepadCursorData;
142 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadCursorPosition;
143 ::ll::TypedStorage<1, 1, bool> mHasSetInitialPosition;
144 ::ll::TypedStorage<1, 1, bool> mGamepadCursorFocusModeEnabled;
145 ::ll::TypedStorage<1, 1, bool> mGamepadCursorMagnetEnabled;
146 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mGamepadMagnetControl;
147 ::ll::TypedStorage<4, 4, float> mGamepadMoveTime;
148 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadTrackedDirection;
149 ::ll::TypedStorage<1, 1, bool> mGamepadHasTapped;
150 ::ll::TypedStorage<4, 20, ::ScreenView::TouchPadData> mTouchPadData;
151 ::ll::TypedStorage<4, 8, ::glm::vec2> mPointerLocationPrevious;
152 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastPointInTime;
153 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mCurrentTime;
154 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mTimeAccumulator;
155 ::ll::TypedStorage<4, 4, ::std::chrono::duration<float, ::std::ratio<1, 1>> const> mFixedAnimationUpdateRate;
156 ::ll::TypedStorage<4, 4, float> mKeyboardHeight;
157 ::ll::TypedStorage<1, 1, bool> mShouldShowKeyboard;
158 ::ll::TypedStorage<1, 1, bool> mInitKeyboard;
159 ::ll::TypedStorage<4, 4, float> mCurrentObfuscateTime;
160 ::ll::TypedStorage<8, 8, ::KeyboardManager&> mKeyboardManager;
161 ::ll::TypedStorage<8, 24, ::std::vector<::RectangleArea>> mInputAreas;
162 ::ll::TypedStorage<8, 8, ::UIMeasureStrategy&> mMeasureStrategy;
163 ::ll::TypedStorage<1, 1, bool> mCanMoveFocus;
164 ::ll::TypedStorage<1, 1, ::FocusImpact> mNextFocusAction;
165 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::UIControlFactory>> mControlFactory;
166 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mAnimationEvents;
167 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mCustomRendererEvents;
168 ::ll::TypedStorage<4, 8, ::glm::vec2> mStartLocation;
169 ::ll::TypedStorage<4, 4, float> mTimeUntilNextPointerHeldEvent;
170 ::ll::TypedStorage<4, 4, float> mDelayBetweenEachPointerHeldEvent;
171 ::ll::TypedStorage<1, 1, bool> mShouldSendPointerHeldEvents;
172 ::ll::TypedStorage<8, 24, ::std::vector<::ScreenView::DelayedCommand>> mDelayedCommands;
173 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenViewProxy>> mProxy;
174 ::ll::TypedStorage<8, 40, ::std::queue<::std::string, ::std::deque<::std::string>>> mQueuedTextChange;
175 ::ll::TypedStorage<1, 1, bool> mIsExiting;
176 ::ll::TypedStorage<1, 1, bool> mIsEntering;
177 ::ll::TypedStorage<1, 1, bool> mIsInitialized;
178 ::ll::TypedStorage<1, 1, bool> mHasFocus;
179 ::ll::TypedStorage<1, 1, bool> mHasHadFocus;
180 ::ll::TypedStorage<1, 1, bool> mIsTerminating;
181 ::ll::TypedStorage<1, 1, bool> mDirectionalButtonWasPressed;
182 ::ll::TypedStorage<1, 1, bool> mDelayedFocusRefresh;
183 ::ll::TypedStorage<1, 1, ::TextEditFocusedListener> mTextEditFocusedListener;
184 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker>> mScreenLoadTimeTracker;
185 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mFocusChangeSub;
186 // NOLINTEND
187
188public:
189 // prevent constructor by default
190 ScreenView& operator=(ScreenView const&);
191 ScreenView(ScreenView const&);
192 ScreenView();
193
194public:
195 // member functions
196 // NOLINTBEGIN
197 MCAPI void _adjustScrollToControl(::UIControl& control);
198
199 MCAPI void
200 _adjustScrollToFocusedControl(::UIControl& focusedControl, bool selectNearestControl, bool isRightStickScrolling);
201
202 MCAPI void _advanceToNextTab(bool right);
203
204 MCAPI void _bindData(bool doAllBinds);
205
206 MCAPI void
207 _changeInputControlCollection(::UIControl& control, ::ControlCollectionChange change, bool const isRemoveCallback);
208
209 MCAPI void _debugRenderControl(::UIRenderContext& context, ::UIControl const& control) const;
210
211 MCAPI void _debugRenderFocusControl(
212 ::UIRenderContext& context,
213 ::UIControl const& control,
214 ::std::vector<::UIControl const*>& visited
215 ) const;
216
217 MCAPI void _deselectControl(bool forceDeselect, bool hoverAfterDeselect);
218
219 MCAPI void _executeDelayedCommands(::ScreenView::DelayedCommandLocation location);
220
221 MCAPI void _fireSelectedStateChangeEvent(::TextEditComponent const& textEditComponent, bool state);
222
223 MCAPI void _fireTextChangedEvent(
224 bool finished,
225 ::TextCharEventResult result,
226 uint id,
227 int index,
228 ::UIPropertyBag* propertyBag
229 );
230
231 MCAPI void _focusChangeCallback(
232 ::std::weak_ptr<::UIControl> previousFocusControl,
233 ::std::weak_ptr<::UIControl> currentFocusControl
234 );
235
236 MCAPI void _forwardEventToAnimationControls(::ScreenEvent const& screenEvent);
237
238 MCAPI ::std::shared_ptr<::UIControl> _getGamepadCursorFocusedControl() const;
239
240 MCAPI ::ScreenSettings const* _getScreenComponent() const;
241
242 MCAPI void _handleDirtyVisualTree(bool overrideFocusControl, bool doAllBinds);
243
244 MCAPI void _handlePointerLocation(
245 ::glm::vec2 const& position,
246 ::FocusImpact focusImpact,
247 bool forceHandleWhenMotionless,
248 bool isRightStickScrolling
249 );
250
251 MCAPI void _handleStickScrolling(::DirectionId directionId);
252
253 MCAPI void _passViewCommand();
254
255 MCAPI void _processControllerCursorMove(::DirectionId directionId);
256
257 MCAPI void _processControllerDirection(::DirectionId directionId);
258
259 MCAPI void _processEvents(::ScreenInputContext& context);
260
261 MCAPI void _queueTextToSpeechIfEnabled(
262 ::std::shared_ptr<::UIControl> focusedControl,
263 bool excludeControlHeader,
264 bool notInterruptible
265 );
266
267 MCAPI void _queueTextToSpeechTextboxCharacter(::std::string const& inputStr);
268
269 MCAPI void _resetButtonState(::UIControl& control);
270
271 MCAPI void _resetFocusedControl();
272
273 MCAPI void
274 _resetInputControl(::UIControl& control, ::InputComponent* const inputComponent, bool const handleModalChange);
275
276 MCAPI void _scrollToGridItem(::UIControl* gridControl, int itemIndex, int numItems);
277
278 MCAPI void _selectControl(::UIControl& control, bool isHandlingTextChar);
279
280 MCAPI void _selectNextFocusObject(
281 ::ui::CardinalDirection direction,
282 bool overrideOrigin,
283 ::glm::vec2 const overridePos,
284 bool isRightStickScrolling
285 );
286
287 MCAPI void _sendScrollEvent(::UIControl& parent, float delta) const;
288
289 MCAPI void _setGamepadCursorFocusMode(bool focusModeEnabled);
290
291 MCAPI void _setKeyboardHeight(float height);
292
293 MCAPI void _setupControlFactoryCallbacks();
294
295 MCAPI void _switchTabToTargetIndex(::std::vector<::std::shared_ptr<::UIControl>>& tabControls, int targetIndex);
296
297 MCAPI bool _updateControlCollections(bool overrideFocusControl);
298
299 MCAPI void
300 _updateFocusControl(bool forceUpdate, bool forceFocusToAdjust, bool isRightStickScrolling, bool isHandlingTextChar);
301
302 MCAPI void _updateInputAreas();
303
304 MCAPI void _updateKeyboardVisibility();
305
306 MCAPI void cleanInputComponents();
307
308 MCAPI ::std::string getRoute() const;
309
310 MCAPI ::std::string getScreenName() const;
311
312 MCAPI void handleButtonEvent(uint buttonId, ::ButtonState buttonState, ::FocusImpact focusImpact);
313
314 MCAPI bool
315 handlePointerLocation(::glm::vec2 const& position, bool forceMotionlessPointer, ::FocusImpact focusImpact);
316
317 MCAPI bool isGamepadDeflectionModeEnabled() const;
318
319 MCAPI void render(::UIRenderContext& uiRenderContext);
320
321 MCAPI void resize();
322
323 MCAPI void setInitialized();
324
325 MCAPI ~ScreenView();
326 // NOLINTEND
327
328public:
329 // static functions
330 // NOLINTBEGIN
331 MCAPI static bool _isFocusEnabled(::std::shared_ptr<::UIControl> const& control);
332
333 MCAPI static bool _isFocusMagnetEnabled(::std::shared_ptr<::UIControl> const& control);
334
335 MCAPI static bool _shouldBindChildren(bool doAllBinds, ::UIControl& control, ::DataBindingComponent& dataBinding);
336 // NOLINTEND
337
338public:
339 // static variables
340 // NOLINTBEGIN
341 MCAPI static ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>&
342 mDebugChangePublisher();
343
344 MCAPI static bool& sIsDebuggingFocus();
345
346 MCAPI static bool& sRenderDebugControls();
347 // NOLINTEND
348
349public:
350 // destructor thunk
351 // NOLINTBEGIN
352 MCAPI void $dtor();
353 // NOLINTEND
354};
Definition DataBindingComponent.h:5
Definition FocusManager.h:5
Definition ITTSEventManager.h:5
Definition InputComponent.h:5
Definition KeyboardManager.h:5
Definition LayoutManager.h:5
Definition RectangleArea.h:5
Definition ScreenController.h:5
Definition ScreenInputContext.h:5
Definition ScreenLoadTimeTracker.h:5
Definition ScreenRenderBatch.h:5
Definition ScreenSettings.h:5
Definition ScreenViewProxy.h:5
Definition ScreenView.h:5
Definition TextEditComponent.h:5
Definition UIAnimationController.h:5
Definition UIControlFactory.h:5
Definition UIControl.h:5
Definition UIMeasureStrategy.h:5
Definition UIPropertyBag.h:5
Definition UIRenderContext.h:5
Definition VisualTree.h:5
Definition ScreenView.h:18
Definition ScreenView.h:16