1 /* 2 Copyright (C) 2008 - 2018 by Mark de Wever <koraq@xs4all.nl> 3 Part of the Battle for Wesnoth Project https://www.wesnoth.org/ 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY. 11 12 See the COPYING file for more details. 13 */ 14 15 #pragma once 16 17 #include "gui/widgets/scrollbar.hpp" 18 19 namespace gui2 20 { 21 namespace implementation 22 { 23 struct builder_vertical_scrollbar; 24 } 25 26 // ------------ WIDGET -----------{ 27 28 /** A vertical scrollbar. */ 29 class vertical_scrollbar : public scrollbar_base 30 { 31 friend struct implementation::builder_vertical_scrollbar; 32 33 public: 34 explicit vertical_scrollbar(const implementation::builder_vertical_scrollbar& builder); 35 36 private: 37 /** Inherited from scrollbar_base. */ get_length() const38 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. */ get_length_difference(const point & original,const point & current) const65 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 81 struct vertical_scrollbar_definition : public styled_widget_definition 82 { 83 explicit vertical_scrollbar_definition(const config& cfg); 84 85 struct resolution : public resolution_definition 86 { 87 explicit resolution(const config& cfg); 88 89 unsigned minimum_positioner_length; 90 unsigned maximum_positioner_length; 91 92 unsigned top_offset; 93 unsigned bottom_offset; 94 }; 95 }; 96 97 // }---------- BUILDER -----------{ 98 99 namespace implementation 100 { 101 102 struct builder_vertical_scrollbar : public builder_styled_widget 103 { 104 explicit builder_vertical_scrollbar(const config& cfg); 105 106 using builder_styled_widget::build; 107 108 widget* build() const; 109 }; 110 111 } // namespace implementation 112 113 // }------------ END -------------- 114 115 } // namespace gui2 116