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/ScreenEvent.h"
14#include "mc/client/gui/screens/TextEditFocusedListener.h"
15#include "mc/deps/core/utility/NonOwnerPointer.h"
16#include "mc/deps/core/utility/pub_sub/Publisher.h"
17#include "mc/deps/core/utility/pub_sub/Subscription.h"
18#include "mc/deps/input/InputMode.h"
19#include "mc/deps/input/TextboxTextUpdateReason.h"
20#include "mc/deps/input/enums/ButtonState.h"
21#include "mc/deps/input/enums/DirectionId.h"
22#include "mc/deps/input/enums/FocusImpact.h"
23#include "mc/deps/input/enums/RawInputType.h"
54namespace Bedrock::PubSub::ThreadModel {
struct MultiThreaded; }
55namespace Json {
class Value; }
67 enum class DelayedCommandLocation :
int {
75 using Result = ::std::pair<::ui::DirtyFlag, bool>;
80 ::ll::TypedStorage<8, 64, ::std::function<::std::pair<::ui::DirtyFlag, bool>()>> mAction;
81 ::ll::TypedStorage<4, 4, ::ScreenView::DelayedCommandLocation> location;
89 ::ll::TypedStorage<4, 4, int> mTouchId;
90 ::ll::TypedStorage<4, 8, ::glm::vec2> mPreviousPosition;
91 ::ll::TypedStorage<4, 8, ::glm::vec2> mCurrentPosition;
95 using clock_type = ::std::chrono::steady_clock;
97 using duration_sec = ::std::chrono::duration<float, ::std::ratio<1, 1>>;
102 ::ll::TypedStorage<4, 4, float> mLastTime;
103 ::ll::TypedStorage<4, 4, float> mTickTime;
104 ::ll::TypedStorage<8, 8, double> mLastRawJoystickEventTime;
105 ::ll::TypedStorage<4, 8, ::glm::vec2> mSize;
106 ::ll::TypedStorage<4, 4, int> mMenuUpButtonId;
107 ::ll::TypedStorage<4, 4, int> mMenuDownButtonId;
108 ::ll::TypedStorage<4, 4, int> mMenuLeftButtonId;
109 ::ll::TypedStorage<4, 4, int> mMenuRightButtonId;
110 ::ll::TypedStorage<4, 4, int> mMenuTabLeftButtonId;
111 ::ll::TypedStorage<4, 4, int> mMenuTabRightButtonId;
112 ::ll::TypedStorage<4, 8, ::std::array<uint, 2>> mPointerButtonIds;
113 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScreenController>> mController;
114 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::VisualTree>> mVisualTree;
115 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysBindControls;
116 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mInputControls;
117 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mScrollViewControls;
118 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mOutOfModalScopeScrollViewControls;
119 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAnimationControls;
120 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFactoryControls;
121 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mTextEditBoxControls;
122 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mAlwaysListeningInputControls;
123 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mRenderableControls;
124 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mFlyingItemRendererControls;
125 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mSliderControls;
126 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomRendererControls;
127 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mCustomFrameUpdateControls;
131 ::std::map<::std::vector<::std::shared_ptr<::UIControl>>*, ::std::vector<::std::shared_ptr<::UIControl>>>>
133 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenRenderBatch>> mRootRenderBatch;
134 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIAnimationController>> mAnimationController;
135 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint, ::std::vector<::std::weak_ptr<::UIControl>>>>
136 mReservedButtonUpEvents;
137 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mSelectedControl;
138 ::ll::TypedStorage<4, 4, ::InputMode> mInputMode;
139 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LayoutManager>> mLayoutManager;
140 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::FocusManager>> mFocusManager;
141 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::ITTSEventManager>> mTTSEventManager;
142 ::ll::TypedStorage<1, 1, bool> mTextToSpeechEnabled;
143 ::ll::TypedStorage<8, 32, ::std::string> mTTSSectionHeader;
144 ::ll::TypedStorage<4, 4, float> mCurrentSliderValue;
145 ::ll::TypedStorage<1, 1, bool> mIsGUIScaleSlider;
146 ::ll::TypedStorage<8, 64, ::std::unordered_map<int, ::ui::CardinalDirection>> mControllerStickDirections;
147 ::ll::TypedStorage<4, 4, int> mControllerLastMoved;
148 ::ll::TypedStorage<4, 4, int> mCursorTick;
149 ::ll::TypedStorage<4, 4, float const> mControllerXThreshold;
150 ::ll::TypedStorage<4, 4, float const> mControllerYThreshold;
151 ::ll::TypedStorage<4, 72, ::glm::vec2[9]> mControllerStickValues;
152 ::ll::TypedStorage<4, 8, ::GamepadCursorData> mGamepadCursorData;
153 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadCursorPosition;
154 ::ll::TypedStorage<1, 1, bool> mHasSetInitialPosition;
155 ::ll::TypedStorage<1, 1, bool> mGamepadCursorFocusModeEnabled;
156 ::ll::TypedStorage<1, 1, bool> mGamepadCursorMagnetEnabled;
157 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mGamepadMagnetControl;
158 ::ll::TypedStorage<4, 4, float> mGamepadMoveTime;
159 ::ll::TypedStorage<4, 8, ::glm::vec2> mGamepadTrackedDirection;
160 ::ll::TypedStorage<1, 1, bool> mGamepadHasTapped;
161 ::ll::TypedStorage<4, 20, ::ScreenView::TouchPadData> mTouchPadData;
162 ::ll::TypedStorage<4, 8, ::glm::vec2> mPointerLocationPrevious;
163 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastPointInTime;
164 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mCurrentTime;
165 ::ll::TypedStorage<8, 8, ::std::chrono::nanoseconds> mTimeAccumulator;
166 ::ll::TypedStorage<4, 4, ::std::chrono::duration<float, ::std::ratio<1, 1>>
const> mFixedAnimationUpdateRate;
167 ::ll::TypedStorage<4, 4, float> mKeyboardHeight;
168 ::ll::TypedStorage<1, 1, bool> mShouldShowKeyboard;
169 ::ll::TypedStorage<1, 1, bool> mInitKeyboard;
170 ::ll::TypedStorage<4, 4, float> mCurrentObfuscateTime;
171 ::ll::TypedStorage<8, 8, ::KeyboardManager&> mKeyboardManager;
172 ::ll::TypedStorage<8, 24, ::std::vector<::RectangleArea>> mInputAreas;
173 ::ll::TypedStorage<8, 8, ::UIMeasureStrategy&> mMeasureStrategy;
174 ::ll::TypedStorage<1, 1, bool> mCanMoveFocus;
175 ::ll::TypedStorage<1, 1, ::FocusImpact> mNextFocusAction;
176 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::UIControlFactory>> mControlFactory;
177 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mAnimationEvents;
178 ::ll::TypedStorage<8, 40, ::std::queue<::ScreenEvent, ::std::deque<::ScreenEvent>>> mCustomRendererEvents;
179 ::ll::TypedStorage<4, 8, ::glm::vec2> mStartLocation;
180 ::ll::TypedStorage<4, 4, float> mTimeUntilNextPointerHeldEvent;
181 ::ll::TypedStorage<4, 4, float> mDelayBetweenEachPointerHeldEvent;
182 ::ll::TypedStorage<1, 1, bool> mShouldSendPointerHeldEvents;
183 ::ll::TypedStorage<8, 24, ::std::vector<::ScreenView::DelayedCommand>> mDelayedCommands;
184 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ScreenViewProxy>> mProxy;
185 ::ll::TypedStorage<8, 40, ::std::queue<::std::string, ::std::deque<::std::string>>> mQueuedTextChange;
186 ::ll::TypedStorage<1, 1, bool> mIsExiting;
187 ::ll::TypedStorage<1, 1, bool> mIsEntering;
188 ::ll::TypedStorage<1, 1, bool> mIsInitialized;
189 ::ll::TypedStorage<1, 1, bool> mHasFocus;
190 ::ll::TypedStorage<1, 1, bool> mHasHadFocus;
191 ::ll::TypedStorage<1, 1, bool> mIsTerminating;
192 ::ll::TypedStorage<1, 1, bool> mDirectionalButtonWasPressed;
193 ::ll::TypedStorage<1, 1, bool> mDelayedFocusRefresh;
194 ::ll::TypedStorage<1, 1, ::TextEditFocusedListener> mTextEditFocusedListener;
195 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker>> mScreenLoadTimeTracker;
196 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mFocusChangeSub;
201 ScreenView& operator=(ScreenView
const&);
202 ScreenView(ScreenView
const&);
209 ::KeyboardManager& keyboardManager,
210 ::std::shared_ptr<::ScreenController> controller,
211 ::std::unique_ptr<::VisualTree> visualTree,
212 ::std::shared_ptr<::UIControlFactory> controlFactory,
213 ::UIMeasureStrategy& measureStrategy,
214 ::std::unique_ptr<::LayoutManager> layoutManager,
215 ::GamepadCursorData gamepadCursorData,
216 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
219 MCAPI
void _addToControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
221 MCAPI
void _adjustFocusedControlToScrollRegion(
bool isRightStickScrolling);
223 MCAPI
void _adjustScrollToControl(::UIControl& control);
226 _adjustScrollToFocusedControl(::UIControl& focusedControl,
bool selectNearestControl,
bool isRightStickScrolling);
228 MCAPI
void _adjustScrollToTopPosition();
230 MCAPI
void _advanceToNextTab(
bool right);
232 MCAPI
void _advanceToNextToggleInNavigationTabGroup(
bool right);
234 MCAPI
void _bindAlwaysBinds();
236 MCAPI
void _bindData(
bool doAllBinds);
239 _changeInputControlCollection(::UIControl& control, ::ControlCollectionChange change,
bool isRemoveCallback);
241 MCAPI
void _debugRenderControl(::UIRenderContext& context, ::UIControl
const& control)
const;
243 MCAPI
void _debugRenderFocusControl(
244 ::UIRenderContext& context,
245 ::UIControl
const& control,
246 ::std::vector<::UIControl const*>& visited
249 MCAPI
void _deselectControl(
bool forceDeselect,
bool hoverAfterDeselect);
251 MCAPI
void _executeDelayedCommands(::ScreenView::DelayedCommandLocation location);
253 MCAPI
void _findAndSetFocusOnFocusableControlNotClippedVertical(
254 ::std::shared_ptr<::UIControl> rootControl,
256 bool isRightScrolling
259 MCAPI ::std::shared_ptr<::UIControl> _findModalRootControl()
const;
261 MCAPI
void _fireSelectedStateChangeEvent(::TextEditComponent
const& textEditComponent,
bool state);
263 MCAPI
void _fireTextChangedEvent(
265 ::TextCharEventResult result,
268 ::UIPropertyBag* propertyBag
271 MCAPI
void _focusChangeCallback(
272 ::std::weak_ptr<::UIControl> previousFocusControl,
273 ::std::weak_ptr<::UIControl> currentFocusControl
276 MCAPI
void _forwardEventToAnimationControls(::ScreenEvent
const& screenEvent);
278 MCAPI ::std::shared_ptr<::UIControl> _getGamepadCursorFocusedControl()
const;
280 MCAPI ::ScreenSettings
const* _getScreenComponent()
const;
282 MCAPI
void _handleDirtyVisualTree(
bool overrideFocusControl,
bool doAllBinds);
284 MCAPI
void _handlePointerLocation(
285 ::glm::vec2
const& position,
286 ::FocusImpact focusImpact,
287 bool forceHandleWhenMotionless,
288 bool isRightStickScrolling
291 MCAPI
bool _handleScreenViewRefresh();
293 MCAPI
void _handleSliderMovement();
295 MCAPI
void _handleStickScrolling(::DirectionId directionId);
298 _handleTTSOnSliderMovement(::SliderComponent* sliderComponent, ::std::shared_ptr<::UIControl>& focusedControl);
300 MCAPI
bool _hasAnimationWithPlayAndEndEventId(uint playEventId, uint endEventId)
const;
302 MCAPI
bool _hasVisibleAnimationWithEndEventId(uint
id)
const;
304 MCAPI
bool _isFocusEnabled(::std::shared_ptr<::UIControl>
const& control)
const;
306 MCAPI
bool _isFocusMagnetEnabled(::std::shared_ptr<::UIControl>
const& control)
const;
308 MCAPI
bool _isFocusable(::FocusComponent
const& focus)
const;
310 MCAPI
void _passViewCommand();
312 MCAPI
void _prepResevedButtonUpLists(::ScreenInputContext& context);
314 MCAPI
void _processControllerCursorDeflectionMove(::DirectionId directionId);
316 MCAPI
void _processControllerCursorMove(::DirectionId directionId);
318 MCAPI
void _processControllerDirection(::DirectionId directionId);
320 MCAPI
void _processControllerFocusChange(::DirectionId directionId);
322 MCAPI
void _processEvents(::ScreenInputContext& context);
324 MCAPI
void _processQueuedText();
326 MCAPI
void _queueTextToSpeechIfEnabled(
327 ::std::shared_ptr<::UIControl> focusedControl,
328 bool excludeControlHeader,
329 bool notInterruptible
332 MCAPI
void _queueTextToSpeechTextboxCharacter(::std::string
const& inputStr);
334 MCAPI
void _removeFromControlCollection(::UIControl& control, ::ControlCollectionFlag flag);
336 MCAPI
void _renderBatches(::UIRenderContext& context, ::ScreenRenderBatch& screenRenderBatch,
float deltaTime);
338 MCAPI
void _resetFocusedControl();
340 MCAPI
void _resetInputControl(::UIControl& control, ::InputComponent*
const inputComponent,
bool handleModalChange);
342 MCAPI
void _scrollToGridItem(::UIControl* gridControl,
int itemIndex,
int numItems);
344 MCAPI
void _selectControl(::UIControl& control,
bool isHandlingTextChar);
346 MCAPI
void _selectNextFocusObject(
347 ::ui::CardinalDirection direction,
349 ::glm::vec2 overridePos,
350 bool isRightStickScrolling
353 MCAPI
void _selectNextFocusObjectFromButtonPress(
354 ::ui::CardinalDirection direction,
356 ::glm::vec2 overridePos
359 MCAPI
void _sendPointerHeldEvents();
361 MCAPI
void _sendScrollEvent(::UIControl& parent,
float delta)
const;
363 MCAPI
void _setGamepadCursorFocusMode(
bool focusModeEnabled);
365 MCAPI
void _setKeyboardHeight(
float height);
367 MCAPI
void _setupControlFactoryCallbacks();
369 MCAPI
void _switchTabToTargetIndex(::std::vector<::std::shared_ptr<::UIControl>>& tabControls,
int targetIndex);
371 MCAPI
void _update();
373 MCAPI
bool _updateControlCollections(
bool);
375 MCAPI
void _updateFocusActivationState();
378 _updateFocusControl(
bool forceUpdate,
bool forceFocusToAdjust,
bool isRightStickScrolling,
bool isHandlingTextChar);
380 MCAPI
void _updateInputAreas();
382 MCAPI
void _updateKeyboardVisibility();
384 MCAPI
bool _updateSelectedControl(::ScreenInputContext& context, uint buttonId, ::ButtonState buttonState);
386 MCAPI
void cleanInputComponents();
388 MCAPI ::RectangleArea getAreaOfControlByName(::std::string
const& controlName)
const;
390 MCAPI ::std::string getRawScreenName()
const;
392 MCAPI ::std::string getRoute()
const;
394 MCAPI ::std::string getScreenName()
const;
396 MCAPI ::std::string getScreenTelemetryName()
const;
398 MCAPI
void handleButtonEvent(uint buttonId, ::ButtonState buttonState, ::FocusImpact focusImpact);
400 MCAPI
void handleControlEvent(::ScreenEvent screenEvent);
402 MCAPI
void handleDirection(::DirectionId directionId,
float x,
float y, ::FocusImpact focusImpact);
404 MCAPI
void handleInputModeChanged(::InputMode inputMode);
407 handlePointerLocation(::glm::vec2
const& position,
bool forceMotionlessPointer, ::FocusImpact focusImpact);
409 MCAPI
void handleRawInputEvent(
int id, ::RawInputType keyType, ::ButtonState state,
bool allowRemapping);
411 MCAPI
void handleTextChar(::std::string
const& inputUtf8, ::FocusImpact focusImpact);
413 MCAPI
void handleTouchPadTouch(::TouchPadTouchEventData
const& touchEventData, ::FocusImpact focusImpact);
415 MCAPI
bool isGamepadDeflectionModeEnabled()
const;
417 MCAPI
void onDelete(::CachedScenes& cache, ::TaskGroup& taskGroup);
419 MCAPI
void onFocusGained();
421 MCAPI
void onFocusLost();
423 MCAPI
void onGameEventNotification(::ui::GameEventNotification notification);
425 MCAPI
void onLeave();
427 MCAPI
void onScreenEntrance(
bool isRevisiting,
bool doScreenTransitions);
429 MCAPI
void onScreenExit(
bool isPopping,
bool doScreenTransitions, ::std::shared_ptr<::AbstractScene> pushedScene);
431 MCAPI
void reload(::Json::Value
const& globalVars);
433 MCAPI
void render(::UIRenderContext& uiRenderContext);
437 MCAPI
void sendManualInputEvent(::std::string
const& eventName);
439 MCAPI
void setInitialized();
441 MCAPI
void setScreenLoadTimeTracker(::Bedrock::NonOwnerPointer<::ScreenLoadTimeTracker> tracker);
443 MCAPI
void setShouldSendEvents(
bool shouldSendEvents);
445 MCAPI
void setTextboxText(::std::string
const& text, ::TextboxTextUpdateReason reason);
453 MCAPI
static bool _shouldBindChildren(
bool doAllBinds, ::UIControl& control, ::DataBindingComponent& dataBinding);
455 MCAPI
static bool isDebugRendering();
457 MCAPI
static bool isDebuggingFocus();
459 MCAPI
static void setDebugFocus(
bool debugFocus);
461 MCAPI
static void setDebugRendering(
bool isDebugRendering);
463 MCAPI static ::Bedrock::PubSub::Subscription subscribeForDebugChanges(::std::function<
void()> callback);
469 MCAPI static ::Bedrock::PubSub::Publisher<void(), ::Bedrock::PubSub::ThreadModel::MultiThreaded, 0>&
470 mDebugChangePublisher();
472 MCAPI
static bool& sIsDebuggingFocus();
474 MCAPI
static bool& sRenderDebugControls();
481 ::KeyboardManager& keyboardManager,
482 ::std::shared_ptr<::ScreenController> controller,
483 ::std::unique_ptr<::VisualTree> visualTree,
484 ::std::shared_ptr<::UIControlFactory> controlFactory,
485 ::UIMeasureStrategy& measureStrategy,
486 ::std::unique_ptr<::LayoutManager> layoutManager,
487 ::GamepadCursorData gamepadCursorData,
488 ::std::weak_ptr<::ITTSEventManager> ttsEventManager
Definition AbstractScene.h:5
Definition CachedScenes.h:5
Definition DataBindingComponent.h:5
Definition FocusComponent.h:5
Definition FocusManager.h:5
Definition ITTSEventManager.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 TaskGroup.h:55
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 ScreenView.h:18
Definition ScreenView.h:16
Definition TouchPadTouchEventData.h:5