20#include "AUI/Common/ASmallVector.h"
21#include <AUI/ASS/Property/IProperty.h>
22#include <AUI/ASS/Property/ScrollbarAppearance.h>
23#include "AUI/Common/ABoxFields.h"
24#include "AUI/Common/ADeque.h"
25#include "AUI/Common/AObject.h"
26#include "AUI/Common/SharedPtr.h"
27#include "AUI/Platform/ACursor.h"
28#include "AUI/Platform/AInput.h"
29#include "AUI/Reflect/AClass.h"
30#include "AUI/Font/AFontStyle.h"
31#include "AUI/Util/AFieldSignalEmitter.h"
32#include "AUI/Render/ARenderContext.h"
33#include "AUI/Util/IBackgroundEffect.h"
34#include <AUI/ASS/PropertyListRecursive.h>
35#include <AUI/Enum/AOverflow.h>
36#include <AUI/Enum/Visibility.h>
37#include <AUI/Enum/MouseCollisionPolicy.h>
38#include <AUI/Util/ALayoutDirection.h>
39#include <AUI/Action/AMenu.h>
41#include <AUI/Event/AScrollEvent.h>
42#include <AUI/Event/AGestureEvent.h>
43#include <AUI/Event/APointerPressedEvent.h>
44#include <AUI/Event/APointerReleasedEvent.h>
45#include <AUI/Event/APointerMoveEvent.h>
46#include <AUI/Render/ITexture.h>
47#include <AUI/Render/IRenderViewToTexture.h>
48#include <AUI/Enum/AFloat.h>
90 AOverflowMask mOverflowMask = AOverflowMask::ROUNDED_RECT;
95 Visibility mVisibility = Visibility::VISIBLE;
105 float mBorderRadius = 0;
110 MouseCollisionPolicy mMouseCollisionPolicy = MouseCollisionPolicy::DEFAULT;
138 virtual void notifyParentEnabledStateChanged(
bool enabled);
146 ALayoutDirection parentLayoutDirection()
const noexcept;
153 bool mMouseEntered =
false;
160 bool mBlockClicksWhenPressed =
true;
186 glm::ivec2 mPosition = { 0, 0 };
191 glm::ivec2 mSize = { 20, 20 };
205 glm::ivec2 mExpanding = {0, 0};
208 bool mMarkedMinContentSizeInvalid =
false;
217 bool mRedrawRequested =
false;
222 glm::ivec2 mMinSize = {0, 0};
227 glm::ivec2 mMaxSize = {0x7fffffff, 0x7fffffff};
232 glm::ivec2 mFixedSize = {0, 0};
258 bool mSkipUntilLayoutUpdate =
true;
273 bool transformGestureEventsToDesktop(
const glm::ivec2& origin,
const AGestureEvent& event);
292 virtual void onViewGraphSubtreeChanged();
300 virtual void markPixelDataInvalid(
ARect<int> invalidArea);
302 virtual void commitStyle();
363 return getPositionInWindow() + getSize() / 2;
382 void setMinSize(glm::ivec2 minSize)
noexcept {
386 virtual void markMinContentSizeInvalid();
392 mExtraStylesheet = std::move(extraStylesheet);
393 invalidateAssHelper();
399 void setExtraStylesheet(
AStylesheet&& extraStylesheet);
406 return mExtraStylesheet;
418 mOverflow = overflow;
426 return mOverflowMask;
428 void setOverflowMask(AOverflowMask overflow)
430 mOverflowMask = overflow;
437 return mBorderRadius;
439 void setBorderRadius(
float radius) {
440 mBorderRadius = radius;
448 int getHeight()
const
458 return !(mVisibility & Visibility::FLAG_CONSUME_SPACE) ? 0 : mSize.x + getTotalFieldHorizontal();
466 return !(mVisibility & Visibility::FLAG_CONSUME_SPACE) ? 0 : mSize.y + getTotalFieldVertical();
477 return getMinimumSize() + mMargin.occupiedSize();
506 virtual bool consumesClick(
const glm::ivec2& pos);
530 virtual AString debugString()
const;
538 return mPadding.horizontal() + mMargin.horizontal();
546 return mPadding.vertical() + mMargin.vertical();
554 return { getTotalFieldHorizontal(), getTotalFieldVertical() };
579 virtual int getContentMinimumWidth();
586 virtual int getContentMinimumHeight();
593 if (!mCachedMinContentSize) {
594 glm::ivec2 minContentSize = glm::ivec2(getContentMinimumWidth(), getContentMinimumHeight());
595 mCachedMinContentSize = minContentSize;
596 return minContentSize;
599 return *mCachedMinContentSize;
603 bool isContentMinimumSizeInvalidated() noexcept {
604 return !mCachedMinContentSize.hasValue();
608 bool hasFocus()
const;
611 virtual int getMinimumWidth();
612 virtual int getMinimumHeight();
614 glm::ivec2 getMinimumSize() {
615 return { getMinimumWidth(), getMinimumHeight() };
618 void setMaxSize(
const glm::ivec2& maxSize) {
630 int getContentWidth()
const
632 return static_cast<int>(mSize.x - mPadding.horizontal());
635 int getContentHeight()
const
637 return static_cast<int>(mSize.y - mPadding.vertical());
640 const glm::ivec2& getExpanding()
const
653 if (mExpanding == expanding) [[unlikely]] {
656 mExpanding = expanding;
657 if (expandingChanged)
emit expandingChanged(expanding);
658 markMinContentSizeInvalid();
669 setExpanding({expanding, expanding});
683 void getTransform(glm::mat4& transform)
const;
686 int getExpandingHorizontal()
const
692 int getExpandingVertical()
const
704 virtual void setPosition(glm::ivec2 position);
713 virtual void setSize(glm::ivec2 size);
714 virtual void setGeometry(
int x,
int y,
int width,
int height);
715 void setGeometry(
const glm::ivec2& position,
const glm::ivec2& size) {
716 setGeometry(position.x, position.y, size.x, size.y);
719 bool isBlockClicksWhenPressed() const noexcept {
720 return mBlockClicksWhenPressed;
723 void setBlockClicksWhenPressed(
bool value)
noexcept {
724 mBlockClicksWhenPressed = value;
734 void setFixedSize(glm::ivec2 size) {
735 AUI_ASSERTX(glm::all(glm::greaterThanEqual(size, glm::ivec2(-100000))),
"abnormal fixed size");
736 if (size == mFixedSize) [[unlikely]] {
740 markMinContentSizeInvalid();
744 bool isMouseHover() const noexcept
750 bool isPressed() const noexcept
752 return !mPressed.empty();
758 return mPressed.contains(index);
762 bool isEnabled() const noexcept
766 bool isFocused()
const {
769 bool isMouseEntered()
const {
770 return mMouseEntered;
773 Visibility getVisibility()
const
777 Visibility getVisibilityRecursive()
const;
779 void setVisibility(Visibility visibility)
noexcept;
781 void setVisible(
bool visible)
noexcept
783 setVisibility(
visible ? Visibility::VISIBLE : Visibility::INVISIBLE);
787 MouseCollisionPolicy getMouseCollisionPolicy()
const {
788 return mMouseCollisionPolicy;
791 void setMouseCollisionPolicy(MouseCollisionPolicy mouseCollisionPolicy) {
792 mMouseCollisionPolicy = mouseCollisionPolicy;
813 void focus(
bool needFocusChainUpdate =
true);
820 virtual bool capturesFocus();
825 bool hasIndirectParent(
const _<AView>& v);
830 [[nodiscard]] glm::ivec2 getPositionInWindow()
const;
836 void addAssName(
const AString& assName);
842 void removeAssName(
const AString& assName);
865 return mCustomStyleRule;
870 void ensureAssUpdated();
875 return _cast<AView>(AObject::sharedPtr());
892 virtual bool onGesture(
const glm::ivec2& origin,
const AGestureEvent& event);
894 virtual void onMouseEnter();
905 virtual void onMouseLeave();
906 virtual void onDpiChanged();
936 virtual void onKeyDown(AInput::Key key);
937 virtual void onKeyRepeat(AInput::Key key);
938 virtual void onKeyUp(AInput::Key key);
939 virtual void onFocusAcquired();
940 virtual void onFocusLost();
941 virtual void onCharEntered(char16_t c);
945 virtual bool handlesNonMouseNavigation();
947 virtual void forceUpdateLayoutRecursively();
949 virtual void setEnabled(
bool enabled =
true);
951 void setDisabled(
bool disabled =
true) {
952 setEnabled(!disabled);
955 void updateEnableState();
971 setCustomStyle(std::move(rule));
977 virtual void onClickPrevented();
994 virtual void invalidateAllStyles();
1008 invalidateStateStylesImpl(getMinimumSizePlusMargin());
1015 virtual void invalidateAssHelper();
1021 virtual bool wantsTouchscreenKeyboard();
1027 mSkipUntilLayoutUpdate = skipUntilLayoutUpdate;
1127 emits<> customCssPropertyChanged;
1144 bool mDirectlyEnabled =
true;
1145 bool mParentEnabled =
true;
1151 AFloat mFloating = AFloat::NONE;
1153 struct RenderToTexture {
1154 _unique<IRenderViewToTexture> rendererInterface;
1157 bool drawFromTexture =
true;
1162 bool skipRedrawUntilTextureIsPresented =
false;
1169 virtual void invalidateStateStylesImpl(glm::ivec2 prevMinimumSizePlusField);
1171 void notifyParentChildFocused(
const _<AView>& view);
1174API_AUI_VIEWS std::ostream& operator<<(std::ostream& os,
const AView& view);
Definition: AAnimator.h:26
Remember, ASS is not a butt. ASS is Aui Style Sheets.
Definition: AAssHelper.h:32
@ DEFAULT
Default arrow.
Definition: ACursor.h:38
Definition: AFieldSignalEmitter.h:51
A base object class.
Definition: AObject.h:49
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
AOptional< AInput::Key > button() const noexcept
Definition: APointerIndex.h:56
Vector-like container consisting of few elements on stack and switches to dynamic allocation vector i...
Definition: ASmallVector.h:34
Represents a Unicode character string.
Definition: AString.h:37
Definition: AStylesheet.h:21
A view that represents a set of views.
Definition: AViewContainerBase.h:68
A trivial modifiable view that represents a set of views.
Definition: AViewContainer.h:33
Base class of all UI objects.
Definition: AView.h:77
int getTotalFieldVertical() const
Definition: AView.h:545
emits< AInput::Key > keyReleased
Keyboard key released.
Definition: AView.h:1113
AOverflowMask getOverflowMask() const
Controls how does the overflow (stencil) mask is produced.
Definition: AView.h:424
const ABoxFields & getMargin()
Returns the margin.
Definition: AView.h:485
emits< glm::ivec2 > positionChanged
Position changed.
Definition: AView.h:1078
AVector< AString > mAssNames
ASS class names.
Definition: AView.h:249
void setExpanding(glm::ivec2 expanding)
Changes the expanding of view.
Definition: AView.h:651
AFloat getFloating() const noexcept
Floating value for AText.
Definition: AView.h:1042
glm::ivec2 getCenterPointInWindow() const noexcept
The center point position of the view relatively to top left corner of the window.
Definition: AView.h:361
int getTotalOccupiedWidth() const
Definition: AView.h:456
glm::ivec2 getMinSize() const noexcept
Definition: AView.h:378
glm::ivec2 getPosition() const noexcept
Top left corner's position relative to top left corner's position of the parent AView.
Definition: AView.h:347
void setFloating(AFloat f) noexcept
Set floating value for AText.
Definition: AView.h:1033
emits< glm::ivec2, glm::ivec2 > geometryChanged
Geometry (position and size) changed.
Definition: AView.h:1088
float getBorderRadius() const
border-radius, specified in ASS.
Definition: AView.h:436
glm::ivec2 getTotalFieldSize() const
Definition: AView.h:553
ass::PropertyListRecursive mCustomStyleRule
Custom ASS Rules.
Definition: AView.h:176
ABoxFields mMargin
Margin, which defines the spacing around this AView. Processed by the layout manager.
Definition: AView.h:237
glm::ivec2 getSize() const noexcept
Size, including content area, border and padding.
Definition: AView.h:370
emits< glm::ivec2 > scrolled
Scroll event.
Definition: AView.h:1103
int getTotalFieldHorizontal() const
Definition: AView.h:537
AViewContainerBase * getParent() const
Parent AView.
Definition: AView.h:561
void setExtraStylesheet(_< AStylesheet > extraStylesheet)
Definition: AView.h:391
void setSkipUntilLayoutUpdate(bool skipUntilLayoutUpdate)
Definition: AView.h:1026
emits< AInput::Key > keyPressed
Keyboard key pressed.
Definition: AView.h:1108
emits< Visibility > visibilityChanged
Visibility changed.
Definition: AView.h:1098
emits< APointerIndex > clickedButton
Some mouse button clicked.
Definition: AView.h:1068
emits clickedRightOrLongPressed
Right mouse button clicked or long press gesture applied.
Definition: AView.h:1123
AOverflow getOverflow() const
Determines whether display graphics that go out of the bounds of this AView or not.
Definition: AView.h:412
ABoxFields mPadding
Padding, which defines the spacing around content area inside the view. Processed by AView implementa...
Definition: AView.h:242
const ABoxFields & getPadding()
Returns the padding.
Definition: AView.h:513
void setMargin(const ABoxFields &margin)
Sets the margin.
Definition: AView.h:495
emits< bool > focusState
Focus state changed.
Definition: AView.h:1133
emits viewGraphSubtreeChanged
Definition: AView.h:1051
const AOptional< ACursor > & getCursor() const
Determines shape which should pointer take when it's above this AView.
Definition: AView.h:569
const _< AStylesheet > & extraStylesheet() const noexcept
Definition: AView.h:405
glm::ivec2 getMinimumSizePlusMargin()
Definition: AView.h:476
void click()
Definition: AView.h:798
void invalidateStateStyles()
Updates state selectors for ASS.
Definition: AView.h:1007
const glm::ivec2 & getMaxSize() const
Definition: AView.h:625
int getTotalOccupiedHeight() const
Definition: AView.h:464
emits clickedRight
Right mouse button clicked.
Definition: AView.h:1118
void setSizeForced(glm::ivec2 size)
Definition: AView.h:710
void operator+(ass::PropertyListRecursive rule)
Helper function for kAUI.h:with_style.
Definition: AView.h:970
emits< glm::ivec2 > sizeChanged
Size changed.
Definition: AView.h:1083
glm::ivec2 getContentMinimumSize() noexcept
Definition: AView.h:592
const glm::ivec2 & getFixedSize()
Fixed size.
Definition: AView.h:731
void setExpanding(int expanding)
Changes the expanding of view.
Definition: AView.h:667
emits< glm::ivec2 > expandingChanged
Expanding changed.
Definition: AView.h:1093
emits clicked
Left mouse button clicked.
Definition: AView.h:1073
void setPadding(const ABoxFields &padding)
Sets the padding.
Definition: AView.h:523
Definition: AWindowBase.h:33
Represents a window in the underlying windowing system.
Definition: AWindow.h:45
Rendering view to texture storage interface.
Definition: IRenderViewToTexture.h:26
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
#define emit
emits the specified signal in context of this object.
Definition: AObject.h:196
#define AUI_ASSERTX(condition, what)
Asserts that the passed condition evaluates to true. Adds extra message string.
Definition: Assert.h:74
AOverflow
Controls visibility of the overflowed contents of AView with AView::drawStencilMask.
Definition: AOverflow.h:25
@ VISIBLE
Overflowed contents are visible.
Represents a rectangle fields. Useful for margin and padding around AViews.
Definition: ABoxFields.h:21
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
Defines areas to invalidate (redraw).
Definition: IRenderViewToTexture.h:32
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:51
Definition: PropertyListRecursive.h:24
Definition: PropertyList.h:25
Base class for all properties.
Definition: IPropertyBase.h:49
Clamps the possible values for a number to the specified range: [min;max].
Definition: values.h:452