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 {
233 virtual void markMinContentSizeInvalid();
253 return mExtraStylesheet;
265 mOverflow = overflow;
273 return mOverflowMask;
275 void setOverflowMask(AOverflowMask overflow)
277 mOverflowMask = overflow;
284 return mBorderRadius;
286 void setBorderRadius(
float radius) {
287 mBorderRadius = radius;
295 int getHeight()
const
324 return getMinimumSize() +
mMargin.occupiedSize();
443 if (!mCachedMinContentSize) {
445 mCachedMinContentSize = minContentSize;
446 return minContentSize;
448 return *mCachedMinContentSize;
452 bool isContentMinimumSizeInvalidated() noexcept {
453 return !mCachedMinContentSize.hasValue();
456 bool hasFocus()
const;
458 virtual int getMinimumWidth();
459 virtual int getMinimumHeight();
461 glm::ivec2 getMinimumSize() {
462 return { getMinimumWidth(), getMinimumHeight() };
465 void setMaxSize(
const glm::ivec2& maxSize) {
480 glm::ivec2
getContentSize()
const {
return { getContentWidth(), getContentHeight() }; }
482 int getContentWidth()
const
484 return static_cast<int>(mSize.x - mPadding.horizontal());
487 int getContentHeight()
const
489 return static_cast<int>(mSize.y - mPadding.vertical());
493 const glm::ivec2& getExpanding()
const
506 if (mExpanding ==
expanding) [[unlikely]] {
511 markMinContentSizeInvalid();
529 const _<AAnimator>& getAnimator()
const {
534 void setAnimator(
const _<AAnimator>& animator);
535 void getTransform(glm::mat4& transform)
const;
538 int getExpandingHorizontal()
const
544 int getExpandingVertical()
const
549 [[nodiscard]] aui::float_within_0_1 getOpacity()
const {
552 void setOpacity(aui::float_within_0_1 opacity) {
556 virtual void setPosition(glm::ivec2 position);
565 virtual void setSize(glm::ivec2 size);
566 virtual void setGeometry(
int x,
int y,
int width,
int height);
567 void setGeometry(
const glm::ivec2& position,
const glm::ivec2& size) {
568 setGeometry(position.x, position.y, size.x, size.y);
571 bool isBlockClicksWhenPressed() const noexcept {
572 return mBlockClicksWhenPressed;
575 void setBlockClicksWhenPressed(
bool value)
noexcept {
576 mBlockClicksWhenPressed = value;
586 void setFixedSize(glm::ivec2 size) {
587 AUI_ASSERTX(glm::all(glm::greaterThanEqual(size, glm::ivec2(-100000))),
"abnormal fixed size");
588 if (size == mFixedSize) [[unlikely]] {
592 markMinContentSizeInvalid();
596 bool isMouseHover() const noexcept
602 bool isPressed() const noexcept
604 return !mPressed.empty();
608 bool isPressed(APointerIndex index)
const noexcept
610 return mPressed.contains(index);
613 bool isFocused()
const {
616 bool isMouseEntered()
const {
617 return mMouseEntered;
620 Visibility getVisibility()
const
625 Visibility getVisibilityRecursive()
const;
627 void setVisibility(Visibility visibility)
noexcept;
629 void setVisible(
bool visible)
noexcept
631 setVisibility(visible ? Visibility::VISIBLE : Visibility::INVISIBLE);
635 MouseCollisionPolicy getMouseCollisionPolicy()
const {
636 return mMouseCollisionPolicy;
639 void setMouseCollisionPolicy(MouseCollisionPolicy mouseCollisionPolicy) {
640 mMouseCollisionPolicy = mouseCollisionPolicy;
661 void focus(
bool needFocusChainUpdate =
true);
721 const _<AAssHelper>& getAssHelper()
const {
725 const ass::PropertyListRecursive& getCustomAss()
const {
726 return mCustomStyleRule;
729 void setCustomStyle(ass::PropertyListRecursive rule);
731 void ensureAssUpdated();
734 _<AView> sharedPtr() {
735 return _cast<AView>(AObject::sharedPtr());
739 _weak<AView> weakPtr() {
740 return _weak<AView>(sharedPtr());
752 virtual bool onGesture(
const glm::ivec2& origin,
const AGestureEvent& event);
754 virtual void onMouseEnter();
766 virtual void onMouseLeave();
767 virtual void onDpiChanged();
793 virtual void onKeyDown(AInput::Key key);
794 virtual void onKeyRepeat(AInput::Key key);
795 virtual void onKeyUp(AInput::Key key);
796 virtual void onFocusAcquired();
797 virtual void onFocusLost();
798 virtual void onCharEntered(
char16_t c);
805 virtual void forceUpdateLayoutRecursively();
807 virtual void setEnabled(
bool enabled =
true);
809 void setDisabled(
bool disabled =
true) {
810 setEnabled(!disabled);
813 void updateEnableState();
828 setCustomStyle(std::move(rule));
967 emits<> customCssPropertyChanged;
1021 bool mMarkedMinContentSizeInvalid =
false;
1121 virtual void commitStyle();
1132 AOverflowMask mOverflowMask = AOverflowMask::ROUNDED_RECT;
1137 Visibility mVisibility = Visibility::VISIBLE;
1148 float mBorderRadius = 0;
1153 MouseCollisionPolicy mMouseCollisionPolicy = MouseCollisionPolicy::DEFAULT;
1158 aui::float_within_0_1 mOpacity = 1;
1181 virtual void notifyParentEnabledStateChanged(
bool enabled);
1188 ALayoutDirection parentLayoutDirection() const noexcept;
1194 bool mMouseEntered = false;
1201 bool mBlockClicksWhenPressed = true;
1206 bool mEnabled = true;
1207 emits<
bool> mEnabledChanged;
1209 bool mDirectlyEnabled = true;
1210 bool mParentEnabled = true;
1213 glm::ivec2 mExpanding = glm::ivec2{0, 0};
1221 struct RenderToTexture {
1222 _unique<IRenderViewToTexture> rendererInterface;
1225 bool drawFromTexture =
true;
1230 bool skipRedrawUntilTextureIsPresented =
false;
1232 AOptional<RenderToTexture> mRenderToTexture;
1237 virtual void invalidateStateStylesImpl(glm::ivec2 prevMinimumSizePlusField);
1239 void notifyParentChildFocused(
const _<AView>& view);
1242API_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:37
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:397
emits< AInput::Key > keyReleased
Keyboard key released.
Definition AView.h:953
AOptional< ACursor > mCursor
Determines shape which should pointer take when it's above this AView.
Definition AView.h:998
AOverflowMask getOverflowMask() const
Controls how does the overflow (stencil) mask is produced.
Definition AView.h:271
virtual void onClickPrevented()
Called on AWindowBase::preventClickOnPointerRelease.
const ABoxFields & getMargin()
Returns the margin.
Definition AView.h:334
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:1013
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:1066
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:504
AFloat getFloating() const noexcept
Floating value for AText.
Definition AView.h:897
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:303
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:983
glm::ivec2 mPosition
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:1003
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:1075
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:888
emits< glm::ivec2, glm::ivec2 > geometryChanged
Geometry (position and size) changed.
Definition AView.h:938
float getBorderRadius() const
border-radius, specified in ASS.
Definition AView.h:283
glm::ivec2 getTotalFieldSize() const
Definition AView.h:405
ass::PropertyListRecursive mCustomStyleRule
Custom ASS Rules.
Definition AView.h:993
ABoxFields mMargin
Margin, which defines the spacing around this AView. Processed by the layout manager.
Definition AView.h:1052
glm::ivec2 mFixedSize
Fixed size.
Definition AView.h:1045
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:943
int getTotalFieldHorizontal() const
Definition AView.h:389
AViewContainerBase * getParent() const
Parent AView.
Definition AView.h:412
void pack()
Sets minimal size.
glm::ivec2 mMaxSize
Maximal size.
Definition AView.h:1040
void setExtraStylesheet(_< AStylesheet > extraStylesheet)
Definition AView.h:238
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:988
void setSkipUntilLayoutUpdate(bool skipUntilLayoutUpdate)
Definition AView.h:881
emits< AInput::Key > keyPressed
Keyboard key pressed.
Definition AView.h:948
emits< APointerIndex > clickedButton
Some mouse button clicked.
Definition AView.h:928
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:963
bool mRedrawRequested
Redraw requested flag for this particular view/.
Definition AView.h:1030
AOverflow getOverflow() const
Determines whether display graphics that go out of the bounds of this AView or not.
Definition AView.h:259
ABoxFields mPadding
Padding, which defines the spacing around content area inside the view. Processed by AView implementa...
Definition AView.h:1059
emits redrawn
View is painted onto the some surface.
Definition AView.h:915
const ABoxFields & getPadding()
Returns the padding.
Definition AView.h:364
void setMargin(const ABoxFields &margin)
Sets the margin.
Definition AView.h:346
emits< bool > focusState
Focus state changed.
Definition AView.h:973
AWindowBase * getWindow() const
Determines window which this AView belongs to.
virtual int getContentMinimumWidth()
glm::ivec2 getPositionInWindow() const
emits viewGraphSubtreeChanged
Definition AView.h:906
const AOptional< ACursor > & getCursor() const
Determines shape which should pointer take when it's above this AView.
Definition AView.h:420
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:252
glm::ivec2 getMinimumSizePlusMargin()
Definition AView.h:323
void click()
Definition AView.h:646
virtual void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event)
Handles pointer hover events.
void invalidateStateStyles()
Updates state selectors for ASS.
Definition AView.h:863
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:472
int getTotalOccupiedHeight() const
Definition AView.h:311
emits< glm::ivec2 > mPositionChanged
Position changed.
Definition AView.h:1008
emits clickedRight
Right mouse button clicked.
Definition AView.h:958
virtual AMenuModel composeContextMenu()
Produce context (right click) menu.
void setExtraStylesheet(AStylesheet &&extraStylesheet)
void setSizeForced(glm::ivec2 size)
Definition AView.h:562
auto visibility() const
Visibility value.
Definition AView.h:146
virtual void onScroll(const AScrollEvent &event)
emits< glm::ivec2 > mSizeChanged
Size changed.
Definition AView.h:1018
virtual bool wantsTouchscreenKeyboard()
Returns true if view is textfield-like view which requires touchscreen keyboard when clicked.
glm::ivec2 getContentMinimumSize() noexcept
Definition AView.h:442
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:583
void setExpanding(int expanding)
Changes the expanding of view.
Definition AView.h:520
glm::ivec2 getContentSize() const
Definition AView.h:480
void setAssName(const AString &assName, bool value)
Depending on value, either adds or removes ass name.
Definition AView.h:697
emits clicked
Left mouse button clicked.
Definition AView.h:933
void setPadding(const ABoxFields &padding)
Sets the padding.
Definition AView.h:376
virtual void onPointerReleased(const APointerReleasedEvent &event)
Called on pointer (mouse) released event.
void focus(bool needFocusChainUpdate=true)
Requests focus for this AView.
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:1035
void operator&(ass::PropertyListRecursive rule)
Helper function for kAUI.h:with_style.
Definition AView.h:827
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:572
#define emit
emits the specified signal in context of this object.
Definition AObject.h:343
#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 AProperty.h:234
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