split_container.h 3.6 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) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 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 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 vertical;
  43. int expand_ofs;
  44. int middle_sep;
  45. bool dragging;
  46. int drag_from;
  47. int drag_ofs;
  48. bool collapsed;
  49. DraggerVisibility dragger_visibility;
  50. bool mouse_inside;
  51. Control *_getch(int p_idx) const;
  52. void _resort();
  53. protected:
  54. void _gui_input(const Ref<InputEvent> &p_event);
  55. void _notification(int p_what);
  56. static void _bind_methods();
  57. public:
  58. void set_split_offset(int p_offset);
  59. int get_split_offset() const;
  60. void set_collapsed(bool p_collapsed);
  61. bool is_collapsed() const;
  62. void set_dragger_visibility(DraggerVisibility p_visibility);
  63. DraggerVisibility get_dragger_visibility() const;
  64. virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const;
  65. virtual Size2 get_minimum_size() const;
  66. SplitContainer(bool p_vertical = false);
  67. };
  68. VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
  69. class HSplitContainer : public SplitContainer {
  70. GDCLASS(HSplitContainer, SplitContainer);
  71. public:
  72. HSplitContainer()
  73. : SplitContainer(false) { set_default_cursor_shape(CURSOR_HSPLIT); }
  74. };
  75. class VSplitContainer : public SplitContainer {
  76. GDCLASS(VSplitContainer, SplitContainer);
  77. public:
  78. VSplitContainer()
  79. : SplitContainer(true) { set_default_cursor_shape(CURSOR_VSPLIT); }
  80. };
  81. #endif // SPLIT_CONTAINER_H