summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/control.cpp57
-rw-r--r--scene/gui/dialogs.cpp39
-rw-r--r--scene/gui/file_dialog.cpp9
-rw-r--r--scene/gui/graph_edit.cpp30
-rw-r--r--scene/gui/line_edit.cpp1
-rw-r--r--scene/gui/option_button.cpp62
-rw-r--r--scene/gui/progress_bar.cpp2
-rw-r--r--scene/gui/rich_text_label.cpp6
-rw-r--r--scene/gui/spin_box.cpp2
-rw-r--r--scene/gui/tab_container.cpp2
-rw-r--r--scene/gui/tree.cpp6
11 files changed, 148 insertions, 68 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 26be17f6c1..5ec6c68163 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -289,7 +289,7 @@ void Control::_update_minimum_size() {
Size2 minsize = get_combined_minimum_size();
if (minsize.x > data.size_cache.x ||
minsize.y > data.size_cache.y) {
- set_size(data.size_cache);
+ _size_changed();
}
data.updating_last_minimum_size = false;
@@ -850,6 +850,12 @@ Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_typ
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_icon(p_name, type)) {
+ return Theme::get_project_default()->get_icon(p_name, type);
+ }
+ }
+
return Theme::get_default()->get_icon(p_name, type);
}
@@ -886,6 +892,12 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_shader(p_name, type)) {
+ return Theme::get_project_default()->get_shader(p_name, type);
+ }
+ }
+
return Theme::get_default()->get_shader(p_name, type);
}
@@ -925,6 +937,9 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName &
}
while (class_name != StringName()) {
+ if (Theme::get_project_default().is_valid() && Theme::get_project_default()->has_stylebox(p_name, type))
+ return Theme::get_project_default()->get_stylebox(p_name, type);
+
if (Theme::get_default()->has_stylebox(p_name, class_name))
return Theme::get_default()->get_stylebox(p_name, class_name);
@@ -1001,6 +1016,11 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return Theme::get_project_default()->get_color(p_name, type);
+ }
+ }
return Theme::get_default()->get_color(p_name, type);
}
@@ -1036,6 +1056,11 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_constant(p_name, type)) {
+ return Theme::get_project_default()->get_constant(p_name, type);
+ }
+ }
return Theme::get_default()->get_constant(p_name, type);
}
@@ -1106,6 +1131,11 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_icon(p_name, type);
}
@@ -1140,6 +1170,11 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_shader(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_shader(p_name, type);
}
bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) const {
@@ -1173,6 +1208,11 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_stylebox(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_stylebox(p_name, type);
}
bool Control::has_font(const StringName &p_name, const StringName &p_type) const {
@@ -1206,6 +1246,11 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_font(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_font(p_name, type);
}
@@ -1240,6 +1285,11 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_color(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_color(p_name, type);
}
@@ -1274,6 +1324,11 @@ bool Control::has_constant(const StringName &p_name, const StringName &p_type) c
theme_owner = NULL;
}
+ if (Theme::get_project_default().is_valid()) {
+ if (Theme::get_project_default()->has_constant(p_name, type)) {
+ return true;
+ }
+ }
return Theme::get_default()->has_constant(p_name, type);
}
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 4da11b671e..59bbdad97a 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -219,6 +219,14 @@ void WindowDialog::_notification(int p_what) {
close_button->set_begin(Point2(-get_constant("close_h_ofs", "WindowDialog"), -get_constant("close_v_ofs", "WindowDialog")));
} break;
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+ String new_title = tr(title);
+ if (title != new_title) {
+ title = new_title;
+ update();
+ }
+ } break;
+
case NOTIFICATION_MOUSE_EXIT: {
// Reset the mouse cursor when leaving the resizable window border.
if (resizable && !drag_type) {
@@ -226,11 +234,13 @@ void WindowDialog::_notification(int p_what) {
set_default_cursor_shape(CURSOR_ARROW);
}
} break;
+
#ifdef TOOLS_ENABLED
case NOTIFICATION_POST_POPUP: {
if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(true);
} break;
+
case NOTIFICATION_POPUP_HIDE: {
if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton())
EditorNode::get_singleton()->dim_editor(false);
@@ -272,8 +282,11 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const {
void WindowDialog::set_title(const String &p_title) {
- title = tr(p_title);
- update();
+ String new_title = tr(p_title);
+ if (title != new_title) {
+ title = new_title;
+ update();
+ }
}
String WindowDialog::get_title() const {
@@ -296,8 +309,8 @@ Size2 WindowDialog::get_minimum_size() const {
const int padding = button_width / 2;
const int button_area = button_width + padding;
- // as the title gets centered, title_width + close_button_width is not enough.
- // we want a width w, such that w / 2 - title_width / 2 >= button_area, i.e.
+ // As the title gets centered, title_width + close_button_width is not enough.
+ // We want a width w, such that w / 2 - title_width / 2 >= button_area, i.e.
// w >= 2 * button_area + title_width
return Size2(2 * button_area + title_width, 1);
@@ -324,7 +337,6 @@ void WindowDialog::_bind_methods() {
WindowDialog::WindowDialog() {
- //title="Hello!";
drag_type = DRAG_NONE;
resizable = false;
close_button = memnew(TextureButton);
@@ -340,7 +352,6 @@ WindowDialog::~WindowDialog() {
void PopupDialog::_notification(int p_what) {
if (p_what == NOTIFICATION_DRAW) {
-
RID ci = get_canvas_item();
get_stylebox("panel", "PopupMenu")->draw(ci, Rect2(Point2(), get_size()));
}
@@ -362,15 +373,15 @@ void AcceptDialog::_post_popup() {
void AcceptDialog::_notification(int p_what) {
- if (p_what == NOTIFICATION_MODAL_CLOSE) {
-
- cancel_pressed();
- } else if (p_what == NOTIFICATION_READY) {
-
- _update_child_rects();
- } else if (p_what == NOTIFICATION_RESIZED) {
+ switch (p_what) {
+ case NOTIFICATION_MODAL_CLOSE: {
+ cancel_pressed();
+ } break;
- _update_child_rects();
+ case NOTIFICATION_READY:
+ case NOTIFICATION_RESIZED: {
+ _update_child_rects();
+ } break;
}
}
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 04fb991f78..f1bdbb5ff5 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -403,11 +403,10 @@ void FileDialog::update_file_list() {
List<String> files;
List<String> dirs;
- bool is_dir;
bool is_hidden;
String item;
- while ((item = dir_access->get_next(&is_dir)) != "") {
+ while ((item = dir_access->get_next()) != "") {
if (item == "." || item == "..")
continue;
@@ -415,7 +414,7 @@ void FileDialog::update_file_list() {
is_hidden = dir_access->current_is_hidden();
if (show_hidden_files || !is_hidden) {
- if (!is_dir)
+ if (!dir_access->current_is_dir())
files.push_back(item);
else
dirs.push_back(item);
@@ -880,14 +879,14 @@ FileDialog::FileDialog() {
dir->set_h_size_flags(SIZE_EXPAND_FILL);
refresh = memnew(ToolButton);
- refresh->set_tooltip(RTR("Refresh"));
+ refresh->set_tooltip(RTR("Refresh files."));
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->set_tooltip(RTR("Toggle the visibility of hidden files."));
show_hidden->connect("toggled", this, "set_show_hidden_files");
hbc->add_child(show_hidden);
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index f238aeb392..38005f1322 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -1030,14 +1030,28 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
}
Ref<InputEventKey> k = p_ev;
- if (k.is_valid() && k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) {
- emit_signal("duplicate_nodes_request");
- accept_event();
- }
- if (k.is_valid() && k->get_scancode() == KEY_DELETE && k->is_pressed()) {
- emit_signal("delete_nodes_request");
- accept_event();
+ if (k.is_valid()) {
+
+ if (k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) {
+ emit_signal("duplicate_nodes_request");
+ accept_event();
+ }
+
+ if (k->get_scancode() == KEY_C && k->is_pressed() && k->get_command()) {
+ emit_signal("copy_nodes_request");
+ accept_event();
+ }
+
+ if (k->get_scancode() == KEY_V && k->is_pressed() && k->get_command()) {
+ emit_signal("paste_nodes_request");
+ accept_event();
+ }
+
+ if (k->get_scancode() == KEY_DELETE && k->is_pressed()) {
+ emit_signal("delete_nodes_request");
+ accept_event();
+ }
}
Ref<InputEventMagnifyGesture> magnify_gesture = p_ev;
@@ -1297,6 +1311,8 @@ void GraphEdit::_bind_methods() {
ADD_SIGNAL(MethodInfo("disconnection_request", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot")));
ADD_SIGNAL(MethodInfo("popup_request", PropertyInfo(Variant::VECTOR2, "position")));
ADD_SIGNAL(MethodInfo("duplicate_nodes_request"));
+ ADD_SIGNAL(MethodInfo("copy_nodes_request"));
+ ADD_SIGNAL(MethodInfo("paste_nodes_request"));
ADD_SIGNAL(MethodInfo("node_selected", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
ADD_SIGNAL(MethodInfo("connection_to_empty", PropertyInfo(Variant::STRING, "from"), PropertyInfo(Variant::INT, "from_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
ADD_SIGNAL(MethodInfo("connection_from_empty", PropertyInfo(Variant::STRING, "to"), PropertyInfo(Variant::INT, "to_slot"), PropertyInfo(Variant::VECTOR2, "release_position")));
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index d5347edb87..ccdc95696c 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -59,6 +59,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) {
menu->set_scale(get_global_transform().get_scale());
menu->popup();
grab_focus();
+ accept_event();
return;
}
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 58671655dc..d1840e43a3 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -43,40 +43,42 @@ Size2 OptionButton::get_minimum_size() const {
void OptionButton::_notification(int p_what) {
- if (p_what == NOTIFICATION_DRAW) {
-
- if (!has_icon("arrow"))
- return;
-
- RID ci = get_canvas_item();
- Ref<Texture> arrow = Control::get_icon("arrow");
- Ref<StyleBox> normal = get_stylebox("normal");
- Color clr = Color(1, 1, 1);
- if (get_constant("modulate_arrow")) {
- switch (get_draw_mode()) {
- case DRAW_PRESSED:
- clr = get_color("font_color_pressed");
- break;
- case DRAW_HOVER:
- clr = get_color("font_color_hover");
- break;
- case DRAW_DISABLED:
- clr = get_color("font_color_disabled");
- break;
- default:
- clr = get_color("font_color");
+ switch (p_what) {
+ case NOTIFICATION_DRAW: {
+
+ if (!has_icon("arrow"))
+ return;
+
+ RID ci = get_canvas_item();
+ Ref<Texture> arrow = Control::get_icon("arrow");
+ Color clr = Color(1, 1, 1);
+ if (get_constant("modulate_arrow")) {
+ switch (get_draw_mode()) {
+ case DRAW_PRESSED:
+ clr = get_color("font_color_pressed");
+ break;
+ case DRAW_HOVER:
+ clr = get_color("font_color_hover");
+ break;
+ case DRAW_DISABLED:
+ clr = get_color("font_color_disabled");
+ break;
+ default:
+ clr = get_color("font_color");
+ }
}
- }
- Size2 size = get_size();
+ Size2 size = get_size();
- Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
- arrow->draw(ci, ofs, clr);
- } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+ Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
+ arrow->draw(ci, ofs, clr);
+ } break;
+ case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible_in_tree()) {
- popup->hide();
- }
+ if (!is_visible_in_tree()) {
+ popup->hide();
+ }
+ } break;
}
}
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 264eda4035..0154a452ad 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -60,7 +60,7 @@ void ProgressBar::_notification(int p_what) {
draw_style_box(bg, Rect2(Point2(), get_size()));
float r = get_as_ratio();
int mp = fg->get_minimum_size().width;
- int p = r * get_size().width - mp;
+ int p = r * (get_size().width - mp);
if (p > 0) {
draw_style_box(fg, Rect2(Point2(), Size2(p + fg->get_minimum_size().width, get_size().height)));
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index d6c0981ebc..8223ea6d1e 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -821,11 +821,7 @@ void RichTextLabel::_notification(int p_what) {
} break;
case NOTIFICATION_THEME_CHANGED: {
- if (is_inside_tree() && use_bbcode) {
- parse_bbcode(bbcode);
- //first_invalid_line=0; //invalidate ALL
- //update();
- }
+ update();
} break;
case NOTIFICATION_DRAW: {
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 279253889c..db277d3705 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -40,7 +40,7 @@ Size2 SpinBox::get_minimum_size() const {
void SpinBox::_value_changed(double) {
- String value = String::num(get_value(), Math::step_decimals(get_step()));
+ String value = String::num(get_value(), Math::range_step_decimals(get_step()));
if (prefix != "")
value = prefix + " " + value;
if (suffix != "")
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 39c76e6646..be8f1cf36e 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -303,7 +303,7 @@ void TabContainer::_notification(int p_what) {
// Draw the tab contents.
Control *control = Object::cast_to<Control>(tabs[i + first_tab_cache]);
- String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(tr(control->get_name()));
int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT);
int top_margin = tab_style->get_margin(MARGIN_TOP);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 814100afdc..81f2f46a80 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1315,7 +1315,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
Ref<Texture> updown = cache.updown;
- String valtext = String::num(p_item->cells[i].val, Math::step_decimals(p_item->cells[i].step));
+ String valtext = String::num(p_item->cells[i].val, Math::range_step_decimals(p_item->cells[i].step));
//String valtext = rtos( p_item->cells[i].val );
if (p_item->cells[i].suffix != String())
@@ -1926,7 +1926,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
} else {
- editor_text = String::num(p_item->cells[col].val, Math::step_decimals(p_item->cells[col].step));
+ editor_text = String::num(p_item->cells[col].val, Math::range_step_decimals(p_item->cells[col].step));
if (select_mode == SELECT_MULTI && get_tree()->get_event_count() == focus_in_id)
bring_up_editor = false;
}
@@ -2755,7 +2755,7 @@ bool Tree::edit_selected() {
text_editor->set_position(textedpos);
text_editor->set_size(rect.size);
text_editor->clear();
- text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::step_decimals(c.step)));
+ text_editor->set_text(c.mode == TreeItem::CELL_MODE_STRING ? c.text : String::num(c.val, Math::range_step_decimals(c.step)));
text_editor->select_all();
if (c.mode == TreeItem::CELL_MODE_RANGE) {