summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp12
-rw-r--r--scene/gui/control.cpp10
-rw-r--r--scene/gui/file_dialog.cpp23
-rw-r--r--scene/gui/file_dialog.h1
-rw-r--r--scene/gui/gradient_edit.cpp9
-rw-r--r--scene/gui/gradient_edit.h2
-rw-r--r--scene/gui/rich_text_label.cpp17
-rw-r--r--scene/gui/text_edit.cpp6
-rw-r--r--scene/gui/text_edit.h4
-rw-r--r--scene/gui/tree.cpp11
10 files changed, 58 insertions, 37 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 5ef2557383..fadf5e432c 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -216,9 +216,7 @@ void BaseButton::set_pressed(bool p_pressed) {
if (p_pressed) {
_unpress_group();
}
- if (toggle_mode) {
- _toggled(status.pressed);
- }
+ _toggled(status.pressed);
update();
}
@@ -337,9 +335,6 @@ bool BaseButton::is_keep_pressed_outside() const {
void BaseButton::set_shortcut(const Ref<ShortCut> &p_shortcut) {
- if (shortcut.is_null() == p_shortcut.is_null())
- return;
-
shortcut = p_shortcut;
set_process_unhandled_input(shortcut.is_valid());
}
@@ -356,11 +351,10 @@ void BaseButton::_unhandled_input(Ref<InputEvent> p_event) {
return; //ignore because of modal window
if (is_toggle_mode()) {
- set_pressed(!is_pressed());
- emit_signal("toggled", is_pressed());
+ set_pressed(!is_pressed()); // Also calls _toggled() internally.
}
- emit_signal("pressed");
+ _pressed();
}
}
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 76275c2420..9d7c08d3f3 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -29,23 +29,23 @@
/*************************************************************************/
#include "control.h"
-#include "core/project_settings.h"
-#include "scene/main/canvas_layer.h"
-#include "scene/main/viewport.h"
-#include "servers/visual_server.h"
#include "core/message_queue.h"
#include "core/os/keyboard.h"
#include "core/os/os.h"
#include "core/print_string.h"
+#include "core/project_settings.h"
#include "scene/gui/label.h"
#include "scene/gui/panel.h"
+#include "scene/main/canvas_layer.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
+#include "servers/visual_server.h"
+
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#endif
-#include <stdio.h>
Dictionary Control::_edit_get_state() const {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index bdb1342019..bc8dcf0e82 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -48,8 +48,9 @@ void FileDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- refresh->set_icon(get_icon("reload"));
dir_up->set_icon(get_icon("parent_folder"));
+ refresh->set_icon(get_icon("reload"));
+ show_hidden->set_icon(get_icon("toggle_hidden"));
}
if (p_what == NOTIFICATION_POPUP_HIDE) {
@@ -393,20 +394,19 @@ void FileDialog::update_file_list() {
List<String> files;
List<String> dirs;
- bool isdir;
- bool ishidden;
- bool show_hidden = show_hidden_files;
+ bool is_dir;
+ bool is_hidden;
String item;
- while ((item = dir_access->get_next(&isdir)) != "") {
+ while ((item = dir_access->get_next(&is_dir)) != "") {
if (item == "." || item == "..")
continue;
- ishidden = dir_access->current_is_hidden();
+ is_hidden = dir_access->current_is_hidden();
- if (show_hidden || !ishidden) {
- if (!isdir)
+ if (show_hidden_files || !is_hidden) {
+ if (!is_dir)
files.push_back(item);
else
dirs.push_back(item);
@@ -873,6 +873,13 @@ FileDialog::FileDialog() {
refresh->connect("pressed", this, "_update_file_list");
hbc->add_child(refresh);
+ show_hidden = memnew(ToolButton);
+ show_hidden->set_toggle_mode(true);
+ show_hidden->set_pressed(is_showing_hidden_files());
+ show_hidden->set_tooltip(RTR("Toggle Hidden Files"));
+ show_hidden->connect("toggled", this, "set_show_hidden_files");
+ hbc->add_child(show_hidden);
+
drives = memnew(OptionButton);
hbc->add_child(drives);
drives->connect("item_selected", this, "_select_drive");
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 85edac0b12..9f7ea1a2f2 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -90,6 +90,7 @@ private:
ToolButton *dir_up;
ToolButton *refresh;
+ ToolButton *show_hidden;
Vector<String> filters;
diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp
index cfbc9d6d18..75f5f79873 100644
--- a/scene/gui/gradient_edit.cpp
+++ b/scene/gui/gradient_edit.cpp
@@ -29,10 +29,17 @@
/*************************************************************************/
#include "gradient_edit.h"
+
#include "core/os/keyboard.h"
-#include "editor/editor_scale.h"
+#ifdef TOOLS_ENABLED
+#include "editor/editor_scale.h"
#define SPACING (3 * EDSCALE)
+#define POINT_WIDTH (8 * EDSCALE)
+#else
+#define SPACING 3
+#define POINT_WIDTH 8
+#endif
GradientEdit::GradientEdit() {
grabbed = -1;
diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h
index 662278a17b..6f31107729 100644
--- a/scene/gui/gradient_edit.h
+++ b/scene/gui/gradient_edit.h
@@ -36,8 +36,6 @@
#include "scene/resources/default_theme/theme_data.h"
#include "scene/resources/gradient.h"
-#define POINT_WIDTH (8 * EDSCALE)
-
class GradientEdit : public Control {
GDCLASS(GradientEdit, Control);
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index c6b6d29384..8891f679ee 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -307,6 +307,13 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
switch (it->type) {
+ case ITEM_ALIGN: {
+
+ ItemAlign *align_it = static_cast<ItemAlign *>(it);
+
+ align = align_it->align;
+
+ } break;
case ITEM_TEXT: {
ItemText *text = static_cast<ItemText *>(it);
@@ -1411,9 +1418,13 @@ void RichTextLabel::_add_item(Item *p_item, bool p_enter, bool p_ensure_newline)
if (p_enter)
current = p_item;
- if (p_ensure_newline && current_frame->lines[current_frame->lines.size() - 1].from) {
- _invalidate_current_line(current_frame);
- current_frame->lines.resize(current_frame->lines.size() + 1);
+ if (p_ensure_newline) {
+ Item *from = current_frame->lines[current_frame->lines.size() - 1].from;
+ // only create a new line for Item types that generate content/layout, ignore those that represent formatting/styling
+ if (from && from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH) {
+ _invalidate_current_line(current_frame);
+ current_frame->lines.resize(current_frame->lines.size() + 1);
+ }
}
if (current_frame->lines[current_frame->lines.size() - 1].from == NULL) {
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 53035fbb9b..83ce71e959 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4078,7 +4078,7 @@ void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport, bool p_can_be_
cursor.line = p_row;
int n_col = get_char_pos_for_line(cursor.last_fit_x, p_row, p_wrap_index);
- if (is_wrap_enabled() && p_wrap_index < times_line_wraps(p_row)) {
+ if (n_col != 0 && is_wrap_enabled() && p_wrap_index < times_line_wraps(p_row)) {
Vector<String> rows = get_wrap_rows_text(p_row);
int row_end_col = 0;
for (int i = 0; i < p_wrap_index + 1; i++) {
@@ -6344,14 +6344,14 @@ int TextEdit::get_info_gutter_width() const {
return info_gutter_width;
}
-void TextEdit::set_hiding_enabled(int p_enabled) {
+void TextEdit::set_hiding_enabled(bool p_enabled) {
if (!p_enabled)
unhide_all_lines();
hiding_enabled = p_enabled;
update();
}
-int TextEdit::is_hiding_enabled() const {
+bool TextEdit::is_hiding_enabled() const {
return hiding_enabled;
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 68e590f1e6..0c26602d2b 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -697,8 +697,8 @@ public:
void set_info_gutter_width(int p_gutter_width);
int get_info_gutter_width() const;
- void set_hiding_enabled(int p_enabled);
- int is_hiding_enabled() const;
+ void set_hiding_enabled(bool p_enabled);
+ bool is_hiding_enabled() const;
void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 2007ae2669..522c1ecb6a 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -39,7 +39,7 @@
#include "scene/main/viewport.h"
#ifdef TOOLS_ENABLED
-#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
#endif
#include <limits.h>
@@ -318,7 +318,7 @@ void TreeItem::set_custom_draw(int p_column, Object *p_object, const StringName
void TreeItem::set_collapsed(bool p_collapsed) {
- if (collapsed == p_collapsed)
+ if (collapsed == p_collapsed || !tree)
return;
collapsed = p_collapsed;
TreeItem *ci = tree->selected_item;
@@ -344,8 +344,7 @@ void TreeItem::set_collapsed(bool p_collapsed) {
}
_changed_notify();
- if (tree)
- tree->emit_signal("item_collapsed", this);
+ tree->emit_signal("item_collapsed", this);
}
bool TreeItem::is_collapsed() {
@@ -3721,6 +3720,10 @@ String Tree::get_tooltip(const Point2 &p_pos) const {
const TreeItem::Cell &c = it->cells[col];
int col_width = get_column_width(col);
+
+ for (int i = 0; i < col; i++)
+ pos.x -= get_column_width(i);
+
for (int j = c.buttons.size() - 1; j >= 0; j--) {
Ref<Texture> b = c.buttons[j].texture;
Size2 size = b->get_size() + cache.button_pressed->get_minimum_size();