AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
AScrollArea Class Reference

A scrollable container with vertical and horizontal scrollbars. More...

Detailed Description

A scrollable container with vertical and horizontal scrollbars.

AScrollArea should have expanding, or fixed size, or max size to be set in order to define it's sizing rules, as it's size cannot be defined by it's contents for obvious reasons.

FixedSize and Expanding stylesheet properties would work as expected. If neither of them is set, AScrollArea would occupy size by minimum size of it's contents, as a AViewContainer would do. In such case, you may restrict maximum size of AScrollArea with MaxSize property. AScrollArea will not exceed MaxSize, but also become actual scroll area, involving displaying scroll bars and handling scroll events. This behaviour is similar to Text.

Expanding is enabled by default. It can be disabled with ass::Expanding(0) property.

Note
Behaviour of vertical and horizontal axes are independent from each other. This behaviour is similar to Text.

Classes

class  Builder
 

Public Member Functions

void setSize (glm::ivec2 size) override
 
void setContents (_< AView > content)
 
int getContentMinimumWidth () override
 
int getContentMinimumHeight () override
 
void onPointerPressed (const APointerPressedEvent &event) override
 Called on pointer (mouse) released event. More...
 
void onPointerReleased (const APointerReleasedEvent &event) override
 Called on pointer (mouse) released event. More...
 
void setScroll (glm::uvec2 scroll)
 
void setScrollX (unsigned scroll)
 
void setScrollY (unsigned scroll)
 
void setStickToEnd (bool stickToEnd)
 Set stick to end. More...
 
void scroll (glm::ivec2 by) noexcept
 
void scroll (int deltaByX, int deltaByY) noexcept
 
bool onGesture (const glm::ivec2 &origin, const AGestureEvent &event) override
 
void onScroll (const AScrollEvent &event) override
 
void setScrollbarAppearance (ass::ScrollbarAppearance scrollbarAppearance)
 
void scrollTo (const _< AView > &target, bool nearestBorder=true)
 Scrolls to the specified target view. More...
 
void scrollTo (ARect< int > target, bool nearestBorder=true)
 Scrolls to the specified rectangle area. More...
 
void setWheelScrollable (bool value)
 
const _< AView > & contents () const noexcept
 
const _< AScrollbar > & verticalScrollbar () const noexcept
 
const _< AScrollbar > & horizontalScrollbar () const noexcept
 
glm::uvec2 scroll () const noexcept
 
- Public Member Functions inherited from AViewContainerBase
void render (ARenderContext context) override
 Draws this AView. Noone should call this function except rendering routine. More...
 
void onMouseEnter () override
 
void onPointerMove (glm::vec2 pos, const APointerMoveEvent &event) override
 Handles pointer hover events. More...
 
void onMouseLeave () override
 
void onDpiChanged () override
 
void onClickPrevented () override
 Called on AWindowBase::preventClickOnPointerRelease. More...
 
int getContentMinimumWidth () override
 
int getContentMinimumHeight () override
 
void onPointerPressed (const APointerPressedEvent &event) override
 Called on pointer (mouse) released event. More...
 
void onPointerDoubleClicked (const APointerPressedEvent &event) override
 
void onPointerReleased (const APointerReleasedEvent &event) override
 Called on pointer (mouse) released event. More...
 
void onScroll (const AScrollEvent &event) override
 
bool onGesture (const glm::ivec2 &origin, const AGestureEvent &event) override
 
bool consumesClick (const glm::ivec2 &pos) override
 Determines whether this AView processes this click or passes it thru. More...
 
void setSize (glm::ivec2 size) override
 
void setEnabled (bool enabled=true) override
 
auto begin () const
 
auto end () const
 
const AVector< _< AView > > & getViews () const
 Get all views of the container.
 
const _unique< ALayout > & getLayout () const noexcept
 Get layout manager of the container.
 
virtual _< AViewgetViewAt (glm::ivec2 pos, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE) const noexcept
 Finds first direct child view under position. More...
 
_< AViewgetViewAtRecursive (glm::ivec2 pos, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE) const noexcept
 Acts as AViewContainerBase::getViewAt but recursively (may include non-direct child). More...
 
template<aui::predicate< _< AView > > Callback>
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. More...
 
template<aui::predicate< _< AView > > Callback>
bool visitsViewRecursive (Callback &&callback, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE)
 
