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>
49#include <AUI/Common/AProperty.h>
77class API_AUI_VIEWS AView:
public AObject
79 friend class AViewContainerBase;
80 friend class AViewContainer;
81 friend class IRenderViewToTexture;
150 &AView::setVisibility,
229 void setMinSize(glm::ivec2 minSize)
noexcept {
258 return mExtraStylesheet;
270 mOverflow = overflow;
278 return mOverflowMask;
280 void setOverflowMask(AOverflowMask overflow)
282 mOverflowMask = overflow;
289 return mBorderRadius;
291 void setBorderRadius(
float radius) {
292 mBorderRadius = radius;
300 int getHeight()
const
448 if (!mCachedMinContentSize) {
450 mCachedMinContentSize = minContentSize;
451 return minContentSize;
453 return *mCachedMinContentSize;
457 bool isContentMinimumSizeInvalidated() noexcept {
458 return !mCachedMinContentSize.hasValue();
461 bool hasFocus()
const;
463 virtual int getMinimumWidth();
464 virtual int getMinimumHeight();
478 return { getMinimumWidth(), getMinimumHeight() };
481 void setMaxSize(
const glm::ivec2& maxSize) {
496 glm::ivec2
getContentSize()
const {
return { getContentWidth(), getContentHeight() }; }
498 int getContentWidth()
const
500 return static_cast<int>(mSize.x - mPadding.horizontal());
503 int getContentHeight()
const
505 return static_cast<int>(mSize.y - mPadding.vertical());
509 const glm::ivec2& getExpanding()
const
522 if (mExpanding ==
expanding) [[unlikely]] {
545 const _<AAnimator>& getAnimator()
const {
550 void setAnimator(
const _<AAnimator>& animator);
551 void getTransform(glm::mat4& transform)
const;
554 int getExpandingHorizontal()
const
560 int getExpandingVertical()
const
565 [[nodiscard]] aui::float_within_0_1 getOpacity()
const {
568 void setOpacity(aui::float_within_0_1 opacity) {
572 virtual void setPosition(glm::ivec2 position);
581 virtual void setSize(glm::ivec2 size);
593 bool isBlockClicksWhenPressed() const noexcept {
594 return mBlockClicksWhenPressed;
597 void setBlockClicksWhenPressed(
bool value)
noexcept {
598 mBlockClicksWhenPressed = value;
608 void setFixedSize(glm::ivec2 size) {
609 AUI_ASSERTX(glm::all(glm::greaterThanEqual(size, glm::ivec2(-100000))),
"abnormal fixed size");
610 if (size == mFixedSize) [[unlikely]] {
614 markMinContentSizeInvalid();
618 bool isMouseHover() const noexcept
624 bool isPressed() const noexcept
626 return !mPressed.empty();
630 bool isPressed(APointerIndex index)
const noexcept
632 return mPressed.contains(index);
635 bool isFocused()
const {
638 bool isMouseEntered()
const {
639 return mMouseEntered;
642 Visibility getVisibility()
const
647 Visibility getVisibilityRecursive()
const;
649 void setVisibility(Visibility visibility)
noexcept;
651 void setVisible(
bool visible)
noexcept
653 setVisibility(visible ? Visibility::VISIBLE : Visibility::INVISIBLE);
657 MouseCollisionPolicy getMouseCollisionPolicy()
const {
658 return mMouseCollisionPolicy;
661 void setMouseCollisionPolicy(MouseCollisionPolicy mouseCollisionPolicy) {
662 mMouseCollisionPolicy = mouseCollisionPolicy;
683 void focus(
bool needFocusChainUpdate =
true);
743 const _<AAssHelper>& getAssHelper()
const {
747 const ass::PropertyListRecursive& getCustomAss()
const {
748 return mCustomStyleRule;
751 void setCustomStyle(ass::PropertyListRecursive rule);
753 void ensureAssUpdated();
756 _<AView> sharedPtr() {
757 return _cast<AView>(AObject::sharedPtr());
761 _weak<AView> weakPtr() {
762 return _weak<AView>(sharedPtr());
774 virtual bool onGesture(
const glm::ivec2& origin,
const AGestureEvent& event);
776 virtual void onMouseEnter();
788 virtual void onMouseLeave();
789 virtual void onDpiChanged();
815 virtual void onKeyDown(AInput::Key key);
816 virtual void onKeyRepeat(AInput::Key key);
817 virtual void onKeyUp(AInput::Key key);
818 virtual void onFocusAcquired();
819 virtual void onFocusLost();
820 virtual void onCharEntered(
char16_t c);
827 virtual void forceUpdateLayoutRecursively();
829 virtual void setEnabled(
bool enabled =
true);
831 void setDisabled(
bool disabled =
true) {
832 setEnabled(!disabled);
835 void updateEnableState();
850 setCustomStyle(std::move(rule));
989 emits<> customCssPropertyChanged;
1043 bool mMarkedMinContentSizeInvalid =
false;
1143 virtual void commitStyle();
1154 AOverflowMask mOverflowMask = AOverflowMask::ROUNDED_RECT;
1159 Visibility mVisibility = Visibility::VISIBLE;
1170 float mBorderRadius = 0;
1175 MouseCollisionPolicy mMouseCollisionPolicy = MouseCollisionPolicy::DEFAULT;
1180 aui::float_within_0_1 mOpacity = 1;
1203 virtual void notifyParentEnabledStateChanged(
bool enabled);
1210 ALayoutDirection parentLayoutDirection() const noexcept;
1216 bool mMouseEntered = false;
1223 bool mBlockClicksWhenPressed = true;
1228 bool mEnabled = true;
1229 emits<
bool> mEnabledChanged;
1231 bool mDirectlyEnabled = true;
1232 bool mParentEnabled = true;
1235 glm::ivec2 mExpanding = glm::ivec2{0, 0};
1243 struct RenderToTexture {
1244 _unique<IRenderViewToTexture> rendererInterface;
1247 bool drawFromTexture =
true;
1252 bool skipRedrawUntilTextureIsPresented =
false;
1254 AOptional<RenderToTexture> mRenderToTexture;
1259 virtual void invalidateStateStylesImpl(glm::ivec2 prevMinimumSizePlusField);
1261 void notifyParentChildFocused(
const _<AView>& view);
1264API_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:34
Stores a value and observes it's changes, emitting a signal.
Definition AFieldSignalEmitter.h:21
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition AOptional.h:33
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
Represents a Unicode character string.
Definition AString.h:38
Definition AStylesheet.h:21
A std::vector with AUI extensions.
Definition AVector.h:39
A view that represents a set of views.
Definition AViewContainerBase.h:68
Base class of all UI objects.
Definition AView.h:78
int getTotalFieldVertical() const
Definition AView.h:402
emits< AInput::Key > keyReleased
Keyboard key released.
Definition AView.h:975
AOptional< ACursor > mCursor
Determines shape which should pointer take when it's above this AView.
Definition AView.h:1020
AOverflowMask getOverflowMask() const
Controls how does the overflow (stencil) mask is produced.
Definition AView.h:276
virtual void onClickPrevented()
Called on AWindowBase::preventClickOnPointerRelease.
const ABoxFields & getMargin()
Returns the margin.
Definition AView.h:339
void removeAssName(const AString &assName)
Removes an ASS class to this AView.
glm::ivec2 mSize
Size, including content area, border and padding.
Definition AView.h:1035
bool transformGestureEventsToDesktop(const glm::ivec2 &origin, const AGestureEvent &event)
Converts touch screen events to desktop.
virtual void render(ARenderContext ctx)
Draws this AView. Noone should call this function except rendering routine.
auto enabled() const
Whether view is enabled (i.e., reacts to user).
Definition AView.h:90
virtual void invalidateAssHelper()
Resets mAssHelper.
AVector< AString > mAssNames
ASS class names.
Definition AView.h:1088
virtual AString debugString() const
String which helps to identify this object in debug string output (i.e., for logging)
void setExpanding(glm::ivec2 expanding)
Changes the expanding of view.
Definition AView.h:520
AFloat getFloating() const noexcept
Floating value for AText.
Definition AView.h:919
glm::ivec2 getCenterPointInWindow() const noexcept
The center point position of the view relatively to top left corner of the window.
Definition AView.h:208
virtual void postRender(ARenderContext ctx)
Performs post-draw routines of this AView. Noone should call this function except rendering routine.
int getTotalOccupiedWidth() const
Definition AView.h:308
bool hasIndirectParent(const _< AView > &v)
Checks if the specified view is an indirect parent of this view.
auto expanding() const
Expansion coefficient. Hints layout manager how much this AView should be extended relative to other ...
Definition AView.h:134
auto size() const
Size, including content area, border and padding.
Definition AView.h:114
AViewContainerBase * mParent
Parent AView.
Definition AView.h:1005
glm::ivec2 mPosition
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:1025
glm::ivec2 getMinSize() const noexcept
Definition AView.h:225
bool mSkipUntilLayoutUpdate
If set to true, AViewContainer is obligated ignore this view. This value is set to false by AView::se...
Definition AView.h:1097
virtual bool capturesFocus()
glm::ivec2 getPosition() const noexcept
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:194
void setFloating(AFloat f) noexcept
Set floating value for AText.
Definition AView.h:910
emits< glm::ivec2, glm::ivec2 > geometryChanged
Geometry (position and size) changed.
Definition AView.h:960
float getBorderRadius() const
border-radius, specified in ASS.
Definition AView.h:288
glm::ivec2 getTotalFieldSize() const
Definition AView.h:410
ass::PropertyListRecursive mCustomStyleRule
Custom ASS Rules.
Definition AView.h:1015
ABoxFields mMargin
Margin, which defines the spacing around this AView. Processed by the layout manager.
Definition AView.h:1074
glm::ivec2 mFixedSize
Fixed size.
Definition AView.h:1067
void redraw()
Request window manager to redraw this AView.
glm::ivec2 getSize() const noexcept
Size, including content area, border and padding.
Definition AView.h:217
emits< glm::ivec2 > scrolled
Scroll event.
Definition AView.h:965
int getTotalFieldHorizontal() const
Definition AView.h:394
AViewContainerBase * getParent() const
Parent AView.
Definition AView.h:417
void pack()
Sets minimal size.
glm::ivec2 mMaxSize
Maximal size.
Definition AView.h:1062
void setExtraStylesheet(_< AStylesheet > extraStylesheet)
Definition AView.h:243
virtual bool handlesNonMouseNavigation()
std::array< ass::prop::IPropertyBase *, int(ass::prop::PropertySlot::COUNT)> mAss
Drawing list, or baking drawing commands so that you don't have to parse the ASS every time.
Definition AView.h:1010
void setSkipUntilLayoutUpdate(bool skipUntilLayoutUpdate)
Definition AView.h:903
emits< AInput::Key > keyPressed
Keyboard key pressed.
Definition AView.h:970
glm::ivec2 getMinimumSize()
Returns the minimum size required for this view.
Definition AView.h:477
emits< APointerIndex > clickedButton
Some mouse button clicked.
Definition AView.h:950
void addAssName(const AString &assName)
Adds an ASS class to this AView.
virtual int getContentMinimumHeight()
virtual bool onGesture(const glm::ivec2 &origin, const AGestureEvent &event)
emits clickedRightOrLongPressed
Right mouse button clicked or long press gesture applied.
Definition AView.h:985
bool mRedrawRequested
Redraw requested flag for this particular view/.
Definition AView.h:1052
AOverflow getOverflow() const
Determines whether display graphics that go out of the bounds of this AView or not.
Definition AView.h:264
ABoxFields mPadding
Padding, which defines the spacing around content area inside the view. Processed by AView implementa...
Definition AView.h:1081
emits redrawn
View is painted onto the some surface.
Definition AView.h:937
const ABoxFields & getPadding()
Returns the padding.
Definition AView.h:369
void setMargin(const ABoxFields &margin)
Sets the margin.
Definition AView.h:351
emits< bool > focusState
Focus state changed.
Definition AView.h:995
AWindowBase * getWindow() const
Determines window which this AView belongs to.
virtual int getContentMinimumWidth()
glm::ivec2 getPositionInWindow() const
emits viewGraphSubtreeChanged
Definition AView.h:928
const AOptional< ACursor > & getCursor() const
Determines shape which should pointer take when it's above this AView.
Definition AView.h:425
virtual bool consumesClick(const glm::ivec2 &pos)
Determines whether this AView processes this click or passes it thru.
const _< AStylesheet > & extraStylesheet() const noexcept
Definition AView.h:257
glm::ivec2 getMinimumSizePlusMargin()
Definition AView.h:328
void click()
Definition AView.h:668
virtual void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event)
Handles pointer hover events.
void invalidateStateStyles()
Updates state selectors for ASS.
Definition AView.h:885
virtual void invalidateAllStyles()
Invalidates all styles, causing to iterate over all rules in global and parent stylesheets.
virtual void onPointerPressed(const APointerPressedEvent &event)
Called on pointer (mouse) released event.
const glm::ivec2 & getMaxSize() const
Definition AView.h:488
int getTotalOccupiedHeight() const
Definition AView.h:316
emits< glm::ivec2 > mPositionChanged
Position changed.
Definition AView.h:1030
emits clickedRight
Right mouse button clicked.
Definition AView.h:980
virtual AMenuModel composeContextMenu()
Produce context (right click) menu.
void setExtraStylesheet(AStylesheet &&extraStylesheet)
void setSizeForced(glm::ivec2 size)
Definition AView.h:578
auto visibility() const
Visibility value.
Definition AView.h:146
virtual void onScroll(const AScrollEvent &event)
emits< glm::ivec2 > mSizeChanged
Size changed.
Definition AView.h:1040
virtual bool wantsTouchscreenKeyboard()
Returns true if view is textfield-like view which requires touchscreen keyboard when clicked.
glm::ivec2 getContentMinimumSize() noexcept
Definition AView.h:447
virtual void markPixelDataInvalid(ARect< int > invalidArea)
A view requests to redraw it and passes it's coords relative to this.
const glm::ivec2 & getFixedSize()
Fixed size.
Definition AView.h:605
void setExpanding(int expanding)
Changes the expanding of view.
Definition AView.h:536
glm::ivec2 getContentSize() const
Definition AView.h:496
void setAssName(const AString &assName, bool value)
Depending on value, either adds or removes ass name.
Definition AView.h:719
emits clicked
Left mouse button clicked.
Definition AView.h:955
virtual void setGeometry(int x, int y, int width, int height)
Sets position and size of the view.
void setPadding(const ABoxFields &padding)
Sets the padding.
Definition AView.h:381
virtual void onPointerReleased(const APointerReleasedEvent &event)
Called on pointer (mouse) released event.
void focus(bool needFocusChainUpdate=true)
Requests focus for this AView.
virtual void markMinContentSizeInvalid()
Marks this view it requires a layout update.
auto position() const
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:102
glm::ivec2 mMinSize
Minimal size.
Definition AView.h:1057
void operator&(ass::PropertyListRecursive rule)
Helper function for kAUI.h:with_style.
Definition AView.h:849
virtual void onViewGraphSubtreeChanged()
Called when direct or indirect parent has changed.
Definition AWindowBase.h:33
Represents a window in the underlying windowing system.
Definition AWindow.h:45
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
AOverflow
Controls visibility of the overflowed contents of AView with AView::drawStencilMask.
Definition AOverflow.h:24
AFloat
Specifies text floating in text wrapping views, i.e, ATextArea, AText.
Definition AFloat.h:19
@ VISIBLE
Overflowed contents are visible.
Definition AOverflow.h:28
@ NONE
Definition AFloat.h:23
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:577
#define emit
emits the specified signal in context of this object.
Definition AObject.h:344
#define AUI_ASSERTX(condition, what)
Asserts that the passed condition evaluates to true. Adds extra message string.
Definition Assert.h:74
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
Property implementation to use with custom getter/setter.
Definition APropertyDef.h:23
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
Definition PropertyListRecursive.h:29
Definition PropertyList.h:28
Base class for all properties.
Definition IPropertyBase.h:50