3#include "mc/_HeaderOutputPredefine.h"
6#include "mc/client/gui/ChildInsertPosition.h"
7#include "mc/client/gui/NameResolutionScope.h"
8#include "mc/client/gui/VisibilityFlag.h"
9#include "mc/client/gui/controls/ComponentReceiveActionType.h"
10#include "mc/deps/core/math/Vec2.h"
11#include "mc/platform/brstd/function_ref.h"
28class UIControl :
public ::std::enable_shared_from_this<::UIControl> {
40 ::ll::TypedStorage<8, 32, ::std::string> targetControlName;
41 ::ll::TypedStorage<4, 4, ::ui::NameResolutionScope> scope;
42 ::ll::TypedStorage<8, 64, ::std::function<void(::UIControl&, ::std::shared_ptr<::UIControl>)>> setter;
47 ControlResolutionInfo& operator=(ControlResolutionInfo
const&);
48 ControlResolutionInfo();
53 MCAPI ControlResolutionInfo(::UIControl::ControlResolutionInfo
const&);
55 MCAPI ControlResolutionInfo(
56 ::std::string
const& aTargetControlName,
57 ::ui::NameResolutionScope aScope,
58 ::std::function<
void(::UIControl&, ::std::shared_ptr<::UIControl>)> aSetter
65 MCFOLD
void* $ctor(::UIControl::ControlResolutionInfo
const&);
68 ::std::string
const& aTargetControlName,
69 ::ui::NameResolutionScope aScope,
70 ::std::function<
void(::UIControl&, ::std::shared_ptr<::UIControl>)> aSetter
75 using CompIdType = uint64;
77 using NameResolverFunc = ::std::function<void(::UIControl&, ::std::shared_ptr<::UIControl>)>;
79 using PostCreateFunc = ::std::function<void(::UIControl&)>;
84 ::ll::TypedStorage<4, 8, ::glm::vec2> mCachedPosition;
85 bool mCachedPositionDirty : 1;
87 ::ui::VisibilityFlag mVisible : 2;
88 bool mIsVisibleInTree : 1;
90 bool mAllAncestorsEnabled : 1;
92 bool mClipsChildren : 1;
93 bool mAllowClipping : 1;
95 bool mEnableClippingScissorTest : 1;
97 bool mPropagateAlpha : 1;
98 bool mDelayCollectionUpdate : 1;
99 bool mTextToSpeechTriggered : 1;
100 ::ll::TypedStorage<2, 2, ushort> mControlCollectionFlag;
101 ::ll::TypedStorage<8, 32, ::std::string> mName;
102 ::ll::TypedStorage<4, 8, ::glm::vec2> mParentRelativePosition;
103 ::ll::TypedStorage<4, 8, ::glm::vec2> mSize;
104 ::ll::TypedStorage<4, 8, ::glm::vec2> mMinSize;
105 ::ll::TypedStorage<4, 8, ::glm::vec2> mMaxSize;
106 ::ll::TypedStorage<4, 4, float> mAlpha;
107 ::ll::TypedStorage<4, 4, int> mZOrder;
108 ::ll::TypedStorage<4, 4, int> mLayer;
109 ::ll::TypedStorage<4, 8, ::Vec2> mClipOffset;
110 ::ll::TypedStorage<4, 4, uint> mClipChangeEventId;
111 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIPropertyBag>> mPropertyBag;
112 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::UIPropertyBag>> mPropertyBagToPropagateToChildren;
113 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mParent;
114 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::UIControl>>> mChildren;
115 ::ll::TypedStorage<8, 8, uint64> mComponentsInUse;
116 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::UIComponent>>> mComponents;
117 ::ll::TypedStorage<8, 24, ::std::vector<::RenderableComponent*>> mRenderableComponentLookup;
118 ::ll::TypedStorage<8, 24, ::std::vector<::CustomFrameUpdateComponent*>> mCustomFrameUpdateComponentLookup;
119 ::ll::TypedStorage<8, 24, ::std::vector<::UIControl::ControlResolutionInfo>> mControlResolvers;
120 ::ll::TypedStorage<8, 24, ::std::vector<::std::function<void(::UIControl&)>>> mPostCreateVector;
121 ::ll::TypedStorage<8, 8, ::ControlScreenAction&> mControlScreenAction;
122 ::ll::TypedStorage<8, 16, ::std::weak_ptr<::UIControl>> mModalAncestor;
127 UIControl& operator=(UIControl
const&);
128 UIControl(UIControl
const&);
134 MCAPI
explicit UIControl(::ControlScreenAction& controlScreenAction);
136 MCAPI uint _getComponentIndexFromBitId(uint64 bitId)
const;
138 MCAPI
void _propagateLockStateChange(
bool broadcastEvent);
140 MCAPI
void _registerControlNameResolver(
141 ::std::string
const& controlName,
142 ::ui::NameResolutionScope scope,
143 ::std::function<
void(::UIControl&, ::std::shared_ptr<::UIControl>)> setter
146 MCAPI
void _registerPostCreateCallback(::std::function<
void(::UIControl&)> setter);
148 MCAPI
void _resolveControlNames(::UIControl& rootControl);
150 MCAPI
void _resolvePostCreate();
152 MCAPI
void _setCachedPosition()
const;
154 MCAPI
void _setPositionDirty();
157 _setVisible(::ui::VisibilityFlag visibleFlags,
bool setLayoutChangedFlag,
bool doLayout,
bool shrinkInvisible);
159 MCAPI
void addChild(::std::shared_ptr<::UIControl> child, ::ui::ChildInsertPosition childInsertPosition);
161 MCAPI
void addControlCollectionFlag(ushort flag);
163 MCAPI
void appendPropertyBag(::UIPropertyBag
const& propertyBag);
165 MCAPI
bool areAllAncestorsEnabled()
const;
167 MCAPI ::ComponentReceiveActionType broadcastEvent(::UIComponent* sender, ::ScreenEvent
const& screenEvent);
169 MCAPI ::ComponentReceiveActionType broadcastEvent(
170 ::VisualTree& visualTree,
171 ::ScreenInputContext& context,
172 ::UIAnimationController& animationController,
173 ::UIComponent* sender,
174 ::ScreenEvent
const& screenEvent
177 MCAPI
bool canBeFocused()
const;
179 MCAPI
bool changeClipState(
bool clipped);
181 MCAPI
void clearControlCollectionFlag();
183 MCAPI ::std::shared_ptr<::UIControl> clone(::UIControl* parent)
const;
185 MCAPI
bool containsPoint(::glm::vec2
const& point)
const;
187 MCAPI
void findAllCollectionIndices(::brstd::function_ref<
void(::std::string
const&,
int)> callback);
189 MCAPI
int findCollectionIndex(::std::string
const& collectionName)
const;
191 MCAPI
void foreachRenderableComponents(::brstd::function_ref<
void(::RenderableComponent&)> predicate)
const;
193 MCAPI ::RectangleArea getAABB()
const;
195 MCAPI
bool getAllowClipping()
const;
197 MCFOLD
float getAlpha()
const;
199 MCAPI ::std::shared_ptr<::UIControl> getAncestorWhere(::brstd::function_ref<
bool(::UIControl
const&)> predicate);
201 MCFOLD ::std::vector<::std::shared_ptr<::UIControl const>>
const& getChildren()
const;
203 MCFOLD ::std::vector<::std::shared_ptr<::UIControl>>
const& getChildren();
205 MCFOLD uint getClipChangeEventId()
const;
207 MCAPI ::Vec2 getClipOffset()
const;
209 MCAPI
bool getClipState()
const;
211 MCAPI
bool getClipsChildren()
const;
213 MCAPI
bool getDelayCollectionUpdate()
const;
215 MCAPI
bool getEnableScissorTestForClipping()
const;
217 MCAPI
bool getEnabled()
const;
219 MCAPI
bool getHover()
const;
221 MCFOLD
int getLayer()
const;
223 MCFOLD ::glm::vec2
const& getMaxSize()
const;
225 MCFOLD ::glm::vec2
const& getMinSize()
const;
227 MCAPI ::std::shared_ptr<::UIControl> getModalAncestor();
229 MCAPI ::std::weak_ptr<::UIControl> getModalAncestorWeak();
231 MCFOLD ::std::string
const& getName()
const;
233 MCAPI ::std::shared_ptr<::UIControl const> getParent()
const;
235 MCAPI ::std::shared_ptr<::UIControl> getParent();
237 MCFOLD ::glm::vec2
const& getParentRelativePosition()
const;
239 MCAPI ::std::string
const getPathedName()
const;
241 MCAPI ::glm::vec2
const& getPosition()
const;
243 MCFOLD ::UIPropertyBag
const& getPropertyBag()
const;
245 MCFOLD ::UIPropertyBag& getPropertyBag();
247 MCAPI ::UIPropertyBag
const& getPropertyBagForChildren()
const;
249 MCFOLD ::ControlScreenAction& getScreenAction(
bool usingForCreation);
251 MCAPI
bool getSelected()
const;
253 MCFOLD ::glm::vec2
const& getSize()
const;
255 MCAPI
bool getVisible()
const;
257 MCFOLD
int getZOrder()
const;
259 MCAPI
bool hasClipChangeEvent()
const;
261 MCAPI
bool hasControlCollectionFlag(ushort flag)
const;
263 MCFOLD
bool hasPropertyBag()
const;
265 MCAPI
bool hasRenderableComponent()
const;
267 MCAPI
bool isTemplate()
const;
269 MCAPI
bool isVisibleInTree()
const;
271 MCAPI
void markToRemoveDeadDependencies();
273 MCAPI ::std::shared_ptr<::UIControl> moveChild(
int index,
bool notify);
275 MCAPI
void notifyBindingsUpdated(
276 ::std::vector<::std::string> controlList,
277 ::std::string propertyName,
282 MCAPI
void notifyChildAdded();
284 MCAPI
bool notifyLayoutChange();
286 MCAPI
void onAdded();
288 MCAPI
void popBackChild();
290 MCAPI
void popFrontChild();
292 MCAPI
void processPropertyBags(
293 ::std::unique_ptr<::UIPropertyBag> propertyBag,
294 ::std::unique_ptr<::UIPropertyBag> propertyBagForChildren
297 MCAPI
bool propagateAlpha()
const;
299 MCAPI
void propogateAlphaValue(
float alpha)
const;
301 MCAPI
void reloadFromControl(::UIControl
const& control);
303 MCAPI
bool removeChild(::std::shared_ptr<::UIControl> control);
305 MCAPI
void removeControlCollectionFlag(ushort flag);
307 MCAPI
bool removeParentByName(::std::string
const& name);
309 MCAPI
void reset(
bool recursive,
bool shouldClearCollectionFlag);
311 MCAPI
void setAlpha(
float alpha);
313 MCAPI
void setDelayCollectionUpdate(
bool delay);
315 MCAPI
void setEnabled(
bool enabled,
bool broadcastEvent);
317 MCAPI
void setHover(
bool hover);
319 MCAPI
void setIsTemplate(
bool isTemplate);
321 MCFOLD
void setMaxSize(::glm::vec2
const& size);
323 MCAPI
void setMinSize(::glm::vec2
const& size);
325 MCAPI
void setModalAncestor(::std::weak_ptr<::UIControl> control);
327 MCAPI
void setName(::std::string_view name);
329 MCAPI
void setParentRelativePosition(::glm::vec2
const& position);
331 MCAPI
void setPropagateAlpha(
bool propagateAlpha);
333 MCAPI
void setPropertyBag(::std::unique_ptr<::UIPropertyBag> propertyBag);
335 MCAPI
void setPropertyBagForChildren(::std::unique_ptr<::UIPropertyBag> propertyBag);
337 MCAPI
void setSelected(
bool selected);
339 MCAPI
void setSize(::glm::vec2
const& size);
341 MCAPI
void setTextToSpeechTriggered(
bool value);
343 MCAPI
void setVisible(
bool visible,
bool setLayoutChangedFlag,
bool doLayout);
345 MCAPI
void setVisibleInStackPanel(
bool visible,
bool setLayoutChangedFlag,
bool doLayout);
347 MCAPI
void setVisibleInTree(
bool visible);
349 MCAPI
void setZOrder(
int zOrder);
351 MCAPI
void updateFrameUpdateComponents(::UIFrameUpdateContext& context);
353 MCFOLD ::std::weak_ptr<::UIControl> weakRef();
361 MCAPI
void* $ctor(::ControlScreenAction& controlScreenAction);
Definition ControlScreenAction.h:5
Definition CustomFrameUpdateComponent.h:5
Definition RectangleArea.h:5
Definition RenderableComponent.h:5
Definition ScreenInputContext.h:5
Definition UIAnimationController.h:5
Definition UIComponent.h:5
Definition UIFrameUpdateContext.h:5
Definition UIPropertyBag.h:5
Definition VisualTree.h:5
Definition ScreenEvent.h:5
Definition UIControl.h:13