template<typename T >
_< T > getViewAtRecursiveOfType (glm::ivec2 pos, ABitField< AViewLookupFlags > flags=AViewLookupFlags::NONE)
 Acts as AViewContainerBase::getViewAtRecursive but finds a view castable to specified template type. More...
 
void setFocusChainTarget (_weak< AView > target)
 Set focus chain target. More...
 
_< AViewfocusChainTarget ()
 
void applyGeometryToChildrenIfNecessary ()
 
void onKeyDown (AInput::Key key) override
 
void onKeyRepeat (AInput::Key key) override
 
void onKeyUp (AInput::Key key) override
 
void onCharEntered (char16_t c) override
 
bool capturesFocus () override
 
const ASmallVector< PointerEventsMapping, 1 > & pointerEventsMapping () const noexcept
 
void forceUpdateLayoutRecursively () override
 
void markMinContentSizeInvalid () override
 
void markPixelDataInvalid (ARect< int > invalidArea) override
 A view requests to redraw it and passes it's coords relative to this. More...
 
- Public Member Functions inherited from AView
void redraw ()
 Request window manager to redraw this AView.
 
AWindowBasegetWindow () const
 Determines window which this AView belongs to. More...
 
virtual void drawStencilMask (ARenderContext ctx)
 
virtual void postRender (ARenderContext ctx)
 Performs post-draw routines of this AView. Noone should call this function except rendering routine. More...
 
void popStencilIfNeeded (ARenderContext ctx)
 
const AVector< AString > & getAssNames () const noexcept
 
glm::ivec2 getPosition () const noexcept
 Top left corner's position relative to top left corner's position of the parent AView.
 
glm::ivec2 getCenterPointInWindow () const noexcept
 The center point position of the view relatively to top left corner of the window. More...
 
glm::ivec2 getSize () const noexcept
 Size, including content area, border and padding.
 
glm::ivec2 getMinSize () const noexcept
 
void setMinSize (glm::ivec2 minSize) noexcept
 
void setExtraStylesheet (_< AStylesheet > extraStylesheet)
 
void setExtraStylesheet (AStylesheet &&extraStylesheet)
 
const _< AStylesheet > & extraStylesheet () const noexcept
 
AOverflow getOverflow () const
 Determines whether display graphics that go out of the bounds of this AView or not.
 
void setOverflow (AOverflow overflow)
 
AOverflowMask getOverflowMask () const
 Controls how does the overflow (stencil) mask is produced.
 
void setOverflowMask (AOverflowMask overflow)
 
float getBorderRadius () const
 border-radius, specified in ASS.
 
void setBorderRadius (float radius)
 
int getWidth () const
 
int getHeight () const
 
int getTotalOccupiedWidth () const
 
int getTotalOccupiedHeight () const
 
glm::ivec2 getMinimumSizePlusMargin ()
 
const ABoxFieldsgetMargin ()
 Returns the margin. More...
 
void setMargin (const ABoxFields &margin)
 Sets the margin. More...
 
const ABoxFieldsgetPadding ()
 Returns the padding. More...
 
void setPadding (const ABoxFields &padding)
 Sets the padding. More...
 
virtual AString debugString () const
 String which helps to identify this object in debug string output (i.e., for logging)
 
int getTotalFieldHorizontal () const
 
int getTotalFieldVertical () const
 
glm::ivec2 getTotalFieldSize () const
 
AViewContainerBasegetParent () const
 Parent AView.
 
const AOptional< ACursor > & getCursor () const
 Determines shape which should pointer take when it's above this AView.
 
void setCursor (AOptional< ACursor > cursor)
 
glm::ivec2 getContentMinimumSize () noexcept
 
bool isContentMinimumSizeInvalidated () noexcept
 
bool hasFocus () const
 
virtual int getMinimumWidth ()
 
virtual int getMinimumHeight ()
 
glm::ivec2 getMinimumSize ()
 
void setMaxSize (const glm::ivec2 &maxSize)
 
const glm::ivec2 & getMaxSize () const
 
int getContentWidth () const
 
int getContentHeight () const
 
const glm::ivec2 & getExpanding () const
 
void setExpanding (glm::ivec2 expanding)
 Changes the expanding of view. More...
 
void setExpanding (int expanding)
 Changes the expanding of view. More...
 
void setExpanding ()
 
const _< AAnimator > & getAnimator () const
 
void setAnimator (const _< AAnimator > &animator)
 
void getTransform (glm::mat4 &transform) const
 
int getExpandingHorizontal () const
 
int getExpandingVertical () const
 
aui::float_within_0_1 getOpacity () const
 
