feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -30,6 +30,8 @@
#include "button.h"
#include "scene/gui/dialogs.h"
#include "scene/theme/theme_db.h"
Size2 Button::get_minimum_size() const {
@ -48,6 +50,10 @@ void Button::_set_internal_margin(Side p_side, float p_value) {
void Button::_queue_update_size_cache() {
}
String Button::_get_translated_text(const String &p_text) const {
return atr(p_text);
}
void Button::_update_theme_item_cache() {
Control::_update_theme_item_cache();
@ -181,15 +187,31 @@ Ref<StyleBox> Button::_get_current_stylebox() const {
void Button::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ACCESSIBILITY_UPDATE: {
RID ae = get_accessibility_element();
ERR_FAIL_COND(ae.is_null());
if (!xl_text.is_empty() && get_accessibility_name().is_empty()) {
DisplayServer::get_singleton()->accessibility_update_set_name(ae, xl_text);
} else if (!xl_text.is_empty() && !get_accessibility_name().is_empty() && get_accessibility_name() != xl_text) {
DisplayServer::get_singleton()->accessibility_update_set_name(ae, get_accessibility_name() + ": " + xl_text);
}
AcceptDialog *dlg = Object::cast_to<AcceptDialog>(get_parent());
if (dlg && dlg->get_ok_button() == this) {
DisplayServer::get_singleton()->accessibility_update_set_role(ae, DisplayServer::AccessibilityRole::ROLE_DEFAULT_BUTTON);
}
} break;
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: {
queue_redraw();
} break;
case NOTIFICATION_TRANSLATION_CHANGED: {
xl_text = atr(text);
xl_text = _get_translated_text(text);
_shape();
update_minimum_size();
queue_accessibility_update();
queue_redraw();
} break;
@ -566,7 +588,7 @@ void Button::_shape(Ref<TextParagraph> p_paragraph, String p_text) const {
case TextServer::AUTOWRAP_OFF:
break;
}
autowrap_flags = autowrap_flags | TextServer::BREAK_TRIM_EDGE_SPACES;
autowrap_flags = autowrap_flags | autowrap_flags_trim;
p_paragraph->set_break_flags(autowrap_flags);
p_paragraph->set_line_spacing(theme_cache.line_spacing);
@ -598,14 +620,17 @@ TextServer::OverrunBehavior Button::get_text_overrun_behavior() const {
}
void Button::set_text(const String &p_text) {
if (text != p_text) {
text = p_text;
xl_text = atr(text);
_shape();
queue_redraw();
update_minimum_size();
const String translated_text = _get_translated_text(p_text);
if (text == p_text && xl_text == translated_text) {
return;
}
text = p_text;
xl_text = translated_text;
_shape();
queue_accessibility_update();
queue_redraw();
update_minimum_size();
}
String Button::get_text() const {
@ -625,11 +650,25 @@ TextServer::AutowrapMode Button::get_autowrap_mode() const {
return autowrap_mode;
}
void Button::set_autowrap_trim_flags(BitField<TextServer::LineBreakFlag> p_flags) {
if (autowrap_flags_trim != (p_flags & TextServer::BREAK_TRIM_MASK)) {
autowrap_flags_trim = p_flags & TextServer::BREAK_TRIM_MASK;
_shape();
queue_redraw();
update_minimum_size();
}
}
BitField<TextServer::LineBreakFlag> Button::get_autowrap_trim_flags() const {
return autowrap_flags_trim;
}
void Button::set_text_direction(Control::TextDirection p_text_direction) {
ERR_FAIL_COND((int)p_text_direction < -1 || (int)p_text_direction > 3);
if (text_direction != p_text_direction) {
text_direction = p_text_direction;
_shape();
queue_accessibility_update();
queue_redraw();
}
}
@ -642,6 +681,7 @@ void Button::set_language(const String &p_language) {
if (language != p_language) {
language = p_language;
_shape();
queue_accessibility_update();
queue_redraw();
}
}
@ -719,6 +759,7 @@ bool Button::get_clip_text() const {
void Button::set_text_alignment(HorizontalAlignment p_alignment) {
if (alignment != p_alignment) {
alignment = p_alignment;
queue_accessibility_update();
queue_redraw();
}
}
@ -766,6 +807,8 @@ void Button::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_text_overrun_behavior"), &Button::get_text_overrun_behavior);
ClassDB::bind_method(D_METHOD("set_autowrap_mode", "autowrap_mode"), &Button::set_autowrap_mode);
ClassDB::bind_method(D_METHOD("get_autowrap_mode"), &Button::get_autowrap_mode);
ClassDB::bind_method(D_METHOD("set_autowrap_trim_flags", "autowrap_trim_flags"), &Button::set_autowrap_trim_flags);
ClassDB::bind_method(D_METHOD("get_autowrap_trim_flags"), &Button::get_autowrap_trim_flags);
ClassDB::bind_method(D_METHOD("set_text_direction", "direction"), &Button::set_text_direction);
ClassDB::bind_method(D_METHOD("get_text_direction"), &Button::get_text_direction);
ClassDB::bind_method(D_METHOD("set_language", "language"), &Button::set_language);
@ -791,8 +834,9 @@ void Button::_bind_methods() {
ADD_GROUP("Text Behavior", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "alignment", PROPERTY_HINT_ENUM, "Left,Center,Right"), "set_text_alignment", "get_text_alignment");
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_overrun_behavior", PROPERTY_HINT_ENUM, "Trim Nothing,Trim Characters,Trim Words,Ellipsis,Word Ellipsis"), "set_text_overrun_behavior", "get_text_overrun_behavior");
ADD_PROPERTY(PropertyInfo(Variant::INT, "text_overrun_behavior", PROPERTY_HINT_ENUM, "Trim Nothing,Trim Characters,Trim Words,Ellipsis (6+ Characters),Word Ellipsis (6+ Characters),Ellipsis (Always),Word Ellipsis (Always)"), "set_text_overrun_behavior", "get_text_overrun_behavior");
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_mode", PROPERTY_HINT_ENUM, "Off,Arbitrary,Word,Word (Smart)"), "set_autowrap_mode", "get_autowrap_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "autowrap_trim_flags", PROPERTY_HINT_FLAGS, vformat("Trim Spaces After Break:%d,Trim Spaces Before Break:%d", TextServer::BREAK_TRIM_START_EDGE_SPACES, TextServer::BREAK_TRIM_END_EDGE_SPACES)), "set_autowrap_trim_flags", "get_autowrap_trim_flags");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clip_text"), "set_clip_text", "get_clip_text");
ADD_GROUP("Icon Behavior", "");
@ -846,7 +890,7 @@ void Button::_bind_methods() {
Button::Button(const String &p_text) {
text_buf.instantiate();
text_buf->set_break_flags(TextServer::BREAK_MANDATORY | TextServer::BREAK_TRIM_EDGE_SPACES);
text_buf->set_break_flags(TextServer::BREAK_MANDATORY | autowrap_flags_trim);
set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text);