link_button.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*************************************************************************/
  2. /* link_button.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 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 LINKBUTTON_H
  31. #define LINKBUTTON_H
  32. #include "scene/gui/base_button.h"
  33. #include "scene/resources/bit_map.h"
  34. #include "scene/resources/text_line.h"
  35. class LinkButton : public BaseButton {
  36. GDCLASS(LinkButton, BaseButton);
  37. public:
  38. enum UnderlineMode {
  39. UNDERLINE_MODE_ALWAYS,
  40. UNDERLINE_MODE_ON_HOVER,
  41. UNDERLINE_MODE_NEVER
  42. };
  43. private:
  44. String text;
  45. String xl_text;
  46. Ref<TextLine> text_buf;
  47. UnderlineMode underline_mode = UNDERLINE_MODE_ALWAYS;
  48. Dictionary opentype_features;
  49. String language;
  50. TextDirection text_direction = TEXT_DIRECTION_AUTO;
  51. Control::StructuredTextParser st_parser = STRUCTURED_TEXT_DEFAULT;
  52. Array st_args;
  53. void _shape();
  54. protected:
  55. virtual Size2 get_minimum_size() const override;
  56. void _notification(int p_what);
  57. static void _bind_methods();
  58. bool _set(const StringName &p_name, const Variant &p_value);
  59. bool _get(const StringName &p_name, Variant &r_ret) const;
  60. void _get_property_list(List<PropertyInfo> *p_list) const;
  61. public:
  62. void set_text(const String &p_text);
  63. String get_text() const;
  64. void set_structured_text_bidi_override(Control::StructuredTextParser p_parser);
  65. Control::StructuredTextParser get_structured_text_bidi_override() const;
  66. void set_structured_text_bidi_override_options(Array p_args);
  67. Array get_structured_text_bidi_override_options() const;
  68. void set_text_direction(TextDirection p_text_direction);
  69. TextDirection get_text_direction() const;
  70. void set_opentype_feature(const String &p_name, int p_value);
  71. int get_opentype_feature(const String &p_name) const;
  72. void clear_opentype_features();
  73. void set_language(const String &p_language);
  74. String get_language() const;
  75. void set_underline_mode(UnderlineMode p_underline_mode);
  76. UnderlineMode get_underline_mode() const;
  77. LinkButton();
  78. };
  79. VARIANT_ENUM_CAST(LinkButton::UnderlineMode);
  80. #endif // LINKBUTTON_H