scroll_view.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2016 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 
34 namespace 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 
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 
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 }
std::shared_ptr< ScrollBarView > scrollbar_x_view() const
void set_overflow(ContentOverflow value_x, ContentOverflow value_y)
Definition: clanapp.h:35
View for an area of the user interface.
Definition: view.h:65
ContentOverflow
Definition: scroll_view.h:36
2D Graphics Canvas
Definition: canvas.h:71
Pointer event.
Definition: pointer_event.h:67
float calculate_last_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the last baseline.
void set_overflow_x(ContentOverflow value)
void on_pointer_press(PointerEvent &e)
Process mouse wheel events. When Shift pressed, scrolls horizontally, otherwise vertically.
ContentOverflow overflow_x() const
Definition: scroll_view.h:46
float calculate_preferred_width(Canvas &canvas) override
Calculates the preferred width of this view.
void layout_children(Canvas &canvas) override
Sets the view geometry for all children of this view.
float calculate_preferred_height(Canvas &canvas, float width) override
Calculates the preferred height of this view.
std::shared_ptr< ScrollBarView > scrollbar_y_view() const
bool disabled() const
void set_overflow_y(ContentOverflow value)
Canvas canvas() const
Pointf content_offset() const
float calculate_first_baseline_offset(Canvas &canvas, float width) override
Calculates the offset to the first baseline.
2D (x,y) point structure - Float
Definition: point.h:71
void set_content_offset(const Pointf &offset, bool animated=false)
ContentOverflow overflow_y() const
std::shared_ptr< View > content_view() const