scroll_container.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*************************************************************************/
  2. /* scroll_container.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef SCROLL_CONTAINER_H
  31. #define SCROLL_CONTAINER_H
  32. #include "container.h"
  33. #include "scroll_bar.h"
  34. class ScrollContainer : public Container {
  35. GDCLASS(ScrollContainer, Container);
  36. HScrollBar *h_scroll;
  37. VScrollBar *v_scroll;
  38. Size2 child_max_size;
  39. Size2 scroll;
  40. void update_scrollbars();
  41. Vector2 drag_speed;
  42. Vector2 drag_accum;
  43. Vector2 drag_from;
  44. Vector2 last_drag_accum;
  45. float last_drag_time;
  46. float time_since_motion;
  47. bool drag_touching;
  48. bool drag_touching_deaccel;
  49. bool click_handled;
  50. bool beyond_deadzone;
  51. bool scroll_h;
  52. bool scroll_v;
  53. int deadzone;
  54. void _cancel_drag();
  55. protected:
  56. Size2 get_minimum_size() const;
  57. void _gui_input(const Ref<InputEvent> &p_gui_input);
  58. void _notification(int p_what);
  59. void _scroll_moved(float);
  60. static void _bind_methods();
  61. void _update_scrollbar_position();
  62. public:
  63. int get_v_scroll() const;
  64. void set_v_scroll(int p_pos);
  65. int get_h_scroll() const;
  66. void set_h_scroll(int p_pos);
  67. void set_enable_h_scroll(bool p_enable);
  68. bool is_h_scroll_enabled() const;
  69. void set_enable_v_scroll(bool p_enable);
  70. bool is_v_scroll_enabled() const;
  71. int get_deadzone() const;
  72. void set_deadzone(int p_deadzone);
  73. HScrollBar *get_h_scrollbar();
  74. VScrollBar *get_v_scrollbar();
  75. virtual bool clips_input() const;
  76. virtual String get_configuration_warning() const;
  77. ScrollContainer();
  78. };
  79. #endif