3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/client/gui/CardinalDirection.h"
7#include "mc/client/gui/DirtyFlag.h"
8#include "mc/client/gui/GameEventNotification.h"
9#include "mc/client/gui/controls/TextCharEventResult.h"
10#include "mc/client/gui/screens/ControlCollectionChange.h"
11#include "mc/client/gui/screens/ControlCollectionFlag.h"
12#include "mc/client/gui/screens/GamepadCursorData.h"
13#include "mc/client/gui/screens/TextEditFocusedListener.h"
14#include "mc/deps/core/utility/NonOwnerPointer.h"
15#include "mc/deps/core/utility/pub_sub/Publisher.h"
16#include "mc/deps/core/utility/pub_sub/Subscription.h"
17#include "mc/deps/input/InputMode.h"
18#include "mc/deps/input/TextboxTextUpdateReason.h"
19#include "mc/deps/input/enums/ButtonState.h"
20#include "mc/deps/input/enums/DirectionId.h"
21#include "mc/deps/input/enums/FocusImpact.h"
50namespace Bedrock::PubSub::ThreadModel {
struct MultiThreaded; }
51namespace Json {
class Value; }
63 enum class DelayedCommandLocation :
int {
71 using Result = ::std::pair<::ui::DirtyFlag, bool>;
76 ::ll::TypedStorage<8, 64, ::std::function<::std::pair<::ui::DirtyFlag, bool>()>> mAction;
77 ::ll::TypedStorage<4, 4, ::ScreenView::DelayedCommandLocation> location;
83 MCAPI ~DelayedCommand();
97 ::ll::TypedStorage<4, 4, int> mTouchId;
98 ::ll::TypedStorage<4, 8, ::glm::vec2> mPreviousPosition;
99 ::ll::TypedStorage<4, 8, ::glm::vec2> mCurrentPosition;
103 using clock_type = ::std::chrono::steady_clock;
105 using duration_sec = ::std::chrono::duration<float, ::std::ratio<1, 1>>;
110 ::ll::TypedStorage<4, 4, float> mLastTime;
111 ::ll::TypedStorage<4, 4, float> mTickTime;
112 ::ll::TypedStorage<8, 8, double> mLastRawJoystickEventTime;
113 ::ll::TypedStorage<4, 8, ::glm::vec2> mSize;
114 ::ll::TypedStorage<4, 4, int> mMenuUpButtonId;
115 ::ll::TypedStorage<4, 4, int> mMenuDownButtonId;
116 ::ll::TypedStorage<4, 4, int> mMenuLeftButtonId;
117 ::ll::TypedStorage<4, 4, int> mMenuRightButtonId;
118 ::ll::TypedStorage<4, 4, int> mMenuTabLeftButtonId;
119 ::ll::TypedStorage<4, 4, int> mMenuTabRightButtonId;
120 ::ll::TypedStorage<4, 8, ::std::array<uint, 2>> mPointerButtonIds;
121 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScreenController>> mController;
122 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::VisualTree>> mVisualTree;
123 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysBindControls;
124 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mInputControls;
125 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mScrollViewControls;
126 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mOutOfModalScopeScrollViewControls;
127 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAnimationControls;
128 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFactoryControls;
129 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mTextEditBoxControls;
130 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysListeningInputControls;
131 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mRenderableControls;
132 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFlyingItemRendererControls;
133 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mSliderControls;
134 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomRendererControls;
135 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomFrameUpdateControls;
139 ::std::map<::std::vector<::std::shared_ptr<::UIControl>>*, ::std::vector<::std::shared_ptr<::UIControl>>>>
141 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenRenderBatch>> mRootRenderBatch;
142 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIAnimationController>> mAnimationController;
143 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint, ::std::vector<::std::weak_ptr<::UIControl>>>>
144 mReservedButtonUpEvents;
145 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mSelectedControl;
146 ::ll::TypedStorage<4, 4, ::InputMode> mInputMode;
147 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LayoutManager>> mLayoutManager;
148 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FocusManager>> mFocusManager;
149 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ITTSEventManager>> mTTSEventManager;
150 ::ll::TypedStorage<1, 1, bool> mTextToSpeechEnabled;
151 ::ll::TypedStorage<8, 32, ::std::string> mTTSSectionHeader;
152 ::ll::TypedStorage<4, 4, float> mCurrentSliderValue;
153 ::ll::TypedStorage<1, 1, bool> mIsGUIScaleSlider;
154 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::ui::CardinalDirection>> mControllerStickDirections;
155 ::ll::TypedStorage<4, 4, int> mControllerLastMoved;
156 ::ll::TypedStorage<4, 4, int> mCursorTick;
157 ::ll::TypedStorage<4, 4, float const> mControllerXThreshold;
158 ::ll::TypedStorage<4, 4, float const> mControllerYThreshold;
159 ::ll::TypedStorage<4, 72, ::glm::vec2[9]> mControllerStickValues;
160 ::ll::TypedStorage<4, 8, ::GamepadCursorData> mGamepadCursorData;
161 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadCursorPosition;
162 ::ll::TypedStorage<1, 1, bool> mHasSetInitialPosition;
163 ::ll::TypedStorage<1, 1, bool> mGamepadCursorFocusModeEnabled;
164 ::ll::TypedStorage<1, 1, bool> mGamepadCursorMagnetEnabled;
165 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mGamepadMagnetControl;
166 ::ll::TypedStorage<4, 4, float> mGamepadMoveTime;
167 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadTrackedDirection;
168 ::ll::TypedStorage<1, 1, bool> mGamepadHasTapped;
169 ::ll::TypedStorage<4, 20, ::ScreenView::TouchPadData> mTouchPadData;
170 ::ll::TypedStorage<4, 8, ::glm::vec2> mPointerLocationPrevious;
171 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastPointInTime;
172 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mCurrentTime;
173 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mTimeAccumulator;
174 ::ll::TypedStorage<4, 4, ::std::chrono::duration<float, ::std::ratio<1, 1>>
const> mFixedAnimationUpdateRate;
175 ::ll::TypedStorage<4, 4, float> mKeyboardHeight;
176 ::ll::TypedStorage<1, 1, bool> mShouldShowKeyboard;
177 ::ll::TypedStorage<1, 1, bool> mInitKeyboard;
178 ::ll::TypedStorage<4, 4, float> mCurrentObfuscateTime;
179 ::ll::TypedStorage<8, 8, ::KeyboardManager&> mKeyboardManager;
180 ::ll::TypedStorage<8, 24, ::std::vector<::RectangleArea>> mInputAreas;
181 ::ll::TypedStorage<8, 8, ::UIMeasureStrategy&> mMeasureStrategy;
182 ::ll::TypedStorage<1, 1, bool> mCanMoveFocus;
183 ::ll::TypedStorage<1, 1, ::FocusImpact> mNextFocusAction;
184 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::UIControlFactory>> mControlFactory;
185 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mAnimationEvents;
186 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mCustomRendererEvents;
187 ::ll::TypedStorage<4, 8, ::glm::vec2> mStartLocation;
188 ::ll::TypedStorage<4, 4, float> mTimeUntilNextPointerHeldEvent;
189 ::ll::TypedStorage<4, 4, float> mDelayBetweenEachPointerHeldEvent;
190 ::ll::TypedStorage<1, 1, bool> mShouldSendPointerHeldEvents;
191 ::ll::TypedStorage<8, 24, ::std::vector<::ScreenView::DelayedCommand>> mDelayedCommands;
192 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenViewProxy>> mProxy;
193 ::ll::TypedStorage<8, 40, ::std::queue<::std::string, ::std::deque<::std::string>>> mQueuedTextChange;
194 ::ll::TypedStorage<1, 1, bool> mIsExiting;
195 ::ll::TypedStorage<1, 1, bool> mIsEntering;
196 ::ll::TypedStorage<1, 1, bool> mIsInitialized;
197 ::ll::TypedStorage<1, 1, bool> mHasFocus;
198 ::ll::TypedStorage<1, 1, bool> mHasHadFocus;
199 ::ll::TypedStorage<1, 1, bool> mIsTerminating;
200 ::ll::TypedStorage<1, 1, bool> mDirectionalButtonWasPressed;
201 ::ll::TypedStorage<1, 1, bool> mDelayedFocusRefresh;
202 ::ll::TypedStorage<1, 1, ::TextEditFocusedListener> mTextEditFocusedListener;
203 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker>> mScreenLoadTimeTracker;
204 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mFocusChangeSub;
209 ScreenView& operator=(ScreenView
const&);
210 ScreenView(ScreenView
const&);
217 ::KeyboardManager& keyboardManager,
218 ::std::shared_ptr<::ScreenController> controller,
219 ::std::unique_ptr<::VisualTree> visualTree,
220 ::std::shared_ptr<::UIControlFactory> controlFactory,
221 ::UIMeasureStrategy& measureStrategy,
222 ::std::unique_ptr<::LayoutManager> layoutManager,
223 ::GamepadCursorData gamepadCursorData,
224 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
227 MCAPI
void _addToControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
229 MCAPI
void _adjustFocusedControlToScrollRegion(
bool isRightStickScrolling);
231 MCAPI
void _adjustScrollToControl(::UIControl& control);
234 _adjustScrollToFocusedControl(::UIControl& focusedControl,
bool selectNearestControl,
bool isRightStickScrolling);
236 MCAPI
void _adjustScrollToIncludePosition(
238 ::glm::vec2 position,
240 bool isRightStickScrolling
243 MCAPI
void _adjustScrollToTopPosition();
245 MCAPI
void _advanceToNextToggleInNavigationTabGroup(
bool right);
247 MCAPI
void _bindData(
bool doAllBinds);
250 _changeInputControlCollection(::UIControl& control, ::ControlCollectionChange change,
bool isRemoveCallback);
252 MCAPI
void _clearTTSQueue();
254 MCAPI
void _consumeFocusImpact(::FocusImpact focusImpact);
256 MCAPI
void _debugRenderControl(::UIRenderContext& context, ::UIControl
const& control)
const;
258 MCAPI
void _debugRenderFocusControl(
259 ::UIRenderContext& context,
260 ::UIControl
const& control,
261 ::std::vector<::UIControl const*>& visited
264 MCAPI
void _deselectControl(
bool forceDeselect,
bool hoverAfterDeselect);
266 MCAPI
void _executeDelayedCommands(::ScreenView::DelayedCommandLocation location);
268 MCAPI
void _findAndSetFocusOnFocusableControlNotClippedVertical(
269 ::std::shared_ptr<::UIControl> rootControl,
271 bool isRightScrolling
274 MCAPI
void _fireSelectedStateChangeEvent(::TextEditComponent
const& textEditComponent,
bool state);
276 MCAPI
void _fireTextChangedEvent(
278 ::TextCharEventResult result,
281 ::UIPropertyBag* propertyBag
284 MCAPI
void _fireTextChangedEventTextEditControl(
285 ::TextEditComponent
const& textEditComponent,
287 ::TextCharEventResult result
290 MCAPI
void _focusChangeCallback(
291 ::std::weak_ptr<::UIControl> previousFocusControl,
292 ::std::weak_ptr<::UIControl> currentFocusControl
295 MCAPI
void _focusControl(::UIControl& control);
297 MCAPI
void _forwardEventToAnimationControls(::ScreenEvent
const& screenEvent);
299 MCAPI ::std::shared_ptr<::UIControl> _getGamepadCursorFocusedControl()
const;
301 MCAPI ::ScreenSettings
const* _getScreenComponent()
const;
303 MCAPI
void _handleDirtyVisualTree(
bool overrideFocusControl,
bool doAllBinds);
305 MCAPI
void _handlePointerLocation(
306 ::glm::vec2
const& position,
307 ::FocusImpact focusImpact,
308 bool forceHandleWhenMotionless,
309 bool isRightStickScrolling
312 MCAPI
bool _handleScreenViewRefresh();
314 MCAPI
void _handleSliderMovement();
316 MCAPI
void _handleStickScrolling(::DirectionId directionId);
319 _handleTTSOnSliderMovement(::SliderComponent* sliderComponent, ::std::shared_ptr<::UIControl>& focusedControl);
321 MCAPI
bool _hasVisibleAnimationWithEndEventId(uint
id)
const;
323 MCAPI
bool _isFocusable(::FocusComponent
const& focus)
const;
325 MCAPI
bool _isTouchTTSEnabled()
const;
327 MCAPI
bool _notifyLayoutChange();
329 MCAPI
void _passViewCommand();
331 MCAPI
void _prepResevedButtonUpLists(::ScreenInputContext& context);
333 MCAPI
void _processControllerCursorMove(::DirectionId directionId);
335 MCAPI
void _processControllerDirection(::DirectionId directionId);
337 MCAPI
void _processControllerFocusChange(::DirectionId directionId);
339 MCAPI
void _processEvents(::ScreenInputContext& context);
341 MCAPI
void _processQueuedText();
343 MCAPI
void _queueTextToSpeechIfEnabled(
344 ::std::shared_ptr<::UIControl> focusedControl,
345 bool excludeControlHeader,
346 bool notInterruptible
349 MCAPI
void _queueTextToSpeechTextboxCharacter(::std::string
const& inputStr);
351 MCAPI
void _removeFromControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
353 MCAPI
void _renderBatches(::UIRenderContext& context, ::ScreenRenderBatch& screenRenderBatch,
float deltaTime);
355 MCAPI
void _resetFocusedControl();
357 MCAPI
void _scrollToGridItem(::UIControl* gridControl,
int itemIndex,
int numItems);
359 MCAPI
void _selectControl(::UIControl& control,
bool isHandlingTextChar);
361 MCAPI
void _selectNextFocusObject(
362 ::ui::CardinalDirection direction,
364 ::glm::vec2 overridePos,
365 bool isRightStickScrolling
368 MCAPI
void _sendScrollEvent(::UIControl& parent,
float delta)
const;
370 MCAPI
void _setGamepadCursorFocusMode(
bool focusModeEnabled);
372 MCAPI
void _setKeyboardHeight(
float height);
374 MCAPI
void _setupControlFactoryCallbacks();
376 MCAPI
void _switchTabToTargetIndex(::std::vector<::std::shared_ptr<::UIControl>>& tabControls,
int targetIndex);
378 MCAPI
void _update();
380 MCAPI
bool _updateControlCollections(
bool overrideFocusControl);
383 _updateFocusControl(
bool forceUpdate,
bool forceFocusToAdjust,
bool isRightStickScrolling,
bool isHandlingTextChar);
385 MCAPI
void _updateInputAreas();
387 MCAPI
void _updateKeyboardVisibility();
389 MCAPI
bool _updateSelectedControl(::ScreenInputContext& context, uint buttonId, ::ButtonState buttonState);
391 MCAPI
void cleanInputComponents();
393 MCAPI ::std::string getRoute()
const;
395 MCAPI ::std::string getScreenName()
const;
397 MCAPI ::std::string getScreenTelemetryName()
const;
399 MCAPI
void handleButtonEvent(uint buttonId, ::ButtonState buttonState, ::FocusImpact focusImpact);
401 MCAPI
void handleControlEvent(::ScreenEvent screenEvent);
403 MCAPI
void handleDirection(::DirectionId directionId,
float x,
float y, ::FocusImpact focusImpact);
405 MCAPI
void handleInputModeChanged(::InputMode inputMode);
408 handlePointerLocation(::glm::vec2
const& position,
bool forceMotionlessPointer, ::FocusImpact focusImpact);
410 MCAPI
void handleTextChar(::std::string
const& inputUtf8, ::FocusImpact focusImpact);
412 MCAPI
void handleTouchPadTouch(::TouchPadTouchEventData
const& touchEventData, ::FocusImpact focusImpact);
414 MCAPI
bool isGamepadDeflectionModeEnabled()
const;
416 MCAPI
void onFocusGained();
418 MCAPI
void onGameEventNotification(::ui::GameEventNotification notification);
420 MCAPI
void onScreenEntrance(
bool isRevisiting,
bool doScreenTransitions);
422 MCAPI
void onScreenExit(
bool isPopping,
bool doScreenTransitions, ::std::shared_ptr<::AbstractScene> pushedScene);
424 MCAPI
void reload(::Json::Value
const& globalVars);
426 MCAPI
void render(::UIRenderContext& uiRenderContext);
430 MCAPI
void setInitialized();
432 MCAPI
void setScreenLoadTimeTracker(::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker> tracker);
434 MCAPI
void setTextboxText(::std::string
const& text, ::TextboxTextUpdateReason reason);
442 MCAPI
static bool _shouldBindChildren(
bool doAllBinds, ::UIControl& control, ::DataBindingComponent& dataBinding);
448 MCAPI static ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>&
449 mDebugChangePublisher();
451 MCAPI
static bool& sIsDebuggingFocus();
453 MCAPI
static bool& sRenderDebugControls();
460 ::KeyboardManager& keyboardManager,
461 ::std::shared_ptr<::ScreenController> controller,
462 ::std::unique_ptr<::VisualTree> visualTree,
463 ::std::shared_ptr<::UIControlFactory> controlFactory,
464 ::UIMeasureStrategy& measureStrategy,
465 ::std::unique_ptr<::LayoutManager> layoutManager,
466 ::GamepadCursorData gamepadCursorData,
467 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
Definition AbstractScene.h:5
Definition DataBindingComponent.h:5
Definition FocusComponent.h:5
Definition FocusManager.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 SliderComponent.h:5
Definition TextEditComponent.h:5
Definition UIAnimationController.h:5
Definition UIControlFactory.h:5
Definition UIMeasureStrategy.h:5
Definition UIPropertyBag.h:5
Definition UIRenderContext.h:5
Definition VisualTree.h:5
Definition MultiThreaded.h:7
Definition ITTSEventManager.h:5
Definition ScreenEvent.h:5
Definition ScreenView.h:18
Definition ScreenView.h:16
Definition TouchPadTouchEventData.h:5