|
@@ -323,6 +323,19 @@ void TabBar::gui_input(const Ref<InputEvent> &p_event) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+String TabBar::get_tooltip(const Point2 &p_pos) const {
|
|
|
|
+ int tab_idx = get_tab_idx_at_point(p_pos);
|
|
|
|
+ if (tab_idx < 0) {
|
|
|
|
+ return Control::get_tooltip(p_pos);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (tabs[tab_idx].tooltip.is_empty() && tabs[tab_idx].truncated) {
|
|
|
|
+ return tabs[tab_idx].text;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return tabs[tab_idx].tooltip;
|
|
|
|
+}
|
|
|
|
+
|
|
void TabBar::_shape(int p_tab) {
|
|
void TabBar::_shape(int p_tab) {
|
|
tabs.write[p_tab].text_buf->clear();
|
|
tabs.write[p_tab].text_buf->clear();
|
|
tabs.write[p_tab].text_buf->set_width(-1);
|
|
tabs.write[p_tab].text_buf->set_width(-1);
|
|
@@ -757,6 +770,16 @@ String TabBar::get_tab_title(int p_tab) const {
|
|
return tabs[p_tab].text;
|
|
return tabs[p_tab].text;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void TabBar::set_tab_tooltip(int p_tab, const String &p_tooltip) {
|
|
|
|
+ ERR_FAIL_INDEX(p_tab, tabs.size());
|
|
|
|
+ tabs.write[p_tab].tooltip = p_tooltip;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+String TabBar::get_tab_tooltip(int p_tab) const {
|
|
|
|
+ ERR_FAIL_INDEX_V(p_tab, tabs.size(), "");
|
|
|
|
+ return tabs[p_tab].tooltip;
|
|
|
|
+}
|
|
|
|
+
|
|
void TabBar::set_tab_text_direction(int p_tab, Control::TextDirection p_text_direction) {
|
|
void TabBar::set_tab_text_direction(int p_tab, Control::TextDirection p_text_direction) {
|
|
ERR_FAIL_INDEX(p_tab, tabs.size());
|
|
ERR_FAIL_INDEX(p_tab, tabs.size());
|
|
ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
|
|
ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
|
|
@@ -998,7 +1021,8 @@ void TabBar::_update_cache(bool p_update_hover) {
|
|
tabs.write[i].size_text = Math::ceil(tabs[i].text_buf->get_size().x);
|
|
tabs.write[i].size_text = Math::ceil(tabs[i].text_buf->get_size().x);
|
|
tabs.write[i].size_cache = get_tab_width(i);
|
|
tabs.write[i].size_cache = get_tab_width(i);
|
|
|
|
|
|
- if (max_width > 0 && tabs[i].size_cache > max_width) {
|
|
|
|
|
|
+ tabs.write[i].truncated = max_width > 0 && tabs[i].size_cache > max_width;
|
|
|
|
+ if (tabs[i].truncated) {
|
|
int size_textless = tabs[i].size_cache - tabs[i].size_text;
|
|
int size_textless = tabs[i].size_cache - tabs[i].size_text;
|
|
int mw = MAX(size_textless, max_width);
|
|
int mw = MAX(size_textless, max_width);
|
|
|
|
|
|
@@ -1730,6 +1754,8 @@ void TabBar::_bind_methods() {
|
|
ClassDB::bind_method(D_METHOD("select_next_available"), &TabBar::select_next_available);
|
|
ClassDB::bind_method(D_METHOD("select_next_available"), &TabBar::select_next_available);
|
|
ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &TabBar::set_tab_title);
|
|
ClassDB::bind_method(D_METHOD("set_tab_title", "tab_idx", "title"), &TabBar::set_tab_title);
|
|
ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &TabBar::get_tab_title);
|
|
ClassDB::bind_method(D_METHOD("get_tab_title", "tab_idx"), &TabBar::get_tab_title);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("set_tab_tooltip", "tab_idx", "tooltip"), &TabBar::set_tab_tooltip);
|
|
|
|
+ ClassDB::bind_method(D_METHOD("get_tab_tooltip", "tab_idx"), &TabBar::get_tab_tooltip);
|
|
ClassDB::bind_method(D_METHOD("set_tab_text_direction", "tab_idx", "direction"), &TabBar::set_tab_text_direction);
|
|
ClassDB::bind_method(D_METHOD("set_tab_text_direction", "tab_idx", "direction"), &TabBar::set_tab_text_direction);
|
|
ClassDB::bind_method(D_METHOD("get_tab_text_direction", "tab_idx"), &TabBar::get_tab_text_direction);
|
|
ClassDB::bind_method(D_METHOD("get_tab_text_direction", "tab_idx"), &TabBar::get_tab_text_direction);
|
|
ClassDB::bind_method(D_METHOD("set_tab_language", "tab_idx", "language"), &TabBar::set_tab_language);
|
|
ClassDB::bind_method(D_METHOD("set_tab_language", "tab_idx", "language"), &TabBar::set_tab_language);
|
|
@@ -1843,6 +1869,7 @@ void TabBar::_bind_methods() {
|
|
|
|
|
|
base_property_helper.set_prefix("tab_");
|
|
base_property_helper.set_prefix("tab_");
|
|
base_property_helper.register_property(PropertyInfo(Variant::STRING, "title"), defaults.text, &TabBar::set_tab_title, &TabBar::get_tab_title);
|
|
base_property_helper.register_property(PropertyInfo(Variant::STRING, "title"), defaults.text, &TabBar::set_tab_title, &TabBar::get_tab_title);
|
|
|
|
+ base_property_helper.register_property(PropertyInfo(Variant::STRING, "tooltip"), defaults.tooltip, &TabBar::set_tab_tooltip, &TabBar::get_tab_tooltip);
|
|
base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon, &TabBar::set_tab_icon, &TabBar::get_tab_icon);
|
|
base_property_helper.register_property(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), defaults.icon, &TabBar::set_tab_icon, &TabBar::get_tab_icon);
|
|
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &TabBar::set_tab_disabled, &TabBar::is_tab_disabled);
|
|
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "disabled"), defaults.disabled, &TabBar::set_tab_disabled, &TabBar::is_tab_disabled);
|
|
}
|
|
}
|