CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIScrollView.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIView.hpp"
11
12namespace CeresEngine {
13
14 class UIClipView;
15 class UIScroller;
16
29 class UIScrollView : public UIView {
30 using super = UIView;
31
32 private:
36
45
53
62 bool mAutohidesScrollers = false;
63
72
80 double mVerticalLineScroll = 1.0;
81
99 double mHorizontalPageScroll = 10.0;
100
118 double mVerticalPageScroll = 10.0;
119
128
133
134 private:
137
138 public:
141
144 explicit UIScrollView(const String& name);
145
148 explicit UIScrollView(const UIRect& frame, const String& name = "");
149
153 explicit UIScrollView(const UISize& size, const String& name = "") : UIScrollView(UIPoint(0, 0), size, name) {}
154
159 explicit UIScrollView(const UIPoint& origin, const UISize& size, const String& name = "") : UIScrollView(UIRect(origin, size), name) {}
160
167 explicit UIScrollView(const double x, const double y, const double width, const double height, const String& name = "") : UIScrollView(UIRect(x, y, width, height), name) {}
168
170 ~UIScrollView() override;
171
172 public: // Views
175
178
181
182 public: // Scrollers
185
192 [[nodiscard]] bool hasHorizontalScroller() const { return mHorizontalScroller != nullptr; }
193
196
199
207
210
213
216
219
222
223 public: // Scrolling behavior
226
229
232
235
238
241
244
247
250
253
254 public:
266
267 public: // UIView
269 void layoutSubviews() override;
270
272 [[nodiscard]] UIScrollView* getScrollView() const final { return const_cast<UIScrollView*>(this); }
273
276
279
280 public: // UIResponder
282 void scrollWheel(const CeresEngine::UIMouseEvent &event) override;
283
284 protected:
287
290
293
295 virtual UIRect getClipViewFrame() const;
296
297 private:
300
303 };
304
305} // namespace CeresEngine
Scoped connection class.
Definition Event.hpp:104
An object that represents a graphics context.
Definition GraphicsContext.hpp:45
An object that clips a document view to a scroll view's frame.
Definition UIClipView.hpp:25
A view that displays a portion of a document view and provides scroll bars that allow the user to mov...
Definition UIScrollView.hpp:29
virtual UIRect getClipViewFrame() const
Calculates the clip view frame.
void didScrollVertically()
An event called whenever the vertical scroller has changed position.
double getVerticalLineScroll() const noexcept
The scroll view’s vertical line by line scroll amount.
Definition UIScrollView.hpp:231
double getVerticalPageScroll() const noexcept
The amount of the document view kept visible when scrolling vertically page by page.
Definition UIScrollView.hpp:243
UIScrollView(const UISize &size, const String &name="")
Initializes new UIScrollView object with an frame rectangle size.
Definition UIScrollView.hpp:153
bool hasHorizontalScroller() const
A boolean that indicates whether the scroll view has a horizontal scroller.
Definition UIScrollView.hpp:192
UIView * getDocumentView() const noexcept
bool mAutohidesScrollers
A Boolean that indicates whether the scroll view automatically hides its scroll bars when they are no...
Definition UIScrollView.hpp:62
void setHorizontalPageScroll(double horizontalPageScroll)
The amount of the document view kept visible when scrolling horizontally page by page.
UIScrollView()
Initializes new UIScrollView object with an empty frame rectangle.
UIClipView * getClipView() const noexcept
The scroll view's clip view, the view that clips the document view.
Definition UIScrollView.hpp:174
void setResizesIfScrollerDisabled(bool resizesIfScrollerDisabled)
A boolean that indicates whether the scroll view resizes the document view frame width if the horizon...
EventConnection mVerticalScrollerDidScrollConnection
Definition UIScrollView.hpp:136
double mHorizontalLineScroll
The scroll view’s horizontal line by line scroll amount.
Definition UIScrollView.hpp:71
void setDocumentView(UIView *documentView)
void setAutohidesScrollers(bool autohidesScrollers)
A Boolean that indicates whether the scroll view automatically hides its scroll bars when they are no...
UIScrollView(const UIRect &frame, const String &name="")
Initializes new UIScrollView object with a frame rectangle.
double mVerticalPageScroll
The amount of the document view kept visible when scrolling vertically page by page.
Definition UIScrollView.hpp:118
UIScroller * getHorizontalScroller() const noexcept
The scroll view's horizontal scroller.
Definition UIScrollView.hpp:184
UIClipView * mClipView
The scroll view's clip view, the view that clips the document view.
Definition UIScrollView.hpp:35
UIScrollView(const double x, const double y, const double width, const double height, const String &name="")
Initializes new UIScrollView object with an frame rectangle size.
Definition UIScrollView.hpp:167
double mHorizontalPageScroll
The amount of the document view kept visible when scrolling horizontally page by page.
Definition UIScrollView.hpp:99
void reflectScrolledClipView()
Adjusts the receiver’s scrollers to reflect the size and positioning of its content view.
void scrollWheel(const CeresEngine::UIMouseEvent &event) override
Informs the receiver that the mouse's scroll wheel has moved.
virtual UIRect getVerticalScrollerFrame() const
Calculates the vertical scroller view frame.
void setHasHorizontalScroller(bool hasHorizontalScroller)
A boolean that indicates whether the scroll view has a horizontal scroller.
double getHorizontalPageScroll() const noexcept
The amount of the document view kept visible when scrolling horizontally page by page.
Definition UIScrollView.hpp:237
void draw(CeresEngine::UIGraphicsContext &context, const CeresEngine::UIRect &dirtyRect) override
Overridden by subclasses to draw the view's texture within the specified rectangle.
virtual UIRect getHorizontalScrollerFrame() const
Calculates the horizontal scroller view frame.
UIRect getInsetBounds() const
Gets the inseted bounds of the scroll view.
UIScroller * mHorizontalScroller
The scroll view's horizontal scroller.
Definition UIScrollView.hpp:44
void didScrollHorizontally()
An event called whenever the horizontal scroller has changed position.
UIScroller * mVerticalScroller
The scroll view's vertical scroller.
Definition UIScrollView.hpp:52
double getHorizontalLineScroll() const noexcept
The scroll view’s horizontal line by line scroll amount.
Definition UIScrollView.hpp:225
UIScrollView(const UIPoint &origin, const UISize &size, const String &name="")
Initializes new UIScrollView object with an frame rectangle size.
Definition UIScrollView.hpp:159
double mVerticalLineScroll
The scroll view’s vertical line by line scroll amount.
Definition UIScrollView.hpp:80
void setHorizontalLineScroll(double horizontalLineScroll)
The scroll view’s horizontal line by line scroll amount.
~UIScrollView() override
Destroys a UIScrollView.
void setScrollsDynamically(bool scrollsDynamically)
A Boolean that indicates whether the scroll view redraws its document view while scrolling continuous...
UIScrollView(const String &name)
Initializes new UIScrollView object with an empty frame rectangle and custom name.
EventConnection mHorizontalScrollerDidScrollConnection
Definition UIScrollView.hpp:135
bool hasVerticalScroller() const noexcept
A boolean that indicates whether the scroll view has a vertical scroller.
Definition UIScrollView.hpp:206
void setHasVerticalScroller(bool hasVerticalScroller)
A boolean that indicates whether the scroll view has a vertical scroller.
bool isScrollsDynamically() const noexcept
A Boolean that indicates whether the scroll view redraws its document view while scrolling continuous...
Definition UIScrollView.hpp:249
UIScrollView * getScrollView() const final
Gets the closest parent scroll view to this view.
Definition UIScrollView.hpp:272
bool autohidesScrollers() const noexcept
A Boolean that indicates whether the scroll view automatically hides its scroll bars when they are no...
Definition UIScrollView.hpp:212
bool resizesIfScrollerDisabled() const noexcept
A boolean that indicates whether the scroll view resizes the document view frame width if the horizon...
Definition UIScrollView.hpp:218
void layoutSubviews() override
Lays out subviews.
UISize calculateFittingLayoutSize(const UISize &targetSize) const override
Returns the optimal size of the view based on its current constraints.
bool mScrollsDynamically
A Boolean that indicates whether the scroll view redraws its document view while scrolling continuous...
Definition UIScrollView.hpp:127
void setVerticalLineScroll(double verticalLineScroll)
The scroll view’s vertical line by line scroll amount.
void setVerticalPageScroll(double verticalPageScroll)
The amount of the document view kept visible when scrolling vertically page by page.
UIScroller * getVerticalScroller() const noexcept
The scroll view's vertical scroller.
Definition UIScrollView.hpp:198
bool mResizesIfScrollerDisabled
A boolean that indicates whether the scroll view resizes the document view frame width if the horizon...
Definition UIScrollView.hpp:132
An object that controls scrolling of a document view within a scroll view or other type of container ...
Definition UIScroller.hpp:32
The infrastructure for drawing and handling events in a UI.
Definition UIView.hpp:153
UIView()
Initializes new UIView object with an empty frame rectangle.
const UILayoutAnchor height
The height of the object's alignment rectangle.
Definition UIView.hpp:1216
const UILayoutAnchor width
The width of the object's alignment rectangle.
Definition UIView.hpp:1213
Definition Application.hpp:19
Size2 UISize
A type that contains width and height values.
Definition UIUtility.hpp:30
Rect2 UIRect
A structure that contains the location and dimensions of a rectangle.
Definition UIUtility.hpp:33
Point2 UIPoint
A type that contains a point in a two-dimensional coordinate system.
Definition UIUtility.hpp:27
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition UIEvent.hpp:173