void setOpacity (aui::float_within_0_1 opacity)
 
virtual void setPosition (glm::ivec2 position)
 
void setSizeForced (glm::ivec2 size)
 
virtual void setGeometry (int x, int y, int width, int height)
 
void setGeometry (const glm::ivec2 &position, const glm::ivec2 &size)
 
bool isBlockClicksWhenPressed () const noexcept
 
void setBlockClicksWhenPressed (bool value) noexcept
 
const glm::ivec2 & getFixedSize ()
 Fixed size. More...
 
void setFixedSize (glm::ivec2 size)
 
bool isMouseHover () const noexcept
 
bool isPressed () const noexcept
 
bool isPressed (APointerIndex index) const noexcept
 
bool isEnabled () const noexcept
 
bool isFocused () const
 
bool isMouseEntered () const
 
Visibility getVisibility () const
 
Visibility getVisibilityRecursive () const
 
void setVisibility (Visibility visibility) noexcept
 
void setVisible (bool visible) noexcept
 
MouseCollisionPolicy getMouseCollisionPolicy () const
 
void setMouseCollisionPolicy (MouseCollisionPolicy mouseCollisionPolicy)
 
void click ()
 
void pack ()
 Sets minimal size.
 
void focus (bool needFocusChainUpdate=true)
 Requests focus for this AView. More...
 
bool hasIndirectParent (const _< AView > &v)
 Checks if the specified view is an indirect parent of this view.
 
glm::ivec2 getPositionInWindow () const
 
void addAssName (const AString &assName)
 Adds an ASS class to this AView. More...
 
void removeAssName (const AString &assName)
 Removes an ASS class to this AView. More...
 
AViewoperator<< (const AString &assName)
 
const _< AAssHelper > & getAssHelper () const
 
const ass::PropertyListRecursivegetCustomAss () const
 
void setCustomStyle (ass::PropertyListRecursive rule)
 
void ensureAssUpdated ()
 
_< AViewsharedPtr ()
 
_weak< AViewweakPtr ()
 
virtual void onFocusAcquired ()
 
virtual void onFocusLost ()
 
virtual bool handlesNonMouseNavigation ()
 
void setDisabled (bool disabled=true)
 
void updateEnableState ()
 
void enable ()
 
void disable ()
 
void operator+ (ass::PropertyListRecursive rule)
 Helper function for kAUI.h:with_style.
 
void invalidateStateStyles ()
 Updates state selectors for ASS. More...
 
virtual bool wantsTouchscreenKeyboard ()
 Returns true if view is textfield-like view which requires touchscreen keyboard when clicked.
 
void setSkipUntilLayoutUpdate (bool skipUntilLayoutUpdate)
 
void setFloating (AFloat f) noexcept
 Set floating value for AText.
 
AFloat getFloating () const noexcept
 Floating value for AText.
 
- Public Member Functions inherited from AObject
_< AObjectsharedPtr ()
 
_weak< AObjectweakPtr ()
 
void clearSignals () noexcept
 
template<AAnySignal Signal, ACompatibleSlotFor< Signal > Function>
void connect (Signal &signal, Function &&function)
 
void setSignalsEnabled (bool enabled)
 
bool isSignalsEnabled () const noexcept
 
template<ASignalInvokable T>
void operator^ (T &&t)
 
_< AAbstractThreadgetThread () const
 
bool isSlotsCallsOnlyOnMyThread () const noexcept
 
void setSlotsCallsOnlyOnMyThread (bool slotsCallsOnlyOnMyThread)
 
- Public Member Functions inherited from aui::noncopyable
 noncopyable (const noncopyable &)=delete
 
noncopyableoperator= (const noncopyable &)=delete
 

Protected Member Functions

 AScrollArea (const Builder &builder)
 
- Protected Member Functions inherited from AViewContainerBase
void drawView (const _< AView > &view, ARenderContext contextOfTheContainer)
 
template<typename Iterator >
void drawViews (Iterator begin, Iterator end, ARenderContext contextPassedToContainer)
 
void invalidateAllStyles () override
 Invalidates all styles, causing to iterate over all rules in global and parent stylesheets. More...
 
void onViewGraphSubtreeChanged () override
 Called when direct or indirect parent has changed. More...
 
void invalidateAssHelper () override
 Resets mAssHelper. More...
 
void setViews (AVector< _< AView > > views)
 Replace views.
 
void addViewCustomLayout (const _< AView > &view)
 Adds view to container without exposing it to the layout manager. More...
 
