15#include <AUI/View/AView.h>
16#include "AUI/Common/SharedPtr.h"
17#include "AUI/Enum/AOverflow.h"
18#include "AUI/Util/ABitField.h"
20#include "AUI/Layout/ALayout.h"
21#include "AUI/Common/AVector.h"
22#include "AUI/Render/IRenderer.h"
23#include "AUI/Render/RenderHints.h"
24#include "AUI/Render/ARenderContext.h"
34 IGNORE_VISIBILITY = 0b1,
42 ONLY_ONE_PER_CONTAINER = 0b10,
50 ONLY_THAT_CONSUMES_CLICK = 0b100,
79 bool isBlockClicksWhenPressed =
true;
90 void onMouseEnter()
override;
94 void onMouseLeave()
override;
96 void onDpiChanged()
override;
112 bool onGesture(
const glm::ivec2& origin,
const AGestureEvent& event)
override;
116 void setSize(glm::ivec2 size)
override;
118 void setEnabled(
bool enabled =
true)
override;
121 return mViews.cbegin();
125 return mViews.cend();
173 template<aui::predicate<_<AView>> Callback>
176 auto process = [&](
const _<AView>& view) {
179 if (
auto container = _cast<AViewContainerBase>(view)) {
180 if (container->getViewAtRecursive(pos - view->getPosition(), callback, flags)) {
188 auto targetPos = pos - view->getPosition();
190 if (targetPos.x < 0 || targetPos.y < 0 || targetPos.x >= view->getSize().x || targetPos.y >= view->getSize().y) {
193 if (!flags.test(AViewLookupFlags::IGNORE_VISIBILITY) && !(view->getVisibility() & Visibility::FLAG_CONSUME_CLICKS)) {
197 if (view->consumesClick(targetPos)) {
198 if (flags.test(AViewLookupFlags::IGNORE_VISIBILITY) || !!(view->getVisibility() & Visibility::FLAG_CONSUME_CLICKS)) {
203 if (flags.test(AViewLookupFlags::ONLY_ONE_PER_CONTAINER)) {
208 if (possibleOutput ==
nullptr) {
209 possibleOutput = view;
213 if (possibleOutput) {
214 return process(possibleOutput);
226 template<aui::predicate<_<AView>> Callback>
228 for (
auto it = mViews.rbegin(); it != mViews.rend(); ++it) {
230 if (flags.test(AViewLookupFlags::IGNORE_VISIBILITY) || !!(view->getVisibility() & Visibility::FLAG_CONSUME_CLICKS)) {
233 if (
auto container = _cast<AViewContainerBase>(view)) {
234 if (container->visitsViewRecursive(callback, flags)) {
238 if (flags.test(AViewLookupFlags::ONLY_ONE_PER_CONTAINER)) {
256 getViewAtRecursive(pos, [&] (
const _<AView>& v) {
return bool(result = _cast<T>(v)); }, flags);
267 if (
auto v = target.lock()) {
270 mFocusChainTarget = std::move(target);
278 if (
auto v = mFocusChainTarget.lock()) {
279 if (v->mParent !=
this) {
280 mFocusChainTarget.reset();
289 void applyGeometryToChildrenIfNecessary();
291 void onKeyDown(AInput::Key key)
override;
293 void onKeyRepeat(AInput::Key key)
override;
295 void onKeyUp(AInput::Key key)
override;
297 void onCharEntered(char16_t c)
override;
305 return mPointerEventsMapping;
308 void forceUpdateLayoutRecursively()
override;
310 void markMinContentSizeInvalid()
override;
315 bool mWantsLayoutUpdate =
true;
316 glm::ivec2 mLastLayoutUpdateSize{0, 0};
320 template<
typename Iterator>
321 void drawViews(Iterator begin, Iterator end,
ARenderContext contextPassedToContainer) {
332 for (
auto i = begin; i != end; ++i) {
333 drawView(*i, contextPassedToContainer);
353 void addViewCustomLayout(
const _<AView>& view);
368 void addView(
size_t index,
const _<AView>& view);
373 void removeView(
const _<AView>& view);
378 void removeView(
AView* view);
383 void removeView(
size_t index);
388 void removeAllViews();
399 void setLayout(_unique<ALayout> layout);
402 drawViews(mViews.begin(), mViews.end(), contextPassedToContainer);
405 virtual void applyGeometryToChildren();
414 _unique<ALayout> mLayout;
415 bool mSizeSet =
false;
419 bool triggered =
false;
423 struct ConsumesClickCache {
450 void notifyParentEnabledStateChanged(
bool enabled)
override;
451 void invalidateCaches();
Bit field implementation.
Definition: ABitField.h:20
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition: AOptional.h:32
Wrapper class that stores either mouse button index or finger index.
Definition: APointerIndex.h:21
Vector-like container consisting of few elements on stack and switches to dynamic allocation vector i...
Definition: ASmallVector.h:34
A std::vector with AUI extensions.
Definition: AVector.h:38
A view that represents a set of views.
Definition: AViewContainerBase.h:68
void setFocusChainTarget(_weak< AView > target)
Set focus chain target.
Definition: AViewContainerBase.h:266
bool getViewAtRecursive(glm::ivec2 pos, const Callback &callback, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE)
Acts as AViewContainerBase::getViewAtRecursive but calls a callback instead of returning value.
Definition: AViewContainerBase.h:174
emits childrenChanged
Emitted when addView(s)/removeView/setLayout was called.
Definition: AViewContainerBase.h:411
const _unique< ALayout > & getLayout() const noexcept
Get layout manager of the container.
Definition: AViewContainerBase.h:140
bool visitsViewRecursive(Callback &&callback, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE)
Definition: AViewContainerBase.h:227
_< AView > focusChainTarget()
Definition: AViewContainerBase.h:277
const ASmallVector< PointerEventsMapping, 1 > & pointerEventsMapping() const noexcept
Definition: AViewContainerBase.h:304
_< T > getViewAtRecursiveOfType(glm::ivec2 pos, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE)
Acts as AViewContainerBase::getViewAtRecursive but finds a view castable to specified template type.
Definition: AViewContainerBase.h:254
const AVector< _< AView > > & getViews() const
Get all views of the container.
Definition: AViewContainerBase.h:131
Base class of all UI objects.
Definition: AView.h:77
virtual int getContentMinimumHeight()
Definition: AView.cpp:252
virtual bool consumesClick(const glm::ivec2 &pos)
Determines whether this AView processes this click or passes it thru.
Definition: AView.cpp:534
virtual bool onGesture(const glm::ivec2 &origin, const AGestureEvent &event)
Definition: AView.cpp:598
virtual void invalidateAssHelper()
Resets mAssHelper.
Definition: AView.cpp:291
virtual void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event)
Handles pointer hover events.
Definition: AView.cpp:343
virtual void onViewGraphSubtreeChanged()
Called when direct or indirect parent has changed.
Definition: AView.cpp:689
virtual void onClickPrevented()
Called on AWindowBase::preventClickOnPointerRelease.
Definition: AView.cpp:674
glm::ivec2 getSize() const noexcept
Size, including content area, border and padding.
Definition: AView.h:370
virtual int getContentMinimumWidth()
Definition: AView.cpp:248
virtual void onPointerPressed(const APointerPressedEvent &event)
Called on pointer (mouse) released event.
Definition: AView.cpp:357
virtual bool capturesFocus()
Definition: AView.cpp:567
virtual void markPixelDataInvalid(ARect< int > invalidArea)
A view requests to redraw it and passes it's coords relative to this.
Definition: AView.cpp:710
virtual void onPointerReleased(const APointerReleasedEvent &event)
Called on pointer (mouse) released event.
Definition: AView.cpp:366
virtual void render(ARenderContext ctx)
Draws this AView. Noone should call this function except rendering routine.
Definition: AView.cpp:142
virtual void invalidateAllStyles()
Invalidates all styles, causing to iterate over all rules in global and parent stylesheets.
Definition: AView.cpp:179
virtual void onScroll(const AScrollEvent &event)
Definition: AView.cpp:407
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
@ NONE
Image is kept in it's original size.
AUI_ENUM_FLAG(ASide)
Describes sides of a 2D rectangle.
Definition: ASide.h:24
#define AUI_ASSERT(condition)
Asserts that the passed condition evaluates to true.
Definition: Assert.h:55
@ HIDDEN_FROM_THIS
Like HIDDEN, but view's ASS-styled background is also affected by mask.
@ HIDDEN
Overflowed contents are hidden. Suitable for lists with scroll.
@ VISIBLE
Overflowed contents are visible.
Pointing method move event.
Definition: APointerMoveEvent.h:21
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19
Axis aligned 2D rectangle.
Definition: ARect.h:24
Render context passed to AView::render.
Definition: ARenderContext.h:43
Definition: AViewContainerBase.h:72
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51
Definition: iterators.h:34