diff options
Diffstat (limited to 'scene/gui')
100 files changed, 367 insertions, 672 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 9054063a4b..8fd19e8655 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "base_button.h" + #include "os/keyboard.h" #include "print_string.h" #include "scene/main/viewport.h" diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h index dfcf3b0f8a..0c08dc53a3 100644 --- a/scene/gui/base_button.h +++ b/scene/gui/base_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 2cc4be96a7..739fd84b38 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,7 +54,7 @@ void BoxContainer::_resort() { Map<Control *, _MinSizeCache> min_size_cache; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) @@ -106,7 +106,7 @@ void BoxContainer::_resort() { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) @@ -159,7 +159,7 @@ void BoxContainer::_resort() { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) @@ -211,7 +211,7 @@ Size2 BoxContainer::get_minimum_size() const { bool first = true; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h index d544ff79d1..4d00a2011f 100644 --- a/scene/gui/box_container.h +++ b/scene/gui/box_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index c8838f3eca..1fa03f81f4 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button.h b/scene/gui/button.h index 499e44c0e1..dd6e730b86 100644 --- a/scene/gui/button.h +++ b/scene/gui/button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp index e54e810d7d..336c88fe9d 100644 --- a/scene/gui/button_group.cpp +++ b/scene/gui/button_group.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,7 +56,7 @@ void ButtonGroup::set_pressed_button(BaseButton *p_button) { void ButtonGroup::_pressed(Object *p_button) { ERR_FAIL_NULL(p_button); - BaseButton *b=p_button->cast_to<BaseButton>(); + BaseButton *b=Object::cast_to<BaseButton>(p_button); ERR_FAIL_COND(!b); for(Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) { diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h index 93c3aaaeb3..6ebc0575d2 100644 --- a/scene/gui/button_group.h +++ b/scene/gui/button_group.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp index bdc811870d..8c9c9d8720 100644 --- a/scene/gui/center_container.cpp +++ b/scene/gui/center_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -36,7 +36,7 @@ Size2 CenterContainer::get_minimum_size() const { Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -69,7 +69,7 @@ void CenterContainer::_notification(int p_what) { Size2 size = get_size(); for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h index 30b526e893..4397539046 100644 --- a/scene/gui/center_container.h +++ b/scene/gui/center_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index b61d516599..21e2269141 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h index ec8e097bae..4da06be8d1 100644 --- a/scene/gui/check_box.h +++ b/scene/gui/check_box.h @@ -1,9 +1,9 @@ /*************************************************************************/ -/* check_box.h */ +/* check_box.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index 1c3d4df308..e68159e27f 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index 8634858cfe..af3b80fe04 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 5257f9df35..704c00b1d6 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -56,11 +56,10 @@ void ColorPicker::_notification(int p_what) { } break; case NOTIFICATION_VISIBILITY_CHANGED: { - if (get_parent()) { - Popup *p = get_parent()->cast_to<Popup>(); - if (p) - p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2)); - } + + Popup *p = Object::cast_to<Popup>(get_parent()); + if (p) + p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2)); } break; case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index d35182e062..7de67a707c 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp index 0641302b1c..6b5247648e 100644 --- a/scene/gui/color_rect.cpp +++ b/scene/gui/color_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h index 65da3d9a7c..382648fddf 100644 --- a/scene/gui/color_rect.h +++ b/scene/gui/color_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 4bbe15ed7e..ba5d92620b 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -43,7 +43,7 @@ void Container::add_child_notify(Node *p_child) { Control::add_child_notify(p_child); - Control *control = p_child->cast_to<Control>(); + Control *control = Object::cast_to<Control>(p_child); if (!control) return; @@ -57,7 +57,7 @@ void Container::move_child_notify(Node *p_child) { Control::move_child_notify(p_child); - if (!p_child->cast_to<Control>()) + if (!Object::cast_to<Control>(p_child)) return; queue_sort(); @@ -67,7 +67,7 @@ void Container::remove_child_notify(Node *p_child) { Control::remove_child_notify(p_child); - Control *control = p_child->cast_to<Control>(); + Control *control = Object::cast_to<Control>(p_child); if (!control) return; diff --git a/scene/gui/container.h b/scene/gui/container.h index bff24c6d55..60a7a9efcb 100644 --- a/scene/gui/container.h +++ b/scene/gui/container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 36fc9a6b3a..961fccc804 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -353,7 +353,7 @@ void Control::_resize(const Size2 &p_size) { void Control::add_child_notify(Node *p_child) { - Control *child_c = p_child->cast_to<Control>(); + Control *child_c = Object::cast_to<Control>(p_child); if (!child_c) return; @@ -364,7 +364,7 @@ void Control::add_child_notify(Node *p_child) { void Control::remove_child_notify(Node *p_child) { - Control *child_c = p_child->cast_to<Control>(); + Control *child_c = Object::cast_to<Control>(p_child); if (!child_c) return; @@ -398,7 +398,7 @@ void Control::_notification(int p_notification) { case NOTIFICATION_ENTER_CANVAS: { - data.parent = get_parent()->cast_to<Control>(); + data.parent = Object::cast_to<Control>(get_parent()); if (is_set_as_toplevel()) { data.SI = get_viewport()->_gui_add_subwindow_control(this); @@ -421,13 +421,13 @@ void Control::_notification(int p_notification) { if (!parent) break; - CanvasItem *ci = parent->cast_to<CanvasItem>(); + CanvasItem *ci = Object::cast_to<CanvasItem>(parent); if (ci && ci->is_set_as_toplevel()) { subwindow = true; break; } - parent_control = parent->cast_to<Control>(); + parent_control = Object::cast_to<Control>(parent); if (parent_control) { break; @@ -624,7 +624,7 @@ Variant Control::get_drag_data(const Point2 &p_point) { if (data.drag_owner) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { - Control *c = obj->cast_to<Control>(); + Control *c = Object::cast_to<Control>(obj); return c->call("get_drag_data_fw", p_point, this); } } @@ -646,7 +646,7 @@ bool Control::can_drop_data(const Point2 &p_point, const Variant &p_data) const if (data.drag_owner) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { - Control *c = obj->cast_to<Control>(); + Control *c = Object::cast_to<Control>(obj); return c->call("can_drop_data_fw", p_point, p_data, this); } } @@ -667,7 +667,7 @@ void Control::drop_data(const Point2 &p_point, const Variant &p_data) { if (data.drag_owner) { Object *obj = ObjectDB::get_instance(data.drag_owner); if (obj) { - Control *c = obj->cast_to<Control>(); + Control *c = Object::cast_to<Control>(obj); c->call("drop_data_fw", p_point, p_data, this); return; } @@ -749,7 +749,7 @@ Ref<Texture> Control::get_icon(const StringName &p_name, const StringName &p_typ class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -785,7 +785,7 @@ Ref<Shader> Control::get_shader(const StringName &p_name, const StringName &p_ty class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -821,7 +821,7 @@ Ref<StyleBox> Control::get_stylebox(const StringName &p_name, const StringName & class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -858,7 +858,7 @@ Ref<Font> Control::get_font(const StringName &p_name, const StringName &p_type) if (theme_owner->data.theme->get_default_theme_font().is_valid()) return theme_owner->data.theme->get_default_theme_font(); - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -892,7 +892,7 @@ Color Control::get_color(const StringName &p_name, const StringName &p_type) con class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -927,7 +927,7 @@ int Control::get_constant(const StringName &p_name, const StringName &p_type) co class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1015,7 +1015,7 @@ bool Control::has_icon(const StringName &p_name, const StringName &p_type) const class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1049,7 +1049,7 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1082,7 +1082,7 @@ bool Control::has_stylebox(const StringName &p_name, const StringName &p_type) c class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1115,7 +1115,7 @@ bool Control::has_font(const StringName &p_name, const StringName &p_type) const class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1149,7 +1149,7 @@ bool Control::has_color(const StringName &p_name, const StringName &p_type) cons class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1183,7 +1183,7 @@ bool Control::has_constant(const StringName &p_name, const StringName &p_type) c class_name = ClassDB::get_parent_class_nocheck(class_name); } - Control *parent = theme_owner->get_parent() ? theme_owner->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(theme_owner->get_parent()); if (parent) theme_owner = parent->data.theme_owner; @@ -1687,7 +1687,7 @@ static Control *_next_control(Control *p_from) { if (p_from->is_set_as_toplevel()) return NULL; // can't go above - Control *parent = p_from->get_parent() ? p_from->get_parent()->cast_to<Control>() : NULL; + Control *parent = Object::cast_to<Control>(p_from->get_parent()); if (!parent) { @@ -1698,7 +1698,7 @@ static Control *_next_control(Control *p_from) { ERR_FAIL_INDEX_V(next, parent->get_child_count(), NULL); for (int i = (next + 1); i < parent->get_child_count(); i++) { - Control *c = parent->get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(parent->get_child(i)); if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) continue; @@ -1721,7 +1721,7 @@ Control *Control::find_next_valid_focus() const { for (int i = 0; i < from->get_child_count(); i++) { - Control *c = from->get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(from->get_child(i)); if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) { continue; } @@ -1739,10 +1739,8 @@ Control *Control::find_next_valid_focus() const { if (!next_child) { //nothing else.. go up and find either window or subwindow next_child = const_cast<Control *>(this); while (next_child && !next_child->is_set_as_toplevel()) { - if (next_child->get_parent()) { - next_child = next_child->get_parent()->cast_to<Control>(); - } else - next_child = NULL; + + next_child = cast_to<Control>(next_child->get_parent()); } if (!next_child) { @@ -1776,7 +1774,7 @@ static Control *_prev_control(Control *p_from) { Control *child = NULL; for (int i = p_from->get_child_count() - 1; i >= 0; i--) { - Control *c = p_from->get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(p_from->get_child(i)); if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) continue; @@ -1800,7 +1798,7 @@ Control *Control::find_prev_valid_focus() const { Control *prev_child = NULL; - if (from->is_set_as_toplevel() || !from->get_parent() || !from->get_parent()->cast_to<Control>()) { + if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) { //find last of the childs @@ -1810,7 +1808,7 @@ Control *Control::find_prev_valid_focus() const { for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) { - Control *c = from->get_parent()->get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i)); if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) { continue; @@ -1822,7 +1820,7 @@ Control *Control::find_prev_valid_focus() const { if (!prev_child) { - prev_child = from->get_parent()->cast_to<Control>(); + prev_child = Object::cast_to<Control>(from->get_parent()); } else { prev_child = _prev_control(prev_child); @@ -1912,14 +1910,14 @@ void Control::_modal_stack_remove() { void Control::_propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign) { - Control *c = p_at->cast_to<Control>(); + Control *c = Object::cast_to<Control>(p_at); if (c && c != p_owner && c->data.theme.is_valid()) // has a theme, this can't be propagated return; for (int i = 0; i < p_at->get_child_count(); i++) { - CanvasItem *child = p_at->get_child(i)->cast_to<CanvasItem>(); + CanvasItem *child = Object::cast_to<CanvasItem>(p_at->get_child(i)); if (child) { _propagate_theme_changed(child, p_owner, p_assign); } @@ -1955,7 +1953,7 @@ void Control::set_theme(const Ref<Theme> &p_theme) { _propagate_theme_changed(this, this); } else { - Control *parent = get_parent() ? get_parent()->cast_to<Control>() : NULL; + Control *parent = cast_to<Control>(get_parent()); if (parent && parent->data.theme_owner) { _propagate_theme_changed(this, parent->data.theme_owner); } else { @@ -2038,7 +2036,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { Control *c = NULL; Node *n = get_node(data.focus_neighbour[p_margin]); if (n) { - c = n->cast_to<Control>(); + c = Object::cast_to<Control>(n); if (!c) { @@ -2095,7 +2093,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { while (base) { - Control *c = base->cast_to<Control>(); + Control *c = Object::cast_to<Control>(base); if (c) { if (c->data.SI) break; @@ -2115,10 +2113,10 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, const Point2 *p_points, float p_min, float &r_closest_dist, Control **r_closest) { - if (p_at->cast_to<Viewport>()) + if (Object::cast_to<Viewport>(p_at)) return; //bye - Control *c = p_at->cast_to<Control>(); + Control *c = Object::cast_to<Control>(p_at); if (c && c != this && c->get_focus_mode() == FOCUS_ALL && c->is_visible_in_tree()) { @@ -2168,7 +2166,7 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con for (int i = 0; i < p_at->get_child_count(); i++) { Node *child = p_at->get_child(i); - Control *childc = child->cast_to<Control>(); + Control *childc = Object::cast_to<Control>(child); if (childc && childc->data.SI) continue; //subwindow, ignore _window_find_focus_neighbour(p_dir, p_at->get_child(i), p_points, p_min, r_closest_dist, r_closest); @@ -2363,7 +2361,7 @@ Control *Control::get_root_parent_control() const { while (ci) { - const Control *c = ci->cast_to<Control>(); + const Control *c = Object::cast_to<Control>(ci); if (c) { root = c; @@ -2705,7 +2703,7 @@ void Control::_bind_methods() { ADD_SIGNAL(MethodInfo("minimum_size_changed")); ADD_SIGNAL(MethodInfo("modal_closed")); - BIND_VMETHOD(MethodInfo("has_point:bool", PropertyInfo(Variant::VECTOR2, "point"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "has_point", PropertyInfo(Variant::VECTOR2, "point"))); } Control::Control() { diff --git a/scene/gui/control.h b/scene/gui/control.h index d73ca3f7c9..da5c4d0908 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,7 +33,7 @@ #include "math_2d.h" #include "rid.h" #include "scene/2d/canvas_item.h" -#include "scene/gui/input_action.h" +#include "scene/gui/shortcut.h" #include "scene/main/node.h" #include "scene/main/timer.h" #include "scene/resources/theme.h" diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index b911a18312..140d002387 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -60,13 +60,13 @@ void WindowDialog::_fix_size() { float right = 0; // Check validity, because the theme could contain a different type of StyleBox if (panel->get_class() == "StyleBoxTexture") { - Ref<StyleBoxTexture> panel_texture = panel->cast_to<StyleBoxTexture>(); + Ref<StyleBoxTexture> panel_texture = Object::cast_to<StyleBoxTexture>(*panel); top = panel_texture->get_expand_margin_size(MARGIN_TOP); left = panel_texture->get_expand_margin_size(MARGIN_LEFT); bottom = panel_texture->get_expand_margin_size(MARGIN_BOTTOM); right = panel_texture->get_expand_margin_size(MARGIN_RIGHT); } else if (panel->get_class() == "StyleBoxFlat") { - Ref<StyleBoxFlat> panel_flat = panel->cast_to<StyleBoxFlat>(); + Ref<StyleBoxFlat> panel_flat = Object::cast_to<StyleBoxFlat>(*panel); top = panel_flat->get_expand_margin_size(MARGIN_TOP); left = panel_flat->get_expand_margin_size(MARGIN_LEFT); bottom = panel_flat->get_expand_margin_size(MARGIN_BOTTOM); @@ -424,7 +424,7 @@ void AcceptDialog::_update_child_rects() { Vector2 csize(size.x - margin * 2, size.y - margin * 3 - hminsize.y - label_size.height); for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -448,7 +448,7 @@ Size2 AcceptDialog::get_minimum_size() const { Size2 minsize = label->get_combined_minimum_size(); for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index 9d8f113caa..54cc290b05 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 0b898c4d2e..990c0f3d96 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 9873a677b2..34cecfe4d0 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 22de28ea7f..c9ce5e2143 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/gradient_edit.h b/scene/gui/gradient_edit.h index 6c4ae6fd15..026e4f783b 100644 --- a/scene/gui/gradient_edit.h +++ b/scene/gui/gradient_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index ec1932ed5a..5b00aab2ef 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "graph_edit.h" + #include "os/input.h" #include "os/keyboard.h" #include "scene/gui/box_container.h" @@ -134,7 +135,7 @@ void GraphEdit::_update_scroll_offset() { for (int i = 0; i < get_child_count(); i++) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -163,7 +164,7 @@ void GraphEdit::_update_scroll() { Rect2 screen; for (int i = 0; i < get_child_count(); i++) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -205,7 +206,7 @@ void GraphEdit::_update_scroll() { void GraphEdit::_graph_node_raised(Node *p_gn) { - GraphNode *gn = p_gn->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(p_gn); ERR_FAIL_COND(!gn); if (gn->is_comment()) { move_child(gn, 0); @@ -214,7 +215,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) { } int first_not_comment = 0; for (int i = 0; i < get_child_count(); i++) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn && !gn->is_comment()) { first_not_comment = i; break; @@ -228,7 +229,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) { void GraphEdit::_graph_node_moved(Node *p_gn) { - GraphNode *gn = p_gn->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(p_gn); ERR_FAIL_COND(!gn); top_layer->update(); update(); @@ -240,7 +241,7 @@ void GraphEdit::add_child_notify(Node *p_child) { Control::add_child_notify(p_child); top_layer->call_deferred("raise"); //top layer always on top! - GraphNode *gn = p_child->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(p_child); if (gn) { gn->set_scale(Vector2(zoom, zoom)); gn->connect("offset_changed", this, "_graph_node_moved", varray(gn)); @@ -256,7 +257,7 @@ void GraphEdit::remove_child_notify(Node *p_child) { Control::remove_child_notify(p_child); top_layer->call_deferred("raise"); //top layer always on top! - GraphNode *gn = p_child->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(p_child); if (gn) { gn->disconnect("offset_changed", this, "_graph_node_moved"); gn->disconnect("raise_request", this, "_graph_node_raised"); @@ -345,7 +346,7 @@ bool GraphEdit::_filter_input(const Point2 &p_point) { float grab_r = port->get_width() * 0.5 * grab_r_extend; for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -379,7 +380,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { float grab_r = port->get_width() * 0.5 * grab_r_extend; for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -395,20 +396,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (E->get().from == gn->get_name() && E->get().from_port == j) { Node *to = get_node(String(E->get().to)); - if (to && to->cast_to<GraphNode>()) { + if (Object::cast_to<GraphNode>(to)) { connecting_from = E->get().to; connecting_index = E->get().to_port; connecting_out = false; - connecting_type = to->cast_to<GraphNode>()->get_connection_input_type(E->get().to_port); - connecting_color = to->cast_to<GraphNode>()->get_connection_input_color(E->get().to_port); + connecting_type = Object::cast_to<GraphNode>(to)->get_connection_input_type(E->get().to_port); + connecting_color = Object::cast_to<GraphNode>(to)->get_connection_input_color(E->get().to_port); connecting_target = false; connecting_to = pos; just_disconected = true; emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port); to = get_node(String(connecting_from)); //maybe it was erased - if (to && to->cast_to<GraphNode>()) { + if (Object::cast_to<GraphNode>(to)) { connecting = true; } return; @@ -443,20 +444,20 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { if (E->get().to == gn->get_name() && E->get().to_port == j) { Node *fr = get_node(String(E->get().from)); - if (fr && fr->cast_to<GraphNode>()) { + if (Object::cast_to<GraphNode>(fr)) { connecting_from = E->get().from; connecting_index = E->get().from_port; connecting_out = true; - connecting_type = fr->cast_to<GraphNode>()->get_connection_output_type(E->get().from_port); - connecting_color = fr->cast_to<GraphNode>()->get_connection_output_color(E->get().from_port); + connecting_type = Object::cast_to<GraphNode>(fr)->get_connection_output_type(E->get().from_port); + connecting_color = Object::cast_to<GraphNode>(fr)->get_connection_output_color(E->get().from_port); connecting_target = false; connecting_to = pos; just_disconected = true; emit_signal("disconnection_request", E->get().from, E->get().from_port, E->get().to, E->get().to_port); fr = get_node(String(connecting_from)); //maybe it was erased - if (fr && fr->cast_to<GraphNode>()) { + if (Object::cast_to<GraphNode>(fr)) { connecting = true; } return; @@ -493,7 +494,7 @@ void GraphEdit::_top_layer_input(const Ref<InputEvent> &p_ev) { float grab_r = port->get_width() * 0.5 * grab_r_extend; for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -593,8 +594,6 @@ void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color) { -#if 1 - //cubic bezier code float diff = p_to.x - p_from.x; float cp_offset; @@ -621,84 +620,53 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const colors.push_back(p_to_color); p_where->draw_polyline_colors(points, colors, 2, true); - -#else - - static const int steps = 20; - - //old cosine code - Rect2 r; - r.pos = p_from; - r.expand_to(p_to); - Vector2 sign = Vector2((p_from.x < p_to.x) ? 1 : -1, (p_from.y < p_to.y) ? 1 : -1); - bool flip = sign.x * sign.y < 0; - - Vector2 prev; - for (int i = 0; i <= steps; i++) { - - float d = i / float(steps); - float c = -Math::cos(d * Math_PI) * 0.5 + 0.5; - if (flip) - c = 1.0 - c; - Vector2 p = r.pos + Vector2(d * r.size.width, c * r.size.height); - - if (i > 0) { - - p_where->draw_line(prev, p, p_color.linear_interpolate(p_to_color, d), 2); - } - - prev = p; - } -#endif } void GraphEdit::_connections_layer_draw() { - { - //draw connections - List<List<Connection>::Element *> to_erase; - for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - - NodePath fromnp(E->get().from); + //draw connections + List<List<Connection>::Element *> to_erase; + for (List<Connection>::Element *E = connections.front(); E; E = E->next()) { - Node *from = get_node(fromnp); - if (!from) { - to_erase.push_back(E); - continue; - } + NodePath fromnp(E->get().from); - GraphNode *gfrom = from->cast_to<GraphNode>(); + Node *from = get_node(fromnp); + if (!from) { + to_erase.push_back(E); + continue; + } - if (!gfrom) { - to_erase.push_back(E); - continue; - } + GraphNode *gfrom = Object::cast_to<GraphNode>(from); - NodePath tonp(E->get().to); - Node *to = get_node(tonp); - if (!to) { - to_erase.push_back(E); - continue; - } + if (!gfrom) { + to_erase.push_back(E); + continue; + } - GraphNode *gto = to->cast_to<GraphNode>(); + NodePath tonp(E->get().to); + Node *to = get_node(tonp); + if (!to) { + to_erase.push_back(E); + continue; + } - if (!gto) { - to_erase.push_back(E); - continue; - } + GraphNode *gto = Object::cast_to<GraphNode>(to); - Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; - Color color = gfrom->get_connection_output_color(E->get().from_port); - Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; - Color tocolor = gto->get_connection_input_color(E->get().to_port); - _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + if (!gto) { + to_erase.push_back(E); + continue; } - while (to_erase.size()) { - connections.erase(to_erase.front()->get()); - to_erase.pop_front(); - } + Vector2 frompos = gfrom->get_connection_output_pos(E->get().from_port) + gfrom->get_offset() * zoom; + Color color = gfrom->get_connection_output_color(E->get().from_port); + Vector2 topos = gto->get_connection_input_pos(E->get().to_port) + gto->get_offset() * zoom; + Color tocolor = gto->get_connection_input_color(E->get().to_port); + _draw_cos_line(connections_layer, frompos, topos, color, tocolor); + } + + while (to_erase.size()) { + connections.erase(to_erase.front()->get()); + to_erase.pop_front(); } } @@ -710,7 +678,7 @@ void GraphEdit::_top_layer_draw() { Node *fromn = get_node(connecting_from); ERR_FAIL_COND(!fromn); - GraphNode *from = fromn->cast_to<GraphNode>(); + GraphNode *from = Object::cast_to<GraphNode>(fromn); ERR_FAIL_COND(!from); Vector2 pos; if (connecting_out) @@ -744,7 +712,7 @@ void GraphEdit::set_selected(Node *p_child) { for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -767,7 +735,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { //drag_accum+=Vector2(mm->get_relative().x,mm->get_relative().y); drag_accum = get_local_mouse_pos() - drag_origin; for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn && gn->is_selected()) { Vector2 pos = (gn->get_drag_from() * zoom + drag_accum) / zoom; @@ -791,7 +759,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -816,7 +784,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { box_selecting = false; for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; @@ -837,7 +805,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (!just_selected && drag_accum == Vector2() && Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { //deselect current node for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn) { Rect2 r = gn->get_rect(); @@ -853,7 +821,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { emit_signal("_begin_node_move"); for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (gn && gn->is_selected()) gn->set_drag(false); } @@ -874,7 +842,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn_selected = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn_selected = Object::cast_to<GraphNode>(get_child(i)); if (gn_selected) { if (gn_selected->is_resizing()) @@ -898,7 +866,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { just_selected = !gn->is_selected(); if (!gn->is_selected() && !Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { for (int i = 0; i < get_child_count(); i++) { - GraphNode *o_gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i)); if (o_gn) o_gn->set_selected(o_gn == gn); } @@ -906,7 +874,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { gn->set_selected(true); for (int i = 0; i < get_child_count(); i++) { - GraphNode *o_gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *o_gn = Object::cast_to<GraphNode>(get_child(i)); if (!o_gn) continue; if (o_gn->is_selected()) @@ -926,7 +894,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { previus_selected.clear(); for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn || !gn->is_selected()) continue; @@ -937,7 +905,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { previus_selected.clear(); for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn || !gn->is_selected()) continue; @@ -948,7 +916,7 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { previus_selected.clear(); for (int i = get_child_count() - 1; i >= 0; i--) { - GraphNode *gn = get_child(i)->cast_to<GraphNode>(); + GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); if (!gn) continue; diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index e908829d5f..4656b50133 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 4b4ecc5e98..8730be0c06 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -96,7 +96,7 @@ void GraphNode::_get_property_list(List<PropertyInfo> *p_list) const { int idx = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || c->is_set_as_toplevel()) continue; @@ -122,7 +122,7 @@ void GraphNode::_resort() { Size2 minsize; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -144,7 +144,7 @@ void GraphNode::_resort() { cache_y.clear(); for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -375,7 +375,7 @@ Size2 GraphNode::get_minimum_size() const { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -462,7 +462,7 @@ void GraphNode::_connpos_update() { int idx = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index a7d9e8ddb0..416d711aab 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index 06a58d69b2..5dd5667f46 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -51,7 +51,7 @@ void GridContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; @@ -109,7 +109,7 @@ void GridContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; int row = idx / columns; @@ -184,7 +184,7 @@ Size2 GridContainer::get_minimum_size() const { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; int row = idx / columns; diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h index aaa6a295ff..45e26ed48e 100644 --- a/scene/gui/grid_container.h +++ b/scene/gui/grid_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index c7889a6cf2..f8d82a339c 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -534,7 +534,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t diff = now - search_time_msec; - if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { + if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { for (int i = current - 1; i >= 0; i--) { @@ -569,7 +569,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) { uint64_t now = OS::get_singleton()->get_ticks_msec(); uint64_t diff = now - search_time_msec; - if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { + if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) { for (int i = current + 1; i < items.size(); i++) { diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h index a80727f568..8166975408 100644 --- a/scene/gui/item_list.h +++ b/scene/gui/item_list.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index cf7303cbe7..e1f77594da 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -85,7 +85,7 @@ void Label::_notification(int p_what) { Size2 string_size; Size2 size = get_size(); - + Ref<StyleBox> style = get_stylebox("normal"); Ref<Font> font = get_font("font"); Color font_color = get_color("font_color"); Color font_color_shadow = get_color("font_color_shadow"); @@ -93,6 +93,8 @@ void Label::_notification(int p_what) { Point2 shadow_ofs(get_constant("shadow_offset_x"), get_constant("shadow_offset_y")); int line_spacing = get_constant("line_spacing"); + style->draw(ci, Rect2(Point2(0, 0), get_size())); + VisualServer::get_singleton()->canvas_item_set_distance_field_mode(get_canvas_item(), font.is_valid() && font->is_distance_field_hint()); int font_h = font->get_height() + line_spacing; @@ -193,21 +195,20 @@ void Label::_notification(int p_what) { case ALIGN_FILL: case ALIGN_LEFT: { - x_ofs = 0; + x_ofs = style->get_offset().x; } break; case ALIGN_CENTER: { x_ofs = int(size.width - (taken + spaces * space_w)) / 2; - } break; case ALIGN_RIGHT: { - x_ofs = int(size.width - (taken + spaces * space_w)); - + x_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (taken + spaces * space_w)); } break; } - int y_ofs = (line - lines_skipped) * font_h + font->get_ascent(); + int y_ofs = style->get_offset().y; + y_ofs += (line - lines_skipped) * font_h + font->get_ascent(); y_ofs += vbegin + line * vsep; while (from != to) { @@ -288,8 +289,10 @@ void Label::_notification(int p_what) { Size2 Label::get_minimum_size() const { + Size2 min_style = get_stylebox("normal")->get_minimum_size(); + if (autowrap) - return Size2(1, clip ? 1 : minsize.height); + return Size2(1, clip ? 1 : minsize.height) + min_style; else { // don't want to mutable everything @@ -299,7 +302,7 @@ Size2 Label::get_minimum_size() const { Size2 ms = minsize; if (clip) ms.width = 1; - return ms; + return ms + min_style; } } @@ -350,7 +353,7 @@ int Label::get_visible_line_count() const { int line_spacing = get_constant("line_spacing"); int font_h = get_font("font")->get_height() + line_spacing; - int lines_visible = (get_size().y + line_spacing) / font_h; + int lines_visible = (get_size().height - get_stylebox("normal")->get_minimum_size().height + line_spacing) / font_h; if (lines_visible > line_count) lines_visible = line_count; @@ -370,7 +373,8 @@ void Label::regenerate_word_cache() { memdelete(current); } - int width = autowrap ? get_size().width : get_longest_line_width(); + Ref<StyleBox> style = get_stylebox("normal"); + int width = autowrap ? (get_size().width - style->get_minimum_size().width) : get_longest_line_width(); Ref<Font> font = get_font("font"); int current_word_size = 0; @@ -397,7 +401,7 @@ void Label::regenerate_word_cache() { bool separatable = (current >= 0x2E08 && current <= 0xFAFF) || (current >= 0xFE30 && current <= 0xFE4F); //current>=33 && (current < 65||current >90) && (current<97||current>122) && (current<48||current>57); bool insert_newline = false; - int char_width; + int char_width = 0; if (current < 33) { diff --git a/scene/gui/label.h b/scene/gui/label.h index dce68f4422..7c1905af7d 100644 --- a/scene/gui/label.h +++ b/scene/gui/label.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index c5360b0df0..66b4e6cec1 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index 7d04e4618b..52a4a29a33 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp index 632e9ec4fc..9fe94fc464 100644 --- a/scene/gui/link_button.cpp +++ b/scene/gui/link_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h index 98a3dc66f6..386eb452ae 100644 --- a/scene/gui/link_button.h +++ b/scene/gui/link_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp index 2bc9db529b..14991f5d44 100644 --- a/scene/gui/margin_container.cpp +++ b/scene/gui/margin_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -40,7 +40,7 @@ Size2 MarginContainer::get_minimum_size() const { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -74,7 +74,7 @@ void MarginContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h index 1cdb3a36cc..9703d9ebe0 100644 --- a/scene/gui/margin_container.h +++ b/scene/gui/margin_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 93284f2b6c..ac450616d6 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -33,7 +33,7 @@ void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) { - if (p_event->is_pressed() && !p_event->is_echo() && (p_event->cast_to<InputEventKey>() || p_event->cast_to<InputEventJoypadButton>() || p_event->cast_to<InputEventAction>())) { + if (p_event->is_pressed() && !p_event->is_echo() && (Object::cast_to<InputEventKey>(p_event.ptr()) || Object::cast_to<InputEventJoypadButton>(p_event.ptr()) || Object::cast_to<InputEventAction>(*p_event))) { if (!get_parent() || !is_visible_in_tree() || is_disabled()) return; diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h index 6bb23452dd..c7f1d976ff 100644 --- a/scene/gui/menu_button.h +++ b/scene/gui/menu_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 00df266a09..b4d0799945 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h index db921b8b97..a06c540678 100644 --- a/scene/gui/option_button.h +++ b/scene/gui/option_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index f3c6142f9e..536b655f75 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel.h b/scene/gui/panel.h index eac8f2d4e8..cc7ca47319 100644 --- a/scene/gui/panel.h +++ b/scene/gui/panel.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp index 86874f7cfd..a0c75d1330 100644 --- a/scene/gui/panel_container.cpp +++ b/scene/gui/panel_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -41,7 +41,7 @@ Size2 PanelContainer::get_minimum_size() const { Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) @@ -90,7 +90,7 @@ void PanelContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h index f8f1fb6494..5d8f1ee64b 100644 --- a/scene/gui/panel_container.h +++ b/scene/gui/panel_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/patch_9_rect.cpp index 71cbef495c..92c34dd3f9 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/patch_9_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -61,7 +61,7 @@ void NinePatchRect::_bind_methods() { ClassDB::bind_method(D_METHOD("set_region_rect", "rect"), &NinePatchRect::set_region_rect); ClassDB::bind_method(D_METHOD("get_region_rect"), &NinePatchRect::get_region_rect); ClassDB::bind_method(D_METHOD("set_draw_center", "draw_center"), &NinePatchRect::set_draw_center); - ClassDB::bind_method(D_METHOD("get_draw_center"), &NinePatchRect::get_draw_center); + ClassDB::bind_method(D_METHOD("is_draw_center_enabled"), &NinePatchRect::is_draw_center_enabled); ClassDB::bind_method(D_METHOD("set_h_axis_stretch_mode", "mode"), &NinePatchRect::set_h_axis_stretch_mode); ClassDB::bind_method(D_METHOD("get_h_axis_stretch_mode"), &NinePatchRect::get_h_axis_stretch_mode); ClassDB::bind_method(D_METHOD("set_v_axis_stretch_mode", "mode"), &NinePatchRect::set_v_axis_stretch_mode); @@ -70,7 +70,7 @@ void NinePatchRect::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "get_draw_center"); + ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "draw_center"), "set_draw_center", "is_draw_center_enabled"); ADD_PROPERTYNZ(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect"); ADD_GROUP("Patch Margin", "patch_margin_"); @@ -151,13 +151,13 @@ Rect2 NinePatchRect::get_region_rect() const { return region_rect; } -void NinePatchRect::set_draw_center(bool p_draw) { +void NinePatchRect::set_draw_center(bool p_enabled) { - draw_center = p_draw; + draw_center = p_enabled; update(); } -bool NinePatchRect::get_draw_center() const { +bool NinePatchRect::is_draw_center_enabled() const { return draw_center; } diff --git a/scene/gui/patch_9_rect.h b/scene/gui/patch_9_rect.h index 636b9127e7..808b7a1f5d 100644 --- a/scene/gui/patch_9_rect.h +++ b/scene/gui/patch_9_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -67,8 +67,8 @@ public: void set_region_rect(const Rect2 &p_region_rect); Rect2 get_region_rect() const; - void set_draw_center(bool p_draw); - bool get_draw_center() const; + void set_draw_center(bool p_enabled); + bool is_draw_center_enabled() const; void set_h_axis_stretch_mode(AxisStretchMode p_mode); AxisStretchMode get_h_axis_stretch_mode() const; diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 4725300a5f..5a2a552943 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -59,17 +59,10 @@ void Popup::_notification(int p_what) { void Popup::_fix_size() { -#if 0 - Point2 pos = get_position(); - Size2 size = get_size(); - Point2 window_size = window==this ? get_parent_area_size() :window->get_size(); -#else - Point2 pos = get_global_position(); Size2 size = get_size(); Point2 window_size = get_viewport_rect().size; -#endif if (pos.x + size.width > window_size.width) pos.x = window_size.width - size.width; if (pos.x < 0) @@ -79,14 +72,8 @@ void Popup::_fix_size() { pos.y = window_size.height - size.height; if (pos.y < 0) pos.y = 0; -#if 0 - if (pos!=get_pos()) - set_position(pos); -#else if (pos != get_position()) set_global_position(pos); - -#endif } void Popup::set_as_minsize() { @@ -95,7 +82,7 @@ void Popup::set_as_minsize() { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (!c->is_visible()) @@ -129,7 +116,7 @@ void Popup::popup_centered_minsize(const Size2 &p_minsize) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (!c->is_visible()) diff --git a/scene/gui/popup.h b/scene/gui/popup.h index 0543ae1937..6739c580f2 100644 --- a/scene/gui/popup.h +++ b/scene/gui/popup.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 1ba936c4e9..f3711b86b6 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -168,7 +168,7 @@ void PopupMenu::_activate_submenu(int over) { Node *n = get_node(items[over].submenu); ERR_EXPLAIN("item subnode does not exist: " + items[over].submenu); ERR_FAIL_COND(!n); - Popup *pm = n->cast_to<Popup>(); + Popup *pm = Object::cast_to<Popup>(n); ERR_EXPLAIN("item subnode is not a Popup: " + items[over].submenu); ERR_FAIL_COND(!pm); if (pm->is_visible_in_tree()) @@ -187,7 +187,7 @@ void PopupMenu::_activate_submenu(int over) { pm->set_position(pos); pm->popup(); - PopupMenu *pum = pm->cast_to<PopupMenu>(); + PopupMenu *pum = Object::cast_to<PopupMenu>(pm); if (pum) { pr.position -= pum->get_global_position(); @@ -869,7 +869,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo if (!n) continue; - PopupMenu *pm = n->cast_to<PopupMenu>(); + PopupMenu *pm = Object::cast_to<PopupMenu>(n); if (!pm) continue; @@ -891,14 +891,14 @@ void PopupMenu::activate_item(int p_item) { //hide all parent PopupMenue's Node *next = get_parent(); - PopupMenu *pop = next->cast_to<PopupMenu>(); + PopupMenu *pop = Object::cast_to<PopupMenu>(next); while (pop) { // We close all parents that are chained together, // with hide_on_item_selection enabled if ((items[p_item].checkable && hide_on_checkable_item_selection && pop->is_hide_on_checkable_item_selection()) || (!items[p_item].checkable && hide_on_item_selection && pop->is_hide_on_item_selection())) { pop->hide(); next = next->get_parent(); - pop = next->cast_to<PopupMenu>(); + pop = Object::cast_to<PopupMenu>(next); } else { // Break out of loop when the next parent has // hide_on_item_selection disabled diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h index 37714ee989..c9e9c8e311 100644 --- a/scene/gui/popup_menu.h +++ b/scene/gui/popup_menu.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp index 13d368d253..6953d03384 100644 --- a/scene/gui/progress_bar.cpp +++ b/scene/gui/progress_bar.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h index 1121a78aab..c5a9252123 100644 --- a/scene/gui/progress_bar.h +++ b/scene/gui/progress_bar.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 68afe8150a..1dbec6e5a1 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -170,7 +170,7 @@ double Range::get_as_ratio() const { void Range::_share(Node *p_range) { - Range *r = p_range->cast_to<Range>(); + Range *r = Object::cast_to<Range>(p_range); ERR_FAIL_COND(!r); share(r); } diff --git a/scene/gui/range.h b/scene/gui/range.h index fdcbbb09ee..daa8af824a 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/reference_rect.cpp b/scene/gui/reference_rect.cpp index 441c3e721b..e2f4abe04a 100644 --- a/scene/gui/reference_rect.cpp +++ b/scene/gui/reference_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/reference_rect.h b/scene/gui/reference_rect.h index b118425eb6..9b826a1145 100644 --- a/scene/gui/reference_rect.h +++ b/scene/gui/reference_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index f0efbdc517..a3f116c883 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 71fa766958..74bf180b5d 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 4242ee4523..16d1b320b7 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,9 +28,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scroll_bar.h" + #include "os/keyboard.h" #include "os/os.h" #include "print_string.h" + bool ScrollBar::focus_by_default = false; void ScrollBar::set_can_focus_by_default(bool p_can_focus) { @@ -315,7 +317,7 @@ void ScrollBar::_notification(int p_what) { if (has_node(drag_slave_path)) { Node *n = get_node(drag_slave_path); - drag_slave = n->cast_to<Control>(); + drag_slave = Object::cast_to<Control>(n); } if (drag_slave) { @@ -663,7 +665,7 @@ void ScrollBar::set_drag_slave(const NodePath &p_path) { if (has_node(p_path)) { Node *n = get_node(p_path); - drag_slave = n->cast_to<Control>(); + drag_slave = Object::cast_to<Control>(n); } if (drag_slave) { @@ -686,138 +688,6 @@ bool ScrollBar::is_smooth_scroll_enabled() const { return smooth_scroll_enabled; } -#if 0 - -void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) { - - // wheel! - - if (b->get_button_index()==BUTTON_WHEEL_UP && b->is_pressed()) { - - if (orientation==VERTICAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - - } - if (b->get_button_index()==BUTTON_WHEEL_DOWN && b->is_pressed()) { - - if (orientation==HORIZONTAL) - set_val( get_val() - get_page() / 4.0 ); - else - set_val( get_val() + get_page() / 4.0 ); - } - - if (b->get_button_index()!=BUTTON_LEFT) - return; - - if (b->is_pressed()) { - - int ofs = orientation==VERTICAL ? p_pos.y : p_pos.x ; - int grabber_ofs = get_grabber_offset(); - int grabber_size = get_grabber_size(); - - if ( ofs < grabber_ofs ) { - - set_val( get_val() - get_page() ); - - } else if (ofs > grabber_ofs + grabber_size ) { - - set_val( get_val() + get_page() ); - - } else { - - - drag.active=true; - drag.pos_at_click=get_click_pos(p_pos); - drag.value_at_click=get_unit_value(); - } - - - } else { - - drag.active=false; - } - -} -void ScrollBar::mouse_motion(const Point2& p_pos, const Point2& p_rel, int b->get_button_index()_mask) { - - if (!drag.active) - return; - - double value_ofs=drag.value_at_click+(get_click_pos(p_pos)-drag.pos_at_click); - - - value_ofs=value_ofs*( get_max() - get_min() ); - if (value_ofs<get_min()) - value_ofs=get_min(); - if (value_ofs>(get_max()-get_page())) - value_ofs=get_max()-get_page(); - if (get_val()==value_ofs) - return; //don't bother if the value is the same - - set_val( value_ofs ); - -} - -bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b->is_pressed(),bool p_repeat,int p_modifier_mask) { - - if (!b->is_pressed()) - return false; - - switch (p_scan_code) { - - case KEY_LEFT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() - get_step() ); - - } break; - case KEY_RIGHT: { - - if (orientation!=HORIZONTAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_UP: { - - if (orientation!=VERTICAL) - return false; - - set_val( get_val() - get_step() ); - - - } break; - case KEY_DOWN: { - - if (orientation!=VERTICAL) - return false; - set_val( get_val() + get_step() ); - - } break; - case KEY_HOME: { - - set_val( get_min() ); - - } break; - case KEY_END: { - - set_val( get_max() ); - - } break; - - default: - return false; - - } - - return true; -} - -#endif - void ScrollBar::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input); diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index e22d4da46d..373483a8a0 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 939bdd8d0c..e182e491d3 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -40,7 +40,7 @@ Size2 ScrollContainer::get_minimum_size() const { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -220,7 +220,7 @@ void ScrollContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) @@ -423,7 +423,7 @@ String ScrollContainer::get_configuration_warning() const { for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index e5df3e5e1c..9076be0d72 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp index 3b00ab4605..3db234f7cc 100644 --- a/scene/gui/separator.cpp +++ b/scene/gui/separator.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/separator.h b/scene/gui/separator.h index 9a5fe2ac66..be2f1e8e77 100644 --- a/scene/gui/separator.h +++ b/scene/gui/separator.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/input_action.cpp b/scene/gui/shortcut.cpp index c08059a049..f37410e77b 100644 --- a/scene/gui/input_action.cpp +++ b/scene/gui/shortcut.cpp @@ -1,9 +1,9 @@ /*************************************************************************/ -/* input_action.cpp */ +/* shortcut.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,7 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "input_action.h" +#include "shortcut.h" + #include "os/keyboard.h" void ShortCut::set_shortcut(const Ref<InputEvent> &p_shortcut) { @@ -52,61 +53,6 @@ String ShortCut::get_as_text() const { return shortcut->as_text(); else return "None"; -#if 0 - switch (shortcut.type) { - - case Ref<InputEvent>::NONE: { - - return "None"; - } break; - case Ref<InputEvent>::KEY: { - - String str; - if (shortcut->get_shift()) - str += RTR("Shift+"); - if (shortcut->get_alt()) - str += RTR("Alt+"); - if (shortcut->get_control()) - str += RTR("Ctrl+"); - if (shortcut->get_metakey()) - str += RTR("Meta+"); - - str += keycode_get_string(shortcut->get_scancode()).capitalize(); - - return str; - } break; - case Ref<InputEvent>::JOYPAD_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Button") + " " + itos(shortcut.joy_button->get_button_index()); - str += "."; - - return str; - } break; - case Ref<InputEvent>::MOUSE_BUTTON: { - - String str = RTR("Device") + " " + itos(shortcut.device) + ", "; - switch (shortcut->get_button_index()) { - case BUTTON_LEFT: str += RTR("Left Button."); break; - case BUTTON_RIGHT: str += RTR("Right Button."); break; - case BUTTON_MIDDLE: str += RTR("Middle Button."); break; - case BUTTON_WHEEL_UP: str += RTR("Wheel Up."); break; - case BUTTON_WHEEL_DOWN: str += RTR("Wheel Down."); break; - default: str += RTR("Button") + " " + itos(shortcut->get_button_index()) + "."; - } - - return str; - } break; - case Ref<InputEvent>::JOYPAD_MOTION: { - - int ax = shortcut.joy_motion.axis; - String str = RTR("Device") + " " + itos(shortcut.device) + ", " + RTR("Axis") + " " + itos(ax) + "."; - - return str; - } break; - } - - return ""; -#endif } bool ShortCut::is_valid() const { diff --git a/scene/gui/input_action.h b/scene/gui/shortcut.h index 5c91d2be28..8d85bb920f 100644 --- a/scene/gui/input_action.h +++ b/scene/gui/shortcut.h @@ -1,9 +1,9 @@ /*************************************************************************/ -/* input_action.h */ +/* shortcut.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef INPUTACTION_H -#define INPUTACTION_H +#ifndef SHORTCUT_H +#define SHORTCUT_H #include "os/input_event.h" #include "resource.h" @@ -53,4 +53,4 @@ public: ShortCut(); }; -#endif // INPUTACTION_H +#endif // SHORTCUT_H diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 9ba17ce34f..4661f54526 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/slider.h b/scene/gui/slider.h index f3cf3c6f48..a2334a69fc 100644 --- a/scene/gui/slider.h +++ b/scene/gui/slider.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 751edc5a43..f462989f53 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 683ed0c344..0c562bd744 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp index 5fc3db4672..4420a936d2 100644 --- a/scene/gui/split_container.cpp +++ b/scene/gui/split_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -44,7 +44,7 @@ Control *SplitContainer::_getch(int p_idx) const { int idx = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = get_child(i)->cast_to<Control>(); + Control *c = Object::cast_to<Control>(get_child(i)); if (!c || !c->is_visible_in_tree()) continue; if (c->is_set_as_toplevel()) diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index 87a210f24c..8ec21b5eaa 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index d32b899de7..461ae3444b 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -230,7 +230,7 @@ void TabContainer::_notification(int p_what) { tab_style->draw(canvas, tab_rect); // Draw the tab contents. - Control *control = tabs[i + first_tab_cache]->cast_to<Control>(); + 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()); int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT); @@ -293,7 +293,7 @@ void TabContainer::_notification(int p_what) { } int TabContainer::_get_tab_width(int p_index) const { - Control *control = _get_tabs()[p_index]->cast_to<Control>(); + Control *control = Object::cast_to<Control>(_get_tabs()[p_index]); if (!control || control->is_set_as_toplevel()) return 0; @@ -332,7 +332,7 @@ Vector<Control *> TabContainer::_get_tabs() const { Vector<Control *> controls; for (int i = 0; i < get_child_count(); i++) { - Control *control = get_child(i)->cast_to<Control>(); + Control *control = Object::cast_to<Control>(get_child(i)); if (!control || control->is_toplevel_control()) continue; @@ -350,7 +350,7 @@ void TabContainer::add_child_notify(Node *p_child) { Control::add_child_notify(p_child); - Control *c = p_child->cast_to<Control>(); + Control *c = Object::cast_to<Control>(p_child); if (!c) return; if (c->is_set_as_toplevel()) @@ -616,7 +616,7 @@ Size2 TabContainer::get_minimum_size() const { void TabContainer::set_popup(Node *p_popup) { ERR_FAIL_NULL(p_popup); - popup = p_popup->cast_to<Popup>(); + popup = Object::cast_to<Popup>(p_popup); update(); } diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index 3e1a2c1598..be59a16b3f 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index b0dc88bbb4..085f6de6b8 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 86ad128dcd..73fa40bbb8 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 245e7e04be..ade665b418 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -27,13 +27,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "text_edit.h" + +#include "message_queue.h" #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" - -#include "message_queue.h" #include "project_settings.h" #include "scene/main/viewport.h" @@ -215,8 +214,8 @@ void TextEdit::Text::_update_line_cache(int p_line) const { const Map<int, TextEdit::Text::ColorRegionInfo> &TextEdit::Text::get_color_region_info(int p_line) { - Map<int, ColorRegionInfo> *cri = NULL; - ERR_FAIL_INDEX_V(p_line, text.size(), *cri); //enjoy your crash + static Map<int, ColorRegionInfo> cri; + ERR_FAIL_INDEX_V(p_line, text.size(), cri); if (text[p_line].width_cache == -1) { _update_line_cache(p_line); @@ -431,7 +430,7 @@ void TextEdit::_notification(int p_what) { double dist = sqrt(target_y * target_y); double vel = ((target_y / dist) * v_scroll_speed) * get_fixed_process_delta_time(); - if (vel >= dist) { + if (Math::abs(vel) >= dist) { v_scroll->set_value(target_v_scroll); scrolling = false; set_fixed_process(false); @@ -2114,7 +2113,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { //keep indentation int space_count = 0; - for (int i = 0; i < text[cursor.line].length(); i++) { + for (int i = 0; i < cursor.column; i++) { if (text[cursor.line][i] == '\t') { if (indent_using_spaces) { ins += space_indent; @@ -2736,6 +2735,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { else undo(); } break; + case KEY_Y: { + + if (!k->get_command()) { + scancode_handled = false; + break; + } + + redo(); + } break; case KEY_V: { if (readonly) { break; @@ -3181,6 +3189,11 @@ void TextEdit::adjust_viewport_to_cursor() { if (cursor.line < cursor.line_ofs) cursor.line_ofs = cursor.line; + if (cursor.line_ofs + visible_rows > text.size() && !scroll_past_end_of_file_enabled) { + cursor.line_ofs = text.size() - visible_rows; + v_scroll->set_value(text.size() - visible_rows); + } + int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]); if (cursor_x > (cursor.x_ofs + visible_width)) @@ -3653,10 +3666,10 @@ void TextEdit::cut() { String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); OS::get_singleton()->set_clipboard(clipboard); - cursor_set_line(selection.from_line); + _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); + cursor_set_line(selection.from_line); // set afterwards else it causes the view to be offset cursor_set_column(selection.from_column); - _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); selection.active = false; selection.selecting_mode = Selection::MODE_NONE; update(); @@ -4319,6 +4332,7 @@ void TextEdit::_cancel_completion() { return; completion_active = false; + completion_forced = false; update(); } @@ -4386,13 +4400,19 @@ void TextEdit::_update_completion_candidates() { } } - if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_strings[0].begins_with("\"")) { + if (cursor.column > 0 && l[cursor.column - 1] == '(' && !pre_keyword && !completion_forced) { cancel = true; } update(); - if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !completion_prefixes.has(String::chr(l[cofs - 1]))))) { + bool prev_is_prefix = false; + if (cofs > 0 && completion_prefixes.has(String::chr(l[cofs - 1]))) + prev_is_prefix = true; + if (cofs > 1 && l[cofs - 1] == ' ' && completion_prefixes.has(String::chr(l[cofs - 2]))) //check with one space before prefix, to allow indent + prev_is_prefix = true; + + if (cancel || (!pre_keyword && s == "" && (cofs == 0 || !prev_is_prefix))) { //none to complete, cancel _cancel_completion(); return; @@ -4450,18 +4470,6 @@ void TextEdit::_update_completion_candidates() { // The top of the list is the best match completion_current = completion_options[0]; - -#if 0 // even there's only one option, user still get the chance to choose using it or not - if (completion_options.size()==1) { - //one option to complete, just complete it automagically - _confirm_completion(); - //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length())); - _cancel_completion(); - return; - - } -#endif - completion_enabled = true; } @@ -4481,6 +4489,8 @@ void TextEdit::query_code_comple() { if (ofs > 0 && (inquote || _is_completable(l[ofs - 1]) || completion_prefixes.has(String::chr(l[ofs - 1])))) emit_signal("request_completion"); + else if (ofs > 1 && l[ofs - 1] == ' ' && completion_prefixes.has(String::chr(l[ofs - 2]))) //make it work with a space too, it's good enough + emit_signal("request_completion"); } void TextEdit::set_code_hint(const String &p_hint) { @@ -4492,12 +4502,13 @@ void TextEdit::set_code_hint(const String &p_hint) { update(); } -void TextEdit::code_complete(const Vector<String> &p_strings) { +void TextEdit::code_complete(const Vector<String> &p_strings, bool p_forced) { VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1); raised_from_completion = true; completion_strings = p_strings; completion_active = true; + completion_forced = p_forced; completion_current = ""; completion_index = 0; _update_completion_candidates(); @@ -4520,7 +4531,7 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const { bool symbol = beg < s.length() && _is_symbol(s[beg]); //not sure if right but most editors behave like this bool inside_quotes = false; - int qbegin, qend; + int qbegin = 0, qend = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '"') { if (inside_quotes) { @@ -4885,24 +4896,6 @@ TextEdit::TextEdit() { click_select_held->set_wait_time(0.05); click_select_held->connect("timeout", this, "_click_selection_held"); -#if 0 - syntax_coloring=true; - keywords["void"]=Color(0.3,0.0,0.1); - keywords["int"]=Color(0.3,0.0,0.1); - keywords["function"]=Color(0.3,0.0,0.1); - keywords["class"]=Color(0.3,0.0,0.1); - keywords["extends"]=Color(0.3,0.0,0.1); - keywords["constructor"]=Color(0.3,0.0,0.1); - symbol_color=Color(0.1,0.0,0.3,1.0); - - color_regions.push_back(ColorRegion("/*","*/",Color(0.4,0.6,0,4))); - color_regions.push_back(ColorRegion("//","",Color(0.6,0.6,0.4))); - color_regions.push_back(ColorRegion("\"","\"",Color(0.4,0.7,0.7))); - color_regions.push_back(ColorRegion("'","'",Color(0.4,0.8,0.8))); - color_regions.push_back(ColorRegion("#","",Color(0.2,1.0,0.2))); - -#endif - current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; undo_stack_pos = NULL; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 6321cad2da..68ef559f46 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -205,6 +205,7 @@ class TextEdit : public Control { Vector<String> completion_strings; Vector<String> completion_options; bool completion_active; + bool completion_forced; String completion_current; String completion_base; int completion_index; @@ -522,7 +523,7 @@ public: void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata); void set_completion(bool p_enabled, const Vector<String> &p_prefixes); - void code_complete(const Vector<String> &p_strings); + void code_complete(const Vector<String> &p_strings, bool p_forced = false); void set_code_hint(const String &p_hint); void query_code_comple(); diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp index d307b463d9..77bc876201 100644 --- a/scene/gui/texture_button.cpp +++ b/scene/gui/texture_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h index 8df30cd35a..94f372decf 100644 --- a/scene/gui/texture_button.h +++ b/scene/gui/texture_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp index 59cff84719..aad7c6b96b 100644 --- a/scene/gui/texture_progress.cpp +++ b/scene/gui/texture_progress.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h index 20546bd11f..04096d35e3 100644 --- a/scene/gui/texture_progress.h +++ b/scene/gui/texture_progress.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index db340fd4d7..38f90fe7b5 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/texture_rect.h b/scene/gui/texture_rect.h index dcc6c3f9bd..8a2b715488 100644 --- a/scene/gui/texture_rect.h +++ b/scene/gui/texture_rect.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp index 5fc4b6ecf8..4dfa3d8f37 100644 --- a/scene/gui/tool_button.cpp +++ b/scene/gui/tool_button.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h index d243b5559f..4c5ea685de 100644 --- a/scene/gui/tool_button.h +++ b/scene/gui/tool_button.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 20bf818d44..5e15bceb7d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tree.h" + #include "os/input.h" #include "os/keyboard.h" #include "os/os.h" @@ -990,41 +991,10 @@ void Tree::draw_item_rect(const TreeItem::Cell &p_cell, const Rect2i &p_rect, co rect.size.x -= bmsize.x + cache.hseparation; } - /* - if (p_tool) - rect.size.x-=Math::floor(rect.size.y/2); - */ - rect.position.y += Math::floor((rect.size.y - font->get_height()) / 2.0) + font->get_ascent(); font->draw(ci, rect.position, text, p_color, rect.size.x); } -#if 0 -void Tree::draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color) { - - RID ci = get_canvas_item(); - if (!p_icon.is_null()) { - Size2i bmsize = p_icon->get_size(); - if (p_icon_max_w>0 && bmsize.width > p_icon_max_w) { - bmsize.height = bmsize.height * p_icon_max_w / bmsize.width; - bmsize.width=p_icon_max_w; - } - - draw_texture_rect(p_icon,Rect2(p_rect.pos + Size2i(0,Math::floor((p_rect.size.y-bmsize.y)/2)),bmsize)); - p_rect.pos.x+=bmsize.x+cache.hseparation; - p_rect.size.x-=bmsize.x+cache.hseparation; - - } - - if (p_tool) - p_rect.size.x-=Math::floor(p_rect.size.y/2); - - Ref<Font> font = cache.font; - - p_rect.pos.y+=Math::floor((p_rect.size.y-font->get_height())/2.0) +font->get_ascent(); - font->draw(ci,p_rect.pos,p_text,p_color,p_rect.size.x); -} -#endif int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 &p_draw_size, TreeItem *p_item) { if (p_pos.y - cache.offset.y > (p_draw_size.height)) @@ -2473,22 +2443,24 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { Point2 pos = b->get_position() - bg->get_offset(); cache.click_type = Cache::CLICK_NONE; - if (show_column_titles && b->get_button_index() == BUTTON_LEFT) { + if (show_column_titles) { pos.y -= _get_title_button_height(); if (pos.y < 0) { - pos.x += cache.offset.x; - int len = 0; - for (int i = 0; i < columns.size(); i++) { - - len += get_column_width(i); - if (pos.x < len) { - - cache.click_type = Cache::CLICK_TITLE; - cache.click_index = i; - //cache.click_id=; - update(); - break; + if (b->get_button_index() == BUTTON_LEFT) { + pos.x += cache.offset.x; + int len = 0; + for (int i = 0; i < columns.size(); i++) { + + len += get_column_width(i); + if (pos.x < len) { + + cache.click_type = Cache::CLICK_TITLE; + cache.click_index = i; + //cache.click_id=; + update(); + break; + } } } break; @@ -2868,8 +2840,8 @@ TreeItem *Tree::create_item(TreeItem *p_parent) { TreeItem *ti = memnew(TreeItem(this)); - ti->cells.resize(columns.size()); ERR_FAIL_COND_V(!ti, NULL); + ti->cells.resize(columns.size()); if (p_parent) { diff --git a/scene/gui/tree.h b/scene/gui/tree.h index 49a410f115..06d6d3ad5a 100644 --- a/scene/gui/tree.h +++ b/scene/gui/tree.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -54,7 +54,7 @@ public: CELL_MODE_CHECK, ///< string + check CELL_MODE_RANGE, ///< Contains a range CELL_MODE_RANGE_EXPRESSION, ///< Contains a range - CELL_MODE_ICON, ///< Contains a icon, not editable + CELL_MODE_ICON, ///< Contains an icon, not editable CELL_MODE_CUSTOM, ///< Contains a custom value, show a string, and an edit button }; @@ -172,7 +172,9 @@ protected: return d; } - void _remove_child(Object *p_child) { remove_child(p_child->cast_to<TreeItem>()); } + void _remove_child(Object *p_child) { + remove_child(Object::cast_to<TreeItem>(p_child)); + } public: /* cell mode */ @@ -504,9 +506,17 @@ protected: static void _bind_methods(); //bind helpers - Object *_create_item(Object *p_parent) { return create_item(p_parent->cast_to<TreeItem>()); } - TreeItem *_get_next_selected(Object *p_item) { return get_next_selected(p_item->cast_to<TreeItem>()); } - Rect2 _get_item_rect(Object *p_item, int p_column) const { return get_item_rect(p_item->cast_to<TreeItem>(), p_column); } + Object *_create_item(Object *p_parent) { + return create_item(Object::cast_to<TreeItem>(p_parent)); + } + + TreeItem *_get_next_selected(Object *p_item) { + return get_next_selected(Object::cast_to<TreeItem>(p_item)); + } + + Rect2 _get_item_rect(Object *p_item, int p_column) const { + return get_item_rect(Object::cast_to<TreeItem>(p_item), p_column); + } public: virtual String get_tooltip(const Point2 &p_pos) const; diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 37d10fb63e..a92155cc4f 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,27 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "video_player.h" + #include "os/os.h" #include "servers/audio_server.h" -/* - -int VideoPlayer::InternalStream::get_channel_count() const { - - return player->sp_get_channel_count(); -} -void VideoPlayer::InternalStream::set_mix_rate(int p_rate){ - - return player->sp_set_mix_rate(p_rate); -} -bool VideoPlayer::InternalStream::mix(int32_t *p_buffer,int p_frames){ - - return player->sp_mix(p_buffer,p_frames); -} -void VideoPlayer::InternalStream::update(){ - - player->sp_update(); -} -*/ int VideoPlayer::sp_get_channel_count() const { @@ -69,31 +51,6 @@ bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) { return false; } -void VideoPlayer::sp_update() { -#if 0 - _THREAD_SAFE_METHOD_ - //update is unused - if (!paused && playback.is_valid()) { - - if (!playback->is_playing()) { - //stream depleted data, but there's still audio in the ringbuffer - //check that all this audio has been flushed before stopping the stream - int to_mix = resampler.get_total() - resampler.get_todo(); - if (to_mix==0) { - stop(); - return; - } - - return; - } - - int todo =resampler.get_todo(); - int wrote = playback->mix(resampler.get_write_buffer(),todo); - resampler.write(wrote); - } -#endif -} - int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) { VideoPlayer *vp = (VideoPlayer *)p_udata; diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index 87c452509b..b78f3aabe7 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,23 +38,12 @@ class VideoPlayer : public Control { GDCLASS(VideoPlayer, Control); - /* struct InternalStream : public AudioServer::AudioStream { - VideoPlayer *player; - virtual int get_channel_count() const; - virtual void set_mix_rate(int p_rate); //notify the stream of the mix rate - virtual bool mix(int32_t *p_buffer,int p_frames); - virtual void update(); - }; -*/ - - // InternalStream internal_stream; Ref<VideoStreamPlayback> playback; Ref<VideoStream> stream; int sp_get_channel_count() const; void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate bool sp_mix(int32_t *p_buffer, int p_frames); - void sp_update(); RID stream_rid; @@ -118,4 +107,4 @@ public: ~VideoPlayer(); }; -#endif +#endif // VIDEO_PLAYER_H diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp index dbc2699867..c321b873fd 100644 --- a/scene/gui/viewport_container.cpp +++ b/scene/gui/viewport_container.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -38,7 +38,7 @@ Size2 ViewportContainer::get_minimum_size() const { Size2 ms; for (int i = 0; i < get_child_count(); i++) { - Viewport *c = get_child(i)->cast_to<Viewport>(); + Viewport *c = Object::cast_to<Viewport>(get_child(i)); if (!c) continue; @@ -71,7 +71,7 @@ void ViewportContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Viewport *c = get_child(i)->cast_to<Viewport>(); + Viewport *c = Object::cast_to<Viewport>(get_child(i)); if (!c) continue; @@ -83,7 +83,7 @@ void ViewportContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Viewport *c = get_child(i)->cast_to<Viewport>(); + Viewport *c = Object::cast_to<Viewport>(get_child(i)); if (!c) continue; @@ -98,7 +98,7 @@ void ViewportContainer::_notification(int p_what) { for (int i = 0; i < get_child_count(); i++) { - Viewport *c = get_child(i)->cast_to<Viewport>(); + Viewport *c = Object::cast_to<Viewport>(get_child(i)); if (!c) continue; diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h index 27eb6ec81b..630523b5fb 100644 --- a/scene/gui/viewport_container.h +++ b/scene/gui/viewport_container.h @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ |