scroll_view.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28
29 #pragma once
30
31 #include "../View/view.h"
32
33 namespace clan
34 {
35 enum class ContentOverflow
36 {
37 hidden,
38 scroll,
39 automatic
40 };
41
42 class ScrollBarView;
43 class ScrollViewImpl;
44
45 class ScrollView : public View
46 {
47 public:
48 ScrollView();
49 ~ScrollView();
50
51 std::shared_ptr<ScrollBarView> scrollbar_x_view() const;
52 std::shared_ptr<ScrollBarView> scrollbar_y_view() const;
53
54 std::shared_ptr<View> content_view() const;
55
56 ContentOverflow overflow_x() const;
57 ContentOverflow overflow_y() const;
58 void set_overflow_x(ContentOverflow value);
59 void set_overflow_y(ContentOverflow value);
60 void set_overflow(ContentOverflow value_x, ContentOverflow value_y);
61
62 Pointf content_offset() const;
63 void set_content_offset(const Pointf &offset, bool animated = false);
64
65 void layout_subviews(Canvas &canvas) override;
66 float get_preferred_width(Canvas &canvas) override;
67 float get_preferred_height(Canvas &canvas, float width) override;
68 float get_first_baseline_offset(Canvas &canvas, float width) override;
69 float get_last_baseline_offset(Canvas &canvas, float width) override;
70
71 private:
72 std::unique_ptr<ScrollViewImpl> impl;
73 };
74 }
clan::ScrollView::scrollbar_x_view
std::shared_ptr< ScrollBarView > scrollbar_x_view() const
clan::ScrollView::set_overflow
void set_overflow(ContentOverflow value_x, ContentOverflow value_y)
clan
Definition: clanapp.h:35
clan::View
View for an area of the user interface.
Definition: view.h:61
clan::ContentOverflow
ContentOverflow
Definition: scroll_view.h:35
clan::ScrollView::get_preferred_width
float get_preferred_width(Canvas &canvas) override
Calculates the preferred width of this view.
clan::Canvas
2D Graphics Canvas
Definition: canvas.h:72
clan::ScrollView::get_last_baseline_offset
float get_last_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the last baseline.
clan::ScrollView::set_overflow_x
void set_overflow_x(ContentOverflow value)
clan::Key::scroll
clan::ScrollView::overflow_x
ContentOverflow overflow_x() const
clan::ScrollView::get_preferred_height
float get_preferred_height(Canvas &canvas, float width) override
Calculates the preferred height of this view.
clan::ScrollView
Definition: scroll_view.h:45
clan::ScrollView::~ScrollView
~ScrollView()
clan::ScrollView::layout_subviews
void layout_subviews(Canvas &canvas) override
Sets the view geometry for all subviews of this view.
clan::ScrollView::ScrollView
ScrollView()
clan::ScrollView::scrollbar_y_view
std::shared_ptr< ScrollBarView > scrollbar_y_view() const
clan::ScrollView::set_overflow_y
void set_overflow_y(ContentOverflow value)
clan::ContentOverflow::hidden
clan::ScrollView::content_offset
Pointf content_offset() const
clan::ContentOverflow::automatic
clan::Pointf
2D (x,y) point structure - Float
Definition: point.h:72
clan::ScrollView::get_first_baseline_offset
float get_first_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the first baseline.
clan::ScrollView::set_content_offset
void set_content_offset(const Pointf &offset, bool animated=false)
clan::ScrollView::overflow_y
ContentOverflow overflow_y() const
clan::ScrollView::content_view
std::shared_ptr< View > content_view() const