scroll_view.h Source File - ClanLib SDK
Description: scroll_view.h Source File

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,
40 automatic
41 };
42
43 class ScrollBarView;
44 class ScrollViewImpl;
45
46 class ScrollView : public View
47 {
48 public:
49 ScrollView();
50 ~ScrollView();
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
57 ContentOverflow overflow_x() const;
58 ContentOverflow overflow_y() const;
59 void set_overflow_x(ContentOverflow value);
60 void set_overflow_y(ContentOverflow value);
61 void set_overflow(ContentOverflow value_x, ContentOverflow value_y);
62
63 Pointf content_offset() const;
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;
70 void set_disabled();
71 void set_enabled();
72
74 void on_pointer_press(PointerEvent &e);
75
76 protected:
77 float calculate_preferred_width(Canvas &canvas) override;
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}
clan::Canvas
2D Graphics Canvas
Definition canvas.h:72
clan::PointerEvent
Pointer event.
Definition pointer_event.h:68
clan::Pointf
2D (x,y) point structure - Float
Definition point.h:72
clan::ScrollView
Definition scroll_view.h:47
clan::ScrollView::scrollbar_x_view
std::shared_ptr< ScrollBarView > scrollbar_x_view() const
clan::ScrollView::ScrollView
ScrollView()
clan::ScrollView::scrollbar_y_view
std::shared_ptr< ScrollBarView > scrollbar_y_view() const
clan::ScrollView::layout_children
void layout_children(Canvas &canvas) override
Sets the view geometry for all children of this view.
clan::ScrollView::overflow_y
ContentOverflow overflow_y() const
clan::ScrollView::set_overflow_x
void set_overflow_x(ContentOverflow value)
clan::ScrollView::calculate_preferred_height
float calculate_preferred_height(Canvas &canvas, float width) override
Calculates the preferred height of this view.
clan::ScrollView::disabled
bool disabled() const
clan::ScrollView::content_offset
Pointf content_offset() const
clan::ScrollView::on_pointer_press
void on_pointer_press(PointerEvent &e)
Process mouse wheel events. When Shift pressed, scrolls horizontally, otherwise vertically.
clan::ScrollView::set_enabled
void set_enabled()
clan::ScrollView::~ScrollView
~ScrollView()
clan::ScrollView::calculate_preferred_width
float calculate_preferred_width(Canvas &canvas) override
Calculates the preferred width of this view.
clan::ScrollView::calculate_last_baseline_offset
float calculate_last_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the last baseline.
clan::ScrollView::set_overflow
void set_overflow(ContentOverflow value_x, ContentOverflow value_y)
clan::ScrollView::calculate_first_baseline_offset
float calculate_first_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the first baseline.
clan::ScrollView::overflow_x
ContentOverflow overflow_x() const
clan::ScrollView::content_view
std::shared_ptr< View > content_view() const
clan::ScrollView::set_overflow_y
void set_overflow_y(ContentOverflow value)
clan::ScrollView::set_disabled
void set_disabled()
clan::ScrollView::set_content_offset
void set_content_offset(const Pointf &offset, bool animated=false)
clan::View
View for an area of the user interface.
Definition view.h:66
clan::View::canvas
Canvas canvas() const
clan
Definition clanapp.h:36
clan::Key::scroll
@ scroll
clan::Key::e
@ e
clan::ContentOverflow
ContentOverflow
Definition scroll_view.h:37
clan::ContentOverflow::automatic
@ automatic
clan::ContentOverflow::hidden
@ hidden