summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp4
-rw-r--r--scene/gui/dialogs.cpp1
-rw-r--r--scene/gui/file_dialog.cpp47
-rw-r--r--scene/gui/file_dialog.h21
-rw-r--r--scene/gui/rich_text_label.cpp5
-rw-r--r--scene/gui/texture_rect.cpp9
6 files changed, 21 insertions, 66 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 775f863a4f..b4dc37c74f 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1893,7 +1893,7 @@ static Control *_next_control(Control *p_from) {
return nullptr;
}
- int next = p_from->get_position_in_parent();
+ int next = p_from->get_index();
ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
@@ -2032,7 +2032,7 @@ Control *Control::find_prev_valid_focus() const {
} else {
- for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) {
+ for (int i = (from->get_index() - 1); i >= 0; i--) {
Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i));
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 2e87a92969..5654219a3e 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -322,7 +322,6 @@ AcceptDialog::AcceptDialog() {
label->set_end(Point2(-margin, -button_margin - 10));
add_child(label);
- hbc = memnew(HBoxContainer);
add_child(hbc);
hbc->add_spacer();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 8ddf86cc68..89d13ecd7f 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -73,9 +73,9 @@ void FileDialog::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
- dir_up->set_icon(vbox->get_theme_icon("parent_folder"));
- refresh->set_icon(vbox->get_theme_icon("reload"));
- show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden"));
+ dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog"));
+ refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog"));
+ show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog"));
_theme_changed();
}
}
@@ -429,8 +429,8 @@ void FileDialog::update_file_list() {
dir_access->list_dir_begin();
TreeItem *root = tree->create_item();
- Ref<Texture2D> folder = vbox->get_theme_icon("folder");
- const Color folder_color = vbox->get_theme_color("folder_icon_modulate");
+ Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog");
+ const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -528,7 +528,7 @@ void FileDialog::update_file_list() {
}
if (mode == FILE_MODE_OPEN_DIR) {
- ti->set_custom_color(0, vbox->get_theme_color("files_disabled"));
+ ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog"));
ti->set_selectable(0, false);
}
Dictionary d;
@@ -909,6 +909,7 @@ FileDialog::FileDialog() {
drives = memnew(OptionButton);
drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive));
+ hbc->add_child(drives);
dir = memnew(LineEdit);
hbc->add_child(dir);
@@ -1005,37 +1006,3 @@ FileDialog::~FileDialog() {
unregister_func(this);
memdelete(dir_access);
}
-
-void LineEditFileChooser::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_button"), &LineEditFileChooser::get_button);
- ClassDB::bind_method(D_METHOD("get_line_edit"), &LineEditFileChooser::get_line_edit);
- ClassDB::bind_method(D_METHOD("get_file_dialog"), &LineEditFileChooser::get_file_dialog);
-}
-
-void LineEditFileChooser::_chosen(const String &p_text) {
-
- line_edit->set_text(p_text);
- line_edit->emit_signal("text_entered", p_text);
-}
-
-void LineEditFileChooser::_browse() {
-
- dialog->popup_centered_ratio();
-}
-
-LineEditFileChooser::LineEditFileChooser() {
-
- line_edit = memnew(LineEdit);
- add_child(line_edit);
- line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- button = memnew(Button);
- button->set_text(" .. ");
- add_child(button);
- button->connect("pressed", callable_mp(this, &LineEditFileChooser::_browse));
- dialog = memnew(FileDialog);
- add_child(dialog);
- dialog->connect("file_selected", callable_mp(this, &LineEditFileChooser::_chosen));
- dialog->connect("dir_selected", callable_mp(this, &LineEditFileChooser::_chosen));
- dialog->connect("files_selected", callable_mp(this, &LineEditFileChooser::_chosen));
-}
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 6faf02d55d..ac0e733abc 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -177,27 +177,6 @@ public:
~FileDialog();
};
-class LineEditFileChooser : public HBoxContainer {
-
- GDCLASS(LineEditFileChooser, HBoxContainer);
- Button *button;
- LineEdit *line_edit;
- FileDialog *dialog;
-
- void _chosen(const String &p_text);
- void _browse();
-
-protected:
- static void _bind_methods();
-
-public:
- Button *get_button() { return button; }
- LineEdit *get_line_edit() { return line_edit; }
- FileDialog *get_file_dialog() { return dialog; }
-
- LineEditFileChooser();
-};
-
VARIANT_ENUM_CAST(FileDialog::FileMode);
VARIANT_ENUM_CAST(FileDialog::Access);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5fb2243aff..2a05207a0f 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -582,13 +582,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} else {
cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color);
}
- } else if (previously_visible) {
+ } else if (previously_visible && c[i] != '\t') {
backtrack += font->get_char_size(fx_char, c[i + 1]).x;
}
p_char_count++;
if (c[i] == '\t') {
cw = tab_size * font->get_char_size(' ').width;
+ backtrack = MAX(0, backtrack - cw);
}
ofs += cw;
@@ -607,7 +608,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} else if (strikethrough) {
Color uc = color;
uc.a *= 0.5;
- int uy = y + lh / 2 - line_descent + 2;
+ int uy = y + lh - (line_ascent + line_descent) / 2;
float strikethrough_width = 1.0;
#ifdef TOOLS_ENABLED
strikethrough_width *= EDSCALE;
diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp
index baa138847f..92f3c5b5d9 100644
--- a/scene/gui/texture_rect.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -95,6 +95,15 @@ void TextureRect::_notification(int p_what) {
} break;
}
+ Ref<AtlasTexture> p_atlas = texture;
+
+ if (p_atlas.is_valid() && region.has_no_area()) {
+ Size2 scale_size(size.width / texture->get_width(), size.height / texture->get_height());
+
+ offset.width += hflip ? p_atlas->get_margin().get_position().width * scale_size.width * 2 : 0;
+ offset.height += vflip ? p_atlas->get_margin().get_position().height * scale_size.height * 2 : 0;
+ }
+
size.width *= hflip ? -1.0f : 1.0f;
size.height *= vflip ? -1.0f : 1.0f;