split_container.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**************************************************************************/
  2. /* split_container.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  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 SPLIT_CONTAINER_H
  31. #define SPLIT_CONTAINER_H
  32. #include "scene/gui/container.h"
  33. class SplitContainer : public Container {
  34. GDCLASS(SplitContainer, Container);
  35. public:
  36. enum DraggerVisibility {
  37. DRAGGER_VISIBLE,
  38. DRAGGER_HIDDEN,
  39. DRAGGER_HIDDEN_COLLAPSED
  40. };
  41. private:
  42. bool should_clamp_split_offset;
  43. int split_offset;
  44. int middle_sep;
  45. bool vertical;
  46. bool dragging;
  47. int drag_from;
  48. int drag_ofs;
  49. bool collapsed;
  50. DraggerVisibility dragger_visibility;
  51. bool mouse_inside;
  52. Control *_getch(int p_idx) const;
  53. void _resort();
  54. protected:
  55. void _gui_input(const Ref<InputEvent> &p_event);
  56. void _notification(int p_what);
  57. static void _bind_methods();
  58. public:
  59. void set_split_offset(int p_offset);
  60. int get_split_offset() const;
  61. void clamp_split_offset();
  62. void set_collapsed(bool p_collapsed);
  63. bool is_collapsed() const;
  64. void set_dragger_visibility(DraggerVisibility p_visibility);
  65. DraggerVisibility get_dragger_visibility() const;
  66. virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
  67. virtual Size2 get_minimum_size() const;
  68. SplitContainer(bool p_vertical = false);
  69. };
  70. VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
  71. class HSplitContainer : public SplitContainer {
  72. GDCLASS(HSplitContainer, SplitContainer);
  73. public:
  74. HSplitContainer() :
  75. SplitContainer(false) {}
  76. };
  77. class VSplitContainer : public SplitContainer {
  78. GDCLASS(VSplitContainer, SplitContainer);
  79. public:
  80. VSplitContainer() :
  81. SplitContainer(true) {}
  82. };
  83. #endif // SPLIT_CONTAINER_H