void addViews (AVector< _< AView > > views)
 Add all views from vector.
 
void addView (const _< AView > &view)
 Add view to the container.
 
void addView (size_t index, const _< AView > &view)
 Add view at specific index to the container.
 
void removeView (const _< AView > &view)
 Remove view from the container.
 
void removeView (AView *view)
 Remove view from the container.
 
void removeView (size_t index)
 Remove view from the container at specified index.
 
void removeAllViews ()
 Remove all views from container.
 
void setContents (const _< AViewContainer > &container)
 Moves (like via std::move) all children and layout of the specified container to this container. More...
 
void setLayout (_unique< ALayout > layout)
 Set new layout manager for this AViewContainerBase. DESTROYS OLD LAYOUT MANAGER WITH ITS VIEWS!!!
 
void renderChildren (ARenderContext contextPassedToContainer)
 
virtual void applyGeometryToChildren ()
 
- Protected Member Functions inherited from AView
bool transformGestureEventsToDesktop (const glm::ivec2 &origin, const AGestureEvent &event)
 Converts touch screen events to desktop. More...
 
void applyAssRule (const ass::PropertyList &propertyList)
 
void applyAssRule (const ass::PropertyListRecursive &propertyList)
 
virtual AMenuModel composeContextMenu ()
 Produce context (right click) menu. More...
 
virtual void commitStyle ()
 
- Protected Member Functions inherited from AObject
void setThread (_< AAbstractThread > thread)
 Set thread of the object.
 

Additional Inherited Members

- Static Public Member Functions inherited from AObject
static void disconnect ()
 
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function>
static void connect (Signal &signal, Object *object, Function &&function)
 
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function>
static void connect (Signal &signal, Object &object, Function &&function)
 
template<AAnySignal Signal, aui::derived_from< AObject > Object, ACompatibleSlotFor< Signal > Function>
static void connect (Signal &signal, _< Object > object, Function &&function)
 
static void moveToThread (aui::no_escape< AObject > object, _< AAbstractThread > thread)
 
- Signals and public fields inherited from AViewContainerBase
emits childrenChanged
 Emitted when addView(s)/removeView/setLayout was called.
 
- Signals and public fields inherited from AView
emits viewGraphSubtreeChanged
 
emits< bool > hoveredState
 
emits mouseEnter
 
emits mouseLeave
 
emits< bool, APointerIndexpressedState
 
emits< APointerIndexpressed
 
emits< APointerIndexreleased
 
emits< bool > enabledState
 
emits enabled
 
emits disabled
 
emits< APointerIndexclickedButton
 Some mouse button clicked.
 
emits clicked
 Left mouse button clicked.
 
emits< glm::ivec2 > positionChanged
 Position changed.
 
emits< glm::ivec2 > sizeChanged
 Size changed.
 
emits< glm::ivec2, glm::ivec2 > geometryChanged
 Geometry (position and size) changed.
 
emits< glm::ivec2 > expandingChanged
 Expanding changed.
 
emits< Visibility > visibilityChanged
 Visibility changed.
 
emits< glm::ivec2 > scrolled
 Scroll event.
 
emits< AInput::Key > keyPressed
 Keyboard key pressed.
 
emits< AInput::Key > keyReleased
 Keyboard key released.
 
emits clickedRight
 Right mouse button clicked.
 
emits clickedRightOrLongPressed
 Right mouse button clicked or long press gesture applied.
 
emits< APointerIndexdoubleClicked
 
emits customCssPropertyChanged
 
emits< bool > focusState
 Focus state changed. More...
 
emits focusAcquired
 
emits focusLost
 
emits< _< AView > > childFocused
 
- Protected Attributes inherited from AViewContainerBase
AVector< _< AView > > mViews
 
bool mWantsLayoutUpdate = true
 
glm::ivec2 mLastLayoutUpdateSize {0, 0}
 
- Protected Attributes inherited from AView
AViewContainerBasemParent = nullptr
 Parent AView.
 
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.
 
ass::PropertyListRecursive mCustomStyleRule
 Custom ASS Rules.
 
AOptional< ACursormCursor = ACursor::DEFAULT
 Determines shape which should pointer take when it's above this AView.
 
glm::ivec2 mPosition = { 0, 0 }
 Top left corner's position relative to top left corner's position of the parent AView.
 
glm::ivec2 mSize = { 20, 20 }
 Size, including content area, border and padding.
 
