The Battle for Wesnoth  1.19.1+dev
vertical_scrollbar.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
20 namespace gui2
21 {
22 namespace implementation
23 {
24 struct builder_vertical_scrollbar;
25 }
26 
27 // ------------ WIDGET -----------{
28 
30 {
32 
33 public:
35 
36 private:
37  /** Inherited from scrollbar_base. */
38  virtual unsigned get_length() const override
39  {
40  return get_height();
41  }
42 
43  /** Inherited from scrollbar_base. */
44  virtual unsigned minimum_positioner_length() const override;
45 
46  /** Inherited from scrollbar_base. */
47  virtual unsigned maximum_positioner_length() const override;
48 
49  /** Inherited from scrollbar_base. */
50  virtual unsigned offset_before() const override;
51 
52  /** Inherited from scrollbar_base. */
53  virtual unsigned offset_after() const override;
54 
55  /** Inherited from scrollbar_base. */
56  virtual bool on_positioner(const point& coordinate) const override;
57 
58  /** Inherited from scrollbar_base. */
59  virtual int on_bar(const point& coordinate) const override;
60 
61  /** Inherited from scrollbar_base. */
62  virtual bool in_orthogonal_range(const point& coordinate) const override;
63 
64  /** Inherited from scrollbar_base. */
65  virtual int get_length_difference(const point& original, const point& current) const override
66  {
67  return current.y - original.y;
68  }
69 
70 public:
71  /** Static type getter that does not rely on the widget being constructed. */
72  static const std::string& type();
73 
74 private:
75  /** Inherited from styled_widget, implemented by REGISTER_WIDGET. */
76  virtual const std::string& get_control_type() const override;
77 };
78 
79 // }---------- DEFINITION ---------{
80 
82 {
83  explicit vertical_scrollbar_definition(const config& cfg);
84 
86  {
87  explicit resolution(const config& cfg);
88 
91 
92  unsigned top_offset;
93  unsigned bottom_offset;
94  };
95 };
96 
97 // }---------- BUILDER -----------{
98 
99 namespace implementation
100 {
101 
103 {
104  explicit builder_vertical_scrollbar(const config& cfg);
105 
107 
108  virtual std::unique_ptr<widget> build() const override;
109 };
110 
111 } // namespace implementation
112 
113 // }------------ END --------------
114 
115 } // namespace gui2
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Base class for a scroll bar.
Definition: scrollbar.hpp:39
virtual int on_bar(const point &coordinate) const override
Inherited from scrollbar_base.
virtual unsigned maximum_positioner_length() const override
Inherited from scrollbar_base.
virtual const std::string & get_control_type() const override
Inherited from styled_widget, implemented by REGISTER_WIDGET.
virtual bool on_positioner(const point &coordinate) const override
Inherited from scrollbar_base.
virtual bool in_orthogonal_range(const point &coordinate) const override
Inherited from scrollbar_base.
static const std::string & type()
Static type getter that does not rely on the widget being constructed.
virtual unsigned get_length() const override
Inherited from scrollbar_base.
vertical_scrollbar(const implementation::builder_vertical_scrollbar &builder)
virtual int get_length_difference(const point &original, const point &current) const override
Inherited from scrollbar_base.
virtual unsigned offset_after() const override
Inherited from scrollbar_base.
virtual unsigned offset_before() const override
Inherited from scrollbar_base.
virtual unsigned minimum_positioner_length() const override
Inherited from scrollbar_base.
unsigned get_height() const
Definition: widget.cpp:331
Generic file dialog.
Contains the implementation details for lexical_cast and shouldn't be used directly.
map_location coordinate
Contains an x and y coordinate used for starting positions in maps.
virtual std::unique_ptr< widget > build() const=0
virtual std::unique_ptr< widget > build() const override
Holds a 2D point.
Definition: point.hpp:25