editor_spin_slider.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*************************************************************************/
  2. /* editor_spin_slider.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 EDITOR_SPIN_SLIDER_H
  31. #define EDITOR_SPIN_SLIDER_H
  32. #include "scene/gui/line_edit.h"
  33. #include "scene/gui/range.h"
  34. #include "scene/gui/texture_rect.h"
  35. class EditorSpinSlider : public Range {
  36. GDCLASS(EditorSpinSlider, Range)
  37. String label;
  38. int updown_offset;
  39. bool hover_updown;
  40. bool mouse_hover;
  41. TextureRect *grabber;
  42. int grabber_range;
  43. bool mouse_over_spin;
  44. bool mouse_over_grabber;
  45. bool grabbing_grabber;
  46. int grabbing_from;
  47. float grabbing_ratio;
  48. bool grabbing_spinner_attempt;
  49. bool grabbing_spinner;
  50. bool read_only;
  51. float grabbing_spinner_dist_cache;
  52. Vector2 grabbing_spinner_mouse_pos;
  53. double pre_grab_value;
  54. LineEdit *value_input;
  55. bool value_input_just_closed;
  56. void _grabber_gui_input(const Ref<InputEvent> &p_event);
  57. void _value_input_closed();
  58. void _value_input_entered(const String &);
  59. void _value_focus_exited();
  60. bool hide_slider;
  61. bool flat;
  62. bool use_custom_label_color;
  63. Color custom_label_color;
  64. void _evaluate_input_text();
  65. protected:
  66. void _notification(int p_what);
  67. void _gui_input(const Ref<InputEvent> &p_event);
  68. static void _bind_methods();
  69. void _grabber_mouse_entered();
  70. void _grabber_mouse_exited();
  71. void _focus_entered();
  72. public:
  73. String get_tooltip(const Point2 &p_pos) const;
  74. String get_text_value() const;
  75. void set_label(const String &p_label);
  76. String get_label() const;
  77. void set_hide_slider(bool p_hide);
  78. bool is_hiding_slider() const;
  79. void set_read_only(bool p_enable);
  80. bool is_read_only() const;
  81. void set_flat(bool p_enable);
  82. bool is_flat() const;
  83. void set_custom_label_color(bool p_use_custom_label_color, Color p_custom_label_color);
  84. virtual Size2 get_minimum_size() const;
  85. EditorSpinSlider();
  86. };
  87. #endif // EDITOR_SPIN_SLIDER_H