tab_container.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* tab_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 TAB_CONTAINER_H
  31. #define TAB_CONTAINER_H
  32. #include "scene/gui/control.h"
  33. #include "scene/gui/popup.h"
  34. class TabContainer : public Control {
  35. GDCLASS(TabContainer, Control);
  36. public:
  37. enum TabAlign {
  38. ALIGN_LEFT,
  39. ALIGN_CENTER,
  40. ALIGN_RIGHT
  41. };
  42. private:
  43. int mouse_x_cache;
  44. int first_tab_cache;
  45. int tabs_ofs_cache;
  46. int last_tab_cache;
  47. int current;
  48. int previous;
  49. bool tabs_visible;
  50. bool buttons_visible_cache;
  51. TabAlign align;
  52. Control *_get_tab(int p_idx) const;
  53. int _get_top_margin() const;
  54. Popup *popup;
  55. Vector<Control *> _get_tabs() const;
  56. int _get_tab_width(int p_index) const;
  57. protected:
  58. void _child_renamed_callback();
  59. void _gui_input(const Ref<InputEvent> &p_event);
  60. void _notification(int p_what);
  61. virtual void add_child_notify(Node *p_child);
  62. virtual void remove_child_notify(Node *p_child);
  63. static void _bind_methods();
  64. public:
  65. void set_tab_align(TabAlign p_align);
  66. TabAlign get_tab_align() const;
  67. void set_tabs_visible(bool p_visibe);
  68. bool are_tabs_visible() const;
  69. void set_tab_title(int p_tab, const String &p_title);
  70. String get_tab_title(int p_tab) const;
  71. void set_tab_icon(int p_tab, const Ref<Texture> &p_icon);
  72. Ref<Texture> get_tab_icon(int p_tab) const;
  73. void set_tab_disabled(int p_tab, bool p_disabled);
  74. bool get_tab_disabled(int p_tab) const;
  75. int get_tab_count() const;
  76. void set_current_tab(int p_current);
  77. int get_current_tab() const;
  78. int get_previous_tab() const;
  79. Control *get_tab_control(int p_idx) const;
  80. Control *get_current_tab_control() const;
  81. virtual Size2 get_minimum_size() const;
  82. virtual void get_translatable_strings(List<String> *p_strings) const;
  83. void set_popup(Node *p_popup);
  84. Popup *get_popup() const;
  85. TabContainer();
  86. };
  87. VARIANT_ENUM_CAST(TabContainer::TabAlign);
  88. #endif // TAB_CONTAINER_H