texture_button.h 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*************************************************************************/
  2. /* texture_button.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 TEXTURE_BUTTON_H
  31. #define TEXTURE_BUTTON_H
  32. #include "scene/gui/base_button.h"
  33. #include "scene/resources/bit_mask.h"
  34. class TextureButton : public BaseButton {
  35. GDCLASS(TextureButton, BaseButton);
  36. public:
  37. enum StretchMode {
  38. STRETCH_SCALE,
  39. STRETCH_TILE,
  40. STRETCH_KEEP,
  41. STRETCH_KEEP_CENTERED,
  42. STRETCH_KEEP_ASPECT,
  43. STRETCH_KEEP_ASPECT_CENTERED,
  44. STRETCH_KEEP_ASPECT_COVERED,
  45. };
  46. private:
  47. Ref<Texture> normal;
  48. Ref<Texture> pressed;
  49. Ref<Texture> hover;
  50. Ref<Texture> disabled;
  51. Ref<Texture> focused;
  52. Ref<BitMap> click_mask;
  53. bool expand;
  54. StretchMode stretch_mode;
  55. protected:
  56. virtual Size2 get_minimum_size() const;
  57. virtual bool has_point(const Point2 &p_point) const;
  58. void _notification(int p_what);
  59. static void _bind_methods();
  60. public:
  61. void set_normal_texture(const Ref<Texture> &p_normal);
  62. void set_pressed_texture(const Ref<Texture> &p_pressed);
  63. void set_hover_texture(const Ref<Texture> &p_hover);
  64. void set_disabled_texture(const Ref<Texture> &p_disabled);
  65. void set_focused_texture(const Ref<Texture> &p_focused);
  66. void set_click_mask(const Ref<BitMap> &p_click_mask);
  67. Ref<Texture> get_normal_texture() const;
  68. Ref<Texture> get_pressed_texture() const;
  69. Ref<Texture> get_hover_texture() const;
  70. Ref<Texture> get_disabled_texture() const;
  71. Ref<Texture> get_focused_texture() const;
  72. Ref<BitMap> get_click_mask() const;
  73. bool get_expand() const;
  74. void set_expand(bool p_expand);
  75. void set_stretch_mode(StretchMode p_stretch_mode);
  76. StretchMode get_stretch_mode() const;
  77. TextureButton();
  78. };
  79. VARIANT_ENUM_CAST(TextureButton::StretchMode);
  80. #endif // TEXTURE_BUTTON_H