glm::ivec2 mExpanding = {0, 0}
 Expansion coefficient. Hints layout manager how much this AView should be extended relative to other AViews in the same container. More...
 
AOptional< glm::ivec2 > mCachedMinContentSize
 
bool mMarkedMinContentSizeInvalid = false
 
bool mRedrawRequested = false
 Redraw requested flag for this particular view/. More...
 
glm::ivec2 mMinSize = {0, 0}
 Minimal size.
 
glm::ivec2 mMaxSize = {0x7fffffff, 0x7fffffff}
 Maximal size.
 
glm::ivec2 mFixedSize = {0, 0}
 Fixed size.
 
ABoxFields mMargin
 Margin, which defines the spacing around this AView. Processed by the layout manager.
 
ABoxFields mPadding
 Padding, which defines the spacing around content area inside the view. Processed by AView implementation.
 
AVector< AStringmAssNames
 ASS class names. More...
 
bool mSkipUntilLayoutUpdate = true
 If set to true, AViewContainer is obligated ignore this view. This value is set to false by AView::setGeometry. More...
 

Member Function Documentation

◆ getContentMinimumHeight()

int AScrollArea::getContentMinimumHeight ( )
overridevirtual
Returns
minimal content-area height.

Reimplemented from AView.

◆ getContentMinimumWidth()

int AScrollArea::getContentMinimumWidth ( )
overridevirtual
Returns
minimal content-area width.

Reimplemented from AView.

◆ onGesture()

bool AScrollArea::onGesture ( const glm::ivec2 &  origin,
const AGestureEvent &  event 
)
overridevirtual

Handles touch screen gesture event.

Parameters
originposition where the event(s) started to occur from.
eventgesture event.
Note
The standard implementation AView::onGesture emulates desktop events such as right click and scroll.
See also
transformGestureEventsToDesktop
Returns
true, if consumed (handled). True value prevents click.

Reimplemented from AView.

◆ onPointerPressed()

void AScrollArea::onPointerPressed ( const APointerPressedEvent event)
overridevirtual

Called on pointer (mouse) released event.

Parameters
eventevent

Reimplemented from AView.

◆ onPointerReleased()

void AScrollArea::onPointerReleased ( const APointerReleasedEvent event)
overridevirtual

Called on pointer (mouse) released event.

Parameters
eventevent
Note
To handle clicks, you should use AView::clicked signal instead. View still receives pointer move and released events even if cursor goes outside the view boundaries, or other exclusive event appeared (i.e. scrollarea scroll). AView::clicked emitted only if release event occurred inside view and no other event has prevented click gesture. See APointerReleasedEvent::triggerClick.

Reimplemented from AView.

◆ onScroll()

void AScrollArea::onScroll ( const AScrollEvent event)
overridevirtual

Handles mouse wheel events.

Parameters
posmouse cursor position.
deltathe distance mouse wheel scrolled.

By default, 120 is single mouse wheel click. 120 = mouse scroll down, -120 = mouse scroll up.

Reimplemented from AView.

◆ scrollTo() [1/2]

void AScrollArea::scrollTo ( ARect< int >  target,
bool  nearestBorder = true 
)

Scrolls to the specified rectangle area.

Parameters
targettarget rectangle area in coordinate space of the window.
nearestBorderif true, the scroll is performed up to the nearest border of scroll area, and if the target is already fully visible, then scrollTo does not take effect. If false, the scroll is performed up to the top border of the target view.

◆ scrollTo() [2/2]

void AScrollArea::scrollTo ( const _< AView > &  target,
bool  nearestBorder = true 
)
inline

Scrolls to the specified target view.

Parameters
targettarget view to scroll to. Must be direct or indirect child.
nearestBorderif true, the scroll is performed up to the nearest border of scroll area, and if the target is already fully visible, then scrollTo does not take effect. If false, the scroll is performed up to the top border of the target view.

◆ setSize()

void AScrollArea::setSize ( glm::ivec2  size)
overridevirtual

Reimplemented from AView.

◆ setStickToEnd()

void AScrollArea::setStickToEnd ( bool  stickToEnd)
inline

Set stick to end.

See also
AScrollbar::setStickToEnd

◆ setWheelScrollable()

void AScrollArea::setWheelScrollable ( bool  value)
inline
See also
mIsWheelScrollable

#include <AUI/View/AScrollArea.h>


The documentation for this class was generated from the following files:
Inheritance diagram for AScrollArea:
Collaboration diagram for AScrollArea: