Merge pull request #58739 from Calinou/control-add-constructors

Add optional constructor arguments to more Control nodes
This commit is contained in:
Rémi Verschelde 2022-03-04 11:42:53 +01:00 committed by GitHub
commit 8845798b44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 31 additions and 17 deletions

View file

@ -583,8 +583,8 @@ void Button::_bind_methods() {
Button::Button(const String &p_text) {
text_buf.instantiate();
text_buf->set_flags(TextServer::BREAK_MANDATORY);
set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text);
}

View file

@ -111,9 +111,12 @@ void CheckButton::_notification(int p_what) {
}
}
CheckButton::CheckButton() {
CheckButton::CheckButton(const String &p_text) :
Button(p_text) {
set_toggle_mode(true);
set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
if (is_layout_rtl()) {
_set_internal_margin(SIDE_LEFT, get_icon_size().width);
} else {

View file

@ -42,7 +42,7 @@ protected:
void _notification(int p_what);
public:
CheckButton();
CheckButton(const String &p_text = String());
~CheckButton();
};

View file

@ -1429,7 +1429,8 @@ void ColorPickerButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha");
}
ColorPickerButton::ColorPickerButton() {
ColorPickerButton::ColorPickerButton(const String &p_text) :
Button(p_text) {
set_toggle_mode(true);
}

View file

@ -231,7 +231,7 @@ public:
ColorPicker *get_picker();
PopupPanel *get_popup();
ColorPickerButton();
ColorPickerButton(const String &p_text = String());
};
VARIANT_ENUM_CAST(ColorPicker::PickerShapeType);

View file

@ -2437,7 +2437,7 @@ void LineEdit::_ensure_menu() {
}
}
LineEdit::LineEdit() {
LineEdit::LineEdit(const String &p_placeholder) {
text_rid = TS->create_shaped_text();
_create_undo_state();
@ -2452,6 +2452,8 @@ LineEdit::LineEdit() {
caret_blink_timer->connect("timeout", callable_mp(this, &LineEdit::_toggle_draw_caret));
set_caret_blink_enabled(false);
set_placeholder(p_placeholder);
set_editable(true); // Initialise to opposite first, so we get past the early-out in set_editable.
}

View file

@ -332,7 +332,7 @@ public:
void show_virtual_keyboard();
LineEdit();
LineEdit(const String &p_placeholder = String());
~LineEdit();
};

View file

@ -317,8 +317,10 @@ void LinkButton::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "structured_text_bidi_override_options"), "set_structured_text_bidi_override_options", "get_structured_text_bidi_override_options");
}
LinkButton::LinkButton() {
LinkButton::LinkButton(const String &p_text) {
text_buf.instantiate();
set_focus_mode(FOCUS_NONE);
set_default_cursor_shape(CURSOR_POINTING_HAND);
set_text(p_text);
}

View file

@ -90,7 +90,7 @@ public:
void set_underline_mode(UnderlineMode p_underline_mode);
UnderlineMode get_underline_mode() const;
LinkButton();
LinkButton(const String &p_text = String());
};
VARIANT_ENUM_CAST(LinkButton::UnderlineMode);

View file

@ -227,7 +227,8 @@ void MenuButton::set_disable_shortcuts(bool p_disabled) {
disable_shortcuts = p_disabled;
}
MenuButton::MenuButton() {
MenuButton::MenuButton(const String &p_text) :
Button(p_text) {
set_flat(true);
set_toggle_mode(true);
set_disable_shortcuts(false);

View file

@ -67,7 +67,7 @@ public:
void set_item_count(int p_count);
int get_item_count() const;
MenuButton();
MenuButton(const String &p_text = String());
~MenuButton();
};

View file

@ -412,7 +412,8 @@ void OptionButton::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_focused", PropertyInfo(Variant::INT, "index")));
}
OptionButton::OptionButton() {
OptionButton::OptionButton(const String &p_text) :
Button(p_text) {
set_toggle_mode(true);
set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
if (is_layout_rtl()) {

View file

@ -94,7 +94,7 @@ public:
virtual void get_translatable_strings(List<String> *p_strings) const override;
OptionButton();
OptionButton(const String &p_text = String());
~OptionButton();
};

View file

@ -4712,7 +4712,7 @@ Dictionary RichTextLabel::parse_expressions_for_values(Vector<String> p_expressi
return d;
}
RichTextLabel::RichTextLabel() {
RichTextLabel::RichTextLabel(const String &p_text) {
main = memnew(ItemFrame);
main->index = 0;
current = main;
@ -4734,6 +4734,8 @@ RichTextLabel::RichTextLabel() {
vscroll->set_step(1);
vscroll->hide();
set_text(p_text);
set_clip_contents(true);
}

View file

@ -620,7 +620,7 @@ public:
void set_fixed_size_to_width(int p_width);
virtual Size2 get_minimum_size() const override;
RichTextLabel();
RichTextLabel(const String &p_text = String());
~RichTextLabel();
};

View file

@ -6581,7 +6581,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li
emit_signal(SNAME("lines_edited_from"), p_to_line, p_from_line);
}
TextEdit::TextEdit() {
TextEdit::TextEdit(const String &p_placeholder) {
placeholder_data_buf.instantiate();
clear();
@ -6623,5 +6623,7 @@ TextEdit::TextEdit() {
undo_stack_max_size = GLOBAL_GET("gui/common/text_edit_undo_stack_max_size");
set_placeholder(p_placeholder);
set_editable(true);
}

View file

@ -940,7 +940,7 @@ public:
void set_draw_spaces(bool p_enabled);
bool is_drawing_spaces() const;
TextEdit();
TextEdit(const String &p_placeholder = String());
};
VARIANT_ENUM_CAST(TextEdit::CaretType);