aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/classes
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-09-13 00:26:41 +0200
committer hop311 <hop3114@gmail.com>2024-09-17 22:19:57 +0200
commitc26247464feabe0fbb9d6a8527b242d667faa066 (patch)
tree6dbafe4337ceb672a6e5972b0155333f73cbf262 /extension/src/openvic-extension/classes
parent110a6ad29fb84e4507698897e97aab3f36b24242 (diff)
Allow tooltips to be as tall as the window + shift them to stay inside ittall-tooltip
Diffstat (limited to 'extension/src/openvic-extension/classes')
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.cpp16
-rw-r--r--extension/src/openvic-extension/classes/GUILabel.hpp3
2 files changed, 19 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/classes/GUILabel.cpp b/extension/src/openvic-extension/classes/GUILabel.cpp
index 4b6b1c1..7e93f01 100644
--- a/extension/src/openvic-extension/classes/GUILabel.cpp
+++ b/extension/src/openvic-extension/classes/GUILabel.cpp
@@ -47,6 +47,8 @@ void GUILabel::_bind_methods() {
OV_BIND_METHOD(GUILabel::clear);
OV_BIND_METHOD(GUILabel::get_gui_text_name);
+ OV_BIND_METHOD(GUILabel::force_update_lines);
+
OV_BIND_METHOD(GUILabel::get_text);
OV_BIND_METHOD(GUILabel::set_text, { "new_text" });
@@ -57,6 +59,7 @@ void GUILabel::_bind_methods() {
OV_BIND_METHOD(GUILabel::get_horizontal_alignment);
OV_BIND_METHOD(GUILabel::set_horizontal_alignment, { "new_horizontal_alignment" });
+ OV_BIND_METHOD(GUILabel::get_base_max_size);
OV_BIND_METHOD(GUILabel::get_max_size);
OV_BIND_METHOD(GUILabel::set_max_size, { "new_max_size" });
OV_BIND_METHOD(GUILabel::get_border_size);
@@ -293,6 +296,11 @@ Error GUILabel::set_gui_text(GUI::Text const* new_gui_text, GFX::Font::colour_co
return err;
}
+void GUILabel::force_update_lines() {
+ line_update_queued = true;
+ _update_lines();
+}
+
void GUILabel::set_text(String const& new_text) {
if (text != new_text) {
text = new_text;
@@ -331,6 +339,10 @@ void GUILabel::set_horizontal_alignment(HorizontalAlignment new_horizontal_align
}
}
+Size2 GUILabel::get_base_max_size() const {
+ return gui_text != nullptr ? Utilities::to_godot_fvec2(gui_text->get_max_size()) : Size2 {};
+}
+
void GUILabel::set_max_size(Size2 new_max_size) {
if (max_size != new_max_size) {
max_size = new_max_size;
@@ -462,6 +474,10 @@ void GUILabel::_queue_line_update() {
}
void GUILabel::_update_lines() {
+ if (!line_update_queued) {
+ return;
+ }
+
line_update_queued = false;
lines.clear();
diff --git a/extension/src/openvic-extension/classes/GUILabel.hpp b/extension/src/openvic-extension/classes/GUILabel.hpp
index 67981d7..f04e3ab 100644
--- a/extension/src/openvic-extension/classes/GUILabel.hpp
+++ b/extension/src/openvic-extension/classes/GUILabel.hpp
@@ -74,6 +74,8 @@ namespace OpenVic {
GUI::Text const* new_gui_text, GFX::Font::colour_codes_t const* override_colour_codes = nullptr
);
+ void force_update_lines();
+
void set_text(godot::String const& new_text);
void add_substitution(godot::String const& key, godot::String const& value);
@@ -81,6 +83,7 @@ namespace OpenVic {
void clear_substitutions();
void set_horizontal_alignment(godot::HorizontalAlignment new_horizontal_alignment);
+ godot::Size2 get_base_max_size() const;
void set_max_size(godot::Size2 new_max_size);
void set_border_size(godot::Size2 new_border_size);
void set_auto_adjust_to_content_size(bool new_auto_adjust_to_content_size);