scroll_container.h 3.2 KB

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