scroll_view.h
1/*
2** ClanLib SDK
3** Copyright (c) 1997-2020 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** Artem Khomenko
28*/
29
30#pragma once
31
32#include "../View/view.h"
33
34namespace clan
35{
36 enum class ContentOverflow
37 {
38 hidden,
39 scroll,
41 };
42
43 class ScrollBarView;
44 class ScrollViewImpl;
45
46 class ScrollView : public View
47 {
48 public:
51
52 std::shared_ptr<ScrollBarView> scrollbar_x_view() const;
53 std::shared_ptr<ScrollBarView> scrollbar_y_view() const;
54
55 std::shared_ptr<View> content_view() const;
56
62
64 void set_content_offset(const Pointf &offset, bool animated = false);
65
66 void layout_children(Canvas &canvas) override;
67
68 // Enable or disable.
69 bool disabled() const;
72
75
76 protected:
78 float calculate_preferred_height(Canvas &canvas, float width) override;
79 float calculate_first_baseline_offset(Canvas &canvas, float width) override;
80 float calculate_last_baseline_offset(Canvas &canvas, float width) override;
81
82 private:
83 std::unique_ptr<ScrollViewImpl> impl;
84 };
85}
2D Graphics Canvas
Definition: canvas.h:72
Pointer event.
Definition: pointer_event.h:68
2D (x,y) point structure - Float
Definition: point.h:72
Definition: scroll_view.h:47
std::shared_ptr< ScrollBarView > scrollbar_x_view() const
std::shared_ptr< ScrollBarView > scrollbar_y_view() const
void layout_children(Canvas &canvas) override
Sets the view geometry for all children of this view.
ContentOverflow overflow_y() const
void set_overflow_x(ContentOverflow value)
float calculate_preferred_height(Canvas &canvas, float width) override
Calculates the preferred height of this view.
bool disabled() const
Pointf content_offset() const
void on_pointer_press(PointerEvent &e)
Process mouse wheel events. When Shift pressed, scrolls horizontally, otherwise vertically.
float calculate_preferred_width(Canvas &canvas) override
Calculates the preferred width of this view.
float calculate_last_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the last baseline.
void set_overflow(ContentOverflow value_x, ContentOverflow value_y)
float calculate_first_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the first baseline.
ContentOverflow overflow_x() const
std::shared_ptr< View > content_view() const
void set_overflow_y(ContentOverflow value)
void set_content_offset(const Pointf &offset, bool animated=false)
View for an area of the user interface.
Definition: view.h:66
Canvas canvas() const
Definition: clanapp.h:36
ContentOverflow
Definition: scroll_view.h:37