summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/SCsub4
-rw-r--r--scene/gui/base_button.cpp183
-rw-r--r--scene/gui/base_button.h46
-rw-r--r--scene/gui/box_container.cpp23
-rw-r--r--scene/gui/box_container.h8
-rw-r--r--scene/gui/button.cpp44
-rw-r--r--scene/gui/button.h8
-rw-r--r--scene/gui/button_array.cpp106
-rw-r--r--scene/gui/button_array.h22
-rw-r--r--scene/gui/button_group.cpp21
-rw-r--r--scene/gui/button_group.h7
-rw-r--r--scene/gui/center_container.cpp8
-rw-r--r--scene/gui/center_container.h4
-rw-r--r--scene/gui/check_box.cpp10
-rw-r--r--scene/gui/check_box.h4
-rw-r--r--scene/gui/check_button.cpp2
-rw-r--r--scene/gui/check_button.h4
-rw-r--r--scene/gui/color_picker.cpp276
-rw-r--r--scene/gui/color_picker.h27
-rw-r--r--scene/gui/color_ramp_edit.cpp12
-rw-r--r--scene/gui/color_ramp_edit.h8
-rw-r--r--scene/gui/color_rect.cpp45
-rw-r--r--scene/gui/color_rect.h40
-rw-r--r--scene/gui/container.cpp12
-rw-r--r--scene/gui/container.h4
-rw-r--r--scene/gui/control.cpp673
-rw-r--r--scene/gui/control.h36
-rw-r--r--scene/gui/dialogs.cpp111
-rw-r--r--scene/gui/dialogs.h21
-rw-r--r--scene/gui/file_dialog.cpp135
-rw-r--r--scene/gui/file_dialog.h6
-rw-r--r--scene/gui/graph_edit.cpp121
-rw-r--r--scene/gui/graph_edit.h10
-rw-r--r--scene/gui/graph_node.cpp87
-rw-r--r--scene/gui/graph_node.h11
-rw-r--r--scene/gui/grid_container.cpp18
-rw-r--r--scene/gui/grid_container.h4
-rw-r--r--scene/gui/input_action.cpp18
-rw-r--r--scene/gui/input_action.h2
-rw-r--r--scene/gui/item_list.cpp170
-rw-r--r--scene/gui/item_list.h6
-rw-r--r--scene/gui/label.cpp103
-rw-r--r--scene/gui/label.h5
-rw-r--r--scene/gui/line_edit.cpp118
-rw-r--r--scene/gui/line_edit.h6
-rw-r--r--scene/gui/link_button.cpp17
-rw-r--r--scene/gui/link_button.h7
-rw-r--r--scene/gui/margin_container.cpp4
-rw-r--r--scene/gui/margin_container.h4
-rw-r--r--scene/gui/menu_button.cpp28
-rw-r--r--scene/gui/menu_button.h6
-rw-r--r--scene/gui/option_button.cpp56
-rw-r--r--scene/gui/option_button.h4
-rw-r--r--scene/gui/panel.cpp4
-rw-r--r--scene/gui/panel.h4
-rw-r--r--scene/gui/panel_container.cpp6
-rw-r--r--scene/gui/panel_container.h4
-rw-r--r--scene/gui/patch_9_rect.cpp (renamed from scene/gui/patch_9_frame.cpp)85
-rw-r--r--scene/gui/patch_9_rect.h (renamed from scene/gui/patch_9_frame.h)16
-rw-r--r--scene/gui/popup.cpp27
-rw-r--r--scene/gui/popup.h8
-rw-r--r--scene/gui/popup_menu.cpp232
-rw-r--r--scene/gui/popup_menu.h29
-rw-r--r--scene/gui/progress_bar.cpp13
-rw-r--r--scene/gui/progress_bar.h4
-rw-r--r--scene/gui/range.cpp109
-rw-r--r--scene/gui/range.h22
-rw-r--r--scene/gui/reference_rect.cpp (renamed from scene/gui/reference_frame.cpp)10
-rw-r--r--scene/gui/reference_rect.h (renamed from scene/gui/reference_frame.h)16
-rw-r--r--scene/gui/rich_text_label.cpp137
-rw-r--r--scene/gui/rich_text_label.h6
-rw-r--r--scene/gui/scroll_bar.cpp110
-rw-r--r--scene/gui/scroll_bar.h10
-rw-r--r--scene/gui/scroll_container.cpp125
-rw-r--r--scene/gui/scroll_container.h9
-rw-r--r--scene/gui/separator.cpp2
-rw-r--r--scene/gui/separator.h8
-rw-r--r--scene/gui/slider.cpp54
-rw-r--r--scene/gui/slider.h10
-rw-r--r--scene/gui/spin_box.cpp75
-rw-r--r--scene/gui/spin_box.h6
-rw-r--r--scene/gui/split_container.cpp26
-rw-r--r--scene/gui/split_container.h10
-rw-r--r--scene/gui/tab_container.cpp42
-rw-r--r--scene/gui/tab_container.h6
-rw-r--r--scene/gui/tabs.cpp30
-rw-r--r--scene/gui/tabs.h6
-rw-r--r--scene/gui/text_edit.cpp325
-rw-r--r--scene/gui/text_edit.h33
-rw-r--r--scene/gui/texture_button.cpp68
-rw-r--r--scene/gui/texture_button.h9
-rw-r--r--scene/gui/texture_progress.cpp58
-rw-r--r--scene/gui/texture_progress.h4
-rw-r--r--scene/gui/texture_rect.cpp (renamed from scene/gui/texture_frame.cpp)73
-rw-r--r--scene/gui/texture_rect.h (renamed from scene/gui/texture_frame.h)17
-rw-r--r--scene/gui/tool_button.cpp2
-rw-r--r--scene/gui/tool_button.h4
-rw-r--r--scene/gui/tree.cpp427
-rw-r--r--scene/gui/tree.h23
-rw-r--r--scene/gui/video_player.cpp69
-rw-r--r--scene/gui/video_player.h4
-rw-r--r--scene/gui/viewport_container.cpp103
-rw-r--r--scene/gui/viewport_container.h25
103 files changed, 2901 insertions, 2319 deletions
diff --git a/scene/gui/SCsub b/scene/gui/SCsub
index bbe59b3054..bf9125be7f 100644
--- a/scene/gui/SCsub
+++ b/scene/gui/SCsub
@@ -1,5 +1,7 @@
+#!/usr/bin/env python
+
Import('env')
-env.add_source_files(env.scene_sources,"*.cpp")
+env.add_source_files(env.scene_sources, "*.cpp")
Export('env')
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 6479dd2d02..0b40983ddf 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -29,11 +29,24 @@
#include "base_button.h"
#include "os/keyboard.h"
#include "print_string.h"
-#include "button_group.h"
#include "scene/scene_string_names.h"
#include "scene/main/viewport.h"
-void BaseButton::_input_event(InputEvent p_event) {
+
+void BaseButton::_unpress_group() {
+
+ if (!button_group.is_valid())
+ return;
+
+ for (Set<BaseButton*>::Element *E=button_group->buttons.front();E;E=E->next()) {
+ if (E->get()==this)
+ continue;
+
+ E->get()->set_pressed(false);
+ }
+}
+
+void BaseButton::_gui_input(InputEvent p_event) {
if (status.disabled) // no interaction with disabled button
@@ -51,7 +64,7 @@ void BaseButton::_input_event(InputEvent p_event) {
if (status.pressing_button)
break;
- if (status.click_on_press) {
+ if (action_mode==ACTION_MODE_BUTTON_PRESS) {
if (b.pressed) {
@@ -69,6 +82,8 @@ void BaseButton::_input_event(InputEvent p_event) {
}
emit_signal("pressed");
+ _unpress_group();
+
} else {
@@ -79,6 +94,8 @@ void BaseButton::_input_event(InputEvent p_event) {
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
}
emit_signal("pressed");
+ _unpress_group();
+
toggled(status.pressed);
emit_signal("toggled",status.pressed);
@@ -90,10 +107,11 @@ void BaseButton::_input_event(InputEvent p_event) {
emit_signal("button_up");
- if (status.press_attempt && status.pressing_inside) {
-// released();
+/* this is pointless if (status.press_attempt && status.pressing_inside) {
+ //released();
emit_signal("released");
}
+*/
status.press_attempt=false;
}
update();
@@ -138,6 +156,9 @@ void BaseButton::_input_event(InputEvent p_event) {
}
+ _unpress_group();
+
+
}
status.press_attempt=false;
@@ -156,7 +177,7 @@ void BaseButton::_input_event(InputEvent p_event) {
}
} break;
case InputEvent::ACTION:
- case InputEvent::JOYSTICK_BUTTON:
+ case InputEvent::JOYPAD_BUTTON:
case InputEvent::KEY: {
@@ -211,6 +232,9 @@ void BaseButton::_input_event(InputEvent p_event) {
}
emit_signal("toggled",status.pressed);
}
+
+ _unpress_group();
+
}
accept_event();
@@ -243,39 +267,37 @@ void BaseButton::_notification(int p_what) {
update();
}
}
+
+ if (p_what==NOTIFICATION_FOCUS_ENTER) {
+
+ status.hovering=true;
+ update();
+ }
if (p_what==NOTIFICATION_FOCUS_EXIT) {
if (status.pressing_button && status.press_attempt) {
status.press_attempt=false;
status.pressing_button=0;
+ status.hovering=false;
+ update();
+ } else if (status.hovering) {
+ status.hovering=false;
update();
}
}
if (p_what==NOTIFICATION_ENTER_TREE) {
- CanvasItem *ci=this;
- while(ci) {
-
- ButtonGroup *bg = ci->cast_to<ButtonGroup>();
- if (bg) {
-
- group=bg;
- group->_add_button(this);
- }
- ci=ci->get_parent_item();
- }
}
if (p_what==NOTIFICATION_EXIT_TREE) {
- if (group)
- group->_remove_button(this);
+
}
- if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible()) {
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED && !is_visible_in_tree()) {
if (!toggle_mode) {
status.pressed = false;
@@ -295,8 +317,9 @@ void BaseButton::pressed() {
void BaseButton::toggled(bool p_pressed) {
- if (get_script_instance())
+ if (get_script_instance()) {
get_script_instance()->call("toggled",p_pressed);
+ }
}
@@ -325,6 +348,11 @@ void BaseButton::set_pressed(bool p_pressed) {
return;
_change_notify("pressed");
status.pressed=p_pressed;
+
+ if (p_pressed) {
+ _unpress_group();
+
+ }
update();
}
@@ -387,14 +415,14 @@ bool BaseButton::is_toggle_mode() const {
return toggle_mode;
}
-void BaseButton::set_click_on_press(bool p_click_on_press) {
+void BaseButton::set_action_mode(ActionMode p_mode) {
- status.click_on_press=p_click_on_press;
+ action_mode=p_mode;
}
-bool BaseButton::get_click_on_press() const {
+BaseButton::ActionMode BaseButton::get_action_mode() const {
- return status.click_on_press;
+ return action_mode;
}
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {
@@ -425,7 +453,7 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
void BaseButton::_unhandled_input(InputEvent p_event) {
- if (!is_disabled() && is_visible() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
+ if (!is_disabled() && is_visible_in_tree() && p_event.is_pressed() && !p_event.is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
return; //ignore because of modal window
@@ -452,39 +480,66 @@ String BaseButton::get_tooltip(const Point2& p_pos) const {
return tooltip;
}
+
+void BaseButton::set_button_group(const Ref<ButtonGroup>& p_group) {
+
+ if (button_group.is_valid()) {
+ button_group->buttons.erase(this);
+ }
+
+ button_group=p_group;
+
+ if (button_group.is_valid()) {
+ button_group->buttons.insert(this);
+ }
+
+ update(); //checkbox changes to radio if set a buttongroup
+
+}
+
+Ref<ButtonGroup> BaseButton::get_button_group() const {
+
+ return button_group;
+}
+
+
void BaseButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&BaseButton::_input_event);
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
- ObjectTypeDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
- ObjectTypeDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
- ObjectTypeDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
- ObjectTypeDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
- ObjectTypeDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
- ObjectTypeDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
- ObjectTypeDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
- ObjectTypeDB::bind_method(_MD("set_click_on_press","enable"),&BaseButton::set_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
- ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
- ObjectTypeDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
- ObjectTypeDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
+ ClassDB::bind_method(_MD("_gui_input"),&BaseButton::_gui_input);
+ ClassDB::bind_method(_MD("_unhandled_input"),&BaseButton::_unhandled_input);
+ ClassDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
+ ClassDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
+ ClassDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
+ ClassDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
+ ClassDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
+ ClassDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
+ ClassDB::bind_method(_MD("is_disabled"),&BaseButton::is_disabled);
+ ClassDB::bind_method(_MD("set_action_mode","mode"),&BaseButton::set_action_mode);
+ ClassDB::bind_method(_MD("get_action_mode"),&BaseButton::get_action_mode);
+ ClassDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
+ ClassDB::bind_method(_MD("set_enabled_focus_mode","mode"),&BaseButton::set_enabled_focus_mode);
+ ClassDB::bind_method(_MD("get_enabled_focus_mode"),&BaseButton::get_enabled_focus_mode);
+
+ ClassDB::bind_method(_MD("set_shortcut","shortcut"),&BaseButton::set_shortcut);
+ ClassDB::bind_method(_MD("get_shortcut"),&BaseButton::get_shortcut);
+
+ ClassDB::bind_method(_MD("set_button_group","button_group"),&BaseButton::set_button_group);
+ ClassDB::bind_method(_MD("get_button_group"),&BaseButton::get_button_group);
BIND_VMETHOD(MethodInfo("_pressed"));
BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed")));
ADD_SIGNAL( MethodInfo("pressed" ) );
- ADD_SIGNAL( MethodInfo("released" ) );
ADD_SIGNAL( MethodInfo("button_up") );
ADD_SIGNAL( MethodInfo("button_down") );
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "disabled"), _SCS("set_disabled"), _SCS("is_disabled"));
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "is_pressed"), _SCS("set_pressed"), _SCS("is_pressed"));
- ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
+ ADD_PROPERTYNO( PropertyInfo( Variant::INT, "action_mode",PROPERTY_HINT_ENUM,"Button Press,Button Release"), _SCS("set_action_mode"), _SCS("get_action_mode"));
ADD_PROPERTY( PropertyInfo( Variant::INT,"enabled_focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_enabled_focus_mode"), _SCS("get_enabled_focus_mode") );
ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "shortcut",PROPERTY_HINT_RESOURCE_TYPE,"ShortCut"), _SCS("set_shortcut"), _SCS("get_shortcut"));
+ ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "group",PROPERTY_HINT_RESOURCE_TYPE,"ButtonGroup"), _SCS("set_button_group"), _SCS("get_button_group"));
BIND_CONSTANT( DRAW_NORMAL );
@@ -492,6 +547,10 @@ void BaseButton::_bind_methods() {
BIND_CONSTANT( DRAW_HOVER );
BIND_CONSTANT( DRAW_DISABLED );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_PRESS );
+ BIND_CONSTANT( ACTION_MODE_BUTTON_RELEASE );
+
+
}
BaseButton::BaseButton() {
@@ -502,11 +561,15 @@ BaseButton::BaseButton() {
status.hovering=false;
status.pressing_inside=false;
status.disabled = false;
- status.click_on_press=false;
status.pressing_button=0;
set_focus_mode( FOCUS_ALL );
enabled_focus_mode = FOCUS_ALL;
- group=NULL;
+ action_mode=ACTION_MODE_BUTTON_RELEASE;
+
+
+ if (button_group.is_valid()) {
+ button_group->buttons.erase(this);
+ }
}
@@ -515,4 +578,30 @@ BaseButton::~BaseButton()
{
}
+void ButtonGroup::get_buttons(List<BaseButton*> *r_buttons) {
+
+ for (Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ r_buttons->push_back(E->get());
+ }
+}
+
+BaseButton* ButtonGroup::get_pressed_button() {
+
+ for (Set<BaseButton*>::Element *E=buttons.front();E;E=E->next()) {
+ if (E->get()->is_pressed())
+ return E->get();
+ }
+
+ return NULL;
+}
+
+void ButtonGroup::_bind_methods() {
+
+ ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+}
+
+ButtonGroup::ButtonGroup() {
+
+ set_local_to_scene(true);
+}
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 0056b00f33..def4ff7536 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,12 +39,21 @@ class ButtonGroup;
class BaseButton : public Control {
- OBJ_TYPE( BaseButton, Control );
+ GDCLASS( BaseButton, Control );
+public:
+
+ enum ActionMode {
+ ACTION_MODE_BUTTON_PRESS,
+ ACTION_MODE_BUTTON_RELEASE,
+ };
+
+private:
bool toggle_mode;
FocusMode enabled_focus_mode;
Ref<ShortCut> shortcut;
+ ActionMode action_mode;
struct Status {
bool pressed;
@@ -53,15 +62,16 @@ class BaseButton : public Control {
bool pressing_inside;
bool disabled;
- bool click_on_press;
int pressing_button;
} status;
- ButtonGroup *group;
+ Ref<ButtonGroup> button_group;
+ void _unpress_group();
+
protected:
@@ -70,7 +80,7 @@ protected:
virtual void pressed();
virtual void toggled(bool p_pressed);
static void _bind_methods();
- virtual void _input_event(InputEvent p_event);
+ virtual void _gui_input(InputEvent p_event);
virtual void _unhandled_input(InputEvent p_event);
void _notification(int p_what);
@@ -98,8 +108,8 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- void set_click_on_press(bool p_click_on_press);
- bool get_click_on_press() const;
+ void set_action_mode(ActionMode p_mode);
+ ActionMode get_action_mode() const;
void set_enabled_focus_mode(FocusMode p_mode);
FocusMode get_enabled_focus_mode() const;
@@ -109,11 +119,31 @@ public:
virtual String get_tooltip(const Point2& p_pos) const;
+ void set_button_group(const Ref<ButtonGroup>& p_group);
+ Ref<ButtonGroup> get_button_group() const;
+
BaseButton();
~BaseButton();
};
-VARIANT_ENUM_CAST( BaseButton::DrawMode );
+VARIANT_ENUM_CAST( BaseButton::DrawMode )
+VARIANT_ENUM_CAST( BaseButton::ActionMode )
+
+
+
+class ButtonGroup : public Resource {
+
+ GDCLASS(ButtonGroup,Resource)
+friend class BaseButton;
+ Set<BaseButton*> buttons;
+protected:
+ static void _bind_methods();
+public:
+
+ BaseButton* get_pressed_button();
+ void get_buttons(List<BaseButton*> *r_buttons);
+ ButtonGroup();
+};
#endif
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp
index a6ffc30a83..7ca44ac27b 100644
--- a/scene/gui/box_container.cpp
+++ b/scene/gui/box_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -55,7 +55,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -108,7 +108,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -164,7 +164,7 @@ void BoxContainer::_resort() {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -227,7 +227,7 @@ Size2 BoxContainer::get_minimum_size() const {
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden()) {
+ if (!c->is_visible()) {
continue;
}
@@ -280,7 +280,8 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
void BoxContainer::add_spacer(bool p_begin) {
Control *c = memnew( Control );
- c->set_stop_mouse(false);
+ c->set_mouse_filter(MOUSE_FILTER_PASS); //allow spacer to pass mouse events
+
if (vertical)
c->set_v_size_flags(SIZE_EXPAND_FILL);
else
@@ -295,15 +296,15 @@ BoxContainer::BoxContainer(bool p_vertical) {
vertical=p_vertical;
align = ALIGN_BEGIN;
-// set_ignore_mouse(true);
- set_stop_mouse(false);
+ //set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_PASS);
}
void BoxContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
- ObjectTypeDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
- ObjectTypeDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
+ ClassDB::bind_method(_MD("add_spacer","begin"),&BoxContainer::add_spacer);
+ ClassDB::bind_method(_MD("get_alignment"),&BoxContainer::get_alignment);
+ ClassDB::bind_method(_MD("set_alignment","alignment"),&BoxContainer::set_alignment);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h
index 6e63e8bdac..c428ec132c 100644
--- a/scene/gui/box_container.h
+++ b/scene/gui/box_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class BoxContainer : public Container {
- OBJ_TYPE(BoxContainer,Container);
+ GDCLASS(BoxContainer,Container);
public:
@@ -68,7 +68,7 @@ public:
class HBoxContainer : public BoxContainer {
- OBJ_TYPE(HBoxContainer,BoxContainer);
+ GDCLASS(HBoxContainer,BoxContainer);
public:
@@ -79,7 +79,7 @@ public:
class MarginContainer;
class VBoxContainer : public BoxContainer {
- OBJ_TYPE(VBoxContainer,BoxContainer);
+ GDCLASS(VBoxContainer,BoxContainer);
public:
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 579f6e08c9..f28595b622 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
Size2 Button::get_minimum_size() const {
- Size2 minsize=get_font("font")->get_string_size( text );
+ Size2 minsize=get_font("font")->get_string_size( xl_text );
if (clip_text)
minsize.width=0;
@@ -48,7 +48,7 @@ Size2 Button::get_minimum_size() const {
minsize.height=MAX( minsize.height, _icon->get_height() );
minsize.width+=_icon->get_width();
- if (text!="")
+ if (xl_text!="")
minsize.width+=get_constant("hseparation");
}
@@ -59,6 +59,13 @@ Size2 Button::get_minimum_size() const {
void Button::_notification(int p_what) {
+ if (p_what==NOTIFICATION_TRANSLATION_CHANGED) {
+
+ xl_text=XL_MESSAGE(text);
+ minimum_size_changed();
+ update();
+ }
+
if (p_what==NOTIFICATION_DRAW) {
RID ci = get_canvas_item();
@@ -114,7 +121,7 @@ void Button::_notification(int p_what) {
Point2 icon_ofs = (!_icon.is_null())?Point2( _icon->get_width() + get_constant("hseparation"), 0):Point2();
int text_clip=size.width - style->get_minimum_size().width - icon_ofs.width;
- Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size( text ) )/2.0;
+ Point2 text_ofs = (size - style->get_minimum_size() - icon_ofs - font->get_string_size( xl_text ) )/2.0;
switch(align) {
case ALIGN_LEFT: {
@@ -128,14 +135,14 @@ void Button::_notification(int p_what) {
text_ofs+=style->get_offset();
} break;
case ALIGN_RIGHT: {
- text_ofs.x=size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size( text ).x;
+ text_ofs.x=size.x - style->get_margin(MARGIN_RIGHT) - font->get_string_size( xl_text ).x;
text_ofs.y+=style->get_offset().y;
} break;
}
text_ofs.y+=font->get_ascent();
- font->draw( ci, text_ofs.floor(), text, color,clip_text?text_clip:-1);
+ font->draw( ci, text_ofs.floor(), xl_text, color,clip_text?text_clip:-1);
if (!_icon.is_null()) {
int valign = size.height-style->get_minimum_size().y;
@@ -152,7 +159,8 @@ void Button::set_text(const String& p_text) {
if (text==p_text)
return;
- text=XL_MESSAGE(p_text);
+ text=p_text;
+ xl_text=XL_MESSAGE(p_text);
update();
_change_notify("text");
minimum_size_changed();
@@ -215,16 +223,16 @@ Button::TextAlign Button::get_text_align() const {
void Button::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Button::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Button::get_text);
- ObjectTypeDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
- ObjectTypeDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
- ObjectTypeDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
- ObjectTypeDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
- ObjectTypeDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
- ObjectTypeDB::bind_method(_MD("is_flat"),&Button::is_flat);
+ ClassDB::bind_method(_MD("set_text","text"),&Button::set_text);
+ ClassDB::bind_method(_MD("get_text"),&Button::get_text);
+ ClassDB::bind_method(_MD("set_button_icon","texture:Texture"),&Button::set_icon);
+ ClassDB::bind_method(_MD("get_button_icon:Texture"),&Button::get_icon);
+ ClassDB::bind_method(_MD("set_flat","enabled"),&Button::set_flat);
+ ClassDB::bind_method(_MD("set_clip_text","enabled"),&Button::set_clip_text);
+ ClassDB::bind_method(_MD("get_clip_text"),&Button::get_clip_text);
+ ClassDB::bind_method(_MD("set_text_align","align"),&Button::set_text_align);
+ ClassDB::bind_method(_MD("get_text_align"),&Button::get_text_align);
+ ClassDB::bind_method(_MD("is_flat"),&Button::is_flat);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
@@ -242,7 +250,7 @@ Button::Button(const String &p_text) {
flat=false;
clip_text=false;
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text);
align=ALIGN_CENTER;
}
diff --git a/scene/gui/button.h b/scene/gui/button.h
index c39237c9af..2fd3a0cace 100644
--- a/scene/gui/button.h
+++ b/scene/gui/button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,9 +33,12 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
+
+
class Button : public BaseButton {
- OBJ_TYPE( Button, BaseButton );
+ GDCLASS( Button, BaseButton );
public:
@@ -49,6 +52,7 @@ private:
bool flat;
String text;
+ String xl_text;
Ref<Texture> icon;
bool clip_text;
TextAlign align;
diff --git a/scene/gui/button_array.cpp b/scene/gui/button_array.cpp
index be48296110..3d7c0e2825 100644
--- a/scene/gui/button_array.cpp
+++ b/scene/gui/button_array.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -60,6 +60,8 @@ bool ButtonArray::_set(const StringName& p_name, const Variant& p_value) {
String f = n.get_slicec('/',2);
if (f=="text")
buttons[idx].text=p_value;
+ else if (f=="tooltip")
+ buttons[idx].tooltip=p_value;
else if (f=="icon")
buttons[idx].icon=p_value;
else
@@ -95,6 +97,8 @@ bool ButtonArray::_get(const StringName& p_name,Variant &r_ret) const {
String f = n.get_slicec('/',2);
if (f=="text")
r_ret=buttons[idx].text;
+ else if (f=="tooltip")
+ r_ret=buttons[idx].tooltip;
else if (f=="icon")
r_ret=buttons[idx].icon;
else
@@ -115,6 +119,7 @@ void ButtonArray::_get_property_list( List<PropertyInfo> *p_list) const {
for(int i=0;i<buttons.size();i++) {
String base="button/"+itos(i)+"/";
p_list->push_back( PropertyInfo( Variant::STRING, base+"text"));
+ p_list->push_back( PropertyInfo( Variant::STRING, base+"tooltip"));
p_list->push_back( PropertyInfo( Variant::OBJECT, base+"icon",PROPERTY_HINT_RESOURCE_TYPE,"Texture"));
}
if (buttons.size()>0) {
@@ -168,8 +173,12 @@ Size2 ButtonArray::get_minimum_size() const {
void ButtonArray::_notification(int p_what) {
switch(p_what) {
+ case NOTIFICATION_MOUSE_EXIT:{
+ hover=-1;
+ update();
+ }break;
case NOTIFICATION_READY:{
- MethodInfo mi;
+ MethodInfo mi;
mi.name="mouse_sub_enter";
add_user_signal(mi);
@@ -245,8 +254,12 @@ void ButtonArray::_notification(int p_what) {
Ref<Font> f;
Color c;
+ Point2 sbsize;
+ Point2 sbofs;
if (i==selected) {
draw_style_box(style_selected,r);
+ sbsize=style_selected->get_minimum_size();
+ sbofs=style_selected->get_offset();
f=font_selected;
c=color_selected;
if (has_focus())
@@ -254,8 +267,10 @@ void ButtonArray::_notification(int p_what) {
} else {
if (hover==i)
draw_style_box(style_hover,r);
- else
+ else if (!flat)
draw_style_box(style_normal,r);
+ sbsize=style_normal->get_minimum_size();
+ sbofs=style_normal->get_offset();
f=font_normal;
c=color_normal;
}
@@ -265,7 +280,7 @@ void ButtonArray::_notification(int p_what) {
ssize.x+=buttons[i].icon->get_width();
}
- Point2 text_ofs=((r.size-ssize)/2.0+Point2(0,f->get_ascent())).floor();
+ Point2 text_ofs=((r.size-ssize-sbsize)/2.0+Point2(0,f->get_ascent())).floor()+sbofs;
if (buttons[i].icon.is_valid()) {
draw_texture(buttons[i].icon,r.pos+Point2(text_ofs.x,Math::floor((r.size.height-buttons[i].icon->get_height())/2.0)));
@@ -285,7 +300,7 @@ void ButtonArray::_notification(int p_what) {
}
-void ButtonArray::_input_event(const InputEvent& p_event) {
+void ButtonArray::_gui_input(const InputEvent& p_event) {
if (
( (orientation==HORIZONTAL && p_event.is_action("ui_left") ) ||
@@ -349,6 +364,18 @@ void ButtonArray::_input_event(const InputEvent& p_event) {
}
+String ButtonArray::get_tooltip(const Point2& p_pos) const {
+
+ int ofs = orientation==HORIZONTAL ? p_pos.x: p_pos.y;
+ for(int i=0;i<buttons.size();i++) {
+
+ if (ofs>=buttons[i]._pos_cache && ofs<buttons[i]._pos_cache+buttons[i]._size_cache)
+ return buttons[i].tooltip;
+
+ }
+ return Control::get_tooltip(p_pos);
+}
+
void ButtonArray::set_align(Align p_align) {
align=p_align;
@@ -361,11 +388,23 @@ ButtonArray::Align ButtonArray::get_align() const {
return align;
}
+void ButtonArray::set_flat(bool p_flat) {
+
+ flat=p_flat;
+ update();
+}
+
+bool ButtonArray::is_flat() const {
+
+ return flat;
+}
+
-void ButtonArray::add_button(const String& p_text) {
+void ButtonArray::add_button(const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
+ button.tooltip=p_tooltip;
buttons.push_back(button);
update();
@@ -375,11 +414,12 @@ void ButtonArray::add_button(const String& p_text) {
minimum_size_changed();
}
-void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text) {
+void ButtonArray::add_icon_button(const Ref<Texture>& p_icon,const String& p_text,const String& p_tooltip) {
Button button;
button.text=p_text;
button.icon=p_icon;
+ button.tooltip=p_tooltip;
buttons.push_back(button);
if (selected==-1)
selected=0;
@@ -397,6 +437,13 @@ void ButtonArray::set_button_text(int p_button, const String& p_text) {
}
+void ButtonArray::set_button_tooltip(int p_button, const String& p_text) {
+
+ ERR_FAIL_INDEX(p_button,buttons.size());
+ buttons[p_button].tooltip=p_text;
+
+}
+
void ButtonArray::set_button_icon(int p_button, const Ref<Texture>& p_icon) {
ERR_FAIL_INDEX(p_button,buttons.size());
@@ -411,6 +458,12 @@ String ButtonArray::get_button_text(int p_button) const {
return buttons[p_button].text;
}
+String ButtonArray::get_button_tooltip(int p_button) const {
+
+ ERR_FAIL_INDEX_V(p_button,buttons.size(),"");
+ return buttons[p_button].tooltip;
+}
+
Ref<Texture> ButtonArray::get_button_icon(int p_button) const {
ERR_FAIL_INDEX_V(p_button,buttons.size(),Ref<Texture>());
@@ -465,27 +518,33 @@ int ButtonArray::get_button_count() const {
void ButtonArray::get_translatable_strings(List<String> *p_strings) const {
- for(int i=0;i<buttons.size();i++)
+ for(int i=0;i<buttons.size();i++) {
p_strings->push_back(buttons[i].text);
+ p_strings->push_back(buttons[i].tooltip);
+ }
}
void ButtonArray::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("add_button","text"),&ButtonArray::add_button);
- ObjectTypeDB::bind_method(_MD("add_icon_button","icon:Texture","text"),&ButtonArray::add_icon_button,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
- ObjectTypeDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
- ObjectTypeDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
- ObjectTypeDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
- ObjectTypeDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
- ObjectTypeDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
- ObjectTypeDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
- ObjectTypeDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
- ObjectTypeDB::bind_method(_MD("clear"),&ButtonArray::clear);
-
- ObjectTypeDB::bind_method(_MD("_input_event"),&ButtonArray::_input_event);
+ ClassDB::bind_method(_MD("add_button","text","tooltip"),&ButtonArray::add_button,DEFVAL(""));
+ ClassDB::bind_method(_MD("add_icon_button","icon:Texture","text","tooltip"),&ButtonArray::add_icon_button,DEFVAL(""),DEFVAL(""));
+ ClassDB::bind_method(_MD("set_button_text","button_idx","text"),&ButtonArray::set_button_text);
+ ClassDB::bind_method(_MD("set_button_tooltip","button_idx","text"),&ButtonArray::set_button_tooltip);
+ ClassDB::bind_method(_MD("set_button_icon","button_idx","icon:Texture"),&ButtonArray::set_button_icon);
+ ClassDB::bind_method(_MD("get_button_text","button_idx"),&ButtonArray::get_button_text);
+ ClassDB::bind_method(_MD("get_button_tooltip","button_idx"),&ButtonArray::get_button_tooltip);
+ ClassDB::bind_method(_MD("get_button_icon:Texture","button_idx"),&ButtonArray::get_button_icon);
+ ClassDB::bind_method(_MD("get_button_count"),&ButtonArray::get_button_count);
+ ClassDB::bind_method(_MD("set_flat","enabled"),&ButtonArray::set_flat);
+ ClassDB::bind_method(_MD("is_flat"),&ButtonArray::is_flat);
+ ClassDB::bind_method(_MD("get_selected"),&ButtonArray::get_selected);
+ ClassDB::bind_method(_MD("get_hovered"),&ButtonArray::get_hovered);
+ ClassDB::bind_method(_MD("set_selected","button_idx"),&ButtonArray::set_selected);
+ ClassDB::bind_method(_MD("erase_button","button_idx"),&ButtonArray::erase_button);
+ ClassDB::bind_method(_MD("clear"),&ButtonArray::clear);
+
+ ClassDB::bind_method(_MD("_gui_input"),&ButtonArray::_gui_input);
BIND_CONSTANT( ALIGN_BEGIN );
BIND_CONSTANT( ALIGN_CENTER );
@@ -493,6 +552,8 @@ void ButtonArray::_bind_methods() {
BIND_CONSTANT( ALIGN_FILL );
BIND_CONSTANT( ALIGN_EXPAND_FILL );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "flat" ), _SCS("set_flat"),_SCS("is_flat") );
+
ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::INT,"button_idx")));
}
@@ -503,5 +564,6 @@ ButtonArray::ButtonArray(Orientation p_orientation) {
selected=-1;
set_focus_mode(FOCUS_ALL);
hover=-1;
+ flat=false;
min_button_size = -1;
}
diff --git a/scene/gui/button_array.h b/scene/gui/button_array.h
index c4b9b0c9e3..37533695c9 100644
--- a/scene/gui/button_array.h
+++ b/scene/gui/button_array.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ButtonArray : public Control {
- OBJ_TYPE(ButtonArray, Control);
+ GDCLASS(ButtonArray, Control);
public:
enum Align {
ALIGN_BEGIN,
@@ -50,6 +50,7 @@ private:
struct Button {
String text;
+ String tooltip;
Ref<Texture> icon;
mutable int _ms_cache;
mutable int _pos_cache;
@@ -58,6 +59,7 @@ private:
int selected;
int hover;
+ bool flat;
double min_button_size;
Vector<Button> buttons;
@@ -72,20 +74,25 @@ protected:
public:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void set_align(Align p_align);
Align get_align() const;
- void add_button(const String& p_button);
- void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="");
+ void set_flat(bool p_flat);
+ bool is_flat() const;
+
+ void add_button(const String& p_button,const String& p_tooltip="");
+ void add_icon_button(const Ref<Texture>& p_icon,const String& p_button="",const String& p_tooltip="");
void set_button_text(int p_button, const String& p_text);
+ void set_button_tooltip(int p_button, const String& p_text);
void set_button_icon(int p_button, const Ref<Texture>& p_icon);
String get_button_text(int p_button) const;
+ String get_button_tooltip(int p_button) const;
Ref<Texture> get_button_icon(int p_button) const;
int get_selected() const;
@@ -100,20 +107,21 @@ public:
virtual Size2 get_minimum_size() const;
virtual void get_translatable_strings(List<String> *p_strings) const;
+ virtual String get_tooltip(const Point2& p_pos) const;
ButtonArray(Orientation p_orientation=HORIZONTAL);
};
class HButtonArray : public ButtonArray {
- OBJ_TYPE(HButtonArray,ButtonArray);
+ GDCLASS(HButtonArray,ButtonArray);
public:
HButtonArray() : ButtonArray(HORIZONTAL) {};
};
class VButtonArray : public ButtonArray {
- OBJ_TYPE(VButtonArray,ButtonArray);
+ GDCLASS(VButtonArray,ButtonArray);
public:
VButtonArray() : ButtonArray(VERTICAL) {};
diff --git a/scene/gui/button_group.cpp b/scene/gui/button_group.cpp
index 04ba5fc06d..01a3f633c3 100644
--- a/scene/gui/button_group.cpp
+++ b/scene/gui/button_group.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -27,6 +27,8 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "button_group.h"
+
+#if 0
#include "base_button.h"
void ButtonGroup::_add_button(BaseButton *p_button) {
@@ -60,6 +62,9 @@ void ButtonGroup::_pressed(Object *p_button) {
BaseButton *bb=E->get();
bb->set_pressed( b==bb );
+ if (b==bb){
+ emit_signal("button_selected", b);
+ }
}
}
@@ -146,15 +151,17 @@ int ButtonGroup::get_pressed_button_index() const {
void ButtonGroup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
- ObjectTypeDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
- ObjectTypeDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
- ObjectTypeDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
- ObjectTypeDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(_MD("get_pressed_button:BaseButton"),&ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(_MD("get_pressed_button_index"),&ButtonGroup::get_pressed_button_index);
+ ClassDB::bind_method(_MD("get_focused_button:BaseButton"),&ButtonGroup::get_focused_button);
+ ClassDB::bind_method(_MD("get_button_list"),&ButtonGroup::_get_button_list);
+ ClassDB::bind_method(_MD("_pressed"),&ButtonGroup::_pressed);
+ ClassDB::bind_method(_MD("set_pressed_button","button:BaseButton"),&ButtonGroup::_pressed);
+ ADD_SIGNAL( MethodInfo("button_selected",PropertyInfo(Variant::OBJECT,"button",PROPERTY_HINT_RESOURCE_TYPE,"BaseButton")));
}
ButtonGroup::ButtonGroup() : BoxContainer(true)
{
}
+#endif
diff --git a/scene/gui/button_group.h b/scene/gui/button_group.h
index 4afba22228..38acd06984 100644
--- a/scene/gui/button_group.h
+++ b/scene/gui/button_group.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,12 +31,12 @@
#include "scene/gui/box_container.h"
-
+#if 0
class BaseButton;
class ButtonGroup : public BoxContainer {
- OBJ_TYPE(ButtonGroup,BoxContainer);
+ GDCLASS(ButtonGroup,BoxContainer);
Set<BaseButton*> buttons;
@@ -63,4 +63,5 @@ public:
ButtonGroup();
};
+#endif
#endif // BUTTON_GROUP_H
diff --git a/scene/gui/center_container.cpp b/scene/gui/center_container.cpp
index 844175e4c1..4d4abb6484 100644
--- a/scene/gui/center_container.cpp
+++ b/scene/gui/center_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@ Size2 CenterContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
ms.width = MAX(ms.width , minsize.width);
@@ -92,8 +92,8 @@ void CenterContainer::_notification(int p_what) {
void CenterContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
- ObjectTypeDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
+ ClassDB::bind_method(_MD("set_use_top_left","enable"),&CenterContainer::set_use_top_left);
+ ClassDB::bind_method(_MD("is_using_top_left"),&CenterContainer::is_using_top_left);
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"use_top_left"),_SCS("set_use_top_left"),_SCS("is_using_top_left"));
}
diff --git a/scene/gui/center_container.h b/scene/gui/center_container.h
index dc95533525..7acc14de19 100644
--- a/scene/gui/center_container.h
+++ b/scene/gui/center_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class CenterContainer : public Container {
- OBJ_TYPE( CenterContainer, Container );
+ GDCLASS( CenterContainer, Container );
bool use_top_left;
protected:
diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp
index 1381d6eb60..c9803bc654 100644
--- a/scene/gui/check_box.cpp
+++ b/scene/gui/check_box.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -56,14 +56,8 @@ void CheckBox::_notification(int p_what) {
bool CheckBox::is_radio()
{
- Node* parent = this;
- do {
- parent = parent->get_parent();
- if (parent->cast_to<ButtonGroup>())
- break;
- } while (parent);
- return (parent != 0);
+ return get_button_group().is_valid();
}
CheckBox::CheckBox(const String &p_text):
diff --git a/scene/gui/check_box.h b/scene/gui/check_box.h
index 95dd4891d4..6a4893936f 100644
--- a/scene/gui/check_box.h
+++ b/scene/gui/check_box.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class CheckBox : public Button {
- OBJ_TYPE( CheckBox, Button );
+ GDCLASS( CheckBox, Button );
protected:
diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp
index f8c0c6b208..6404f066e8 100644
--- a/scene/gui/check_button.cpp
+++ b/scene/gui/check_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h
index a1ed4c1896..1c5440a25d 100644
--- a/scene/gui/check_button.h
+++ b/scene/gui/check_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class CheckButton : public Button {
- OBJ_TYPE( CheckButton, Button );
+ GDCLASS( CheckButton, Button );
protected:
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 5e66544153..da2fb1bc91 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,41 +34,20 @@
#include "os/input.h"
#include "os/keyboard.h"
-void update_material(Ref<CanvasItemMaterial>mat,const Color& p_color,float h,float s,float v) {
- if (!mat.is_valid())
- return;
- Ref<Shader> sdr = mat->get_shader();
- if (!sdr.is_valid())
- return;
-
- mat->set_shader_param("R",p_color.r);
- mat->set_shader_param("G",p_color.g);
- mat->set_shader_param("B",p_color.b);
- mat->set_shader_param("H",h);
- mat->set_shader_param("S",s);
- mat->set_shader_param("V",v);
- mat->set_shader_param("A",p_color.a);
-}
void ColorPicker::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_THEME_CHANGED: {
- uv_material->set_shader(get_shader("uv_editor"));
- w_material->set_shader(get_shader("w_editor"));
- update_material(uv_material,color,h,s,v);
- update_material(w_material,color,h,s,v);
+ //sample->set_texture(get_icon("color_sample"));
+
_update_controls();
} break;
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
- uv_edit->get_child(0)->cast_to<Control>()->update();
- w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
}
@@ -96,7 +75,7 @@ void ColorPicker::_update_controls() {
}
-void ColorPicker::set_color(const Color& p_color) {
+void ColorPicker::set_pick_color(const Color& p_color) {
color=p_color;
if (color != last_hsv) {
@@ -109,9 +88,7 @@ void ColorPicker::set_color(const Color& p_color) {
if (!is_inside_tree())
return;
- update_material(uv_material, color,h,s,v);
- update_material(w_material, color,h,s,v);
-
+ return; //it crashes, so returning
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
@@ -141,10 +118,10 @@ void ColorPicker::_value_changed(double) {
return;
for(int i=0;i<4;i++) {
- color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0);
+ color.components[i] = scroll[i]->get_value()/(raw_mode_enabled?1.0:255.0);
}
- set_color(color);
+ set_pick_color(color);
_update_text_value();
@@ -162,7 +139,7 @@ void ColorPicker::_html_entered(const String& p_html) {
if (!is_inside_tree())
return;
- _update_color();
+ set_pick_color(color);
emit_signal("color_changed",color);
}
@@ -176,9 +153,9 @@ void ColorPicker::_update_color() {
if (raw_mode_enabled) {
if (i == 3)
scroll[i]->set_max(1);
- scroll[i]->set_val(color.components[i]);
+ scroll[i]->set_value(color.components[i]);
} else {
- scroll[i]->set_val(color.components[i] * 255);
+ scroll[i]->set_value(color.components[i] * 255);
}
}
@@ -192,10 +169,24 @@ void ColorPicker::_update_presets()
{
Size2 size=bt_add_preset->get_size();
preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height));
- Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB);
- for (int y=0;y<size.y;y++)
- for (int x=0;x<size.x*presets.size();x++)
- i.put_pixel(x,y,presets[(int)x/size.x]);
+
+ PoolVector<uint8_t> img;
+ img.resize(size.x*presets.size()*size.y*3);
+
+ {
+ PoolVector<uint8_t>::Write w=img.write();
+ for (int y=0;y<size.y;y++) {
+ for (int x=0;x<size.x*presets.size();x++) {
+ int ofs = (y*(size.x*presets.size())+x)*3;
+ w[ofs+0]=uint8_t(CLAMP(presets[(int)x/size.x].r*255.0,0,255));
+ w[ofs+1]=uint8_t(CLAMP(presets[(int)x/size.x].g*255.0,0,255));
+ w[ofs+2]=uint8_t(CLAMP(presets[(int)x/size.x].b*255.0,0,255));
+ }
+ }
+ }
+
+ Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB8,img);
+
Ref<ImageTexture> t;
t.instance();
t->create_from_image(i);
@@ -217,7 +208,7 @@ void ColorPicker::_text_type_toggled()
_update_color();
}
-Color ColorPicker::get_color() const {
+Color ColorPicker::get_pick_color() const {
return color;
}
@@ -278,14 +269,39 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
if (!c)
return;
if (p_wich==0) {
+ Vector<Point2> points;
+ points.push_back(Vector2());
+ points.push_back(Vector2(c->get_size().x,0));
+ points.push_back(c->get_size());
+ points.push_back(Vector2(0,c->get_size().y));
+ Vector<Color> colors;
+ colors.push_back(Color(1,1,1));
+ colors.push_back(Color(1,1,1));
+ colors.push_back(Color());
+ colors.push_back(Color());
+ c->draw_polygon(points,colors);
+ Vector<Color> colors2;
+ Color col = color;
+ col.set_hsv(color.get_h(),1,1);
+ col.a = 0;
+ colors2.push_back(col);
+ col.a = 1;
+ colors2.push_back(col);
+ col.set_hsv(color.get_h(),1,0);
+ colors2.push_back(col);
+ col.a = 0;
+ colors2.push_back(col);
+ c->draw_polygon(points,colors);
int x = CLAMP(c->get_size().x * s, 0, c->get_size().x);
int y = CLAMP(c->get_size().y-c->get_size().y * v, 0, c->get_size().y);
- Color col = color;
+ col = color;
col.a=1;
c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted());
c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted());
c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2);
} else if (p_wich==1) {
+ Ref<Texture> hue = get_icon("color_hue","ColorPicker");
+ c->draw_texture_rect(hue,Rect2(Point2(),c->get_size()));
int y=c->get_size().y-c->get_size().y*h;
Color col=Color();
col.set_hsv(h,1,1);
@@ -296,7 +312,7 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c)
void ColorPicker::_uv_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed) {
+ if (bev.pressed && bev.button_index==BUTTON_LEFT) {
changing_color = true;
float x = CLAMP((float)bev.x,0,256);
float y = CLAMP((float)bev.y,0,256);
@@ -304,7 +320,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else {
@@ -320,7 +336,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
v=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -329,7 +345,7 @@ void ColorPicker::_uv_input(const InputEvent &ev) {
void ColorPicker::_w_input(const InputEvent &ev) {
if (ev.type == InputEvent::MOUSE_BUTTON) {
const InputEventMouseButton &bev = ev.mouse_button;
- if (bev.pressed) {
+ if (bev.pressed && bev.button_index==BUTTON_LEFT) {
changing_color = true;
h=1-((float)bev.y)/256.0;
@@ -338,7 +354,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
}
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
} else if (ev.type == InputEvent::MOUSE_MOTION) {
@@ -349,7 +365,7 @@ void ColorPicker::_w_input(const InputEvent &ev) {
h=1.0-y/256.0;
color.set_hsv(h,s,v,color.a);
last_hsv = color;
- set_color(color);
+ set_pick_color(color);
_update_color();
emit_signal("color_changed", color);
}
@@ -360,7 +376,7 @@ void ColorPicker::_preset_input(const InputEvent &ev) {
const InputEventMouseButton &bev = ev.mouse_button;
if (bev.pressed && bev.button_index==BUTTON_LEFT) {
int index = bev.x/(preset->get_size().x/presets.size());
- set_color(presets[index]);
+ set_pick_color(presets[index]);
} else if (bev.pressed && bev.button_index==BUTTON_RIGHT) {
int index = bev.x/(preset->get_size().x/presets.size());
presets.erase(presets[index]);
@@ -394,15 +410,23 @@ void ColorPicker::_screen_input(const InputEvent &ev)
} else if (ev.type==InputEvent::MOUSE_MOTION) {
const InputEventMouse &mev = ev.mouse_motion;
Viewport *r=get_tree()->get_root();
- if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y)))
+ if (!r->get_visible_rect().has_point(Point2(mev.global_x,mev.global_y)))
return;
Image img =r->get_screen_capture();
if (!img.empty()) {
last_capture=img;
r->queue_screen_capture();
}
- if (!last_capture.empty())
- set_color(last_capture.get_pixel(mev.global_x,mev.global_y));
+ if (!last_capture.empty()) {
+ int pw = last_capture.get_format()==Image::FORMAT_RGBA8?4:3;
+ int ofs = (mev.global_y*last_capture.get_width()+mev.global_x)*pw;
+
+ PoolVector<uint8_t>::Read r = last_capture.get_data().read();
+
+ Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 );
+
+ set_pick_color(c);
+ }
}
}
@@ -418,7 +442,7 @@ void ColorPicker::_screen_pick_pressed()
r->add_child(screen);
screen->set_as_toplevel(true);
screen->set_area_as_parent_rect();
- screen->connect("input_event",this,"_screen_input");
+ screen->connect("gui_input",this,"_screen_input");
}
screen->raise();
screen->show_modal();
@@ -427,24 +451,24 @@ void ColorPicker::_screen_pick_pressed()
void ColorPicker::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPicker::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPicker::get_color);
- ObjectTypeDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
- ObjectTypeDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
- ObjectTypeDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
- ObjectTypeDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
- ObjectTypeDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
- ObjectTypeDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
- ObjectTypeDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
- ObjectTypeDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
- ObjectTypeDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
- ObjectTypeDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
- ObjectTypeDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
- ObjectTypeDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
- ObjectTypeDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
- ObjectTypeDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
+ ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPicker::set_pick_color);
+ ClassDB::bind_method(_MD("get_pick_color"),&ColorPicker::get_pick_color);
+ ClassDB::bind_method(_MD("set_raw_mode","mode"),&ColorPicker::set_raw_mode);
+ ClassDB::bind_method(_MD("is_raw_mode"),&ColorPicker::is_raw_mode);
+ ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPicker::set_edit_alpha);
+ ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPicker::is_editing_alpha);
+ ClassDB::bind_method(_MD("add_preset"), &ColorPicker::add_preset);
+ ClassDB::bind_method(_MD("_value_changed"),&ColorPicker::_value_changed);
+ ClassDB::bind_method(_MD("_html_entered"),&ColorPicker::_html_entered);
+ ClassDB::bind_method(_MD("_text_type_toggled"),&ColorPicker::_text_type_toggled);
+ ClassDB::bind_method(_MD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed);
+ ClassDB::bind_method(_MD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed);
+ ClassDB::bind_method(_MD("_sample_draw"),&ColorPicker::_sample_draw);
+ ClassDB::bind_method(_MD("_hsv_draw"),&ColorPicker::_hsv_draw);
+ ClassDB::bind_method(_MD("_uv_input"),&ColorPicker::_uv_input);
+ ClassDB::bind_method(_MD("_w_input"),&ColorPicker::_w_input);
+ ClassDB::bind_method(_MD("_preset_input"),&ColorPicker::_preset_input);
+ ClassDB::bind_method(_MD("_screen_input"),&ColorPicker::_screen_input);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
}
@@ -463,7 +487,7 @@ ColorPicker::ColorPicker() :
btn_pick = memnew( ToolButton );
btn_pick->connect("pressed",this,"_screen_pick_pressed");
- sample = memnew( TextureFrame );
+ sample = memnew( TextureRect );
sample->set_h_size_flags(SIZE_EXPAND_FILL);
sample->connect("draw",this,"_sample_draw");
@@ -473,50 +497,30 @@ ColorPicker::ColorPicker() :
HBoxContainer *hb_edit = memnew( HBoxContainer );
- uv_edit= memnew ( TextureFrame );
- Image i(256, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<256;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> t;
- t.instance();
- t->create_from_image(i);
- uv_edit->set_texture(t);
- uv_edit->set_ignore_mouse(false);
- uv_edit->set_custom_minimum_size(Size2(256,256));
- uv_edit->connect("input_event", this, "_uv_input");
- Control *c= memnew( Control );
- uv_edit->add_child(c);
- c->set_area_as_parent_rect();
- c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
+ uv_edit= memnew ( Control );
+
+
+
+
+ uv_edit->connect("gui_input", this, "_uv_input");
+ uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
+ uv_edit->set_custom_minimum_size(Size2 (256,256));
Vector<Variant> args=Vector<Variant>();
args.push_back(0);
- args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ args.push_back(uv_edit);
+ uv_edit->connect("draw",this,"_hsv_draw",args);
add_child(hb_edit);
- w_edit= memnew( TextureFrame );
- i = Image(15, 256, false, Image::FORMAT_RGB);
- for (int y=0;y<256;y++)
- for (int x=0;x<15;x++)
- i.put_pixel(x,y,Color());
- Ref<ImageTexture> tw;
- tw.instance();
- tw->create_from_image(i);
- w_edit->set_texture(tw);
- w_edit->set_ignore_mouse(false);
- w_edit->set_custom_minimum_size(Size2(15,256));
- w_edit->connect("input_event", this, "_w_input");
- c= memnew( Control );
- w_edit->add_child(c);
- c->set_area_as_parent_rect();
- c->set_stop_mouse(false);
- c->set_material(memnew ( CanvasItemMaterial ));
+
+ w_edit= memnew( Control );
+ //w_edit->set_ignore_mouse(false);
+ w_edit->set_custom_minimum_size(Size2(30,256));
+ w_edit->connect("gui_input", this, "_w_input");
args.clear();
args.push_back(1);
- args.push_back(c);
- c->connect("draw",this,"_hsv_draw",args);
+ args.push_back(w_edit);
+ w_edit->connect("draw",this,"_hsv_draw",args);
+
hb_edit->add_child(uv_edit);
hb_edit->add_child(memnew( VSeparator ));
@@ -580,39 +584,16 @@ ColorPicker::ColorPicker() :
//_update_color();
updating=false;
- uv_material.instance();
- Ref<Shader> s_uv = get_shader("uv_editor");
- uv_material->set_shader(s_uv);
-
- w_material.instance();
-
- Ref<Shader> s_w = get_shader("w_editor");
- w_material->set_shader(s_w);
+ set_pick_color(Color(1,1,1));
- uv_edit->set_material(uv_material);
- w_edit->set_material(w_material);
-
- set_color(Color(1,1,1));
-
- i.create(256,20,false,Image::FORMAT_RGB);
- for (int y=0;y<20;y++)
- for(int x=0;x<256;x++)
- if ((x/4+y/4)%2)
- i.put_pixel(x,y,Color(1,1,1));
- else
- i.put_pixel(x,y,Color(0.6,0.6,0.6));
- Ref<ImageTexture> t_smpl;
- t_smpl.instance();
- t_smpl->create_from_image(i);
- sample->set_texture(t_smpl);
HBoxContainer *bbc = memnew( HBoxContainer );
add_child(bbc);
- preset = memnew( TextureFrame );
+ preset = memnew( TextureRect );
bbc->add_child(preset);
- preset->set_ignore_mouse(false);
- preset->connect("input_event", this, "_preset_input");
+ //preset->set_ignore_mouse(false);
+ preset->connect("gui_input", this, "_preset_input");
bt_add_preset = memnew ( Button );
bt_add_preset->set_icon(get_icon("add_preset"));
@@ -651,19 +632,20 @@ void ColorPickerButton::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
Ref<StyleBox> normal = get_stylebox("normal" );
- draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_color());
+ draw_rect(Rect2(normal->get_offset(),get_size()-normal->get_minimum_size()),picker->get_pick_color());
}
}
-void ColorPickerButton::set_color(const Color& p_color){
+void ColorPickerButton::set_pick_color(const Color& p_color){
- picker->set_color(p_color);
+ picker->set_pick_color(p_color);
update();
+ emit_signal("color_changed",p_color);
}
-Color ColorPickerButton::get_color() const{
+Color ColorPickerButton::get_pick_color() const{
- return picker->get_color();
+ return picker->get_pick_color();
}
void ColorPickerButton::set_edit_alpha(bool p_show) {
@@ -683,15 +665,15 @@ ColorPicker *ColorPickerButton::get_picker() {
void ColorPickerButton::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_color","color"),&ColorPickerButton::set_color);
- ObjectTypeDB::bind_method(_MD("get_color"),&ColorPickerButton::get_color);
- ObjectTypeDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
- ObjectTypeDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
- ObjectTypeDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
+ ClassDB::bind_method(_MD("set_pick_color","color"),&ColorPickerButton::set_pick_color);
+ ClassDB::bind_method(_MD("get_pick_color"),&ColorPickerButton::get_pick_color);
+ ClassDB::bind_method(_MD("get_picker:ColorPicker"),&ColorPickerButton::get_picker);
+ ClassDB::bind_method(_MD("set_edit_alpha","show"),&ColorPickerButton::set_edit_alpha);
+ ClassDB::bind_method(_MD("is_editing_alpha"),&ColorPickerButton::is_editing_alpha);
+ ClassDB::bind_method(_MD("_color_changed"),&ColorPickerButton::_color_changed);
ADD_SIGNAL( MethodInfo("color_changed",PropertyInfo(Variant::COLOR,"color")));
- ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_color"),_SCS("get_color") );
+ ADD_PROPERTY( PropertyInfo(Variant::COLOR,"color"),_SCS("set_pick_color"),_SCS("get_pick_color") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"edit_alpha"),_SCS("set_edit_alpha"),_SCS("is_editing_alpha") );
}
@@ -701,7 +683,7 @@ ColorPickerButton::ColorPickerButton() {
popup = memnew( PopupPanel );
picker = memnew( ColorPicker );
popup->add_child(picker);
- popup->set_child_rect(picker);
+
picker->connect("color_changed",this,"_color_changed");
add_child(popup);
}
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 5e2cc57274..d9db9c89f7 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,29 +36,26 @@
#include "scene/gui/button.h"
#include "scene/gui/popup.h"
#include "scene/gui/box_container.h"
-#include "scene/gui/texture_frame.h"
+#include "scene/gui/texture_rect.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/check_button.h"
-#include "scene/resources/material.h"
class ColorPicker : public BoxContainer {
- OBJ_TYPE(ColorPicker,BoxContainer);
+ GDCLASS(ColorPicker,BoxContainer);
private:
Control *screen;
Image last_capture;
- TextureFrame *uv_edit;
- TextureFrame *w_edit;
- TextureFrame *sample;
- TextureFrame *preset;
+ Control *uv_edit;
+ Control *w_edit;
+ TextureRect *sample;
+ TextureRect *preset;
Button *bt_add_preset;
List<Color> presets;
ToolButton *btn_pick;
CheckButton *btn_mode;
- Ref<CanvasItemMaterial> uv_material;
- Ref<CanvasItemMaterial> w_material;
HSlider *scroll[4];
SpinBox *values[4];
Label *labels[4];
@@ -101,8 +98,8 @@ public:
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void add_preset(const Color& p_color);
void set_raw_mode(bool p_enabled);
@@ -115,7 +112,7 @@ public:
class ColorPickerButton : public Button {
- OBJ_TYPE(ColorPickerButton,Button);
+ GDCLASS(ColorPickerButton,Button);
PopupPanel *popup;
ColorPicker *picker;
@@ -129,8 +126,8 @@ protected:
static void _bind_methods();
public:
- void set_color(const Color& p_color);
- Color get_color() const;
+ void set_pick_color(const Color& p_color);
+ Color get_pick_color() const;
void set_edit_alpha(bool p_show);
bool is_editing_alpha() const;
diff --git a/scene/gui/color_ramp_edit.cpp b/scene/gui/color_ramp_edit.cpp
index b7347f00dc..5d5d6c31a2 100644
--- a/scene/gui/color_ramp_edit.cpp
+++ b/scene/gui/color_ramp_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ ColorRampEdit::ColorRampEdit(){
popup = memnew( PopupPanel );
picker = memnew( ColorPicker );
popup->add_child(picker);
- popup->set_child_rect(picker);
+
add_child(popup);
checker = Ref<ImageTexture>(memnew( ImageTexture ));
@@ -60,7 +60,7 @@ void ColorRampEdit::_show_color_picker() {
if (grabbed==-1)
return;
Size2 ms = Size2(350, picker->get_combined_minimum_size().height+10);
- picker->set_color(points[grabbed].color);
+ picker->set_pick_color(points[grabbed].color);
popup->set_pos(get_global_pos()-Vector2(ms.width-get_size().width,ms.height));
popup->set_size(ms);
popup->popup();
@@ -70,7 +70,7 @@ ColorRampEdit::~ColorRampEdit() {
}
-void ColorRampEdit::_input_event(const InputEvent& p_event) {
+void ColorRampEdit::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::KEY && p_event.key.pressed && p_event.key.scancode==KEY_DELETE && grabbed!=-1) {
@@ -446,7 +446,7 @@ Vector<ColorRamp::Point>& ColorRampEdit::get_points() {
}
void ColorRampEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ColorRampEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&ColorRampEdit::_gui_input);
+ ClassDB::bind_method(_MD("_color_changed"),&ColorRampEdit::_color_changed);
ADD_SIGNAL(MethodInfo("ramp_changed"));
}
diff --git a/scene/gui/color_ramp_edit.h b/scene/gui/color_ramp_edit.h
index 61365d9f07..c6a20a539d 100644
--- a/scene/gui/color_ramp_edit.h
+++ b/scene/gui/color_ramp_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -38,7 +38,7 @@
class ColorRampEdit : public Control {
- OBJ_TYPE(ColorRampEdit,Control);
+ GDCLASS(ColorRampEdit,Control);
PopupPanel *popup;
ColorPicker *picker;
@@ -55,7 +55,7 @@ class ColorRampEdit : public Control {
void _show_color_picker();
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
@@ -73,7 +73,7 @@ public:
/*class ColorRampEditPanel : public Panel
{
- OBJ_TYPE(ColorRampEditPanel, Panel );
+ GDCLASS(ColorRampEditPanel, Panel );
};*/
diff --git a/scene/gui/color_rect.cpp b/scene/gui/color_rect.cpp
index a0e4df66b5..99797aa9c1 100644
--- a/scene/gui/color_rect.cpp
+++ b/scene/gui/color_rect.cpp
@@ -1,36 +1,61 @@
+/*************************************************************************/
+/* color_rect.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
#include "color_rect.h"
-
-
-void ColorFrame::set_frame_color(const Color& p_color) {
+void ColorRect::set_frame_color(const Color& p_color) {
color=p_color;
update();
}
-Color ColorFrame::get_frame_color() const{
+Color ColorRect::get_frame_color() const{
return color;
}
-void ColorFrame::_notification(int p_what) {
+void ColorRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
draw_rect(Rect2(Point2(),get_size()),color);
}
}
-void ColorFrame::_bind_methods() {
+void ColorRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_frame_color","color"),&ColorFrame::set_frame_color);
- ObjectTypeDB::bind_method(_MD("get_frame_color"),&ColorFrame::get_frame_color);
+ ClassDB::bind_method(_MD("set_frame_color","color"),&ColorRect::set_frame_color);
+ ClassDB::bind_method(_MD("get_frame_color"),&ColorRect::get_frame_color);
ADD_PROPERTY(PropertyInfo(Variant::COLOR,"color"),_SCS("set_frame_color"),_SCS("get_frame_color") );
}
-ColorFrame::ColorFrame() {
+ColorRect::ColorRect() {
color=Color(1,1,1);
}
-
diff --git a/scene/gui/color_rect.h b/scene/gui/color_rect.h
index 3816d44052..55e413ce27 100644
--- a/scene/gui/color_rect.h
+++ b/scene/gui/color_rect.h
@@ -1,10 +1,38 @@
-#ifndef COLORRECT_H
-#define COLORRECT_H
+/*************************************************************************/
+/* color_rect.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef COLOR_RECT_H
+#define COLOR_RECT_H
#include "scene/gui/control.h"
-class ColorFrame : public Control {
- OBJ_TYPE(ColorFrame,Control)
+class ColorRect : public Control {
+ GDCLASS(ColorRect,Control)
Color color;
protected:
@@ -16,7 +44,7 @@ public:
void set_frame_color(const Color& p_color);
Color get_frame_color() const;
- ColorFrame();
+ ColorRect();
};
-#endif // COLORRECT_H
+#endif // COLOR_RECT_H
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index feaf516f42..de5f35933c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -147,7 +147,7 @@ void Container::_notification(int p_what) {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
queue_sort();
}
} break;
@@ -156,11 +156,11 @@ void Container::_notification(int p_what) {
void Container::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
- ObjectTypeDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
+ ClassDB::bind_method(_MD("_sort_children"),&Container::_sort_children);
+ ClassDB::bind_method(_MD("_child_minsize_changed"),&Container::_child_minsize_changed);
- ObjectTypeDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
- ObjectTypeDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
+ ClassDB::bind_method(_MD("queue_sort"),&Container::queue_sort);
+ ClassDB::bind_method(_MD("fit_child_in_rect","child:Control","rect"),&Container::fit_child_in_rect);
BIND_CONSTANT( NOTIFICATION_SORT_CHILDREN );
ADD_SIGNAL(MethodInfo("sort_children"));
diff --git a/scene/gui/container.h b/scene/gui/container.h
index 1c7587c155..bb47524972 100644
--- a/scene/gui/container.h
+++ b/scene/gui/container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Container : public Control {
- OBJ_TYPE(Container,Control);
+ GDCLASS(Container,Control);
bool pending_sort;
void _sort_children();
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index a5bee32a69..533d24f998 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -96,7 +96,7 @@ Size2 Control::edit_get_minimum_size() const {
void Control::edit_set_rect(const Rect2& p_edit_rect) {
- Matrix32 postxf;
+ Transform2D postxf;
postxf.set_rotation_and_scale(data.rotation,data.scale);
Vector2 new_pos = postxf.xform(p_edit_rect.pos);
@@ -116,30 +116,7 @@ bool Control::_set(const StringName& p_name, const Variant& p_value) {
String name= p_name;
if (!name.begins_with("custom")) {
- if (name.begins_with("margin/")) {
- String dname = name.get_slicec('/', 1);
- if (dname == "left") {
- set_margin(MARGIN_LEFT, p_value);
- return true;
- }
- else if (dname == "top") {
- set_margin(MARGIN_TOP, p_value);
- return true;
- }
- else if (dname == "right") {
- set_margin(MARGIN_RIGHT, p_value);
- return true;
- }
- else if (dname == "bottom") {
- set_margin(MARGIN_BOTTOM, p_value);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
}
if (p_value.get_type()==Variant::NIL) {
@@ -235,30 +212,8 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
String sname=p_name;
if (!sname.begins_with("custom")) {
- if (sname.begins_with("margin/")) {
- String dname = sname.get_slicec('/', 1);
- if (dname == "left") {
- r_ret = get_margin(MARGIN_LEFT);
- return true;
- }
- else if (dname == "top") {
- r_ret = get_margin(MARGIN_TOP);
- return true;
- }
- else if (dname == "right") {
- r_ret = get_margin(MARGIN_RIGHT);
- return true;
- }
- else if (dname == "bottom") {
- r_ret = get_margin(MARGIN_BOTTOM);
- return true;
- }
- else {
- return false;
- }
- } else {
- return false;
- }
+ return false;
+
}
if (sname.begins_with("custom_icons/")) {
@@ -295,36 +250,6 @@ bool Control::_get(const StringName& p_name,Variant &r_ret) const {
}
void Control::_get_property_list( List<PropertyInfo> *p_list) const {
- {
- if (get_anchor(MARGIN_LEFT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/left", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_TOP) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/top", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_RIGHT) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/right", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
-
- if (get_anchor(MARGIN_BOTTOM) == ANCHOR_RATIO) {
- p_list->push_back(PropertyInfo(Variant::REAL, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096,0.001"));
- }
- else {
- p_list->push_back(PropertyInfo(Variant::INT, "margin/bottom", PROPERTY_HINT_RANGE, "-4096,4096"));
- }
- }
-
Ref<Theme> theme;
if (data.theme.is_valid()) {
@@ -336,7 +261,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
{
List<StringName> names;
- theme->get_icon_list(get_type_name(),&names);
+ theme->get_icon_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -348,7 +273,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_shader_list(get_type_name(),&names);
+ theme->get_shader_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -360,7 +285,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_stylebox_list(get_type_name(),&names);
+ theme->get_stylebox_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -372,7 +297,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_font_list(get_type_name(),&names);
+ theme->get_font_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -384,7 +309,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_color_list(get_type_name(),&names);
+ theme->get_color_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -396,7 +321,7 @@ void Control::_get_property_list( List<PropertyInfo> *p_list) const {
}
{
List<StringName> names;
- theme->get_constant_list(get_type_name(),&names);
+ theme->get_constant_list(get_class_name(),&names);
for(List<StringName>::Element *E=names.front();E;E=E->next()) {
uint32_t hint= PROPERTY_USAGE_EDITOR|PROPERTY_USAGE_CHECKABLE;
@@ -449,7 +374,7 @@ void Control::remove_child_notify(Node *p_child) {
void Control::_update_canvas_item_transform() {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Transform2D xform=Transform2D(data.rotation,get_pos());
xform.scale_basis(data.scale);
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
@@ -480,10 +405,10 @@ void Control::_notification(int p_notification) {
if (is_set_as_toplevel()) {
data.SI=get_viewport()->_gui_add_subwindow_control(this);
- /*if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
data.theme_owner=data.parent->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
- }*/
+ }
} else {
@@ -519,10 +444,10 @@ void Control::_notification(int p_notification) {
if (parent_control) {
//do nothing, has a parent control
- /*if (data.theme.is_null() && parent_control->data.theme_owner) {
+ if (data.theme.is_null() && parent_control->data.theme_owner) {
data.theme_owner=parent_control->data.theme_owner;
notification(NOTIFICATION_THEME_CHANGED);
- }*/
+ }
} else if (subwindow) {
//is a subwindow (process input before other controls for that canvas)
data.SI=get_viewport()->_gui_add_subwindow_control(this);
@@ -543,10 +468,12 @@ void Control::_notification(int p_notification) {
}
- //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
- // data.theme_owner=data.parent->data.theme_owner;
- // notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
+ data.theme_owner=data.parent->data.theme_owner;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_EXIT_CANVAS: {
@@ -578,10 +505,12 @@ void Control::_notification(int p_notification) {
data.parent=NULL;
data.parent_canvas_item=NULL;
- //if (data.theme_owner && data.theme.is_null()) {
- // data.theme_owner=NULL;
- //notification(NOTIFICATION_THEME_CHANGED);
- //}
+ /*
+ if (data.theme_owner && data.theme.is_null()) {
+ data.theme_owner=NULL;
+ notification(NOTIFICATION_THEME_CHANGED);
+ }
+ */
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
@@ -607,26 +536,26 @@ void Control::_notification(int p_notification) {
_update_canvas_item_transform();
VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),!data.disable_visibility_clip, Rect2(Point2(),get_size()));
-
+ VisualServer::get_singleton()->canvas_item_set_clip( get_canvas_item(), data.clip_contents );
//emit_signal(SceneStringNames::get_singleton()->draw);
} break;
case NOTIFICATION_MOUSE_ENTER: {
- emit_signal(SceneStringNames::get_singleton()->mouse_enter);
+ emit_signal(SceneStringNames::get_singleton()->mouse_entered);
} break;
case NOTIFICATION_MOUSE_EXIT: {
- emit_signal(SceneStringNames::get_singleton()->mouse_exit);
+ emit_signal(SceneStringNames::get_singleton()->mouse_exited);
} break;
case NOTIFICATION_FOCUS_ENTER: {
- emit_signal(SceneStringNames::get_singleton()->focus_enter);
+ emit_signal(SceneStringNames::get_singleton()->focus_entered);
update();
} break;
case NOTIFICATION_FOCUS_EXIT: {
- emit_signal(SceneStringNames::get_singleton()->focus_exit);
+ emit_signal(SceneStringNames::get_singleton()->focus_exited);
update();
} break;
@@ -636,11 +565,11 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_MODAL_CLOSE: {
- emit_signal("modal_close");
+ emit_signal("modal_closed");
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
- if (!is_visible()) {
+ if (!is_visible_in_tree()) {
if(get_viewport() != NULL)
get_viewport()->_gui_hid_control(this);
@@ -822,15 +751,23 @@ Ref<Texture> Control::get_icon(const StringName& p_name,const StringName& p_type
return *tex;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
- return theme_owner->data.theme->get_icon(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_icon(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_icon(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -852,15 +789,23 @@ Ref<Shader> Control::get_shader(const StringName& p_name,const StringName& p_typ
return *sdr;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_shader(p_name, type))
- return theme_owner->data.theme->get_shader(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_shader(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_shader(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -881,16 +826,23 @@ Ref<StyleBox> Control::get_stylebox(const StringName& p_name,const StringName& p
return *style;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) ) {
- return theme_owner->data.theme->get_stylebox(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_stylebox(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
}
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -910,15 +862,23 @@ Ref<Font> Control::get_font(const StringName& p_name,const StringName& p_type) c
return *font;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
- return theme_owner->data.theme->get_font(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_font(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_font(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
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;
@@ -941,14 +901,22 @@ Color Control::get_color(const StringName& p_name,const StringName& p_type) cons
return *color;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
- return theme_owner->data.theme->get_color(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_color(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_color(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -970,14 +938,22 @@ int Control::get_constant(const StringName& p_name,const StringName& p_type) con
return *constant;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
- return theme_owner->data.theme->get_constant(p_name, type );
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_constant(p_name, class_name ) ) {
+ return theme_owner->data.theme->get_constant(p_name, class_name );
+ }
+
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1053,15 +1029,22 @@ bool Control::has_icon(const StringName& p_name,const StringName& p_type) const
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_icon(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_icon(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1082,15 +1065,22 @@ bool Control::has_shader(const StringName &p_name, const StringName &p_type) con
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_shader(p_name, type))
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_shader(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1110,15 +1100,22 @@ bool Control::has_stylebox(const StringName& p_name,const StringName& p_type) co
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_stylebox(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_stylebox(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1139,15 +1136,22 @@ bool Control::has_font(const StringName& p_name,const StringName& p_type) const
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_font(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_font(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1168,15 +1172,22 @@ bool Control::has_color(const StringName& p_name, const StringName& p_type) cons
return true;
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_color(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_color(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1198,15 +1209,22 @@ bool Control::has_constant(const StringName& p_name,const StringName& p_type) co
}
- StringName type = p_type?p_type:get_type_name();
+ StringName type = p_type?p_type:get_class_name();
// try with custom themes
Control *theme_owner = data.theme_owner;
while(theme_owner) {
- if (theme_owner->data.theme->has_constant(p_name, type ) )
- return true;
+ StringName class_name = type;
+
+ while(class_name!=StringName()) {
+ if (theme_owner->data.theme->has_constant(p_name, class_name ) ) {
+ return true;
+ }
+ class_name = ClassDB::get_parent_class_nocheck(class_name);
+ }
+
Control *parent = theme_owner->get_parent()?theme_owner->get_parent()->cast_to<Control>():NULL;
if (parent)
@@ -1258,14 +1276,10 @@ void Control::_size_changed() {
margin_pos[i]=area-data.margin[i];
} break;
- case ANCHOR_RATIO: {
+ case ANCHOR_CENTER: {
- margin_pos[i]=area*data.margin[i];
+ margin_pos[i]=(area/2)-data.margin[i];
} break;
- case ANCHOR_CENTER: {
-
- margin_pos[i]=(area/2)-data.margin[i];
- } break;
}
}
@@ -1334,12 +1348,9 @@ float Control::_s2a(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return p_range-p_val;
} break;
- case ANCHOR_RATIO: {
- return p_val/p_range;
+ case ANCHOR_CENTER: {
+ return (p_range/2)-p_val;
} break;
- case ANCHOR_CENTER: {
- return (p_range/2)-p_val;
- } break;
}
return 0;
@@ -1356,11 +1367,8 @@ float Control::_a2s(float p_val, AnchorType p_anchor,float p_range) const {
case ANCHOR_END: {
return Math::floor(p_range-p_val);
} break;
- case ANCHOR_RATIO: {
- return Math::floor(p_range*p_val);
- } break;
case ANCHOR_CENTER: {
- return Math::floor((p_range/2)-p_val);
+ return Math::floor((p_range/2)-p_val);
} break;
}
return 0;
@@ -1387,7 +1395,7 @@ void Control::set_anchor(Margin p_margin,AnchorType p_anchor, bool p_keep_margin
void Control::_set_anchor(Margin p_margin,AnchorType p_anchor) {
#ifdef TOOLS_ENABLED
if (is_inside_tree() && get_tree()->is_editor_hint()) {
- set_anchor(p_margin, p_anchor, EDITOR_DEF("2d_editor/keep_margins_when_changing_anchors", false));
+ set_anchor(p_margin, p_anchor, EDITOR_DEF("editors/2d/keep_margins_when_changing_anchors", false));
} else {
set_anchor(p_margin, p_anchor, false);
}
@@ -1467,7 +1475,7 @@ Point2 Control::get_global_pos() const {
void Control::set_global_pos(const Point2& p_point) {
- Matrix32 inv;
+ Transform2D inv;
if (data.parent_canvas_item) {
@@ -1656,7 +1664,7 @@ static Control *_next_control(Control *p_from) {
for(int i=(next+1);i<parent->get_child_count();i++) {
Control *c = parent->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
return c;
@@ -1681,7 +1689,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>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1725,11 +1733,11 @@ Control *Control::find_next_valid_focus() const {
if (next_child==this) // no next control->
return (get_focus_mode()==FOCUS_ALL)?next_child:NULL;
-
- if (next_child->get_focus_mode()==FOCUS_ALL)
- return next_child;
-
- from = next_child;
+ if (next_child) {
+ if (next_child->get_focus_mode()==FOCUS_ALL)
+ return next_child;
+ from = next_child;
+ } else break;
}
return NULL;
@@ -1747,7 +1755,7 @@ static Control *_prev_control(Control *p_from) {
for(int i=p_from->get_child_count()-1;i>=0;i--) {
Control *c = p_from->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel())
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel())
continue;
child=c;
@@ -1787,7 +1795,7 @@ Control *Control::find_prev_valid_focus() const {
Control *c = from->get_parent()->get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible() || c->is_set_as_toplevel()) {
+ if (!c || !c->is_visible_in_tree() || c->is_set_as_toplevel()) {
continue;
}
@@ -1871,7 +1879,7 @@ void Control::show_modal(bool p_exclusive) {
ERR_FAIL_COND(!is_inside_tree());
ERR_FAIL_COND(!data.SI);
- if (is_visible())
+ if (is_visible_in_tree())
hide();
ERR_FAIL_COND( data.MI!=NULL );
@@ -1879,7 +1887,7 @@ void Control::show_modal(bool p_exclusive) {
raise();
data.modal_exclusive=p_exclusive;
data.MI=get_viewport()->_gui_show_modal(this);
- data.modal_frame=OS::get_singleton()->get_frames_drawn();
+ data.modal_frame=Engine::get_singleton()->get_frames_drawn();
}
@@ -2003,9 +2011,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const {
return data.default_cursor;
}
-Matrix32 Control::get_transform() const {
+Transform2D Control::get_transform() const {
- Matrix32 xform=Matrix32(data.rotation,get_pos());
+ Transform2D xform=Transform2D(data.rotation,get_pos());
xform.scale_basis(data.scale);
return xform;
}
@@ -2049,7 +2057,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
return NULL;
}
bool valid=true;
- if (c->is_hidden())
+ if (!c->is_visible())
valid=false;
if (c->get_focus_mode()==FOCUS_NONE)
valid=false;
@@ -2066,7 +2074,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin,int p_count) {
Point2 points[4];
- Matrix32 xform = get_global_transform();
+ Transform2D xform = get_global_transform();
Rect2 rect = get_item_rect();
points[0]=xform.xform(rect.pos);
@@ -2122,11 +2130,11 @@ void Control::_window_find_focus_neighbour(const Vector2& p_dir, Node *p_at,cons
Control *c = p_at->cast_to<Control>();
- if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible()) {
+ if (c && c !=this && c->get_focus_mode()==FOCUS_ALL && c->is_visible_in_tree()) {
Point2 points[4];
- Matrix32 xform = c->get_global_transform();
+ Transform2D xform = c->get_global_transform();
Rect2 rect = c->get_item_rect();
points[0]=xform.xform(rect.pos);
@@ -2246,25 +2254,17 @@ int Control::get_v_size_flags() const{
return data.v_size_flags;
}
-void Control::set_ignore_mouse(bool p_ignore) {
-
- data.ignore_mouse=p_ignore;
-}
-
-bool Control::is_ignoring_mouse() const {
+void Control::set_mouse_filter(MouseFilter p_filter) {
- return data.ignore_mouse;
+ ERR_FAIL_INDEX(p_filter,3);
+ data.mouse_filter=p_filter;
}
-void Control::set_stop_mouse(bool p_stop) {
+Control::MouseFilter Control::get_mouse_filter() const{
- data.stop_mouse=p_stop;
+ return data.mouse_filter;
}
-bool Control::is_stopping_mouse() const {
-
- return data.stop_mouse;
-}
Control *Control::get_focus_owner() const {
@@ -2414,15 +2414,15 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S
List<StringName> sn;
String pf = p_function;
if (pf=="add_color_override" || pf=="has_color" || pf=="has_color_override" || pf=="get_color") {
- Theme::get_default()->get_color_list(get_type(),&sn);
+ Theme::get_default()->get_color_list(get_class(),&sn);
} else if (pf=="add_style_override" || pf=="has_style" || pf=="has_style_override" || pf=="get_style") {
- Theme::get_default()->get_stylebox_list(get_type(),&sn);
+ Theme::get_default()->get_stylebox_list(get_class(),&sn);
} else if (pf=="add_font_override" || pf=="has_font" || pf=="has_font_override" || pf=="get_font") {
- Theme::get_default()->get_font_list(get_type(),&sn);
+ Theme::get_default()->get_font_list(get_class(),&sn);
} else if (pf=="add_constant_override" || pf=="has_constant" || pf=="has_constant_override" || pf=="get_constant") {
- Theme::get_default()->get_constant_list(get_type(),&sn);
+ Theme::get_default()->get_constant_list(get_class(),&sn);
} else if (pf=="add_color_override" || pf=="has_color" || pf=="has_color_override" || pf=="get_color") {
- Theme::get_default()->get_color_list(get_type(),&sn);
+ Theme::get_default()->get_color_list(get_class(),&sn);
}
sn.sort_custom<StringName::AlphCompare>();
@@ -2433,163 +2433,190 @@ void Control::get_argument_options(const StringName& p_function,int p_idx,List<S
}
+void Control::set_clip_contents(bool p_clip) {
+
+ data.clip_contents=p_clip;
+ update();
+}
+
+bool Control::is_clipping_contents() {
+
+ return data.clip_contents;
+}
void Control::_bind_methods() {
-// ObjectTypeDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
- ObjectTypeDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
- ObjectTypeDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
-
- ObjectTypeDB::bind_method(_MD("accept_event"),&Control::accept_event);
- ObjectTypeDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
- ObjectTypeDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
- ObjectTypeDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
- ObjectTypeDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
- ObjectTypeDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
- ObjectTypeDB::bind_method(_MD("set_end","pos"),&Control::set_end);
- ObjectTypeDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
- ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size);
- ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
- ObjectTypeDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
- ObjectTypeDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
+ //ClassDB::bind_method(_MD("_window_resize_event"),&Control::_window_resize_event);
+ ClassDB::bind_method(_MD("_size_changed"),&Control::_size_changed);
+ ClassDB::bind_method(_MD("_update_minimum_size"),&Control::_update_minimum_size);
+
+ ClassDB::bind_method(_MD("accept_event"),&Control::accept_event);
+ ClassDB::bind_method(_MD("get_minimum_size"),&Control::get_minimum_size);
+ ClassDB::bind_method(_MD("get_combined_minimum_size"),&Control::get_combined_minimum_size);
+ ClassDB::bind_method(_MD("set_anchor","margin","anchor_mode","keep_margin"),&Control::set_anchor,DEFVAL(false));
+ ClassDB::bind_method(_MD("_set_anchor","margin","anchor_mode"),&Control::_set_anchor);
+ ClassDB::bind_method(_MD("get_anchor","margin"),&Control::get_anchor);
+ ClassDB::bind_method(_MD("set_margin","margin","offset"),&Control::set_margin);
+ ClassDB::bind_method(_MD("set_anchor_and_margin","margin","anchor_mode","offset"),&Control::set_anchor_and_margin);
+ ClassDB::bind_method(_MD("set_begin","pos"),&Control::set_begin);
+ ClassDB::bind_method(_MD("set_end","pos"),&Control::set_end);
+ ClassDB::bind_method(_MD("set_pos","pos"),&Control::set_pos);
+ ClassDB::bind_method(_MD("set_size","size"),&Control::set_size);
+ ClassDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
+ ClassDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
+ ClassDB::bind_method(_MD("set_rotation","radians"),&Control::set_rotation);
+ ClassDB::bind_method(_MD("set_rotation_deg","degrees"),&Control::set_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
- ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
- ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
- ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end);
- ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos);
- ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
- ObjectTypeDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
+ ClassDB::bind_method(_MD("_set_rotation_deg","degrees"),&Control::_set_rotation_deg);
+ ClassDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
+ ClassDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
+ ClassDB::bind_method(_MD("get_begin"),&Control::get_begin);
+ ClassDB::bind_method(_MD("get_end"),&Control::get_end);
+ ClassDB::bind_method(_MD("get_pos"),&Control::get_pos);
+ ClassDB::bind_method(_MD("get_size"),&Control::get_size);
+ ClassDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
+ ClassDB::bind_method(_MD("get_rotation_deg"),&Control::get_rotation_deg);
// TODO: Obsolete this method (old name) properly (GH-4397)
- ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
- ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale);
- ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
- ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
- ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
- ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect);
- ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
- ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
- ObjectTypeDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
- ObjectTypeDB::bind_method(_MD("has_focus"),&Control::has_focus);
- ObjectTypeDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
- ObjectTypeDB::bind_method(_MD("release_focus"),&Control::release_focus);
- ObjectTypeDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
+ ClassDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
+ ClassDB::bind_method(_MD("get_scale"),&Control::get_scale);
+ ClassDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
+ ClassDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
+ ClassDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
+ ClassDB::bind_method(_MD("get_rect"),&Control::get_rect);
+ ClassDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
+ ClassDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
+ ClassDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
+ ClassDB::bind_method(_MD("set_focus_mode","mode"),&Control::set_focus_mode);
+ ClassDB::bind_method(_MD("get_focus_mode"),&Control::get_focus_mode);
+ ClassDB::bind_method(_MD("has_focus"),&Control::has_focus);
+ ClassDB::bind_method(_MD("grab_focus"),&Control::grab_focus);
+ ClassDB::bind_method(_MD("release_focus"),&Control::release_focus);
+ ClassDB::bind_method(_MD("get_focus_owner:Control"),&Control::get_focus_owner);
- ObjectTypeDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
- ObjectTypeDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
+ ClassDB::bind_method(_MD("set_h_size_flags","flags"),&Control::set_h_size_flags);
+ ClassDB::bind_method(_MD("get_h_size_flags"),&Control::get_h_size_flags);
- ObjectTypeDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
+ ClassDB::bind_method(_MD("set_stretch_ratio","ratio"),&Control::set_stretch_ratio);
+ ClassDB::bind_method(_MD("get_stretch_ratio"),&Control::get_stretch_ratio);
- ObjectTypeDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
- ObjectTypeDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
+ ClassDB::bind_method(_MD("set_v_size_flags","flags"),&Control::set_v_size_flags);
+ ClassDB::bind_method(_MD("get_v_size_flags"),&Control::get_v_size_flags);
- ObjectTypeDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
- ObjectTypeDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
+ ClassDB::bind_method(_MD("set_theme","theme:Theme"),&Control::set_theme);
+ ClassDB::bind_method(_MD("get_theme:Theme"),&Control::get_theme);
- ObjectTypeDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
- ObjectTypeDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
- ObjectTypeDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
- ObjectTypeDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
- ObjectTypeDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
- ObjectTypeDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
+ ClassDB::bind_method(_MD("add_icon_override","name","texture:Texture"),&Control::add_icon_override);
+ ClassDB::bind_method(_MD("add_shader_override","name","shader:Shader"),&Control::add_shader_override);
+ ClassDB::bind_method(_MD("add_style_override","name","stylebox:StyleBox"),&Control::add_style_override);
+ ClassDB::bind_method(_MD("add_font_override","name","font:Font"),&Control::add_font_override);
+ ClassDB::bind_method(_MD("add_color_override","name","color"),&Control::add_color_override);
+ ClassDB::bind_method(_MD("add_constant_override","name","constant"),&Control::add_constant_override);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_icon:Texture","name","type"),&Control::get_icon,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_stylebox:StyleBox","name","type"),&Control::get_stylebox,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_font:Font","name","type"),&Control::get_font,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_color","name","type"),&Control::get_color,DEFVAL(""));
+ ClassDB::bind_method(_MD("get_constant","name","type"),&Control::get_constant,DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
- ObjectTypeDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
- ObjectTypeDB::bind_method(_MD("has_font_override", "name"), &Control::has_font_override);
- ObjectTypeDB::bind_method(_MD("has_color_override", "name"), &Control::has_color_override);
- ObjectTypeDB::bind_method(_MD("has_constant_override", "name"), &Control::has_constant_override);
+ ClassDB::bind_method(_MD("has_icon_override", "name"), &Control::has_icon_override);
+ ClassDB::bind_method(_MD("has_stylebox_override", "name"), &Control::has_stylebox_override);
+ ClassDB::bind_method(_MD("has_font_override", "name"), &Control::has_font_override);
+ ClassDB::bind_method(_MD("has_color_override", "name"), &Control::has_color_override);
+ ClassDB::bind_method(_MD("has_constant_override", "name"), &Control::has_constant_override);
- ObjectTypeDB::bind_method(_MD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_icon", "name", "type"), &Control::has_icon, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_stylebox", "name", "type"), &Control::has_stylebox, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_font", "name", "type"), &Control::has_font, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_color", "name", "type"), &Control::has_color, DEFVAL(""));
+ ClassDB::bind_method(_MD("has_constant", "name", "type"), &Control::has_constant, DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
+ ClassDB::bind_method(_MD("get_parent_control:Control"),&Control::get_parent_control);
- ObjectTypeDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
+ ClassDB::bind_method(_MD("set_tooltip","tooltip"),&Control::set_tooltip);
+ ClassDB::bind_method(_MD("get_tooltip","atpos"),&Control::get_tooltip,DEFVAL(Point2()));
+ ClassDB::bind_method(_MD("_get_tooltip"),&Control::_get_tooltip);
- ObjectTypeDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
- ObjectTypeDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
+ ClassDB::bind_method(_MD("set_default_cursor_shape","shape"),&Control::set_default_cursor_shape);
+ ClassDB::bind_method(_MD("get_default_cursor_shape"),&Control::get_default_cursor_shape);
+ ClassDB::bind_method(_MD("get_cursor_shape","pos"),&Control::get_cursor_shape,DEFVAL(Point2()));
- ObjectTypeDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
+ ClassDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour);
+ ClassDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour);
- ObjectTypeDB::bind_method(_MD("set_ignore_mouse","ignore"),&Control::set_ignore_mouse);
- ObjectTypeDB::bind_method(_MD("is_ignoring_mouse"),&Control::is_ignoring_mouse);
+ ClassDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag);
- ObjectTypeDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag);
+ ClassDB::bind_method(_MD("set_mouse_filter","filter"),&Control::set_mouse_filter);
+ ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter);
- ObjectTypeDB::bind_method(_MD("set_stop_mouse","stop"),&Control::set_stop_mouse);
- ObjectTypeDB::bind_method(_MD("is_stopping_mouse"),&Control::is_stopping_mouse);
+ ClassDB::bind_method(_MD("set_clip_contents","enable"),&Control::set_clip_contents);
+ ClassDB::bind_method(_MD("is_clipping_contents"),&Control::is_clipping_contents);
- ObjectTypeDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
+ ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus);
- ObjectTypeDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
- ObjectTypeDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
+ ClassDB::bind_method(_MD("set_drag_forwarding","target:Control"),&Control::set_drag_forwarding);
+ ClassDB::bind_method(_MD("set_drag_preview","control:Control"),&Control::set_drag_preview);
- ObjectTypeDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
+ ClassDB::bind_method(_MD("warp_mouse","to_pos"),&Control::warp_mouse);
- ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
+ ClassDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
- ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
+ ClassDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
- ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
+ ClassDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
- BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));
+ BIND_VMETHOD(MethodInfo("_gui_input",PropertyInfo(Variant::INPUT_EVENT,"event")));
BIND_VMETHOD(MethodInfo(Variant::VECTOR2,"get_minimum_size"));
BIND_VMETHOD(MethodInfo(Variant::OBJECT,"get_drag_data",PropertyInfo(Variant::VECTOR2,"pos")));
BIND_VMETHOD(MethodInfo(Variant::BOOL,"can_drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
BIND_VMETHOD(MethodInfo("drop_data",PropertyInfo(Variant::VECTOR2,"pos"),PropertyInfo(Variant::NIL,"data")));
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/left", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/top", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/right", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor/bottom", PROPERTY_HINT_ENUM, "Begin,End,Ratio,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
-
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
- ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus/stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") );
-
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/horizontal", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
- ADD_PROPERTY( PropertyInfo(Variant::INT,"size_flags/vertical", PROPERTY_HINT_FLAGS, "Expand,Fill"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
- ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags/stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
- ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme/theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_GROUP("Anchor","anchor_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_left", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_top", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_right", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"anchor_bottom", PROPERTY_HINT_ENUM, "Begin,End,Center"), _SCS("_set_anchor"),_SCS("get_anchor"), MARGIN_BOTTOM );
+
+ ADD_GROUP("Margin","margin_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_left", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_top", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_right", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::INT,"margin_bottom", PROPERTY_HINT_RANGE, "-4096,4096"), _SCS("set_margin"),_SCS("get_margin"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Rect","rect_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect_min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect_rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("set_rotation_deg"),_SCS("get_rotation_deg") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect_scale"), _SCS("set_scale"),_SCS("get_scale") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL,"rect_clip_content"), _SCS("set_clip_contents"),_SCS("is_clipping_contents") );
+
+
+ ADD_GROUP("Hint","hint_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
+
+ ADD_GROUP("Focus","focus_");
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Mouse","mouse_");
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"mouse_filter",PROPERTY_HINT_ENUM,"Stop,Pass,Ignore"), _SCS("set_mouse_filter"),_SCS("get_mouse_filter") );
+
+ ADD_GROUP("Size Flags","size_flags_");
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_stretch_ratio", PROPERTY_HINT_RANGE, "1,128,0.01"), _SCS("set_stretch_ratio"),_SCS("get_stretch_ratio") );
+ ADD_GROUP("Theme","");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"theme", PROPERTY_HINT_RESOURCE_TYPE, "Theme"), _SCS("set_theme"),_SCS("get_theme") );
+ ADD_GROUP("","");
BIND_CONSTANT( ANCHOR_BEGIN );
BIND_CONSTANT( ANCHOR_END );
- BIND_CONSTANT( ANCHOR_RATIO );
BIND_CONSTANT( ANCHOR_CENTER );
BIND_CONSTANT( FOCUS_NONE );
BIND_CONSTANT( FOCUS_CLICK );
@@ -2626,15 +2653,19 @@ void Control::_bind_methods() {
BIND_CONSTANT( SIZE_FILL );
BIND_CONSTANT( SIZE_EXPAND_FILL );
+ BIND_CONSTANT( MOUSE_FILTER_STOP );
+ BIND_CONSTANT( MOUSE_FILTER_PASS );
+ BIND_CONSTANT( MOUSE_FILTER_IGNORE );
+
ADD_SIGNAL( MethodInfo("resized") );
- ADD_SIGNAL( MethodInfo("input_event",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
- ADD_SIGNAL( MethodInfo("mouse_enter") );
- ADD_SIGNAL( MethodInfo("mouse_exit") );
- ADD_SIGNAL( MethodInfo("focus_enter") );
- ADD_SIGNAL( MethodInfo("focus_exit") );
+ ADD_SIGNAL( MethodInfo("gui_input",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
+ ADD_SIGNAL( MethodInfo("mouse_entered") );
+ ADD_SIGNAL( MethodInfo("mouse_exited") );
+ ADD_SIGNAL( MethodInfo("focus_entered") );
+ ADD_SIGNAL( MethodInfo("focus_exited") );
ADD_SIGNAL( MethodInfo("size_flags_changed") );
ADD_SIGNAL( MethodInfo("minimum_size_changed") );
- ADD_SIGNAL( MethodInfo("modal_close") );
+ ADD_SIGNAL( MethodInfo("modal_closed") );
}
@@ -2642,9 +2673,7 @@ Control::Control() {
data.parent=NULL;
- data.ignore_mouse=false;
- data.stop_mouse=true;
-
+ data.mouse_filter=MOUSE_FILTER_STOP;
data.SI=NULL;
data.MI=NULL;
@@ -2665,7 +2694,7 @@ Control::Control() {
data.block_minimum_size_adjust=false;
data.disable_visibility_clip=false;
-
+ data.clip_contents=false;
for (int i=0;i<4;i++) {
data.anchor[i]=ANCHOR_BEGIN;
data.margin[i]=0;
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 37efd80970..68795b054c 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -46,7 +46,7 @@ class Panel;
class Control : public CanvasItem {
- OBJ_TYPE( Control, CanvasItem );
+ GDCLASS( Control, CanvasItem );
OBJ_CATEGORY("GUI Nodes");
public:
@@ -54,7 +54,6 @@ public:
enum AnchorType {
ANCHOR_BEGIN,
ANCHOR_END,
- ANCHOR_RATIO,
ANCHOR_CENTER,
};
@@ -66,12 +65,18 @@ public:
enum SizeFlags {
- SIZE_EXPAND=1,
- SIZE_FILL=2,
+ SIZE_FILL=1,
+ SIZE_EXPAND=2,
SIZE_EXPAND_FILL=SIZE_EXPAND|SIZE_FILL
};
+ enum MouseFilter {
+ MOUSE_FILTER_STOP,
+ MOUSE_FILTER_PASS,
+ MOUSE_FILTER_IGNORE
+ };
+
enum CursorShape {
CURSOR_ARROW,
CURSOR_IBEAM,
@@ -125,8 +130,9 @@ private:
bool pending_min_size_update;
Point2 custom_minimum_size;
- bool ignore_mouse;
- bool stop_mouse;
+ MouseFilter mouse_filter;
+
+ bool clip_contents;
bool block_minimum_size_adjust;
bool disable_visibility_clip;
@@ -162,7 +168,7 @@ private:
} data;
// used internally
- Control* _find_control_at_pos(CanvasItem* p_node,const Point2& p_pos,const Matrix32& p_xform,Matrix32& r_inv_xform);
+ Control* _find_control_at_pos(CanvasItem* p_node,const Point2& p_pos,const Transform2D& p_xform,Transform2D& r_inv_xform);
void _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);
@@ -208,7 +214,7 @@ protected:
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
- //virtual void _window_input_event(InputEvent p_event);
+ //virtual void _window_gui_input(InputEvent p_event);
bool _set(const StringName& p_name, const Variant& p_value);
bool _get(const StringName& p_name,Variant &r_ret) const;
@@ -338,11 +344,8 @@ public:
Control *get_focus_owner() const;
- void set_ignore_mouse(bool p_ignore);
- bool is_ignoring_mouse() const;
-
- void set_stop_mouse(bool p_stop);
- bool is_stopping_mouse() const;
+ void set_mouse_filter(MouseFilter p_filter);
+ MouseFilter get_mouse_filter() const;
/* SKINNING */
@@ -386,7 +389,7 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
virtual Rect2 get_item_rect() const;
- virtual Matrix32 get_transform() const;
+ virtual Transform2D get_transform() const;
bool is_toplevel_control() const;
@@ -400,6 +403,8 @@ public:
Control *get_root_parent_control() const;
+ void set_clip_contents(bool p_clip);
+ bool is_clipping_contents();
void set_block_minimum_size_adjust(bool p_block);
bool is_minimum_size_adjust_blocked() const;
@@ -418,5 +423,6 @@ VARIANT_ENUM_CAST(Control::AnchorType);
VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_ENUM_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape);
+VARIANT_ENUM_CAST(Control::MouseFilter);
#endif
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 15ff334c92..cc6fe7cae8 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,7 +47,7 @@ bool WindowDialog::has_point(const Point2& p_point) const {
}
-void WindowDialog::_input_event(const InputEvent& p_event) {
+void WindowDialog::_gui_input(const InputEvent& p_event) {
if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
@@ -141,13 +141,13 @@ TextureButton *WindowDialog::get_close_button() {
void WindowDialog::_bind_methods() {
- ObjectTypeDB::bind_method( _MD("_input_event"),&WindowDialog::_input_event);
- ObjectTypeDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
- ObjectTypeDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
- ObjectTypeDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
- ObjectTypeDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
+ ClassDB::bind_method( _MD("_gui_input"),&WindowDialog::_gui_input);
+ ClassDB::bind_method( _MD("set_title","title"),&WindowDialog::set_title);
+ ClassDB::bind_method( _MD("get_title"),&WindowDialog::get_title);
+ ClassDB::bind_method( _MD("_closed"),&WindowDialog::_closed);
+ ClassDB::bind_method( _MD("get_close_button:TextureButton"),&WindowDialog::get_close_button);
- ADD_PROPERTY( PropertyInfo(Variant::STRING,"window/title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
+ ADD_PROPERTY( PropertyInfo(Variant::STRING,"window_title",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_title"),_SCS("get_title"));
}
WindowDialog::WindowDialog() {
@@ -203,7 +203,7 @@ void AcceptDialog::_notification(int p_what) {
cancel_pressed();
} if (p_what==NOTIFICATION_RESIZED) {
- _update_child_rect();
+ _update_child_rects();
}
}
@@ -232,6 +232,8 @@ String AcceptDialog::get_text() const {
void AcceptDialog::set_text(String p_text) {
label->set_text(p_text);
+ minimum_size_changed();
+ _update_child_rects();
}
void AcceptDialog::set_hide_on_ok(bool p_hide) {
@@ -251,21 +253,31 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) {
p_line_edit->connect("text_entered", this,"_builtin_text_entered");
}
-void AcceptDialog::_update_child_rect() {
+void AcceptDialog::_update_child_rects() {
+
+ Size2 label_size=label->get_minimum_size();
+ if (label->get_text().empty()) {
+ label_size.height = 0;
+ }
int margin = get_constant("margin","Dialogs");
Size2 size = get_size();
Size2 hminsize = hbc->get_combined_minimum_size();
- Vector2 cpos(margin,margin);
- Vector2 csize(size.x-margin*2,size.y-margin*3-hminsize.y);
- label->set_pos(cpos);
- label->set_size(csize);
+ Vector2 cpos(margin,margin+label_size.height);
+ 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>();
+ if (!c)
+ continue;
+
+ if (c==hbc || c==label || c==get_close_button())
+ continue;
- if (child) {
+ c->set_pos(cpos);
+ c->set_size(csize);
- child->set_pos(cpos);
- child->set_size(csize);
}
cpos.y+=csize.y+margin;
@@ -280,13 +292,23 @@ Size2 AcceptDialog::get_minimum_size() const {
int margin = get_constant("margin","Dialogs");
Size2 minsize = label->get_combined_minimum_size();
- if (child) {
- Size2 cminsize = child->get_combined_minimum_size();
+
+ for(int i=0;i<get_child_count();i++) {
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c)
+ continue;
+
+ if (c==hbc || c==label || c==const_cast<AcceptDialog*>(this)->get_close_button())
+ continue;
+
+ Size2 cminsize = c->get_combined_minimum_size();
minsize.x=MAX(cminsize.x,minsize.x);
minsize.y=MAX(cminsize.y,minsize.y);
+
}
+
Size2 hminsize = hbc->get_combined_minimum_size();
minsize.x = MAX(hminsize.x,minsize.x);
minsize.y+=hminsize.y;
@@ -299,23 +321,6 @@ Size2 AcceptDialog::get_minimum_size() const {
}
-void AcceptDialog::set_child_rect(Control *p_child) {
-
- ERR_FAIL_COND(p_child->get_parent()!=this);
-
- //p_child->set_area_as_parent_rect(get_constant("margin","Dialogs"));
- child=p_child;
- minimum_size_changed();
- _update_child_rect();
-}
-
-void AcceptDialog::remove_child_notify(Node *p_child) {
-
- if (p_child==child) {
- child=NULL;
- }
-}
-
void AcceptDialog::_custom_action(const String& p_action) {
emit_signal("custom_action",p_action);
@@ -356,25 +361,25 @@ Button* AcceptDialog::add_cancel(const String &p_cancel) {
void AcceptDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
- ObjectTypeDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
- ObjectTypeDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
- ObjectTypeDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
- ObjectTypeDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
- ObjectTypeDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
- ObjectTypeDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
- ObjectTypeDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
- ObjectTypeDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
- ObjectTypeDB::bind_method(_MD("set_child_rect","child:Control"),&AcceptDialog::set_child_rect);
+ ClassDB::bind_method(_MD("_ok"),&AcceptDialog::_ok_pressed);
+ ClassDB::bind_method(_MD("get_ok"),&AcceptDialog::get_ok);
+ ClassDB::bind_method(_MD("get_label"),&AcceptDialog::get_label);
+ ClassDB::bind_method(_MD("set_hide_on_ok","enabled"),&AcceptDialog::set_hide_on_ok);
+ ClassDB::bind_method(_MD("get_hide_on_ok"),&AcceptDialog::get_hide_on_ok);
+ ClassDB::bind_method(_MD("add_button:Button","text","right","action"),&AcceptDialog::add_button,DEFVAL(false),DEFVAL(""));
+ ClassDB::bind_method(_MD("add_cancel:Button","name"),&AcceptDialog::add_cancel);
+ ClassDB::bind_method(_MD("_builtin_text_entered"),&AcceptDialog::_builtin_text_entered);
+ ClassDB::bind_method(_MD("register_text_enter:LineEdit","line_edit"),&AcceptDialog::register_text_enter);
+ ClassDB::bind_method(_MD("_custom_action"),&AcceptDialog::_custom_action);
+ ClassDB::bind_method(_MD("set_text","text"),&AcceptDialog::set_text);
+ ClassDB::bind_method(_MD("get_text"),&AcceptDialog::get_text);
ADD_SIGNAL( MethodInfo("confirmed") );
ADD_SIGNAL( MethodInfo("custom_action",PropertyInfo(Variant::STRING,"action")) );
- ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog/text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog/hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
+ ADD_GROUP("Dialog","dialog");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"dialog_text",PROPERTY_HINT_MULTILINE_TEXT,"",PROPERTY_USAGE_DEFAULT_INTL),_SCS("set_text"),_SCS("get_text"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "dialog_hide_on_ok"),_SCS("set_hide_on_ok"),_SCS("get_hide_on_ok") );
}
@@ -414,8 +419,6 @@ AcceptDialog::AcceptDialog() {
hide_on_ok=true;
set_title(RTR("Alert!"));
-
- child=NULL;
}
@@ -426,7 +429,7 @@ AcceptDialog::~AcceptDialog()
void ConfirmationDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
+ ClassDB::bind_method(_MD("get_cancel:Button"),&ConfirmationDialog::get_cancel);
}
Button *ConfirmationDialog::get_cancel() {
diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h
index d00bb41ff6..6650c5eb5d 100644
--- a/scene/gui/dialogs.h
+++ b/scene/gui/dialogs.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,13 +42,13 @@
class WindowDialog : public Popup {
- OBJ_TYPE(WindowDialog,Popup);
+ GDCLASS(WindowDialog,Popup);
TextureButton *close_button;
String title;
bool dragging;
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _closed();
protected:
virtual void _post_popup();
@@ -73,7 +73,7 @@ public:
class PopupDialog : public Popup {
- OBJ_TYPE(PopupDialog,Popup);
+ GDCLASS(PopupDialog,Popup);
protected:
void _notification(int p_what);
@@ -89,13 +89,12 @@ class LineEdit;
class AcceptDialog : public WindowDialog {
- OBJ_TYPE(AcceptDialog,WindowDialog);
+ GDCLASS(AcceptDialog,WindowDialog);
- Control *child;
HBoxContainer *hbc;
Label *label;
Button *ok;
-// Button *cancel; no more cancel (there is X on tht titlebar)
+ //Button *cancel; no more cancel (there is X on tht titlebar)
bool hide_on_ok;
@@ -103,13 +102,11 @@ class AcceptDialog : public WindowDialog {
void _ok_pressed();
void _close_pressed();
void _builtin_text_entered(const String& p_text);
- void _update_child_rect();
+ void _update_child_rects();
static bool swap_ok_cancel;
- virtual void remove_child_notify(Node *p_child);
-
protected:
@@ -140,8 +137,6 @@ public:
void set_text(String p_text);
String get_text() const;
- void set_child_rect(Control *p_child);
-
AcceptDialog();
~AcceptDialog();
@@ -150,7 +145,7 @@ public:
class ConfirmationDialog : public AcceptDialog {
- OBJ_TYPE(ConfirmationDialog,AcceptDialog);
+ GDCLASS(ConfirmationDialog,AcceptDialog);
Button *cancel;
protected:
static void _bind_methods();
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6b43425edc..393f14bee2 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -164,7 +164,7 @@ void FileDialog::_action_pressed() {
TreeItem *ti=tree->get_next_selected(NULL);
String fbase=dir_access->get_current_dir();
- DVector<String> files;
+ PoolVector<String> files;
while(ti) {
files.push_back( fbase.plus_file(ti->get_text(0)) );
@@ -186,15 +186,17 @@ void FileDialog::_action_pressed() {
hide();
}else if (mode==MODE_OPEN_ANY || mode==MODE_OPEN_DIR) {
-
String path=dir_access->get_current_dir();
- /*if (tree->get_selected()) {
- Dictionary d = tree->get_selected()->get_metadata(0);
+
+ path=path.replace("\\","/");
+
+ if (TreeItem* item = tree->get_selected()) {
+ Dictionary d = item->get_metadata(0);
if (d["dir"]) {
- path=path+"/"+String(d["name"]);
+ path=path.plus_file(d["name"]);
}
- }*/
- path=path.replace("\\","/");
+ }
+
emit_signal("dir_selected",path);
hide();
}
@@ -348,18 +350,18 @@ void FileDialog::update_file_list() {
files.sort_custom<NoCaseComparator>();
while(!dirs.empty()) {
+ String& dir_name = dirs.front()->get();
+ TreeItem *ti=tree->create_item(root);
+ ti->set_text(0,dir_name+"/");
+ ti->set_icon(0,folder);
- if (dirs.front()->get()!=".") {
- TreeItem *ti=tree->create_item(root);
- ti->set_text(0,dirs.front()->get()+"/");
- ti->set_icon(0,folder);
- Dictionary d;
- d["name"]=dirs.front()->get();
- d["dir"]=true;
- ti->set_metadata(0,d);
- }
- dirs.pop_front();
+ Dictionary d;
+ d["name"]=dir_name;
+ d["dir"]=true;
+
+ ti->set_metadata(0,d);
+ dirs.pop_front();
}
dirs.clear();
@@ -401,11 +403,12 @@ void FileDialog::update_file_list() {
while(!files.empty()) {
bool match=patterns.empty();
+ String match_str;
for(List<String>::Element *E=patterns.front();E;E=E->next()) {
if (files.front()->get().matchn(E->get())) {
-
+ match_str=E->get();
match=true;
break;
}
@@ -430,14 +433,14 @@ void FileDialog::update_file_list() {
d["dir"]=false;
ti->set_metadata(0,d);
- if (file->get_text()==files.front()->get())
+ if (file->get_text()==files.front()->get() || match_str==files.front()->get())
ti->select(0);
}
files.pop_front();
}
- if (tree->get_root() && tree->get_root()->get_children())
+ if (tree->get_root() && tree->get_root()->get_children() && tree->get_selected()==NULL)
tree->get_root()->get_children()->select(0);
files.clear();
@@ -612,7 +615,7 @@ void FileDialog::set_access(Access p_access) {
void FileDialog::invalidate() {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
update_file_list();
invalidated=false;
} else {
@@ -683,44 +686,44 @@ bool FileDialog::default_show_hidden_files=false;
void FileDialog::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
-
- ObjectTypeDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
- ObjectTypeDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
- ObjectTypeDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
- ObjectTypeDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
- ObjectTypeDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
- ObjectTypeDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
- ObjectTypeDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
- ObjectTypeDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
-
- ObjectTypeDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
- ObjectTypeDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
- ObjectTypeDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
- ObjectTypeDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
- ObjectTypeDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
- ObjectTypeDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
- ObjectTypeDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
- ObjectTypeDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
- ObjectTypeDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
- ObjectTypeDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
- ObjectTypeDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
- ObjectTypeDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
- ObjectTypeDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
- ObjectTypeDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
- ObjectTypeDB::bind_method(_MD("get_access"),&FileDialog::get_access);
- ObjectTypeDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
- ObjectTypeDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
- ObjectTypeDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
- ObjectTypeDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
- ObjectTypeDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
- ObjectTypeDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
- ObjectTypeDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
-
- ObjectTypeDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
+ ClassDB::bind_method(_MD("_unhandled_input"),&FileDialog::_unhandled_input);
+
+ ClassDB::bind_method(_MD("_tree_selected"),&FileDialog::_tree_selected);
+ ClassDB::bind_method(_MD("_tree_db_selected"),&FileDialog::_tree_dc_selected);
+ ClassDB::bind_method(_MD("_dir_entered"),&FileDialog::_dir_entered);
+ ClassDB::bind_method(_MD("_file_entered"),&FileDialog::_file_entered);
+ ClassDB::bind_method(_MD("_action_pressed"),&FileDialog::_action_pressed);
+ ClassDB::bind_method(_MD("_cancel_pressed"),&FileDialog::_cancel_pressed);
+ ClassDB::bind_method(_MD("_filter_selected"),&FileDialog::_filter_selected);
+ ClassDB::bind_method(_MD("_save_confirm_pressed"),&FileDialog::_save_confirm_pressed);
+
+ ClassDB::bind_method(_MD("clear_filters"),&FileDialog::clear_filters);
+ ClassDB::bind_method(_MD("add_filter","filter"),&FileDialog::add_filter);
+ ClassDB::bind_method(_MD("set_filters","filters"),&FileDialog::set_filters);
+ ClassDB::bind_method(_MD("get_filters"),&FileDialog::get_filters);
+ ClassDB::bind_method(_MD("get_current_dir"),&FileDialog::get_current_dir);
+ ClassDB::bind_method(_MD("get_current_file"),&FileDialog::get_current_file);
+ ClassDB::bind_method(_MD("get_current_path"),&FileDialog::get_current_path);
+ ClassDB::bind_method(_MD("set_current_dir","dir"),&FileDialog::set_current_dir);
+ ClassDB::bind_method(_MD("set_current_file","file"),&FileDialog::set_current_file);
+ ClassDB::bind_method(_MD("set_current_path","path"),&FileDialog::set_current_path);
+ ClassDB::bind_method(_MD("set_mode","mode"),&FileDialog::set_mode);
+ ClassDB::bind_method(_MD("get_mode"),&FileDialog::get_mode);
+ ClassDB::bind_method(_MD("get_vbox:VBoxContainer"),&FileDialog::get_vbox);
+ ClassDB::bind_method(_MD("set_access","access"),&FileDialog::set_access);
+ ClassDB::bind_method(_MD("get_access"),&FileDialog::get_access);
+ ClassDB::bind_method(_MD("set_show_hidden_files","show"),&FileDialog::set_show_hidden_files);
+ ClassDB::bind_method(_MD("is_showing_hidden_files"),&FileDialog::is_showing_hidden_files);
+ ClassDB::bind_method(_MD("_select_drive"),&FileDialog::_select_drive);
+ ClassDB::bind_method(_MD("_make_dir"),&FileDialog::_make_dir);
+ ClassDB::bind_method(_MD("_make_dir_confirm"),&FileDialog::_make_dir_confirm);
+ ClassDB::bind_method(_MD("_update_file_list"),&FileDialog::update_file_list);
+ ClassDB::bind_method(_MD("_update_dir"),&FileDialog::update_dir);
+
+ ClassDB::bind_method(_MD("invalidate"),&FileDialog::invalidate);
ADD_SIGNAL(MethodInfo("file_selected",PropertyInfo( Variant::STRING,"path")));
- ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::STRING_ARRAY,"paths")));
+ ADD_SIGNAL(MethodInfo("files_selected",PropertyInfo( Variant::POOL_STRING_ARRAY,"paths")));
ADD_SIGNAL(MethodInfo("dir_selected",PropertyInfo( Variant::STRING,"dir")));
BIND_CONSTANT( MODE_OPEN_FILE );
@@ -736,7 +739,7 @@ void FileDialog::_bind_methods() {
ADD_PROPERTY( PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"),_SCS("set_mode"),_SCS("get_mode") );
ADD_PROPERTY( PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"),_SCS("set_access"),_SCS("get_access") );
- ADD_PROPERTY( PropertyInfo(Variant::STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
+ ADD_PROPERTY( PropertyInfo(Variant::POOL_STRING_ARRAY, "filters"),_SCS("set_filters"),_SCS("get_filters") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "show_hidden_files"),_SCS("set_show_hidden_files"),_SCS("is_showing_hidden_files") );
}
@@ -761,7 +764,7 @@ FileDialog::FileDialog() {
VBoxContainer *vbc = memnew( VBoxContainer );
add_child(vbc);
- set_child_rect(vbc);
+
mode=MODE_SAVE_FILE;
set_title(RTR("Save a File"));
@@ -825,7 +828,7 @@ FileDialog::FileDialog() {
makedialog->set_title(RTR("Create Folder"));
VBoxContainer *makevb= memnew( VBoxContainer );
makedialog->add_child(makevb);
- makedialog->set_child_rect(makevb);
+
makedirname = memnew( LineEdit );
makevb->add_margin_child(RTR("Name:"),makedirname);
add_child(makedialog);
@@ -865,11 +868,11 @@ FileDialog::~FileDialog() {
void LineEditFileChooser::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
- ObjectTypeDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
- ObjectTypeDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
- ObjectTypeDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
- ObjectTypeDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
+ ClassDB::bind_method(_MD("_browse"),&LineEditFileChooser::_browse);
+ ClassDB::bind_method(_MD("_chosen"),&LineEditFileChooser::_chosen);
+ ClassDB::bind_method(_MD("get_button:Button"),&LineEditFileChooser::get_button);
+ ClassDB::bind_method(_MD("get_line_edit:LineEdit"),&LineEditFileChooser::get_line_edit);
+ ClassDB::bind_method(_MD("get_file_dialog:FileDialog"),&LineEditFileChooser::get_file_dialog);
}
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 150b24cb3f..653b38e40d 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -42,7 +42,7 @@
*/
class FileDialog : public ConfirmationDialog {
- OBJ_TYPE( FileDialog, ConfirmationDialog );
+ GDCLASS( FileDialog, ConfirmationDialog );
public:
@@ -167,7 +167,7 @@ public:
class LineEditFileChooser : public HBoxContainer {
- OBJ_TYPE( LineEditFileChooser, HBoxContainer );
+ GDCLASS( LineEditFileChooser, HBoxContainer );
Button *button;
LineEdit *line_edit;
FileDialog *dialog;
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 0de6add8cb..ba1ab1afa8 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -107,15 +107,15 @@ void GraphEdit::get_connection_list(List<Connection> *r_connections) const {
void GraphEdit::set_scroll_ofs(const Vector2& p_ofs) {
setting_scroll_ofs=true;
- h_scroll->set_val(p_ofs.x);
- v_scroll->set_val(p_ofs.y);
+ h_scroll->set_value(p_ofs.x);
+ v_scroll->set_value(p_ofs.y);
_update_scroll();
setting_scroll_ofs=false;
}
Vector2 GraphEdit::get_scroll_ofs() const{
- return Vector2(h_scroll->get_val(),v_scroll->get_val());
+ return Vector2(h_scroll->get_value(),v_scroll->get_value());
}
void GraphEdit::_scroll_moved(double) {
@@ -144,14 +144,14 @@ void GraphEdit::_update_scroll_offset() {
continue;
Point2 pos=gn->get_offset()*zoom;
- pos-=Point2(h_scroll->get_val(),v_scroll->get_val());
+ pos-=Point2(h_scroll->get_value(),v_scroll->get_value());
gn->set_pos(pos);
if (gn->get_scale()!=Vector2(zoom,zoom)) {
gn->set_scale(Vector2(zoom,zoom));
}
}
- connections_layer->set_pos(-Point2(h_scroll->get_val(),v_scroll->get_val())*zoom);
+ connections_layer->set_pos(-Point2(h_scroll->get_value(),v_scroll->get_value()));
set_block_minimum_size_adjust(false);
awaiting_scroll_offset_update=false;
@@ -254,8 +254,9 @@ void GraphEdit::add_child_notify(Node *p_child) {
gn->set_scale(Vector2(zoom,zoom));
gn->connect("offset_changed",this,"_graph_node_moved",varray(gn));
gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
+ gn->connect("item_rect_changed",connections_layer,"update");
_graph_node_moved(gn);
- gn->set_stop_mouse(false);
+ gn->set_mouse_filter(MOUSE_FILTER_PASS);
}
@@ -294,14 +295,13 @@ void GraphEdit::_notification(int p_what) {
zoom_reset->set_icon(get_icon("reset"));
zoom_plus->set_icon(get_icon("more"));
snap_button->set_icon(get_icon("snap"));
-// zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
+ //zoom_icon->set_texture( get_icon("Zoom", "EditorIcons"));
}
if (p_what==NOTIFICATION_DRAW) {
draw_style_box( get_stylebox("bg"),Rect2(Point2(),get_size()) );
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
if (is_using_snap()) {
//draw grid
@@ -650,8 +650,8 @@ void GraphEdit::_draw_cos_line(CanvasItem* p_where,const Vector2& p_from, const
cp_offset=MAX(MIN(cp_len-diff,cp_neg_len),-diff*0.5);
}
- Vector2 c1 = Vector2(cp_offset,0);
- Vector2 c2 = Vector2(-cp_offset,0);
+ Vector2 c1 = Vector2(cp_offset*zoom,0);
+ Vector2 c2 = Vector2(-cp_offset*zoom,0);
int lines=0;
_bake_segment2d(p_where,0,1,p_from,c1,p_to,c2,0,3,9,8,p_color,p_to_color,lines);
@@ -726,9 +726,9 @@ void GraphEdit::_connections_layer_draw() {
continue;
}
- Vector2 frompos=gfrom->get_connection_output_pos(E->get().from_port)+gfrom->get_offset();
+ 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();
+ 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);
@@ -792,11 +792,11 @@ void GraphEdit::set_selected(Node* p_child) {
}
}
-void GraphEdit::_input_event(const InputEvent& p_ev) {
+void GraphEdit::_gui_input(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_MOTION && (p_ev.mouse_motion.button_mask&BUTTON_MASK_MIDDLE || (p_ev.mouse_motion.button_mask&BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
- h_scroll->set_val( h_scroll->get_val() - p_ev.mouse_motion.relative_x );
- v_scroll->set_val( v_scroll->get_val() - p_ev.mouse_motion.relative_y );
+ h_scroll->set_value( h_scroll->get_value() - p_ev.mouse_motion.relative_x );
+ v_scroll->set_value( v_scroll->get_value() - p_ev.mouse_motion.relative_y );
}
if (p_ev.type==InputEvent::MOUSE_MOTION && dragging) {
@@ -912,18 +912,20 @@ void GraphEdit::_input_event(const InputEvent& p_ev) {
if (b.button_index==BUTTON_LEFT && b.pressed) {
GraphNode *gn = NULL;
+ GraphNode *gn_selected = NULL;
for(int i=get_child_count()-1;i>=0;i--) {
- gn=get_child(i)->cast_to<GraphNode>();
+ gn_selected=get_child(i)->cast_to<GraphNode>();
- if (gn) {
+ if (gn_selected) {
- if (gn->is_resizing())
+ if (gn_selected->is_resizing())
continue;
- Rect2 r = gn->get_rect();
+ Rect2 r = gn_selected->get_rect();
r.size*=zoom;
if (r.has_point(get_local_mouse_pos()))
+ gn = gn_selected;
break;
}
}
@@ -1044,18 +1046,19 @@ void GraphEdit::set_zoom(float p_zoom) {
zoom_minus->set_disabled(zoom==MIN_ZOOM);
zoom_plus->set_disabled(zoom==MAX_ZOOM);
- Vector2 sbofs = (Vector2( h_scroll->get_val(), v_scroll->get_val() ) + get_size()/2)/zoom;
+ Vector2 sbofs = (Vector2( h_scroll->get_value(), v_scroll->get_value() ) + get_size()/2)/zoom;
zoom = p_zoom;
top_layer->update();
_update_scroll();
+ connections_layer->update();
- if (is_visible()) {
+ if (is_visible_in_tree()) {
Vector2 ofs = sbofs*zoom - get_size()/2;
- h_scroll->set_val( ofs.x );
- v_scroll->set_val( ofs.y );
+ h_scroll->set_value( ofs.x );
+ v_scroll->set_value( ofs.y );
}
@@ -1177,13 +1180,13 @@ bool GraphEdit::is_using_snap() const{
int GraphEdit::get_snap() const{
- return snap_amount->get_val();
+ return snap_amount->get_value();
}
void GraphEdit::set_snap(int p_snap) {
ERR_FAIL_COND(p_snap<5);
- snap_amount->set_val(p_snap);
+ snap_amount->set_value(p_snap);
update();
}
void GraphEdit::_snap_toggled() {
@@ -1198,44 +1201,44 @@ void GraphEdit::_snap_value_changed(double) {
void GraphEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
- ObjectTypeDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
- ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
- ObjectTypeDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
- ObjectTypeDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
- ObjectTypeDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
+ ClassDB::bind_method(_MD("connect_node:Error","from","from_port","to","to_port"),&GraphEdit::connect_node);
+ ClassDB::bind_method(_MD("is_node_connected","from","from_port","to","to_port"),&GraphEdit::is_node_connected);
+ ClassDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node);
+ ClassDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list);
+ ClassDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs);
+ ClassDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs);
- ObjectTypeDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
- ObjectTypeDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
+ ClassDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom);
+ ClassDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom);
- ObjectTypeDB::bind_method(_MD("set_snap","pixels"),&GraphEdit::set_snap);
- ObjectTypeDB::bind_method(_MD("get_snap"),&GraphEdit::get_snap);
+ ClassDB::bind_method(_MD("set_snap","pixels"),&GraphEdit::set_snap);
+ ClassDB::bind_method(_MD("get_snap"),&GraphEdit::get_snap);
- ObjectTypeDB::bind_method(_MD("set_use_snap","enable"),&GraphEdit::set_use_snap);
- ObjectTypeDB::bind_method(_MD("is_using_snap"),&GraphEdit::is_using_snap);
+ ClassDB::bind_method(_MD("set_use_snap","enable"),&GraphEdit::set_use_snap);
+ ClassDB::bind_method(_MD("is_using_snap"),&GraphEdit::is_using_snap);
- ObjectTypeDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
- ObjectTypeDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
+ ClassDB::bind_method(_MD("set_right_disconnects","enable"),&GraphEdit::set_right_disconnects);
+ ClassDB::bind_method(_MD("is_right_disconnects_enabled"),&GraphEdit::is_right_disconnects_enabled);
- ObjectTypeDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
- ObjectTypeDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
+ ClassDB::bind_method(_MD("_graph_node_moved"),&GraphEdit::_graph_node_moved);
+ ClassDB::bind_method(_MD("_graph_node_raised"),&GraphEdit::_graph_node_raised);
- ObjectTypeDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
- ObjectTypeDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
- ObjectTypeDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
- ObjectTypeDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
- ObjectTypeDB::bind_method(_MD("_snap_toggled"),&GraphEdit::_snap_toggled);
- ObjectTypeDB::bind_method(_MD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
+ ClassDB::bind_method(_MD("_top_layer_input"),&GraphEdit::_top_layer_input);
+ ClassDB::bind_method(_MD("_top_layer_draw"),&GraphEdit::_top_layer_draw);
+ ClassDB::bind_method(_MD("_scroll_moved"),&GraphEdit::_scroll_moved);
+ ClassDB::bind_method(_MD("_zoom_minus"),&GraphEdit::_zoom_minus);
+ ClassDB::bind_method(_MD("_zoom_reset"),&GraphEdit::_zoom_reset);
+ ClassDB::bind_method(_MD("_zoom_plus"),&GraphEdit::_zoom_plus);
+ ClassDB::bind_method(_MD("_snap_toggled"),&GraphEdit::_snap_toggled);
+ ClassDB::bind_method(_MD("_snap_value_changed"),&GraphEdit::_snap_value_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_update_scroll_offset"),&GraphEdit::_update_scroll_offset);
- ObjectTypeDB::bind_method(_MD("_connections_layer_draw"),&GraphEdit::_connections_layer_draw);
+ ClassDB::bind_method(_MD("_gui_input"),&GraphEdit::_gui_input);
+ ClassDB::bind_method(_MD("_update_scroll_offset"),&GraphEdit::_update_scroll_offset);
+ ClassDB::bind_method(_MD("_connections_layer_draw"),&GraphEdit::_connections_layer_draw);
- ObjectTypeDB::bind_method(_MD("set_selected","node"),&GraphEdit::set_selected);
+ ClassDB::bind_method(_MD("set_selected","node"),&GraphEdit::set_selected);
ADD_SIGNAL(MethodInfo("connection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
ADD_SIGNAL(MethodInfo("disconnection_request",PropertyInfo(Variant::STRING,"from"),PropertyInfo(Variant::INT,"from_slot"),PropertyInfo(Variant::STRING,"to"),PropertyInfo(Variant::INT,"to_slot")));
@@ -1258,11 +1261,11 @@ GraphEdit::GraphEdit() {
top_layer=NULL;
top_layer=memnew(GraphEditFilter(this));
add_child(top_layer);
- top_layer->set_stop_mouse(false);
+ top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
top_layer->set_area_as_parent_rect();
top_layer->connect("draw",this,"_top_layer_draw");
- top_layer->set_stop_mouse(false);
- top_layer->connect("input_event",this,"_top_layer_input");
+ top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
+ top_layer->connect("gui_input",this,"_top_layer_input");
connections_layer = memnew( Control );
add_child(connections_layer);
@@ -1327,13 +1330,13 @@ GraphEdit::GraphEdit() {
snap_amount->set_min(5);
snap_amount->set_max(100);
snap_amount->set_step(1);
- snap_amount->set_val(20);
+ snap_amount->set_value(20);
snap_amount->connect("value_changed",this,"_snap_value_changed");
zoom_hb->add_child(snap_amount);
setting_scroll_ofs=false;
just_disconected=false;
-
+ set_clip_contents(true);
}
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index c5174f6699..3e9944332f 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,13 +34,13 @@
#include "scene/gui/slider.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/spin_box.h"
-#include "texture_frame.h"
+#include "scene/gui/texture_rect.h"
class GraphEdit;
class GraphEditFilter : public Control {
- OBJ_TYPE(GraphEditFilter,Control);
+ GDCLASS(GraphEditFilter,Control);
friend class GraphEdit;
GraphEdit *ge;
@@ -54,7 +54,7 @@ public:
class GraphEdit : public Control {
- OBJ_TYPE(GraphEdit,Control);
+ GDCLASS(GraphEdit,Control);
public:
struct Connection {
@@ -123,7 +123,7 @@ private:
void _update_scroll();
void _scroll_moved(double);
- void _input_event(const InputEvent& p_ev);
+ void _gui_input(const InputEvent& p_ev);
Control *connections_layer;
GraphEditFilter *top_layer;
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index da298a795a..aa8c875f40 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -217,8 +217,8 @@ void GraphNode::_notification(int p_what) {
sb = get_stylebox( selected ? "selectedframe" : "frame");
}
- sb=sb->duplicate();
- sb->call("set_modulate",modulate);
+ //sb=sb->duplicate();
+ //sb->call("set_modulate",modulate);
Ref<Texture> port =get_icon("port");
Ref<Texture> close =get_icon("close");
Ref<Texture> resizer =get_icon("resizer");
@@ -621,7 +621,7 @@ Color GraphNode::get_connection_output_color(int p_idx) {
return conn_output_cache[p_idx].color;
}
-void GraphNode::_input_event(const InputEvent& p_ev) {
+void GraphNode::_gui_input(const InputEvent& p_ev) {
if (p_ev.type==InputEvent::MOUSE_BUTTON) {
@@ -675,16 +675,6 @@ void GraphNode::_input_event(const InputEvent& p_ev) {
}
-void GraphNode::set_modulate(const Color &p_color) {
-
- modulate=p_color;
- update();
-}
-
-Color GraphNode::get_modulate() const{
-
- return modulate;
-}
void GraphNode::set_overlay(Overlay p_overlay) {
overlay=p_overlay;
@@ -722,50 +712,51 @@ bool GraphNode::is_resizeable() const{
void GraphNode::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
- ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
- ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
+ ClassDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
+ ClassDB::bind_method(_MD("get_title"),&GraphNode::get_title);
+ ClassDB::bind_method(_MD("_gui_input"),&GraphNode::_gui_input);
- ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
- ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
- ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
- ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
- ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
- ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
- ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
- ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
+ ClassDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right","custom_left","custom_right"),&GraphNode::set_slot,DEFVAL(Ref<Texture>()),DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
+ ClassDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
+ ClassDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
+ ClassDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
+ ClassDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
+ ClassDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
+ ClassDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
+ ClassDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
- ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
- ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
+ ClassDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
+ ClassDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
- ObjectTypeDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
- ObjectTypeDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
+ ClassDB::bind_method(_MD("set_comment","comment"),&GraphNode::set_comment);
+ ClassDB::bind_method(_MD("is_comment"),&GraphNode::is_comment);
- ObjectTypeDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
- ObjectTypeDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
+ ClassDB::bind_method(_MD("set_resizeable","resizeable"),&GraphNode::set_resizeable);
+ ClassDB::bind_method(_MD("is_resizeable"),&GraphNode::is_resizeable);
- ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
- ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
+ ClassDB::bind_method(_MD("set_selected","selected"),&GraphNode::set_selected);
+ ClassDB::bind_method(_MD("is_selected"),&GraphNode::is_selected);
- ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
- ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
- ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
- ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
- ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
+ ClassDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
+ ClassDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&GraphNode::set_modulate);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate);
+ ClassDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
+ ClassDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
+ ClassDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
+ ClassDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
+ ClassDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
+ ClassDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
- ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
- ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
+ ClassDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
+ ClassDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
- ObjectTypeDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
- ObjectTypeDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
+ ClassDB::bind_method(_MD("set_overlay","overlay"),&GraphNode::set_overlay);
+ ClassDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay);
ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"resizeable"),_SCS("set_resizeable"),_SCS("is_resizeable"));
ADD_SIGNAL(MethodInfo("offset_changed"));
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
@@ -783,9 +774,9 @@ GraphNode::GraphNode() {
overlay=OVERLAY_DISABLED;
show_close=false;
connpos_dirty=true;
- set_stop_mouse(false);
- modulate=Color(1,1,1,1);
+ set_mouse_filter(MOUSE_FILTER_PASS);
comment=false;
resizeable=false;
resizing=false;
+ selected=false;
}
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index cbfd34f556..9cb46fc49c 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class GraphNode : public Container {
- OBJ_TYPE(GraphNode,Container);
+ GDCLASS(GraphNode,Container);
public:
enum Overlay {
@@ -92,14 +92,12 @@ private:
Overlay overlay;
- Color modulate;
-
bool has_point(const Point2& p_point) const;
protected:
- void _input_event(const InputEvent& p_ev);
+ void _gui_input(const InputEvent& p_ev);
void _notification(int p_what);
static void _bind_methods();
@@ -147,9 +145,6 @@ public:
Color get_connection_output_color(int p_idx);
- void set_modulate(const Color& p_color);
- Color get_modulate() const;
-
void set_overlay(Overlay p_overlay);
Overlay get_overlay() const;
diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp
index 5e6622b3f8..597169ca83 100644
--- a/scene/gui/grid_container.cpp
+++ b/scene/gui/grid_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
@@ -70,7 +70,7 @@ void GridContainer::_notification(int p_what) {
else
row_minh[row]=ms.height;
- // print_line("store row "+itos(row)+" mw "+itos(ms.height));
+ //print_line("store row "+itos(row)+" mw "+itos(ms.height));
if (c->get_h_size_flags()&SIZE_EXPAND)
col_expanded.insert(col);
@@ -112,7 +112,7 @@ void GridContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
@@ -136,7 +136,7 @@ void GridContainer::_notification(int p_what) {
Point2 p(col_ofs,row_ofs);
-// print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
+ //print_line("col: "+itos(col)+" row: "+itos(row)+" col_ofs: "+itos(col_ofs)+" row_ofs: "+itos(row_ofs));
fit_child_in_rect(c,Rect2(p,s));
//print_line("col: "+itos(col)+" row: "+itos(row)+" rect: "+Rect2(p,s));
@@ -170,8 +170,8 @@ int GridContainer::get_columns() const{
void GridContainer::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
+ ClassDB::bind_method(_MD("set_columns","columns"),&GridContainer::set_columns);
+ ClassDB::bind_method(_MD("get_columns"),&GridContainer::get_columns);
ADD_PROPERTY( PropertyInfo(Variant::INT,"columns",PROPERTY_HINT_RANGE,"1,1024,1"),_SCS("set_columns"),_SCS("get_columns"));
}
@@ -191,7 +191,7 @@ Size2 GridContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
int row = idx / columns;
int col = idx % columns;
@@ -230,6 +230,6 @@ Size2 GridContainer::get_minimum_size() const {
GridContainer::GridContainer() {
- set_stop_mouse(false);
+ set_mouse_filter(MOUSE_FILTER_PASS);
columns=1;
}
diff --git a/scene/gui/grid_container.h b/scene/gui/grid_container.h
index 588bb17fa1..cc1d04cdb2 100644
--- a/scene/gui/grid_container.h
+++ b/scene/gui/grid_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class GridContainer : public Container {
- OBJ_TYPE(GridContainer,Container);
+ GDCLASS(GridContainer,Container);
int columns;
protected:
diff --git a/scene/gui/input_action.cpp b/scene/gui/input_action.cpp
index c4e7a75298..77026dfdb1 100644
--- a/scene/gui/input_action.cpp
+++ b/scene/gui/input_action.cpp
@@ -24,7 +24,7 @@ bool ShortCut::is_shortcut(const InputEvent& p_event) const {
same=(shortcut.key.scancode==p_event.key.scancode && shortcut.key.mod == p_event.key.mod);
} break;
- case InputEvent::JOYSTICK_BUTTON: {
+ case InputEvent::JOYPAD_BUTTON: {
same=(shortcut.joy_button.button_index==p_event.joy_button.button_index);
@@ -34,7 +34,7 @@ bool ShortCut::is_shortcut(const InputEvent& p_event) const {
same=(shortcut.mouse_button.button_index==p_event.mouse_button.button_index);
} break;
- case InputEvent::JOYSTICK_MOTION: {
+ case InputEvent::JOYPAD_MOTION: {
same=(shortcut.joy_motion.axis==p_event.joy_motion.axis && (shortcut.joy_motion.axis_value < 0) == (p_event.joy_motion.axis_value < 0));
@@ -69,7 +69,7 @@ String ShortCut::get_as_text() const {
return str;
} break;
- case InputEvent::JOYSTICK_BUTTON: {
+ case InputEvent::JOYPAD_BUTTON: {
String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Button")+" "+itos(shortcut.joy_button.button_index);
str+=".";
@@ -90,7 +90,7 @@ String ShortCut::get_as_text() const {
return str;
} break;
- case InputEvent::JOYSTICK_MOTION: {
+ case InputEvent::JOYPAD_MOTION: {
int ax = shortcut.joy_motion.axis;
String str = RTR("Device")+" "+itos(shortcut.device)+", "+RTR("Axis")+" "+itos(ax)+".";
@@ -109,13 +109,13 @@ bool ShortCut::is_valid() const {
void ShortCut::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
- ObjectTypeDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
+ ClassDB::bind_method(_MD("set_shortcut","event"),&ShortCut::set_shortcut);
+ ClassDB::bind_method(_MD("get_shortcut"),&ShortCut::get_shortcut);
- ObjectTypeDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
+ ClassDB::bind_method(_MD("is_valid"),&ShortCut::is_valid);
- ObjectTypeDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
- ObjectTypeDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
+ ClassDB::bind_method(_MD("is_shortcut","event"),&ShortCut::is_shortcut);
+ ClassDB::bind_method(_MD("get_as_text"),&ShortCut::get_as_text);
ADD_PROPERTY(PropertyInfo(Variant::INPUT_EVENT,"shortcut"),_SCS("set_shortcut"),_SCS("get_shortcut"));
}
diff --git a/scene/gui/input_action.h b/scene/gui/input_action.h
index 8e0e1ef0bd..a83b3a70cd 100644
--- a/scene/gui/input_action.h
+++ b/scene/gui/input_action.h
@@ -5,7 +5,7 @@
class ShortCut : public Resource {
- OBJ_TYPE(ShortCut,Resource);
+ GDCLASS(ShortCut,Resource);
InputEvent shortcut;
protected:
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 89cd509fbd..a3ed0a91cf 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -446,7 +446,7 @@ Size2 ItemList::Item::get_icon_size() const {
return icon_region.size;
}
-void ItemList::_input_event(const InputEvent& p_event) {
+void ItemList::_gui_input(const InputEvent& p_event) {
if (defer_select_single>=0 && p_event.type==InputEvent::MOUSE_MOTION) {
defer_select_single=-1;
@@ -471,7 +471,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
Vector2 pos(mb.x,mb.y);
Ref<StyleBox> bg = get_stylebox("bg");
pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos.y+=scroll_bar->get_value();
int closest = -1;
@@ -561,12 +561,12 @@ void ItemList::_input_event(const InputEvent& p_event) {
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_UP && p_event.mouse_button.pressed) {
- scroll_bar->set_val( scroll_bar->get_val()-scroll_bar->get_page()/8 );
+ scroll_bar->set_value( scroll_bar->get_value()-scroll_bar->get_page()/8 );
}
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_WHEEL_DOWN && p_event.mouse_button.pressed) {
- scroll_bar->set_val( scroll_bar->get_val()+scroll_bar->get_page()/8 );
+ scroll_bar->set_value( scroll_bar->get_value()+scroll_bar->get_page()/8 );
}
@@ -578,7 +578,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current-1;i>=0;i--) {
@@ -614,7 +614,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current+1;i<items.size();i++) {
@@ -725,7 +725,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000));
+ uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000));
search_time_msec = now;
if (diff>max_interval) {
@@ -788,7 +788,6 @@ void ItemList::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
- VS::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
Ref<StyleBox> bg = get_stylebox("bg");
int mw = scroll_bar->get_minimum_size().x;
@@ -801,7 +800,10 @@ void ItemList::_notification(int p_what) {
Size2 size = get_size();
float page = size.height-bg->get_minimum_size().height;
- int width = size.width - mw - bg->get_minimum_size().width;
+ int width = size.width-bg->get_minimum_size().width;
+ if (scroll_bar->is_visible()){
+ width-=mw+bg->get_margin(MARGIN_RIGHT);
+ }
scroll_bar->set_page(page);
draw_style_box(bg,Rect2(Point2(),size));
@@ -946,7 +948,7 @@ void ItemList::_notification(int p_what) {
scroll_bar->set_max(max);
//print_line("max: "+rtos(max)+" page "+rtos(page));
if (max<=page) {
- scroll_bar->set_val(0);
+ scroll_bar->set_value(0);
scroll_bar->hide();
} else {
scroll_bar->show();
@@ -959,12 +961,28 @@ void ItemList::_notification(int p_what) {
shape_changed=false;
}
+ //ensure_selected_visible needs to be checked before we draw the list.
+ if (ensure_selected_visible && current>=0 && current <=items.size()) {
+
+ Rect2 r = items[current].rect_cache;
+ int from = scroll_bar->get_value();
+ int to = from + scroll_bar->get_page();
+ if (r.pos.y < from) {
+ scroll_bar->set_value(r.pos.y);
+ } else if (r.pos.y+r.size.y > to) {
+ scroll_bar->set_value(r.pos.y+r.size.y - (to-from));
+ }
+
+
+ }
+
+ ensure_selected_visible=false;
Vector2 base_ofs = bg->get_offset();
- base_ofs.y-=int(scroll_bar->get_val());
+ base_ofs.y-=int(scroll_bar->get_value());
- Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_val()));
+ Rect2 clip(Point2(),size-bg->get_minimum_size()+Vector2(0,scroll_bar->get_value()));
for(int i=0;i<items.size();i++) {
@@ -1147,25 +1165,6 @@ void ItemList::_notification(int p_what) {
for(int i=0;i<separators.size();i++) {
draw_line(Vector2(bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),Vector2(size.width-bg->get_margin(MARGIN_LEFT),base_ofs.y+separators[i]),guide_color);
}
-
-
- if (ensure_selected_visible && current>=0 && current <=items.size()) {
-
- Rect2 r = items[current].rect_cache;
- int from = scroll_bar->get_val();
- int to = from + scroll_bar->get_page();
-
- if (r.pos.y < from) {
- scroll_bar->set_val(r.pos.y);
- } else if (r.pos.y+r.size.y > to) {
- scroll_bar->set_val(r.pos.y+r.size.y - (to-from));
- }
-
-
- }
-
- ensure_selected_visible=false;
-
}
}
@@ -1178,7 +1177,7 @@ int ItemList::get_item_at_pos(const Point2& p_pos, bool p_exact) const {
Vector2 pos=p_pos;
Ref<StyleBox> bg = get_stylebox("bg");
pos-=bg->get_offset();
- pos.y+=scroll_bar->get_val();
+ pos.y+=scroll_bar->get_value();
int closest = -1;
int closest_dist=0x7FFFFFFF;
@@ -1285,83 +1284,83 @@ Vector<int> ItemList::get_selected_items() {
void ItemList::_bind_methods(){
- ObjectTypeDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
+ ClassDB::bind_method(_MD("add_item","text","icon:Texture","selectable"),&ItemList::add_item,DEFVAL(Variant()),DEFVAL(true));
+ ClassDB::bind_method(_MD("add_icon_item","icon:Texture","selectable"),&ItemList::add_icon_item,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&ItemList::set_item_text);
+ ClassDB::bind_method(_MD("get_item_text","idx"),&ItemList::get_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
+ ClassDB::bind_method(_MD("set_item_icon","idx","icon:Texture"),&ItemList::set_item_icon);
+ ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&ItemList::get_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
- ObjectTypeDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
+ ClassDB::bind_method(_MD("set_item_icon_region","idx","rect"),&ItemList::set_item_icon_region);
+ ClassDB::bind_method(_MD("get_item_icon_region","idx"),&ItemList::get_item_icon_region);
- ObjectTypeDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
- ObjectTypeDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
+ ClassDB::bind_method(_MD("set_item_selectable","idx","selectable"),&ItemList::set_item_selectable);
+ ClassDB::bind_method(_MD("is_item_selectable","idx"),&ItemList::is_item_selectable);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&ItemList::set_item_disabled);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&ItemList::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&ItemList::set_item_metadata);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&ItemList::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
+ ClassDB::bind_method(_MD("set_item_custom_bg_color","idx","custom_bg_color"),&ItemList::set_item_custom_bg_color);
+ ClassDB::bind_method(_MD("get_item_custom_bg_color","idx"),&ItemList::get_item_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
+ ClassDB::bind_method(_MD("set_item_tooltip_enabled","idx","enable"),&ItemList::set_item_tooltip_enabled);
+ ClassDB::bind_method(_MD("is_item_tooltip_enabled","idx"),&ItemList::is_item_tooltip_enabled);
- ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
- ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
+ ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&ItemList::set_item_tooltip);
+ ClassDB::bind_method(_MD("get_item_tooltip","idx"),&ItemList::get_item_tooltip);
- ObjectTypeDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
- ObjectTypeDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
- ObjectTypeDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
+ ClassDB::bind_method(_MD("select","idx","single"),&ItemList::select,DEFVAL(true));
+ ClassDB::bind_method(_MD("unselect","idx"),&ItemList::unselect);
+ ClassDB::bind_method(_MD("is_selected","idx"),&ItemList::is_selected);
+ ClassDB::bind_method(_MD("get_selected_items"),&ItemList::get_selected_items);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
+ ClassDB::bind_method(_MD("get_item_count"),&ItemList::get_item_count);
+ ClassDB::bind_method(_MD("remove_item","idx"),&ItemList::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&ItemList::clear);
- ObjectTypeDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
+ ClassDB::bind_method(_MD("clear"),&ItemList::clear);
+ ClassDB::bind_method(_MD("sort_items_by_text"),&ItemList::sort_items_by_text);
- ObjectTypeDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
+ ClassDB::bind_method(_MD("set_fixed_column_width","width"),&ItemList::set_fixed_column_width);
+ ClassDB::bind_method(_MD("get_fixed_column_width"),&ItemList::get_fixed_column_width);
- ObjectTypeDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
- ObjectTypeDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
+ ClassDB::bind_method(_MD("set_same_column_width","enable"),&ItemList::set_same_column_width);
+ ClassDB::bind_method(_MD("is_same_column_width"),&ItemList::is_same_column_width);
- ObjectTypeDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
- ObjectTypeDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
+ ClassDB::bind_method(_MD("set_max_text_lines","lines"),&ItemList::set_max_text_lines);
+ ClassDB::bind_method(_MD("get_max_text_lines"),&ItemList::get_max_text_lines);
- ObjectTypeDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
- ObjectTypeDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
+ ClassDB::bind_method(_MD("set_max_columns","amount"),&ItemList::set_max_columns);
+ ClassDB::bind_method(_MD("get_max_columns"),&ItemList::get_max_columns);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
- ObjectTypeDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
+ ClassDB::bind_method(_MD("set_select_mode","mode"),&ItemList::set_select_mode);
+ ClassDB::bind_method(_MD("get_select_mode"),&ItemList::get_select_mode);
- ObjectTypeDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
- ObjectTypeDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
+ ClassDB::bind_method(_MD("set_icon_mode","mode"),&ItemList::set_icon_mode);
+ ClassDB::bind_method(_MD("get_icon_mode"),&ItemList::get_icon_mode);
- ObjectTypeDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
+ ClassDB::bind_method(_MD("set_fixed_icon_size","size"),&ItemList::set_fixed_icon_size);
+ ClassDB::bind_method(_MD("get_fixed_icon_size"),&ItemList::get_fixed_icon_size);
- ObjectTypeDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
- ObjectTypeDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
+ ClassDB::bind_method(_MD("set_icon_scale","scale"),&ItemList::set_icon_scale);
+ ClassDB::bind_method(_MD("get_icon_scale"),&ItemList::get_icon_scale);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
+ ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&ItemList::set_allow_rmb_select);
+ ClassDB::bind_method(_MD("get_allow_rmb_select"),&ItemList::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_item_at_pos","pos","exact"),&ItemList::get_item_at_pos,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
+ ClassDB::bind_method(_MD("ensure_current_is_visible"),&ItemList::ensure_current_is_visible);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&ItemList::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ItemList::_input_event);
+ ClassDB::bind_method(_MD("_scroll_changed"),&ItemList::_scroll_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&ItemList::_gui_input);
BIND_CONSTANT( ICON_MODE_TOP );
BIND_CONSTANT( ICON_MODE_LEFT );
@@ -1372,6 +1371,8 @@ void ItemList::_bind_methods(){
ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::VECTOR2,"atpos")));
ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::BOOL,"selected")));
ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
+
+ GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000);
}
ItemList::ItemList() {
@@ -1400,6 +1401,7 @@ ItemList::ItemList() {
allow_rmb_select=false;
icon_scale = 1.0f;
+ set_clip_contents(true);
}
ItemList::~ItemList() {
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index cb5908bc79..f4a864c782 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class ItemList : public Control {
- OBJ_TYPE( ItemList, Control );
+ GDCLASS( ItemList, Control );
public:
enum IconMode {
@@ -102,7 +102,7 @@ private:
real_t icon_scale;
void _scroll_changed(double);
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
protected:
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index ec89b7b690..cd500a62bc 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -68,10 +68,18 @@ int Label::get_line_height() const {
void Label::_notification(int p_what) {
+ if (p_what==NOTIFICATION_TRANSLATION_CHANGED) {
+
+ xl_text=XL_MESSAGE(text);
+ minimum_size_changed();
+ update();
+ }
+
if (p_what==NOTIFICATION_DRAW) {
- if (clip || autowrap)
+ if (clip || autowrap) {
VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
+ }
if (word_cache_dirty)
regenerate_word_cache();
@@ -85,7 +93,7 @@ void Label::_notification(int p_what) {
Ref<Font> font = get_font("font");
Color font_color = get_color("font_color");
Color font_color_shadow = get_color("font_color_shadow");
- bool use_outlinde = get_constant("shadow_as_outline");
+ bool use_outline = get_constant("shadow_as_outline");
Point2 shadow_ofs(get_constant("shadow_offset_x"),get_constant("shadow_offset_y"));
int line_spacing = get_constant("line_spacing");
@@ -118,19 +126,19 @@ void Label::_notification(int p_what) {
//nothing
} break;
case VALIGN_CENTER: {
- vbegin=(size.y - lines_visible * font_h) / 2;
+ vbegin=(size.y - (lines_visible * font_h - line_spacing)) / 2;
vsep=0;
} break;
case VALIGN_BOTTOM: {
- vbegin=size.y - lines_visible * font_h;
+ vbegin=size.y - (lines_visible * font_h - line_spacing);
vsep=0;
} break;
case VALIGN_FILL: {
vbegin=0;
if (lines_visible>1) {
- vsep=(size.y - lines_visible * font_h) / (lines_visible - 1);
+ vsep=(size.y - (lines_visible * font_h - line_spacing)) / (lines_visible - 1);
} else {
vsep=0;
}
@@ -239,15 +247,15 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total_shadow<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
}
float move=font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+shadow_ofs, c, n,font_color_shadow );
- if (use_outlinde) {
+ if (use_outline) {
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
font->draw_char(ci, Point2( x_ofs_shadow, y_ofs )+Vector2(-shadow_ofs.x,-shadow_ofs.y), c, n,font_color_shadow );
@@ -262,8 +270,8 @@ void Label::_notification(int p_what) {
for (int i=0;i<from->word_len;i++) {
if (visible_chars < 0 || chars_total<visible_chars) {
- CharType c = text[i+pos];
- CharType n = text[i+pos+1];
+ CharType c = xl_text[i+pos];
+ CharType n = xl_text[i+pos+1];
if (uppercase) {
c=String::char_uppercase(c);
n=String::char_uppercase(c);
@@ -318,9 +326,9 @@ int Label::get_longest_line_width() const {
int max_line_width=0;
int line_width=0;
- for (int i=0;i<text.size();i++) {
+ for (int i=0;i<xl_text.size();i++) {
- CharType current=text[i];
+ CharType current=xl_text[i];
if (uppercase)
current=String::char_uppercase(current);
@@ -334,7 +342,7 @@ int Label::get_longest_line_width() const {
}
} else {
- int char_width=font->get_char_size(current,text[i+1]).width;
+ int char_width=font->get_char_size(current,xl_text[i+1]).width;
line_width+=char_width;
}
@@ -395,9 +403,9 @@ void Label::regenerate_word_cache() {
WordCache *last=NULL;
- for (int i=0;i<text.size()+1;i++) {
+ for (int i=0;i<xl_text.size()+1;i++) {
- CharType current=i<text.length()?text[i]:' '; //always a space at the end, so the algo works
+ CharType current=i<xl_text.length()?xl_text[i]:' '; //always a space at the end, so the algo works
if (uppercase)
current=String::char_uppercase(current);
@@ -437,7 +445,7 @@ void Label::regenerate_word_cache() {
total_char_cache++;
}
- if (i<text.length() && text[i] == ' ') {
+ if (i<xl_text.length() && xl_text[i] == ' ') {
total_char_cache--; // do not count spaces
if (line_width > 0 || last==NULL || last->char_pos!=WordCache::CHAR_WRAPLINE) {
space_count++;
@@ -454,7 +462,7 @@ void Label::regenerate_word_cache() {
word_pos=i;
}
- char_width=font->get_char_size(current,text[i+1]).width;
+ char_width=font->get_char_size(current,xl_text[i+1]).width;
current_word_size+=char_width;
line_width+=char_width;
total_char_cache++;
@@ -540,12 +548,11 @@ Label::VAlign Label::get_valign() const{
void Label::set_text(const String& p_string) {
- String str = XL_MESSAGE(p_string);
- if (text==str)
+ if (text==p_string)
return;
-
- text=str;
+ text=p_string;
+ xl_text=XL_MESSAGE(p_string);
word_cache_dirty=true;
if (percent_visible<1)
visible_chars=get_total_character_count()*percent_visible;
@@ -641,30 +648,30 @@ int Label::get_total_character_count() const {
void Label::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_align","align"),&Label::set_align);
- ObjectTypeDB::bind_method(_MD("get_align"),&Label::get_align);
- ObjectTypeDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
- ObjectTypeDB::bind_method(_MD("get_valign"),&Label::get_valign);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&Label::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&Label::get_text);
- ObjectTypeDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
- ObjectTypeDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
- ObjectTypeDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
- ObjectTypeDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
- ObjectTypeDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
- ObjectTypeDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
- ObjectTypeDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
- ObjectTypeDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
- ObjectTypeDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
- ObjectTypeDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
- ObjectTypeDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
- ObjectTypeDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
+ ClassDB::bind_method(_MD("set_align","align"),&Label::set_align);
+ ClassDB::bind_method(_MD("get_align"),&Label::get_align);
+ ClassDB::bind_method(_MD("set_valign","valign"),&Label::set_valign);
+ ClassDB::bind_method(_MD("get_valign"),&Label::get_valign);
+ ClassDB::bind_method(_MD("set_text","text"),&Label::set_text);
+ ClassDB::bind_method(_MD("get_text"),&Label::get_text);
+ ClassDB::bind_method(_MD("set_autowrap","enable"),&Label::set_autowrap);
+ ClassDB::bind_method(_MD("has_autowrap"),&Label::has_autowrap);
+ ClassDB::bind_method(_MD("set_clip_text","enable"),&Label::set_clip_text);
+ ClassDB::bind_method(_MD("is_clipping_text"),&Label::is_clipping_text);
+ ClassDB::bind_method(_MD("set_uppercase","enable"),&Label::set_uppercase);
+ ClassDB::bind_method(_MD("is_uppercase"),&Label::is_uppercase);
+ ClassDB::bind_method(_MD("get_line_height"),&Label::get_line_height);
+ ClassDB::bind_method(_MD("get_line_count"),&Label::get_line_count);
+ ClassDB::bind_method(_MD("get_visible_line_count"),&Label::get_visible_line_count);
+ ClassDB::bind_method(_MD("get_total_character_count"),&Label::get_total_character_count);
+ ClassDB::bind_method(_MD("set_visible_characters","amount"),&Label::set_visible_characters);
+ ClassDB::bind_method(_MD("get_visible_characters"),&Label::get_visible_characters);
+ ClassDB::bind_method(_MD("set_percent_visible","percent_visible"),&Label::set_percent_visible);
+ ClassDB::bind_method(_MD("get_percent_visible"),&Label::get_percent_visible);
+ ClassDB::bind_method(_MD("set_lines_skipped","lines_skipped"),&Label::set_lines_skipped);
+ ClassDB::bind_method(_MD("get_lines_skipped"),&Label::get_lines_skipped);
+ ClassDB::bind_method(_MD("set_max_lines_visible","lines_visible"),&Label::set_max_lines_visible);
+ ClassDB::bind_method(_MD("get_max_lines_visible"),&Label::get_max_lines_visible);
BIND_CONSTANT( ALIGN_LEFT );
BIND_CONSTANT( ALIGN_CENTER );
@@ -692,14 +699,14 @@ Label::Label(const String &p_text) {
align=ALIGN_LEFT;
valign=VALIGN_TOP;
- text="";
+ xl_text="";
word_cache=NULL;
word_cache_dirty=true;
autowrap=false;
line_count=0;
set_v_size_flags(0);
clip=false;
- set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
total_char_cache=0;
visible_chars=-1;
percent_visible=1;
diff --git a/scene/gui/label.h b/scene/gui/label.h
index b472eca1a2..80e4c970f6 100644
--- a/scene/gui/label.h
+++ b/scene/gui/label.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
*/
class Label : public Control {
- OBJ_TYPE( Label, Control );
+ GDCLASS( Label, Control );
public:
enum Align {
@@ -58,6 +58,7 @@ private:
Align align;
VAlign valign;
String text;
+ String xl_text;
bool autowrap;
bool clip;
Size2 minsize;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 90a8af9238..3a72e0e445 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ static bool _is_text_char(CharType c) {
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
}
-void LineEdit::_input_event(InputEvent p_event) {
+void LineEdit::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -96,8 +96,6 @@ void LineEdit::_input_event(InputEvent p_event) {
}
}
- // if (!editable)
- // non_editable_clicked_signal.call();
update();
} else {
@@ -551,8 +549,8 @@ void LineEdit::_notification(int p_what) {
#ifdef TOOLS_ENABLED
case NOTIFICATION_ENTER_TREE: {
if (get_tree()->is_editor_hint()) {
- cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
- cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
+ cursor_set_blink_enabled(EDITOR_DEF("text_editor/cursor/caret_blink", false));
+ cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65));
if (!EditorSettings::get_singleton()->is_connected("settings_changed",this,"_editor_settings_changed")) {
EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed");
@@ -639,6 +637,7 @@ void LineEdit::_notification(int p_what) {
if(text.empty())
font_color.a *= placeholder_alpha;
+ int caret_height = font->get_height() > y_area ? y_area : font->get_height();
while(true) {
//end of string, break!
@@ -657,14 +656,14 @@ void LineEdit::_notification(int p_what) {
bool selected=selection.enabled && char_ofs>=selection.begin && char_ofs<selection.end;
if (selected)
- VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, y_area)), selection_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(char_width, caret_height)), selection_color);
font->draw_char(ci, Point2(x_ofs, y_ofs + font_ascent), cchar, next, selected ? font_color_selected : font_color);
if (char_ofs==cursor_pos && draw_caret) {
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
x_ofs+=char_width;
@@ -673,7 +672,7 @@ void LineEdit::_notification(int p_what) {
if (char_ofs==cursor_pos && draw_caret) {//may be at the end
VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(
- Point2( x_ofs , y_ofs ), Size2( 1, y_area ) ), cursor_color );
+ Point2( x_ofs , y_ofs ), Size2( 1, caret_height ) ), cursor_color );
}
} break;
case NOTIFICATION_FOCUS_ENTER: {
@@ -852,7 +851,7 @@ void LineEdit::_reset_caret_blink_timer() {
void LineEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -872,7 +871,7 @@ void LineEdit::delete_char() {
if (cursor_pos==window_pos) {
- // set_window_pos(cursor_pos-get_window_length());
+ //set_window_pos(cursor_pos-get_window_length());
}
_text_changed();
@@ -917,6 +916,7 @@ void LineEdit::set_text(String p_text) {
update();
cursor_pos=0;
window_pos=0;
+ _text_changed();
}
void LineEdit::clear() {
@@ -1191,24 +1191,28 @@ void LineEdit::menu_option(int p_option) {
switch(p_option) {
case MENU_CUT: {
- cut_text();
+ if (editable) {
+ cut_text();
+ }
} break;
case MENU_COPY: {
copy_text();
} break;
case MENU_PASTE: {
-
- paste_text();
+ if (editable) {
+ paste_text();
+ }
} break;
case MENU_CLEAR: {
- clear();
+ if (editable) {
+ clear();
+ }
} break;
case MENU_SELECT_ALL: {
select_all();
} break;
case MENU_UNDO: {
-
undo();
} break;
@@ -1222,8 +1226,8 @@ PopupMenu *LineEdit::get_menu() const {
#ifdef TOOLS_ENABLED
void LineEdit::_editor_settings_changed() {
- cursor_set_blink_enabled(EDITOR_DEF("text_editor/caret_blink", false));
- cursor_set_blink_speed(EDITOR_DEF("text_editor/caret_blink_speed", 0.65));
+ cursor_set_blink_enabled(EDITOR_DEF("text_editor/cursor/caret_blink", false));
+ cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65));
}
#endif
@@ -1252,42 +1256,42 @@ void LineEdit::_text_changed() {
void LineEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
+ ClassDB::bind_method(_MD("_toggle_draw_caret"),&LineEdit::_toggle_draw_caret);
#ifdef TOOLS_ENABLED
- ObjectTypeDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
+ ClassDB::bind_method("_editor_settings_changed",&LineEdit::_editor_settings_changed);
#endif
- ObjectTypeDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
- ObjectTypeDB::bind_method(_MD("get_align"), &LineEdit::get_align);
-
- ObjectTypeDB::bind_method(_MD("_input_event"),&LineEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("clear"),&LineEdit::clear);
- ObjectTypeDB::bind_method(_MD("select_all"),&LineEdit::select_all);
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LineEdit::get_text);
- ObjectTypeDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
- ObjectTypeDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
- ObjectTypeDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
- ObjectTypeDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
- ObjectTypeDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
- ObjectTypeDB::bind_method(_MD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
- ObjectTypeDB::bind_method(_MD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
- ObjectTypeDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
- ObjectTypeDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
- ObjectTypeDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
- ObjectTypeDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
- ObjectTypeDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
- ObjectTypeDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
- ObjectTypeDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
+ ClassDB::bind_method(_MD("set_align", "align"), &LineEdit::set_align);
+ ClassDB::bind_method(_MD("get_align"), &LineEdit::get_align);
+
+ ClassDB::bind_method(_MD("_gui_input"),&LineEdit::_gui_input);
+ ClassDB::bind_method(_MD("clear"),&LineEdit::clear);
+ ClassDB::bind_method(_MD("select_all"),&LineEdit::select_all);
+ ClassDB::bind_method(_MD("set_text","text"),&LineEdit::set_text);
+ ClassDB::bind_method(_MD("get_text"),&LineEdit::get_text);
+ ClassDB::bind_method(_MD("set_placeholder","text"),&LineEdit::set_placeholder);
+ ClassDB::bind_method(_MD("get_placeholder"),&LineEdit::get_placeholder);
+ ClassDB::bind_method(_MD("set_placeholder_alpha","alpha"),&LineEdit::set_placeholder_alpha);
+ ClassDB::bind_method(_MD("get_placeholder_alpha"),&LineEdit::get_placeholder_alpha);
+ ClassDB::bind_method(_MD("set_cursor_pos","pos"),&LineEdit::set_cursor_pos);
+ ClassDB::bind_method(_MD("get_cursor_pos"),&LineEdit::get_cursor_pos);
+ ClassDB::bind_method(_MD("set_expand_to_text_length","enabled"),&LineEdit::set_expand_to_text_length);
+ ClassDB::bind_method(_MD("get_expand_to_text_length"),&LineEdit::get_expand_to_text_length);
+ ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enabled"),&LineEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&LineEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&LineEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(_MD("cursor_get_blink_speed"),&LineEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(_MD("set_max_length","chars"),&LineEdit::set_max_length);
+ ClassDB::bind_method(_MD("get_max_length"),&LineEdit::get_max_length);
+ ClassDB::bind_method(_MD("append_at_cursor","text"),&LineEdit::append_at_cursor);
+ ClassDB::bind_method(_MD("set_editable","enabled"),&LineEdit::set_editable);
+ ClassDB::bind_method(_MD("is_editable"),&LineEdit::is_editable);
+ ClassDB::bind_method(_MD("set_secret","enabled"),&LineEdit::set_secret);
+ ClassDB::bind_method(_MD("is_secret"),&LineEdit::is_secret);
+ ClassDB::bind_method(_MD("select","from","to"),&LineEdit::select,DEFVAL(0),DEFVAL(-1));
+ ClassDB::bind_method(_MD("menu_option","option"),&LineEdit::menu_option);
+ ClassDB::bind_method(_MD("get_menu:PopupMenu"),&LineEdit::get_menu);
ADD_SIGNAL( MethodInfo("text_changed", PropertyInfo( Variant::STRING, "text" )) );
ADD_SIGNAL( MethodInfo("text_entered", PropertyInfo( Variant::STRING, "text" )) );
@@ -1306,16 +1310,18 @@ void LineEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "text" ), _SCS("set_text"),_SCS("get_text") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder/text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
- ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder/alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), _SCS("set_align"), _SCS("get_align"));
ADD_PROPERTYNZ( PropertyInfo( Variant::INT, "max_length" ), _SCS("set_max_length"),_SCS("get_max_length") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "editable" ), _SCS("set_editable"),_SCS("is_editable") );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "secret" ), _SCS("set_secret"),_SCS("is_secret") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "expand_to_len" ), _SCS("set_expand_to_text_length"),_SCS("get_expand_to_text_length") );
ADD_PROPERTY( PropertyInfo( Variant::INT,"focus_mode", PROPERTY_HINT_ENUM, "None,Click,All" ), _SCS("set_focus_mode"), _SCS("get_focus_mode") );
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+ ADD_GROUP("Placeholder","placeholder_");
+ ADD_PROPERTYNZ( PropertyInfo( Variant::STRING, "placeholder_text" ), _SCS("set_placeholder"),_SCS("get_placeholder") );
+ ADD_PROPERTYNZ( PropertyInfo( Variant::REAL, "placeholder_alpha",PROPERTY_HINT_RANGE,"0,1,0.001" ), _SCS("set_placeholder_alpha"),_SCS("get_placeholder_alpha") );
+ ADD_GROUP("Caret","caret_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
}
LineEdit::LineEdit() {
@@ -1333,7 +1339,7 @@ LineEdit::LineEdit() {
set_focus_mode( FOCUS_ALL );
editable=true;
set_default_cursor_shape(CURSOR_IBEAM);
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
draw_caret=true;
caret_blink_enabled=false;
@@ -1353,7 +1359,7 @@ LineEdit::LineEdit() {
menu->add_item(TTR("Clear"),MENU_CLEAR);
menu->add_separator();
menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
+ menu->connect("id_pressed",this,"menu_option");
expand_to_text_length=false;
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index 47d5706bbe..64c37861d0 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class LineEdit : public Control {
- OBJ_TYPE( LineEdit, Control );
+ GDCLASS( LineEdit, Control );
public:
enum Align {
@@ -119,7 +119,7 @@ private:
void _editor_settings_changed();
#endif
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
diff --git a/scene/gui/link_button.cpp b/scene/gui/link_button.cpp
index 62829fd5a4..5b791064a8 100644
--- a/scene/gui/link_button.cpp
+++ b/scene/gui/link_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -87,13 +87,13 @@ void LinkButton::_notification(int p_what) {
else
color=get_color("font_color");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_HOVER: {
color=get_color("font_color_hover");
- do_underline=true;
+ do_underline=underline_mode!=UNDERLINE_MODE_NEVER;
} break;
case DRAW_DISABLED: {
@@ -130,18 +130,19 @@ void LinkButton::_notification(int p_what) {
void LinkButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
- ObjectTypeDB::bind_method(_MD("get_text"),&LinkButton::get_text);
+ ClassDB::bind_method(_MD("set_text","text"),&LinkButton::set_text);
+ ClassDB::bind_method(_MD("get_text"),&LinkButton::get_text);
- ObjectTypeDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
- ObjectTypeDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
+ ClassDB::bind_method(_MD("set_underline_mode","underline_mode"),&LinkButton::set_underline_mode);
+ ClassDB::bind_method(_MD("get_underline_mode"),&LinkButton::get_underline_mode);
BIND_CONSTANT( UNDERLINE_MODE_ALWAYS );
BIND_CONSTANT( UNDERLINE_MODE_ON_HOVER );
+ BIND_CONSTANT( UNDERLINE_MODE_NEVER );
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING,"text"), _SCS("set_text"), _SCS("get_text"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::INT,"underline",PROPERTY_HINT_ENUM,"Always,On Hover,Never"), _SCS("set_underline_mode"), _SCS("get_underline_mode"));
}
diff --git a/scene/gui/link_button.h b/scene/gui/link_button.h
index 9978f66cc0..42d7c05cff 100644
--- a/scene/gui/link_button.h
+++ b/scene/gui/link_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,12 +35,13 @@
class LinkButton : public BaseButton {
- OBJ_TYPE( LinkButton, BaseButton );
+ GDCLASS( LinkButton, BaseButton );
public:
enum UnderlineMode {
UNDERLINE_MODE_ALWAYS,
- UNDERLINE_MODE_ON_HOVER
+ UNDERLINE_MODE_ON_HOVER,
+ UNDERLINE_MODE_NEVER
};
private:
String text;
diff --git a/scene/gui/margin_container.cpp b/scene/gui/margin_container.cpp
index 5f798f445c..be27c40117 100644
--- a/scene/gui/margin_container.cpp
+++ b/scene/gui/margin_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,7 +45,7 @@ Size2 MarginContainer::get_minimum_size() const {
continue;
if (c->is_set_as_toplevel())
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 s = c->get_combined_minimum_size();
diff --git a/scene/gui/margin_container.h b/scene/gui/margin_container.h
index df9a5c9361..542578dd01 100644
--- a/scene/gui/margin_container.h
+++ b/scene/gui/margin_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/gui/container.h"
class MarginContainer : public Container {
- OBJ_TYPE(MarginContainer,Container);
+ GDCLASS(MarginContainer,Container);
protected:
void _notification(int p_what);
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 725f1ddf17..4a366c55c6 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,16 +34,14 @@
void MenuButton::_unhandled_key_input(InputEvent p_event) {
- if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYSTICK_BUTTON)) {
+ if (p_event.is_pressed() && !p_event.is_echo() && (p_event.type==InputEvent::KEY || p_event.type==InputEvent::ACTION || p_event.type==InputEvent::JOYPAD_BUTTON)) {
- if (!get_parent() || !is_visible() || is_disabled())
+ if (!get_parent() || !is_visible_in_tree() || is_disabled())
return;
- if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
- return; //ignore because of modal window
+ bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
-
- if (popup->activate_item_by_event(p_event))
+ if (popup->activate_item_by_event(p_event,global_only))
accept_event();
}
}
@@ -64,12 +62,12 @@ void MenuButton::pressed() {
}
-void MenuButton::_input_event(InputEvent p_event) {
+void MenuButton::_gui_input(InputEvent p_event) {
/*if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) {
clicked=p_event.mouse_button.pressed;
}
- if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible()) {
+ if (clicked && p_event.type==InputEvent::MOUSE_MOTION && popup->is_visible_in_tree()) {
Point2 gt = Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
gt = get_global_transform().xform(gt);
@@ -81,7 +79,7 @@ void MenuButton::_input_event(InputEvent p_event) {
}*/
- BaseButton::_input_event(p_event);
+ BaseButton::_gui_input(p_event);
}
PopupMenu *MenuButton::get_popup() {
@@ -100,10 +98,10 @@ void MenuButton::_set_items(const Array& p_items) {
void MenuButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
- ObjectTypeDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
- ObjectTypeDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
+ ClassDB::bind_method(_MD("get_popup:PopupMenu"),&MenuButton::get_popup);
+ ClassDB::bind_method(_MD("_unhandled_key_input"),&MenuButton::_unhandled_key_input);
+ ClassDB::bind_method(_MD("_set_items"),&MenuButton::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&MenuButton::_get_items);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
@@ -119,7 +117,7 @@ MenuButton::MenuButton() {
add_child(popup);
popup->set_as_toplevel(true);
set_process_unhandled_key_input(true);
- set_click_on_press(true);
+ set_action_mode(ACTION_MODE_BUTTON_PRESS);
}
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 650e4aba5c..5b5573456f 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class MenuButton : public Button {
- OBJ_TYPE( MenuButton, Button );
+ GDCLASS( MenuButton, Button );
bool clicked;
PopupMenu *popup;
@@ -46,7 +46,7 @@ class MenuButton : public Button {
Array _get_items() const;
void _set_items(const Array& p_items);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
protected:
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 587a68ae37..1b5b21ae92 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -287,32 +287,32 @@ void OptionButton::get_translatable_strings(List<String> *p_strings) const {
void OptionButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_selected"),&OptionButton::_selected);
-
- ObjectTypeDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
- ObjectTypeDB::bind_method(_MD("clear"),&OptionButton::clear);
- ObjectTypeDB::bind_method(_MD("select","idx"),&OptionButton::select);
- ObjectTypeDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
- ObjectTypeDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
- ObjectTypeDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
-
- ObjectTypeDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
+ ClassDB::bind_method(_MD("_selected"),&OptionButton::_selected);
+
+ ClassDB::bind_method(_MD("add_item","label","id"),&OptionButton::add_item,DEFVAL(-1));
+ ClassDB::bind_method(_MD("add_icon_item","texture:Texture","label","id"),&OptionButton::add_icon_item);
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&OptionButton::set_item_text);
+ ClassDB::bind_method(_MD("set_item_icon","idx","texture:Texture"),&OptionButton::set_item_icon);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&OptionButton::set_item_disabled);
+ ClassDB::bind_method(_MD("set_item_ID","idx","id"),&OptionButton::set_item_ID);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&OptionButton::set_item_metadata);
+ ClassDB::bind_method(_MD("get_item_text","idx"),&OptionButton::get_item_text);
+ ClassDB::bind_method(_MD("get_item_icon:Texture","idx"),&OptionButton::get_item_icon);
+ ClassDB::bind_method(_MD("get_item_ID","idx"),&OptionButton::get_item_ID);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&OptionButton::get_item_metadata);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&OptionButton::is_item_disabled);
+ ClassDB::bind_method(_MD("get_item_count"),&OptionButton::get_item_count);
+ ClassDB::bind_method(_MD("add_separator"),&OptionButton::add_separator);
+ ClassDB::bind_method(_MD("clear"),&OptionButton::clear);
+ ClassDB::bind_method(_MD("select","idx"),&OptionButton::select);
+ ClassDB::bind_method(_MD("get_selected"),&OptionButton::get_selected);
+ ClassDB::bind_method(_MD("get_selected_ID"),&OptionButton::get_selected_ID);
+ ClassDB::bind_method(_MD("get_selected_metadata"),&OptionButton::get_selected_metadata);
+ ClassDB::bind_method(_MD("remove_item","idx"),&OptionButton::remove_item);
+ ClassDB::bind_method(_MD("_select_int"),&OptionButton::_select_int);
+
+ ClassDB::bind_method(_MD("_set_items"),&OptionButton::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&OptionButton::_get_items);
ADD_PROPERTY( PropertyInfo(Variant::INT,"selected"), _SCS("_select_int"),_SCS("get_selected") );
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
@@ -326,7 +326,7 @@ OptionButton::OptionButton() {
popup->hide();
popup->set_as_toplevel(true);
add_child(popup);
- popup->connect("item_pressed", this,"_selected");
+ popup->connect("id_pressed", this,"_selected");
current=-1;
set_text_align(ALIGN_LEFT);
diff --git a/scene/gui/option_button.h b/scene/gui/option_button.h
index 70ebc66a46..681cb5a088 100644
--- a/scene/gui/option_button.h
+++ b/scene/gui/option_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class OptionButton : public Button {
- OBJ_TYPE( OptionButton, Button );
+ GDCLASS( OptionButton, Button );
PopupMenu *popup;
int current;
diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp
index 682ea5b92c..c4b7199c3e 100644
--- a/scene/gui/panel.cpp
+++ b/scene/gui/panel.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -41,7 +41,7 @@ void Panel::_notification(int p_what) {
Panel::Panel() {
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
}
diff --git a/scene/gui/panel.h b/scene/gui/panel.h
index 9e2e7df7f0..34c73960e7 100644
--- a/scene/gui/panel.h
+++ b/scene/gui/panel.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
*/
class Panel : public Control{
- OBJ_TYPE(Panel,Control);
+ GDCLASS(Panel,Control);
protected:
void _notification(int p_what);
diff --git a/scene/gui/panel_container.cpp b/scene/gui/panel_container.cpp
index b5e3ef8c7b..48270d12c7 100644
--- a/scene/gui/panel_container.cpp
+++ b/scene/gui/panel_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -43,7 +43,7 @@ Size2 PanelContainer::get_minimum_size() const {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -98,7 +98,7 @@ void PanelContainer::_notification(int p_what) {
for(int i=0;i<get_child_count();i++) {
Control *c = get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
diff --git a/scene/gui/panel_container.h b/scene/gui/panel_container.h
index a40519c9f2..86f390fdf3 100644
--- a/scene/gui/panel_container.h
+++ b/scene/gui/panel_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class PanelContainer : public Container {
- OBJ_TYPE( PanelContainer, Container );
+ GDCLASS( PanelContainer, Container );
protected:
diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_rect.cpp
index 9ad6398359..4e1856778e 100644
--- a/scene/gui/patch_9_frame.cpp
+++ b/scene/gui/patch_9_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* patch_9_frame.cpp */
+/* patch_9_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,11 +26,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "patch_9_frame.h"
+#include "patch_9_rect.h"
#include "servers/visual_server.h"
-void Patch9Frame::_notification(int p_what) {
+void NinePatchRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -39,8 +39,8 @@ void Patch9Frame::_notification(int p_what) {
Size2 s=get_size();
RID ci = get_canvas_item();
- VS::get_singleton()->canvas_item_add_style_box(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate);
-// draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center);
+ //draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
/*
Vector<Point2> points;
@@ -61,68 +61,59 @@ void Patch9Frame::_notification(int p_what) {
}
}
-Size2 Patch9Frame::get_minimum_size() const {
+Size2 NinePatchRect::get_minimum_size() const {
return Size2(margin[MARGIN_LEFT]+margin[MARGIN_RIGHT],margin[MARGIN_TOP]+margin[MARGIN_BOTTOM]);
}
-void Patch9Frame::_bind_methods() {
+void NinePatchRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & Patch9Frame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & Patch9Frame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & Patch9Frame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & Patch9Frame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_patch_margin","margin","value"), & Patch9Frame::set_patch_margin );
- ObjectTypeDB::bind_method(_MD("get_patch_margin","margin"), & Patch9Frame::get_patch_margin );
- ObjectTypeDB::bind_method(_MD("set_region_rect","rect"),&Patch9Frame::set_region_rect);
- ObjectTypeDB::bind_method(_MD("get_region_rect"),&Patch9Frame::get_region_rect);
- ObjectTypeDB::bind_method(_MD("set_draw_center","draw_center"), & Patch9Frame::set_draw_center );
- ObjectTypeDB::bind_method(_MD("get_draw_center"), & Patch9Frame::get_draw_center );
+ ClassDB::bind_method(_MD("set_texture","texture"), & NinePatchRect::set_texture );
+ ClassDB::bind_method(_MD("get_texture"), & NinePatchRect::get_texture );
+ ClassDB::bind_method(_MD("set_patch_margin","margin","value"), & NinePatchRect::set_patch_margin );
+ ClassDB::bind_method(_MD("get_patch_margin","margin"), & NinePatchRect::get_patch_margin );
+ ClassDB::bind_method(_MD("set_region_rect","rect"),&NinePatchRect::set_region_rect);
+ ClassDB::bind_method(_MD("get_region_rect"),&NinePatchRect::get_region_rect);
+ ClassDB::bind_method(_MD("set_draw_center","draw_center"), & NinePatchRect::set_draw_center );
+ ClassDB::bind_method(_MD("get_draw_center"), & NinePatchRect::get_draw_center );
ADD_SIGNAL(MethodInfo("texture_changed"));
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "draw_center"), _SCS("set_draw_center"),_SCS("get_draw_center") );
ADD_PROPERTYNZ( PropertyInfo( Variant::RECT2, "region_rect"), _SCS("set_region_rect"),_SCS("get_region_rect"));
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
- ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin/bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
+
+ ADD_GROUP("Patch Margin","patch_margin_");
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_left",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_LEFT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_top",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_TOP );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_right",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_RIGHT );
+ ADD_PROPERTYINZ( PropertyInfo( Variant::INT, "patch_margin_bottom",PROPERTY_HINT_RANGE,"0,16384,1"), _SCS("set_patch_margin"),_SCS("get_patch_margin"),MARGIN_BOTTOM );
}
-void Patch9Frame::set_texture(const Ref<Texture>& p_tex) {
+void NinePatchRect::set_texture(const Ref<Texture>& p_tex) {
if (texture==p_tex)
return;
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
emit_signal("texture_changed");
}
-Ref<Texture> Patch9Frame::get_texture() const {
+Ref<Texture> NinePatchRect::get_texture() const {
return texture;
}
-void Patch9Frame::set_modulate(const Color& p_tex) {
-
- modulate=p_tex;
- update();
-}
-
-Color Patch9Frame::get_modulate() const{
-
- return modulate;
-}
-void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
+void NinePatchRect::set_patch_margin(Margin p_margin,int p_size) {
ERR_FAIL_INDEX(p_margin,4);
margin[p_margin]=p_size;
@@ -144,13 +135,13 @@ void Patch9Frame::set_patch_margin(Margin p_margin,int p_size) {
}
}
-int Patch9Frame::get_patch_margin(Margin p_margin) const{
+int NinePatchRect::get_patch_margin(Margin p_margin) const{
ERR_FAIL_INDEX_V(p_margin,4,0);
return margin[p_margin];
}
-void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
+void NinePatchRect::set_region_rect(const Rect2& p_region_rect) {
if (region_rect==p_region_rect)
return;
@@ -161,35 +152,35 @@ void Patch9Frame::set_region_rect(const Rect2& p_region_rect) {
_change_notify("region_rect");
}
-Rect2 Patch9Frame::get_region_rect() const {
+Rect2 NinePatchRect::get_region_rect() const {
return region_rect;
}
-void Patch9Frame::set_draw_center(bool p_draw) {
+void NinePatchRect::set_draw_center(bool p_draw) {
draw_center=p_draw;
update();
}
-bool Patch9Frame::get_draw_center() const{
+bool NinePatchRect::get_draw_center() const{
return draw_center;
}
-Patch9Frame::Patch9Frame() {
+NinePatchRect::NinePatchRect() {
margin[MARGIN_LEFT]=0;
margin[MARGIN_RIGHT]=0;
margin[MARGIN_BOTTOM]=0;
margin[MARGIN_TOP]=0;
- modulate=Color(1,1,1,1);
- set_ignore_mouse(true);
+
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
draw_center=true;
}
-Patch9Frame::~Patch9Frame()
+NinePatchRect::~NinePatchRect()
{
}
diff --git a/scene/gui/patch_9_frame.h b/scene/gui/patch_9_rect.h
index 7763db567a..b87f2f64ec 100644
--- a/scene/gui/patch_9_frame.h
+++ b/scene/gui/patch_9_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* patch_9_frame.h */
+/* patch_9_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,14 +33,13 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Patch9Frame : public Control {
+class NinePatchRect : public Control {
- OBJ_TYPE(Patch9Frame,Control);
+ GDCLASS(NinePatchRect,Control);
bool draw_center;
int margin[4];
Rect2 region_rect;
- Color modulate;
Ref<Texture> texture;
protected:
@@ -53,9 +52,6 @@ public:
void set_texture(const Ref<Texture>& p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
- Color get_modulate() const;
-
void set_patch_margin(Margin p_margin,int p_size);
int get_patch_margin(Margin p_margin) const;
@@ -65,8 +61,8 @@ public:
void set_draw_center(bool p_enable);
bool get_draw_center() const;
- Patch9Frame();
- ~Patch9Frame();
+ NinePatchRect();
+ ~NinePatchRect();
};
#endif // PATCH_9_FRAME_H
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 5b83c3f8b8..3f0f76f184 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,7 +31,7 @@
-void Popup::_input_event(InputEvent p_event) {
+void Popup::_gui_input(InputEvent p_event) {
}
@@ -39,7 +39,7 @@ void Popup::_input_event(InputEvent p_event) {
void Popup::_notification(int p_what) {
if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
- if (popped_up && !is_visible()) {
+ if (popped_up && !is_visible_in_tree()) {
popped_up=false;
notification(NOTIFICATION_POPUP_HIDE);
emit_signal("popup_hide");
@@ -103,7 +103,7 @@ void Popup::set_as_minsize() {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -144,7 +144,7 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
Control *c=get_child(i)->cast_to<Control>();
if (!c)
continue;
- if (c->is_hidden())
+ if (!c->is_visible())
continue;
Size2 minsize = c->get_combined_minimum_size();
@@ -257,15 +257,16 @@ bool Popup::is_exclusive() const {
void Popup::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
- ObjectTypeDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
- ObjectTypeDB::bind_method(_MD("popup"),&Popup::popup);
- ObjectTypeDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
- ObjectTypeDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
+ ClassDB::bind_method(_MD("popup_centered","size"),&Popup::popup_centered,DEFVAL(Size2()));
+ ClassDB::bind_method(_MD("popup_centered_ratio","ratio"),&Popup::popup_centered_ratio,DEFVAL(0.75));
+ ClassDB::bind_method(_MD("popup_centered_minsize","minsize"),&Popup::popup_centered_minsize,DEFVAL(Size2()));
+ ClassDB::bind_method(_MD("popup"),&Popup::popup);
+ ClassDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
+ ClassDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
ADD_SIGNAL( MethodInfo("about_to_show") );
ADD_SIGNAL( MethodInfo("popup_hide") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup/exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
+ ADD_GROUP("Popup","popup_");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup_exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
@@ -282,7 +283,7 @@ Popup::Popup() {
String Popup::get_configuration_warning() const {
- if (is_visible()) {
+ if (is_visible_in_tree()) {
return TTR("Popups will hide by default unless you call popup() or any of the popup*() functions. Making them visible for editing is fine though, but they will hide upon running.");
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index dccaf2ae69..17ae4a938a 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
*/
class Popup : public Control {
- OBJ_TYPE( Popup, Control );
+ GDCLASS( Popup, Control );
bool exclusive;
bool popped_up;
@@ -45,7 +45,7 @@ protected:
virtual void _post_popup() {}
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
void _fix_size();
static void _bind_methods();
@@ -74,7 +74,7 @@ public:
class PopupPanel : public Popup {
- OBJ_TYPE(PopupPanel,Popup);
+ GDCLASS(PopupPanel,Popup);
protected:
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index b3f18bf8fa..65e7c3ab39 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -89,12 +89,14 @@ Size2 PopupMenu::get_minimum_size() const {
size.height=font_h;
}
+ size.width+=items[i].h_ofs;
+
if (items[i].checkable) {
size.width+=check_w+hseparation;
}
- String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
size.width+=font->get_string_size(text).width;
if (i>0)
size.height+=vseparation;
@@ -106,6 +108,7 @@ Size2 PopupMenu::get_minimum_size() const {
accel_max_w = MAX( accel_w, accel_max_w );
}
+
minsize.height+=size.height;
max_w = MAX( max_w, size.width );
@@ -133,7 +136,7 @@ int PopupMenu::_get_mouse_over(const Point2& p_over) const {
Ref<Font> font = get_font("font");
int vseparation = get_constant("vseparation");
-// int hseparation = get_constant("hseparation");
+ //int hseparation = get_constant("hseparation");
float font_h=font->get_height();
@@ -171,7 +174,7 @@ void PopupMenu::_activate_submenu(int over) {
Popup *pm = n->cast_to<Popup>();
ERR_EXPLAIN("item subnode is not a Popup: "+items[over].submenu);
ERR_FAIL_COND(!pm);
- if (pm->is_visible())
+ if (pm->is_visible_in_tree())
return; //already visible!
@@ -212,7 +215,7 @@ void PopupMenu::_submenu_timeout() {
}
-void PopupMenu::_input_event(const InputEvent &p_event) {
+void PopupMenu::_gui_input(const InputEvent &p_event) {
switch( p_event.type) {
@@ -305,7 +308,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
ie.type=InputEvent::MOUSE_MOTION;
ie.mouse_motion.x=b.x;
ie.mouse_motion.y=b.y+s;
- _input_event(ie);
+ _gui_input(ie);
}
} break;
case BUTTON_WHEEL_UP: {
@@ -325,7 +328,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
ie.type=InputEvent::MOUSE_MOTION;
ie.mouse_motion.x=b.x;
ie.mouse_motion.y=b.y-s;
- _input_event(ie);
+ _gui_input(ie);
}
@@ -418,7 +421,16 @@ void PopupMenu::_notification(int p_what) {
switch(p_what) {
+ case NOTIFICATION_TRANSLATION_CHANGED: {
+
+ for(int i=0;i<items.size();i++) {
+ items[i].xl_text=XL_MESSAGE(items[i].text);
+ }
+
+ minimum_size_changed();
+ update();
+ } break;
case NOTIFICATION_DRAW: {
RID ci = get_canvas_item();
@@ -450,6 +462,7 @@ void PopupMenu::_notification(int p_what) {
float h;
Size2 icon_size;
+ item_ofs.x+=items[i].h_ofs;
if (!items[i].icon.is_null()) {
icon_size = items[i].icon->get_size();
@@ -461,13 +474,13 @@ void PopupMenu::_notification(int p_what) {
if (i==mouse_over) {
- hover->draw(ci, Rect2( ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
+ hover->draw(ci, Rect2( item_ofs+Point2(-hseparation,-vseparation), Size2( get_size().width - style->get_minimum_size().width + hseparation*2, h+vseparation*2 ) ));
}
if (items[i].separator) {
int sep_h=separator->get_center_size().height+separator->get_minimum_size().height;
- separator->draw(ci, Rect2( ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
+ separator->draw(ci, Rect2( item_ofs+Point2(0,Math::floor((h-sep_h)/2.0)), Size2( get_size().width - style->get_minimum_size().width , sep_h ) ));
}
@@ -492,7 +505,7 @@ void PopupMenu::_notification(int p_what) {
}
item_ofs.y+=font->get_ascent();
- String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].text;
+ String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
if (!items[i].separator) {
font->draw(ci,item_ofs+Point2(0,Math::floor((h-font_h)/2.0)),text,items[i].disabled?font_color_disabled:(i==mouse_over?font_color_hover:font_color));
@@ -533,6 +546,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
Item item;
item.icon=p_icon;
item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
items.push_back(item);
@@ -541,7 +555,8 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
items.push_back(item);
@@ -551,7 +566,8 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,int p_ID){
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.ID=p_ID;
item.submenu=p_submenu;
items.push_back(item);
@@ -562,7 +578,8 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
Item item;
item.icon=p_icon;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
item.checkable=true;
@@ -572,7 +589,8 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
- item.text=XL_MESSAGE(p_label);
+ item.text=p_label;
+ item.xl_text=XL_MESSAGE(p_label);
item.accel=p_accel;
item.ID=p_ID;
item.checkable=true;
@@ -581,7 +599,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
}
-void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID) {
+void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon, const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global) {
ERR_FAIL_COND(p_shortcut.is_null());
@@ -591,12 +609,13 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>
item.ID=p_ID;
item.icon=p_icon;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -605,11 +624,12 @@ void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon, const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -620,11 +640,12 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<Sho
item.shortcut=p_shortcut;
item.checkable=true;
item.icon=p_icon;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -633,6 +654,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
item.checkable=true;
items.push_back(item);
update();
@@ -641,7 +663,8 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
void PopupMenu::set_item_text(int p_idx,const String& p_text) {
ERR_FAIL_INDEX(p_idx,items.size());
- items[p_idx].text=XL_MESSAGE(p_text);
+ items[p_idx].text=p_text;
+ items[p_idx].xl_text=XL_MESSAGE(p_text);
update();
@@ -701,6 +724,13 @@ void PopupMenu::set_item_submenu(int p_idx, const String& p_submenu) {
update();
}
+void PopupMenu::toggle_item_checked(int p_idx) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].checked = !items[p_idx].checked;
+ update();
+}
+
String PopupMenu::get_item_text(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),"");
@@ -804,12 +834,14 @@ void PopupMenu::set_item_tooltip(int p_idx,const String& p_tooltip) {
update();
}
-void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
+void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut, bool p_global) {
ERR_FAIL_INDEX(p_idx,items.size());
if (items[p_idx].shortcut.is_valid()) {
_unref_shortcut(items[p_idx].shortcut);
}
items[p_idx].shortcut=p_shortcut;
+ items[p_idx].shortcut_is_global=p_global;
+
if (items[p_idx].shortcut.is_valid()) {
_ref_shortcut(items[p_idx].shortcut);
@@ -819,6 +851,15 @@ void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
update();
}
+void PopupMenu::set_item_h_offset(int p_idx, int p_offset) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].h_ofs=p_offset;
+ update();
+
+}
+
+
bool PopupMenu::is_item_checkable(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),false);
return items[p_idx].checkable;
@@ -829,7 +870,7 @@ int PopupMenu::get_item_count() const {
return items.size();
}
-bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
+bool PopupMenu::activate_item_by_event(const InputEvent& p_event, bool p_for_global_only) {
uint32_t code=0;
if (p_event.type==InputEvent::KEY) {
@@ -853,7 +894,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
continue;
- if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event)) {
+ if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
activate_item(i);
return true;
}
@@ -872,7 +913,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
if(!pm)
continue;
- if(pm->activate_item_by_event(p_event)) {
+ if(pm->activate_item_by_event(p_event,p_for_global_only)) {
return true;
}
}
@@ -886,17 +927,31 @@ void PopupMenu::activate_item(int p_item) {
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_COND(items[p_item].separator);
int id = items[p_item].ID>=0?items[p_item].ID:p_item;
- emit_signal("item_pressed",id);
+ emit_signal("id_pressed",id);
+ emit_signal("index_pressed",p_item);
//hide all parent PopupMenue's
Node *next = get_parent();
PopupMenu *pop = next->cast_to<PopupMenu>();
while (pop) {
- pop->hide();
- next = next->get_parent();
- pop = next->cast_to<PopupMenu>();
+ // We close all parents that are chained together,
+ // with hide_on_item_selection enabled
+ if(hide_on_item_selection && pop->is_hide_on_item_selection()) {
+ pop->hide();
+ next = next->get_parent();
+ pop = next->cast_to<PopupMenu>();
+ }
+ else {
+ // Break out of loop when the next parent has
+ // hide_on_item_selection disabled
+ break;
+ }
+ }
+ // Hides popup by default; unless otherwise specified
+ // by using set_hide_on_item_selection
+ if (hide_on_item_selection) {
+ hide();
}
- hide();
}
@@ -1012,6 +1067,16 @@ void PopupMenu::_set_items(const Array& p_items){
}
+// Hide on item selection determines whether or not the popup will close after item selection
+void PopupMenu::set_hide_on_item_selection(bool p_enabled) {
+
+ hide_on_item_selection=p_enabled;
+}
+
+bool PopupMenu::is_hide_on_item_selection() {
+
+ return hide_on_item_selection;
+}
String PopupMenu::get_tooltip(const Point2& p_pos) const {
@@ -1032,8 +1097,8 @@ void PopupMenu::get_translatable_strings(List<String> *p_strings) const {
for(int i=0;i<items.size();i++) {
- if (items[i].text!="")
- p_strings->push_back(items[i].text);
+ if (items[i].xl_text!="")
+ p_strings->push_back(items[i].xl_text);
}
}
@@ -1049,55 +1114,67 @@ void PopupMenu::clear_autohide_areas(){
void PopupMenu::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&PopupMenu::_input_event);
- ObjectTypeDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
- ObjectTypeDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
-
- ObjectTypeDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
-
-
- ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
- ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
- ObjectTypeDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
- ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
- ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
- ObjectTypeDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
- ObjectTypeDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
- ObjectTypeDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
- ObjectTypeDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
- ObjectTypeDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
- ObjectTypeDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
- ObjectTypeDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
- ObjectTypeDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
- ObjectTypeDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
- ObjectTypeDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
- ObjectTypeDB::bind_method(_MD("clear"),&PopupMenu::clear);
-
- ObjectTypeDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
- ObjectTypeDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
-
- ObjectTypeDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
+ ClassDB::bind_method(_MD("_gui_input"),&PopupMenu::_gui_input);
+ ClassDB::bind_method(_MD("add_icon_item","texture","label","id","accel"),&PopupMenu::add_icon_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_item","label","id","accel"),&PopupMenu::add_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_icon_check_item","texture","label","id","accel"),&PopupMenu::add_icon_check_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
+ ClassDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
+
+ ClassDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_check_shortcut,DEFVAL(-1),DEFVAL(false));
+
+ ClassDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
+ ClassDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
+ ClassDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
+ ClassDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
+ ClassDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
+ ClassDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
+ ClassDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
+ ClassDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
+ ClassDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
+ ClassDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
+ ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
+ ClassDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut","global"),&PopupMenu::set_item_shortcut,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
+
+ ClassDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
+ ClassDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
+ ClassDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
+ ClassDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
+ ClassDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
+ ClassDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
+ ClassDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ClassDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
+ ClassDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
+ ClassDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
+ ClassDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
+ ClassDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
+ ClassDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+
+ ClassDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
+
+ ClassDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
+
+ ClassDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
+ ClassDB::bind_method(_MD("clear"),&PopupMenu::clear);
+
+ ClassDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
+ ClassDB::bind_method(_MD("_get_items"),&PopupMenu::_get_items);
+
+ ClassDB::bind_method(_MD("set_hide_on_item_selection","enable"),&PopupMenu::set_hide_on_item_selection);
+ ClassDB::bind_method(_MD("is_hide_on_item_selection"),&PopupMenu::is_hide_on_item_selection);
+
+ ClassDB::bind_method(_MD("_submenu_timeout"),&PopupMenu::_submenu_timeout);
ADD_PROPERTY( PropertyInfo(Variant::ARRAY,"items",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR), _SCS("_set_items"),_SCS("_get_items") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::BOOL, "hide_on_item_selection" ), _SCS("set_hide_on_item_selection"), _SCS("is_hide_on_item_selection") );
- ADD_SIGNAL( MethodInfo("item_pressed", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_SIGNAL( MethodInfo("id_pressed", PropertyInfo( Variant::INT,"ID") ) );
+ ADD_SIGNAL( MethodInfo("index_pressed", PropertyInfo( Variant::INT,"index") ) );
}
@@ -1114,6 +1191,7 @@ PopupMenu::PopupMenu() {
set_focus_mode(FOCUS_ALL);
set_as_toplevel(true);
+ set_hide_on_item_selection(true);
submenu_timer = memnew( Timer );
submenu_timer->set_wait_time(0.3);
@@ -1125,5 +1203,3 @@ PopupMenu::PopupMenu() {
PopupMenu::~PopupMenu() {
}
-
-
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index f35e91d4e4..b5fca9a451 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,11 +39,12 @@
class PopupMenu : public Popup {
- OBJ_TYPE(PopupMenu, Popup );
+ GDCLASS(PopupMenu, Popup );
struct Item {
Ref<Texture> icon;
String text;
+ String xl_text;
bool checked;
bool checkable;
bool separator;
@@ -54,9 +55,11 @@ class PopupMenu : public Popup {
String tooltip;
uint32_t accel;
int _ofs_cache;
+ int h_ofs;
Ref<ShortCut> shortcut;
+ bool shortcut_is_global;
- Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; }
+ Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; h_ofs=0; shortcut_is_global=false; }
};
@@ -69,11 +72,12 @@ class PopupMenu : public Popup {
String _get_accel_text(int p_item) const;
int _get_mouse_over(const Point2& p_over) const;
virtual Size2 get_minimum_size() const;
- void _input_event(const InputEvent &p_event);
+ void _gui_input(const InputEvent &p_event);
void _activate_submenu(int over);
void _submenu_timeout();
bool invalidated_click;
+ bool hide_on_item_selection;
Vector2 moved;
Array _get_items() const;
@@ -98,10 +102,10 @@ public:
void add_check_item(const String& p_label,int p_ID=-1,uint32_t p_accel=0);
void add_submenu_item(const String& p_label,const String& p_submenu, int p_ID=-1);
- void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
+ void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
void set_item_text(int p_idx,const String& p_text);
void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
@@ -114,7 +118,10 @@ public:
void set_item_as_separator(int p_idx, bool p_separator);
void set_item_as_checkable(int p_idx, bool p_checkable);
void set_item_tooltip(int p_idx,const String& p_tooltip);
- void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut,bool p_global=false);
+ void set_item_h_offset(int p_idx, int p_offset);
+
+ void toggle_item_checked(int p_idx);
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
@@ -132,7 +139,7 @@ public:
int get_item_count() const;
- bool activate_item_by_event(const InputEvent& p_event);
+ bool activate_item_by_event(const InputEvent& p_event,bool p_for_global_only=false);
void activate_item(int p_item);
void remove_item(int p_idx);
@@ -151,6 +158,8 @@ public:
void clear_autohide_areas();
void set_invalidate_click_until_motion();
+ void set_hide_on_item_selection(bool p_enabled);
+ bool is_hide_on_item_selection();
PopupMenu();
~PopupMenu();
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 8af94c3638..0f99d4f19e 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -53,7 +53,7 @@ void ProgressBar::_notification(int p_what) {
Color font_color=get_color("font_color");
draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
+ float r = get_as_ratio();
int mp = fg->get_minimum_size().width;
int p = r*get_size().width-mp;
if (p>0) {
@@ -62,7 +62,7 @@ void ProgressBar::_notification(int p_what) {
}
if (percent_visible) {
- String txt=itos(int(get_unit_value()*100))+"%";
+ String txt=itos(int(get_as_ratio()*100))+"%";
font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
}
}
@@ -82,9 +82,10 @@ bool ProgressBar::is_percent_visible() const{
void ProgressBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
- ObjectTypeDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent/visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+ ClassDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
+ ClassDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
+ ADD_GROUP("Percent","percent_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent_visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
}
ProgressBar::ProgressBar() {
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index f50df346ac..01306a2ac4 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class ProgressBar : public Range {
- OBJ_TYPE( ProgressBar, Range );
+ GDCLASS( ProgressBar, Range );
bool percent_visible;
protected:
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index e056c55f71..d5c1034c9c 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -66,7 +66,7 @@ void Range::Shared::emit_changed(const char *p_what) {
}
-void Range::set_val(double p_val) {
+void Range::set_value(double p_val) {
if(_rounded_values){
p_val = Math::round(p_val);
@@ -88,14 +88,14 @@ void Range::set_val(double p_val) {
void Range::set_min(double p_min) {
shared->min=p_min;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/min");
}
void Range::set_max(double p_max) {
shared->max=p_max;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/max");
@@ -109,12 +109,12 @@ void Range::set_step(double p_step) {
void Range::set_page(double p_page) {
shared->page=p_page;
- set_val(shared->val);
+ set_value(shared->val);
shared->emit_changed("range/page");
}
-double Range::get_val() const {
+double Range::get_value() const {
return shared->val;
}
@@ -135,31 +135,40 @@ double Range::get_page() const {
return shared->page;
}
-void Range::set_unit_value(double p_value) {
- if (shared->exp_unit_value && get_min()>0) {
+void Range::set_as_ratio(double p_value) {
+
+ double v;
+
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
-
- set_val( v );
+ v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
} else {
- set_val( (get_max() - get_min()) * p_value + get_min() );
+
+ double percent = (get_max() - get_min()) * p_value;
+ if (get_step() > 0) {
+ double steps = round(percent / get_step());
+ v = steps * get_step() + get_min();
+ } else {
+ v = percent + get_min();
+ }
}
+ set_value( v );
}
-double Range::get_unit_value() const {
+double Range::get_as_ratio() const {
- if (shared->exp_unit_value && get_min()>0) {
+ if (shared->exp_ratio && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
- double v = Math::log(get_val())/Math::log(2);
+ double v = Math::log(get_value())/Math::log(2);
return (v - exp_min) / (exp_max - exp_min);
} else {
- return (get_val() - get_min()) / (get_max() - get_min());
+ return (get_value() - get_min()) / (get_max() - get_min());
}
}
@@ -213,59 +222,57 @@ void Range::_unref_shared() {
void Range::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("get_val"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_value"),&Range::get_val);
- ObjectTypeDB::bind_method(_MD("get_min"),&Range::get_min);
- ObjectTypeDB::bind_method(_MD("get_max"),&Range::get_max);
- ObjectTypeDB::bind_method(_MD("get_step"),&Range::get_step);
- ObjectTypeDB::bind_method(_MD("get_page"),&Range::get_page);
- ObjectTypeDB::bind_method(_MD("get_unit_value"),&Range::get_unit_value);
- ObjectTypeDB::bind_method(_MD("set_val","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_value","value"),&Range::set_val);
- ObjectTypeDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
- ObjectTypeDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
- ObjectTypeDB::bind_method(_MD("set_step","step"),&Range::set_step);
- ObjectTypeDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
- ObjectTypeDB::bind_method(_MD("set_unit_value","value"),&Range::set_unit_value);
- ObjectTypeDB::bind_method(_MD("set_rounded_values","enabled"),&Range::set_rounded_values);
- ObjectTypeDB::bind_method(_MD("is_rounded_values"),&Range::is_rounded_values);
- ObjectTypeDB::bind_method(_MD("set_exp_unit_value","enabled"),&Range::set_exp_unit_value);
- ObjectTypeDB::bind_method(_MD("is_unit_value_exp"),&Range::is_unit_value_exp);
-
- ObjectTypeDB::bind_method(_MD("share","with"),&Range::_share);
- ObjectTypeDB::bind_method(_MD("unshare"),&Range::unshare);
+ ClassDB::bind_method(_MD("get_value"),&Range::get_value);
+ ClassDB::bind_method(_MD("get_min"),&Range::get_min);
+ ClassDB::bind_method(_MD("get_max"),&Range::get_max);
+ ClassDB::bind_method(_MD("get_step"),&Range::get_step);
+ ClassDB::bind_method(_MD("get_page"),&Range::get_page);
+ ClassDB::bind_method(_MD("get_as_ratio"),&Range::get_as_ratio);
+ ClassDB::bind_method(_MD("set_value","value"),&Range::set_value);
+ ClassDB::bind_method(_MD("set_min","minimum"),&Range::set_min);
+ ClassDB::bind_method(_MD("set_max","maximum"),&Range::set_max);
+ ClassDB::bind_method(_MD("set_step","step"),&Range::set_step);
+ ClassDB::bind_method(_MD("set_page","pagesize"),&Range::set_page);
+ ClassDB::bind_method(_MD("set_as_ratio","value"),&Range::set_as_ratio);
+ ClassDB::bind_method(_MD("set_use_rounded_values","enabled"),&Range::set_use_rounded_values);
+ ClassDB::bind_method(_MD("is_using_rounded_values"),&Range::is_using_rounded_values);
+ ClassDB::bind_method(_MD("set_exp_ratio","enabled"),&Range::set_exp_ratio);
+ ClassDB::bind_method(_MD("is_ratio_exp"),&Range::is_ratio_exp);
+
+ ClassDB::bind_method(_MD("share","with"),&Range::_share);
+ ClassDB::bind_method(_MD("unshare"),&Range::unshare);
ADD_SIGNAL( MethodInfo("value_changed", PropertyInfo(Variant::REAL,"value")));
ADD_SIGNAL( MethodInfo("changed"));
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/min" ), _SCS("set_min"), _SCS("get_min") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/max" ), _SCS("set_max"), _SCS("get_max") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/step" ), _SCS("set_step"), _SCS("get_step") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/page" ), _SCS("set_page"), _SCS("get_page") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "range/value" ), _SCS("set_val"), _SCS("get_val") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/exp_edit" ), _SCS("set_exp_unit_value"), _SCS("is_unit_value_exp") );
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "range/rounded" ), _SCS("set_rounded_values"), _SCS("is_rounded_values") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "min_value" ), _SCS("set_min"), _SCS("get_min") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "max_value" ), _SCS("set_max"), _SCS("get_max") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "step" ), _SCS("set_step"), _SCS("get_step") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "page" ), _SCS("set_page"), _SCS("get_page") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "value" ), _SCS("set_value"), _SCS("get_value") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "exp_edit" ), _SCS("set_exp_ratio"), _SCS("is_ratio_exp") );
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "rounded" ), _SCS("set_use_rounded_values"), _SCS("is_using_rounded_values") );
}
-void Range::set_rounded_values(bool p_enable) {
+void Range::set_use_rounded_values(bool p_enable) {
_rounded_values = p_enable;
}
-bool Range::is_rounded_values() const {
+bool Range::is_using_rounded_values() const {
return _rounded_values;
}
-void Range::set_exp_unit_value(bool p_enable) {
+void Range::set_exp_ratio(bool p_enable) {
- shared->exp_unit_value=p_enable;
+ shared->exp_ratio=p_enable;
}
-bool Range::is_unit_value_exp() const {
+bool Range::is_ratio_exp() const {
- return shared->exp_unit_value;
+ return shared->exp_ratio;
}
@@ -278,7 +285,7 @@ Range::Range()
shared->step=1;
shared->page=0;
shared->owners.insert(this);
- shared->exp_unit_value=false;
+ shared->exp_ratio=false;
_rounded_values = false;
}
diff --git a/scene/gui/range.h b/scene/gui/range.h
index 85c3687b7d..5f274a6901 100644
--- a/scene/gui/range.h
+++ b/scene/gui/range.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,13 +35,13 @@
*/
class Range : public Control {
- OBJ_TYPE( Range, Control );
+ GDCLASS( Range, Control );
struct Shared {
double val,min,max;
double step,page;
- bool exp_unit_value;
+ bool exp_ratio;
Set<Range*> owners;
void emit_value_changed();
void emit_changed(const char *p_what="");
@@ -66,25 +66,25 @@ protected:
bool _rounded_values;
public:
- void set_val(double p_val);
+ void set_value(double p_val);
void set_min(double p_min);
void set_max(double p_max);
void set_step(double p_step);
void set_page(double p_page);
- void set_unit_value(double p_value);
+ void set_as_ratio(double p_value);
- double get_val() const;
+ double get_value() const;
double get_min() const;
double get_max() const;
double get_step() const;
double get_page() const;
- double get_unit_value() const;
+ double get_as_ratio() const;
- void set_rounded_values(bool p_enable);
- bool is_rounded_values() const;
+ void set_use_rounded_values(bool p_enable);
+ bool is_using_rounded_values() const;
- void set_exp_unit_value(bool p_enable);
- bool is_unit_value_exp() const;
+ void set_exp_ratio(bool p_enable);
+ bool is_ratio_exp() const;
void share(Range *p_range);
void unshare();
diff --git a/scene/gui/reference_frame.cpp b/scene/gui/reference_rect.cpp
index d037664a62..ff4cdf04fd 100644
--- a/scene/gui/reference_frame.cpp
+++ b/scene/gui/reference_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* reference_frame.cpp */
+/* reference_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,9 +26,9 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "reference_frame.h"
+#include "reference_rect.h"
-void ReferenceFrame::_notification(int p_what) {
+void ReferenceRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -39,6 +39,6 @@ void ReferenceFrame::_notification(int p_what) {
}
}
-ReferenceFrame::ReferenceFrame()
+ReferenceRect::ReferenceRect()
{
}
diff --git a/scene/gui/reference_frame.h b/scene/gui/reference_rect.h
index 5d3694e6e8..be493f346c 100644
--- a/scene/gui/reference_frame.h
+++ b/scene/gui/reference_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* reference_frame.h */
+/* reference_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,20 +26,20 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef REFERENCE_FRAME_H
-#define REFERENCE_FRAME_H
+#ifndef REFERENCE_RECT_H
+#define REFERENCE_RECT_H
#include "scene/gui/control.h"
-class ReferenceFrame : public Control {
+class ReferenceRect : public Control {
- OBJ_TYPE( ReferenceFrame, Control);
+ GDCLASS( ReferenceRect, Control);
protected:
void _notification(int p_what);
public:
- ReferenceFrame();
+ ReferenceRect();
};
-#endif // REFERENCE_FRAME_H
+#endif // REFERENCE_RECT_H
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 73a3cda5f3..434fb36e24 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -610,7 +610,7 @@ void RichTextLabel::_scroll_changed(double) {
if (updating_scroll)
return;
- if (scroll_follow && vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
+ if (scroll_follow && vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
scroll_following=true;
else
scroll_following=false;
@@ -687,15 +687,13 @@ void RichTextLabel::_notification(int p_what) {
RID ci=get_canvas_item();
Size2 size = get_size();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
-
if (has_focus()) {
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,true);
draw_style_box(get_stylebox("focus"),Rect2(Point2(),size));
VisualServer::get_singleton()->canvas_item_add_clip_ignore(ci,false);
}
- int ofs = vscroll->get_val();
+ int ofs = vscroll->get_value();
//todo, change to binary search
@@ -734,7 +732,7 @@ void RichTextLabel::_find_click(ItemFrame* p_frame,const Point2i& p_click,Item *
Size2 size = get_size();
- int ofs = vscroll->get_val();
+ int ofs = vscroll->get_value();
//todo, change to binary search
int from_line = 0;
@@ -789,7 +787,7 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2& p_pos) const
}
-void RichTextLabel::_input_event(InputEvent p_event) {
+void RichTextLabel::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -838,12 +836,12 @@ void RichTextLabel::_input_event(InputEvent p_event) {
if (b.button_index==BUTTON_WHEEL_UP) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()-vscroll->get_page()/8 );
+ vscroll->set_value( vscroll->get_value()-vscroll->get_page()/8 );
}
if (b.button_index==BUTTON_WHEEL_DOWN) {
if (scroll_active)
- vscroll->set_val( vscroll->get_val()+vscroll->get_page()/8 );
+ vscroll->set_value( vscroll->get_value()+vscroll->get_page()/8 );
}
} break;
case InputEvent::KEY: {
@@ -854,33 +852,33 @@ void RichTextLabel::_input_event(InputEvent p_event) {
switch(k.scancode) {
case KEY_PAGEUP: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - vscroll->get_page() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() - vscroll->get_page() );
} break;
case KEY_PAGEDOWN: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + vscroll->get_page() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() + vscroll->get_page() );
} break;
case KEY_UP: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() - get_font("normal_font")->get_height() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() - get_font("normal_font")->get_height() );
} break;
case KEY_DOWN: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_val() + get_font("normal_font")->get_height() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_value() + get_font("normal_font")->get_height() );
} break;
case KEY_HOME: {
- if (vscroll->is_visible())
- vscroll->set_val( 0 );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( 0 );
} break;
case KEY_END: {
- if (vscroll->is_visible())
- vscroll->set_val( vscroll->get_max() );
+ if (vscroll->is_visible_in_tree())
+ vscroll->set_value( vscroll->get_max() );
} break;
case KEY_INSERT:
case KEY_C: {
@@ -1113,7 +1111,7 @@ void RichTextLabel::_validate_line_caches(ItemFrame* p_frame) {
vscroll->set_max(total_height);
vscroll->set_page(size.height);
if (scroll_follow && scroll_following)
- vscroll->set_val(total_height-size.height);
+ vscroll->set_value(total_height-size.height);
updating_scroll=false;
@@ -1179,7 +1177,8 @@ void RichTextLabel::add_text(const String& p_text) {
item->line=current_frame->lines.size();
_add_item(item,false);
current_frame->lines.resize(current_frame->lines.size()+1);
- current_frame->lines[current_frame->lines.size()-1].from=item;
+ if (item->type!=ITEM_NEWLINE)
+ current_frame->lines[current_frame->lines.size()-1].from=item;
_invalidate_current_line(current_frame);
}
@@ -1410,7 +1409,7 @@ bool RichTextLabel::is_meta_underlined() const {
void RichTextLabel::set_offset(int p_pixel) {
- vscroll->set_val(p_pixel);
+ vscroll->set_value(p_pixel);
}
void RichTextLabel::set_scroll_active(bool p_active) {
@@ -1430,7 +1429,7 @@ bool RichTextLabel::is_scroll_active() const {
void RichTextLabel::set_scroll_follow(bool p_follow) {
scroll_follow=p_follow;
- if (!vscroll->is_visible() || vscroll->get_val()>=(vscroll->get_max()-vscroll->get_page()))
+ if (!vscroll->is_visible_in_tree() || vscroll->get_value()>=(vscroll->get_max()-vscroll->get_page()))
scroll_following=true;
}
@@ -1727,7 +1726,7 @@ void RichTextLabel::scroll_to_line(int p_line) {
ERR_FAIL_INDEX(p_line,main->lines.size());
_validate_line_caches(main);
- vscroll->set_val(main->lines[p_line].height_accum_cache-main->lines[p_line].height_cache);
+ vscroll->set_value(main->lines[p_line].height_accum_cache-main->lines[p_line].height_cache);
}
@@ -1794,7 +1793,7 @@ bool RichTextLabel::search(const String& p_string,bool p_from_selection) {
}
item=item->parent;
}
- vscroll->set_val(offset-fh);
+ vscroll->set_value(offset-fh);
return true;
}
@@ -1901,61 +1900,62 @@ String RichTextLabel::get_text() {
void RichTextLabel::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&RichTextLabel::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
- ObjectTypeDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
- ObjectTypeDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
- ObjectTypeDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
- ObjectTypeDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
- ObjectTypeDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
- ObjectTypeDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
- ObjectTypeDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
- ObjectTypeDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
- ObjectTypeDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
- ObjectTypeDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
- ObjectTypeDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
- ObjectTypeDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
- ObjectTypeDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
- ObjectTypeDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
- ObjectTypeDB::bind_method(_MD("pop"),&RichTextLabel::pop);
+ ClassDB::bind_method(_MD("_gui_input"),&RichTextLabel::_gui_input);
+ ClassDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
+ ClassDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
+ ClassDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
+ ClassDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
+ ClassDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
+ ClassDB::bind_method(_MD("push_font","font"),&RichTextLabel::push_font);
+ ClassDB::bind_method(_MD("push_color","color"),&RichTextLabel::push_color);
+ ClassDB::bind_method(_MD("push_align","align"),&RichTextLabel::push_align);
+ ClassDB::bind_method(_MD("push_indent","level"),&RichTextLabel::push_indent);
+ ClassDB::bind_method(_MD("push_list","type"),&RichTextLabel::push_list);
+ ClassDB::bind_method(_MD("push_meta","data"),&RichTextLabel::push_meta);
+ ClassDB::bind_method(_MD("push_underline"),&RichTextLabel::push_underline);
+ ClassDB::bind_method(_MD("push_table","columns"),&RichTextLabel::push_table);
+ ClassDB::bind_method(_MD("set_table_column_expand","column","expand","ratio"),&RichTextLabel::set_table_column_expand);
+ ClassDB::bind_method(_MD("push_cell"),&RichTextLabel::push_cell);
+ ClassDB::bind_method(_MD("pop"),&RichTextLabel::pop);
- ObjectTypeDB::bind_method(_MD("clear"),&RichTextLabel::clear);
+ ClassDB::bind_method(_MD("clear"),&RichTextLabel::clear);
- ObjectTypeDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
- ObjectTypeDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
+ ClassDB::bind_method(_MD("set_meta_underline","enable"),&RichTextLabel::set_meta_underline);
+ ClassDB::bind_method(_MD("is_meta_underlined"),&RichTextLabel::is_meta_underlined);
- ObjectTypeDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
- ObjectTypeDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
+ ClassDB::bind_method(_MD("set_scroll_active","active"),&RichTextLabel::set_scroll_active);
+ ClassDB::bind_method(_MD("is_scroll_active"),&RichTextLabel::is_scroll_active);
- ObjectTypeDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
- ObjectTypeDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
+ ClassDB::bind_method(_MD("set_scroll_follow","follow"),&RichTextLabel::set_scroll_follow);
+ ClassDB::bind_method(_MD("is_scroll_following"),&RichTextLabel::is_scroll_following);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&RichTextLabel::get_v_scroll);
- ObjectTypeDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
+ ClassDB::bind_method(_MD("scroll_to_line","line"),&RichTextLabel::scroll_to_line);
- ObjectTypeDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
- ObjectTypeDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
+ ClassDB::bind_method(_MD("set_tab_size","spaces"),&RichTextLabel::set_tab_size);
+ ClassDB::bind_method(_MD("get_tab_size"),&RichTextLabel::get_tab_size);
- ObjectTypeDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
- ObjectTypeDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
+ ClassDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
+ ClassDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
- ObjectTypeDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
- ObjectTypeDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
+ ClassDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
+ ClassDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
- ObjectTypeDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
- ObjectTypeDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
+ ClassDB::bind_method(_MD("set_bbcode","text"),&RichTextLabel::set_bbcode);
+ ClassDB::bind_method(_MD("get_bbcode"),&RichTextLabel::get_bbcode);
- ObjectTypeDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
+ ClassDB::bind_method(_MD("set_visible_characters","amount"),&RichTextLabel::set_visible_characters);
+ ClassDB::bind_method(_MD("get_visible_characters"),&RichTextLabel::get_visible_characters);
- ObjectTypeDB::bind_method(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
+ ClassDB::bind_method(_MD("get_total_character_count"),&RichTextLabel::get_total_character_count);
- ObjectTypeDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
- ObjectTypeDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
+ ClassDB::bind_method(_MD("set_use_bbcode","enable"),&RichTextLabel::set_use_bbcode);
+ ClassDB::bind_method(_MD("is_using_bbcode"),&RichTextLabel::is_using_bbcode);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode/enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
- ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode/bbcode",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
+ ADD_GROUP("BBCode","bbcode_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"bbcode_enabled"),_SCS("set_use_bbcode"),_SCS("is_using_bbcode"));
+ ADD_PROPERTY(PropertyInfo(Variant::STRING,"bbcode_text",PROPERTY_HINT_MULTILINE_TEXT),_SCS("set_bbcode"),_SCS("get_bbcode"));
ADD_PROPERTY(PropertyInfo(Variant::INT,"visible_characters",PROPERTY_HINT_RANGE,"-1,128000,1"),_SCS("set_visible_characters"),_SCS("get_visible_characters"));
ADD_SIGNAL( MethodInfo("meta_clicked",PropertyInfo(Variant::NIL,"meta")));
@@ -2044,6 +2044,7 @@ RichTextLabel::RichTextLabel() {
visible_characters=-1;
+ set_clip_contents(true);
}
RichTextLabel::~RichTextLabel() {
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 5147905a0e..39032185f8 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class RichTextLabel : public Control {
- OBJ_TYPE( RichTextLabel, Control );
+ GDCLASS( RichTextLabel, Control );
public:
enum Align {
@@ -267,7 +267,7 @@ private:
void _update_scroll();
void _scroll_changed(double);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
Item *_get_next_item(Item* p_item, bool p_free=false);
bool use_bbcode;
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index d8365feb24..fc406ff0f5 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
focus_by_default=p_can_focus;
}
-void ScrollBar::_input_event(InputEvent p_event) {
+void ScrollBar::_gui_input(InputEvent p_event) {
switch(p_event.type) {
@@ -51,20 +51,24 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (b.button_index==5 && b.pressed) {
- //if (orientation==VERTICAL)
- // set_val( get_val() + get_page() / 4.0 );
- //else
- set_val( get_val() + get_page() / 4.0 );
+ /*
+ if (orientation==VERTICAL)
+ set_val( get_val() + get_page() / 4.0 );
+ else
+ */
+ set_value( get_value() + get_page() / 4.0 );
accept_event();
}
if (b.button_index==4 && b.pressed) {
- //if (orientation==HORIZONTAL)
- // set_val( get_val() - get_page() / 4.0 );
- //else
- set_val( get_val() - get_page() / 4.0 );
+ /*
+ if (orientation==HORIZONTAL)
+ set_val( get_val() - get_page() / 4.0 );
+ else
+ */
+ set_value( get_value() - get_page() / 4.0 );
accept_event();
}
@@ -87,13 +91,13 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (ofs < decr_size ) {
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
break;
}
if (ofs > total-incr_size ) {
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
break;
}
@@ -101,7 +105,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
if ( ofs < grabber_ofs ) {
- set_val( get_val() - get_page() );
+ set_value( get_value() - get_page() );
break;
}
@@ -112,12 +116,12 @@ void ScrollBar::_input_event(InputEvent p_event) {
drag.active=true;
drag.pos_at_click=grabber_ofs+ofs;
- drag.value_at_click=get_unit_value();
+ drag.value_at_click=get_as_ratio();
update();
} else {
- set_val( get_val() + get_page() );
+ set_value( get_value() + get_page() );
}
@@ -145,7 +149,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
double diff = (ofs-drag.pos_at_click) / get_area_size();
- set_unit_value( drag.value_at_click + diff );
+ set_as_ratio( drag.value_at_click + diff );
} else {
@@ -194,14 +198,14 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_RIGHT: {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_UP: {
@@ -209,7 +213,7 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
} break;
@@ -217,17 +221,17 @@ void ScrollBar::_input_event(InputEvent p_event) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
} break;
case KEY_HOME: {
- set_val( get_min() );
+ set_value( get_min() );
} break;
case KEY_END: {
- set_val( get_max() );
+ set_value( get_max() );
} break;
@@ -302,8 +306,8 @@ void ScrollBar::_notification(int p_what) {
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("gui_input",this,"_drag_slave_input");
+ drag_slave->connect("tree_exited",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
}
@@ -311,8 +315,8 @@ void ScrollBar::_notification(int p_what) {
if (p_what==NOTIFICATION_EXIT_TREE) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
+ drag_slave->disconnect("tree_exited",this,"_drag_slave_exit");
}
drag_slave=NULL;
@@ -325,7 +329,7 @@ void ScrollBar::_notification(int p_what) {
if (drag_slave_touching_deaccel) {
- Vector2 pos = Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ Vector2 pos = Vector2(orientation==HORIZONTAL?get_value():0,orientation==VERTICAL?get_value():0);
pos+=drag_slave_speed*get_fixed_process_delta_time();
bool turnoff=false;
@@ -342,7 +346,7 @@ void ScrollBar::_notification(int p_what) {
turnoff=true;
}
- set_val(pos.x);
+ set_value(pos.x);
float sgn_x = drag_slave_speed.x<0? -1 : 1;
float val_x = Math::abs(drag_slave_speed.x);
@@ -367,7 +371,7 @@ void ScrollBar::_notification(int p_what) {
turnoff=true;
}
- set_val(pos.y);
+ set_value(pos.y);
float sgn_y = drag_slave_speed.y<0? -1 : 1;
float val_y = Math::abs(drag_slave_speed.y);
@@ -425,8 +429,10 @@ double ScrollBar::get_grabber_size() const {
return 0;
float page = (get_page()>0)? get_page() : 0;
-// if (grabber_range < get_step())
-// grabber_range=get_step();
+ /*
+ if (grabber_range < get_step())
+ grabber_range=get_step();
+ */
double area_size=get_area_size();
double grabber_size = page / range * area_size;
@@ -497,7 +503,7 @@ double ScrollBar::get_click_pos(const Point2& p_pos) const {
double ScrollBar::get_grabber_offset() const {
- return (get_area_size()) * get_unit_value();
+ return (get_area_size()) * get_as_ratio();
}
@@ -546,7 +552,7 @@ float ScrollBar::get_custom_step() const {
void ScrollBar::_drag_slave_exit() {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
}
drag_slave=NULL;
}
@@ -580,7 +586,7 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
drag_slave_accum=Vector2();
last_drag_slave_accum=Vector2();
//drag_slave_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
- drag_slave_from= Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ drag_slave_from= Vector2(orientation==HORIZONTAL?get_value():0,orientation==VERTICAL?get_value():0);
drag_slave_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_slave_touching_deaccel=false;
@@ -619,13 +625,17 @@ void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
Vector2 diff = drag_slave_from+drag_slave_accum;
if (orientation==HORIZONTAL)
- set_val(diff.x);
- //else
- // drag_slave_accum.x=0;
+ set_value(diff.x);
+ /*
+ else
+ drag_slave_accum.x=0;
+ */
if (orientation==VERTICAL)
- set_val(diff.y);
- //else
- // drag_slave_accum.y=0;
+ set_value(diff.y);
+ /*
+ else
+ drag_slave_accum.y=0;
+ */
time_since_motion=0;
}
@@ -638,8 +648,8 @@ void ScrollBar::set_drag_slave(const NodePath& p_path) {
if (is_inside_tree()) {
if (drag_slave) {
- drag_slave->disconnect("input_event",this,"_drag_slave_input");
- drag_slave->disconnect("exit_tree",this,"_drag_slave_exit");
+ drag_slave->disconnect("gui_input",this,"_drag_slave_input");
+ drag_slave->disconnect("tree_exited",this,"_drag_slave_exit");
}
}
@@ -654,8 +664,8 @@ void ScrollBar::set_drag_slave(const NodePath& p_path) {
}
if (drag_slave) {
- drag_slave->connect("input_event",this,"_drag_slave_input");
- drag_slave->connect("exit_tree",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ drag_slave->connect("gui_input",this,"_drag_slave_input");
+ drag_slave->connect("tree_exited",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
}
}
}
@@ -804,11 +814,11 @@ bool ScrollBar::key(unsigned long p_unicode, unsigned long p_scan_code,bool b.pr
void ScrollBar::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollBar::_input_event);
- ObjectTypeDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
- ObjectTypeDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
- ObjectTypeDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
- ObjectTypeDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
+ ClassDB::bind_method(_MD("_gui_input"),&ScrollBar::_gui_input);
+ ClassDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
+ ClassDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
+ ClassDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
+ ClassDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), _SCS("set_custom_step"),_SCS("get_custom_step"));
@@ -832,7 +842,7 @@ ScrollBar::ScrollBar(Orientation p_orientation)
if (focus_by_default)
set_focus_mode( FOCUS_ALL );
-
+ set_step(0);
}
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index c68db02b33..be8b394957 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
*/
class ScrollBar : public Range {
- OBJ_TYPE( ScrollBar, Range );
+ GDCLASS( ScrollBar, Range );
enum HiliteStatus {
HILITE_NONE,
@@ -87,7 +87,7 @@ class ScrollBar : public Range {
void _drag_slave_exit();
void _drag_slave_input(const InputEvent& p_input);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
protected:
void _notification(int p_what);
@@ -109,7 +109,7 @@ public:
class HScrollBar : public ScrollBar {
- OBJ_TYPE( HScrollBar, ScrollBar );
+ GDCLASS( HScrollBar, ScrollBar );
public:
HScrollBar() : ScrollBar(HORIZONTAL) { set_v_size_flags(0); }
@@ -117,7 +117,7 @@ public:
class VScrollBar : public ScrollBar {
- OBJ_TYPE( VScrollBar, ScrollBar );
+ GDCLASS( VScrollBar, ScrollBar );
public:
VScrollBar() : ScrollBar(VERTICAL) { set_h_size_flags(0); }
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 479bb96fe2..b3ed9b209a 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -59,10 +59,10 @@ Size2 ScrollContainer::get_minimum_size() const {
}
}
- if (h_scroll->is_visible()) {
+ if (h_scroll->is_visible_in_tree()) {
min_size.y+=h_scroll->get_minimum_size().y;
}
- if (v_scroll->is_visible()) {
+ if (v_scroll->is_visible_in_tree()) {
min_size.x+=v_scroll->get_minimum_size().x;
}
return min_size;
@@ -79,23 +79,31 @@ void ScrollContainer::_cancel_drag() {
drag_from=Vector2();
}
-void ScrollContainer::_input_event(const InputEvent& p_input_event) {
+void ScrollContainer::_gui_input(const InputEvent& p_gui_input) {
- switch(p_input_event.type) {
+ switch(p_gui_input.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb=p_gui_input.mouse_button;
- if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed && v_scroll->is_visible()) {
-
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ if (mb.button_index==BUTTON_WHEEL_UP && mb.pressed) {
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
+ // only horizontal is enabled, scroll horizontally
+ h_scroll->set_value( h_scroll->get_value()-h_scroll->get_page()/8 );
+ } else if (v_scroll->is_visible_in_tree()) {
+ v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 );
+ }
}
- if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed && v_scroll->is_visible()) {
-
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ if (mb.button_index==BUTTON_WHEEL_DOWN && mb.pressed) {
+ if (h_scroll->is_visible_in_tree() && !v_scroll->is_visible_in_tree()){
+ // only horizontal is enabled, scroll horizontally
+ h_scroll->set_value( h_scroll->get_value()+h_scroll->get_page()/8 );
+ } else if (v_scroll->is_visible_in_tree()) {
+ v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 );
+ }
}
if(!OS::get_singleton()->has_touchscreen_ui_hint())
@@ -120,7 +128,7 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
drag_speed=Vector2();
drag_accum=Vector2();
last_drag_accum=Vector2();
- drag_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
+ drag_from=Vector2(h_scroll->get_value(),v_scroll->get_value());
drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel=false;
time_since_motion=0;
@@ -150,7 +158,7 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm=p_gui_input.mouse_motion;
if (drag_touching && ! drag_touching_deaccel) {
@@ -159,11 +167,11 @@ void ScrollContainer::_input_event(const InputEvent& p_input_event) {
Vector2 diff = drag_from+drag_accum;
if (scroll_h)
- h_scroll->set_val(diff.x);
+ h_scroll->set_value(diff.x);
else
drag_accum.x=0;
if (scroll_v)
- v_scroll->set_val(diff.y);
+ v_scroll->set_value(diff.y);
else
drag_accum.y=0;
time_since_motion=0;
@@ -208,10 +216,10 @@ void ScrollContainer::_notification(int p_what) {
child_max_size = Size2(0, 0);
Size2 size = get_size();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
size.y-=h_scroll->get_minimum_size().y;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
size.x-=h_scroll->get_minimum_size().x;
for(int i=0;i<get_child_count();i++) {
@@ -228,14 +236,14 @@ void ScrollContainer::_notification(int p_what) {
child_max_size.y = MAX(child_max_size.y, minsize.y);
Rect2 r = Rect2(-scroll,minsize);
- if (!(scroll_h || h_scroll->is_visible())) {
+ if (!(scroll_h || h_scroll->is_visible_in_tree())) {
r.pos.x=0;
if (c->get_h_size_flags()&SIZE_EXPAND)
r.size.width=MAX(size.width,minsize.width);
else
r.size.width=minsize.width;
}
- if (!(scroll_v || v_scroll->is_visible())) {
+ if (!(scroll_v || v_scroll->is_visible_in_tree())) {
r.pos.y=0;
r.size.height=size.height;
if (c->get_v_size_flags()&SIZE_EXPAND)
@@ -253,7 +261,6 @@ void ScrollContainer::_notification(int p_what) {
update_scrollbars();
- VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true);
}
if (p_what==NOTIFICATION_FIXED_PROCESS) {
@@ -262,7 +269,7 @@ void ScrollContainer::_notification(int p_what) {
if (drag_touching_deaccel) {
- Vector2 pos = Vector2(h_scroll->get_val(),v_scroll->get_val());
+ Vector2 pos = Vector2(h_scroll->get_value(),v_scroll->get_value());
pos+=drag_speed*get_fixed_process_delta_time();
bool turnoff_h=false;
@@ -287,9 +294,9 @@ void ScrollContainer::_notification(int p_what) {
}
if (scroll_h)
- h_scroll->set_val(pos.x);
+ h_scroll->set_value(pos.x);
if (scroll_v)
- v_scroll->set_val(pos.y);
+ v_scroll->set_value(pos.y);
float sgn_x = drag_speed.x<0? -1 : 1;
float val_x = Math::abs(drag_speed.x);
@@ -351,7 +358,7 @@ void ScrollContainer::update_scrollbars() {
} else {
v_scroll->show();
- scroll.y=v_scroll->get_val();
+ scroll.y=v_scroll->get_value();
}
@@ -368,14 +375,14 @@ void ScrollContainer::update_scrollbars() {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- scroll.x=h_scroll->get_val();
+ scroll.x=h_scroll->get_value();
}
}
void ScrollContainer::_scroll_moved(float) {
- scroll.x=h_scroll->get_val();
- scroll.y=v_scroll->get_val();
+ scroll.x=h_scroll->get_value();
+ scroll.y=v_scroll->get_value();
queue_sort();
update();
@@ -407,42 +414,66 @@ bool ScrollContainer::is_v_scroll_enabled() const{
int ScrollContainer::get_v_scroll() const {
- return v_scroll->get_val();
+ return v_scroll->get_value();
}
void ScrollContainer::set_v_scroll(int p_pos) {
- v_scroll->set_val(p_pos);
+ v_scroll->set_value(p_pos);
_cancel_drag();
}
int ScrollContainer::get_h_scroll() const {
- return h_scroll->get_val();
+ return h_scroll->get_value();
}
void ScrollContainer::set_h_scroll(int p_pos) {
- h_scroll->set_val(p_pos);
+ h_scroll->set_value(p_pos);
_cancel_drag();
}
+String ScrollContainer::get_configuration_warning() const {
+
+ int found=0;
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Control *c = get_child(i)->cast_to<Control>();
+ if (!c)
+ continue;
+ if (c->is_set_as_toplevel())
+ continue;
+ if (c == h_scroll || c == v_scroll)
+ continue;
+
+ found++;
+ }
+
+ if (found!=1)
+ return TTR("ScrollContainer is intended to work with a single child control.\nUse a container as child (VBox,HBox,etc), or a Control and set the custom minimum size manually.");
+ else
+ return "";
+}
+
void ScrollContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
- ObjectTypeDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
- ObjectTypeDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
- ObjectTypeDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
- ObjectTypeDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
- ObjectTypeDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
- ObjectTypeDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
- ObjectTypeDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
-
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
- ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll/vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
+ ClassDB::bind_method(_MD("_scroll_moved"),&ScrollContainer::_scroll_moved);
+ ClassDB::bind_method(_MD("_gui_input"),&ScrollContainer::_gui_input);
+ ClassDB::bind_method(_MD("set_enable_h_scroll","enable"),&ScrollContainer::set_enable_h_scroll);
+ ClassDB::bind_method(_MD("is_h_scroll_enabled"),&ScrollContainer::is_h_scroll_enabled);
+ ClassDB::bind_method(_MD("set_enable_v_scroll","enable"),&ScrollContainer::set_enable_v_scroll);
+ ClassDB::bind_method(_MD("is_v_scroll_enabled"),&ScrollContainer::is_v_scroll_enabled);
+ ClassDB::bind_method(_MD("_update_scrollbar_pos"),&ScrollContainer::_update_scrollbar_pos);
+ ClassDB::bind_method(_MD("set_h_scroll","val"),&ScrollContainer::set_h_scroll);
+ ClassDB::bind_method(_MD("get_h_scroll"),&ScrollContainer::get_h_scroll);
+ ClassDB::bind_method(_MD("set_v_scroll","val"),&ScrollContainer::set_v_scroll);
+ ClassDB::bind_method(_MD("get_v_scroll"),&ScrollContainer::get_v_scroll);
+
+ ADD_GROUP("Scroll","scroll_");
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_horizontal"), _SCS("set_enable_h_scroll"),_SCS("is_h_scroll_enabled"));
+ ADD_PROPERTY( PropertyInfo( Variant::BOOL, "scroll_vertical"), _SCS("set_enable_v_scroll"),_SCS("is_v_scroll_enabled"));
};
@@ -465,6 +496,6 @@ ScrollContainer::ScrollContainer() {
scroll_h=true;
scroll_v=true;
-
+ set_clip_contents(true);
};
diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h
index 50ae236714..114cd06306 100644
--- a/scene/gui/scroll_container.h
+++ b/scene/gui/scroll_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class ScrollContainer : public Container {
- OBJ_TYPE(ScrollContainer, Container);
+ GDCLASS(ScrollContainer, Container);
HScrollBar* h_scroll;
VScrollBar* v_scroll;
@@ -64,7 +64,7 @@ protected:
Size2 get_minimum_size() const;
- void _input_event(const InputEvent& p_input_event);
+ void _gui_input(const InputEvent& p_gui_input);
void _notification(int p_what);
void _scroll_moved(float);
@@ -86,6 +86,9 @@ public:
bool is_v_scroll_enabled() const;
virtual bool clips_input() const;
+
+ virtual String get_configuration_warning() const;
+
ScrollContainer();
};
diff --git a/scene/gui/separator.cpp b/scene/gui/separator.cpp
index 626b093a2f..32bd2239fc 100644
--- a/scene/gui/separator.cpp
+++ b/scene/gui/separator.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/separator.h b/scene/gui/separator.h
index 7a7dc92b93..5fb17e1c2e 100644
--- a/scene/gui/separator.h
+++ b/scene/gui/separator.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -36,7 +36,7 @@
#include "scene/gui/control.h"
class Separator : public Control {
- OBJ_TYPE( Separator, Control );
+ GDCLASS( Separator, Control );
protected:
@@ -54,7 +54,7 @@ public:
class VSeparator : public Separator {
- OBJ_TYPE( VSeparator, Separator );
+ GDCLASS( VSeparator, Separator );
public:
@@ -64,7 +64,7 @@ public:
class HSeparator : public Separator {
- OBJ_TYPE( HSeparator, Separator );
+ GDCLASS( HSeparator, Separator );
public:
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 3b9ca40bd8..ad6e8786d7 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@ Size2 Slider::get_minimum_size() const {
return ms;
}
-void Slider::_input_event(InputEvent p_event) {
+void Slider::_gui_input(InputEvent p_event) {
@@ -53,19 +53,19 @@ void Slider::_input_event(InputEvent p_event) {
double grab_height = (double)grabber->get_size().height;
double max = orientation==VERTICAL ? get_size().height - grab_height : get_size().width - grab_width;
if (orientation==VERTICAL)
- set_unit_value( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
+ set_as_ratio( 1 - (((double)grab.pos - (grab_height / 2.0)) / max) );
else
- set_unit_value(((double)grab.pos - (grab_width/2.0)) / max);
+ set_as_ratio(((double)grab.pos - (grab_width/2.0)) / max);
grab.active=true;
- grab.uvalue=get_unit_value();
+ grab.uvalue=get_as_ratio();
} else {
grab.active=false;
}
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_UP) {
- set_val( get_val() + get_step());
+ set_value( get_value() + get_step());
} else if (mb.pressed && mb.button_index==BUTTON_WHEEL_DOWN) {
- set_val( get_val() - get_step());
+ set_value( get_value() - get_step());
}
} else if (p_event.type==InputEvent::MOUSE_MOTION) {
@@ -81,7 +81,7 @@ void Slider::_input_event(InputEvent p_event) {
if (areasize<=0)
return;
float umotion = motion / float(areasize);
- set_unit_value( grab.uvalue + umotion );
+ set_as_ratio( grab.uvalue + umotion );
}
} else {
@@ -89,26 +89,26 @@ void Slider::_input_event(InputEvent p_event) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_right") && p_event.is_pressed()) {
if (orientation!=HORIZONTAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_up") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() + (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() + (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.is_action("ui_down") && p_event.is_pressed()) {
if (orientation!=VERTICAL)
return;
- set_val( get_val() - (custom_step>=0?custom_step:get_step()) );
+ set_value( get_value() - (custom_step>=0?custom_step:get_step()) );
accept_event();
} else if (p_event.type==InputEvent::KEY) {
@@ -122,12 +122,12 @@ void Slider::_input_event(InputEvent p_event) {
case KEY_HOME: {
- set_val( get_min() );
+ set_value( get_min() );
accept_event();
} break;
case KEY_END: {
- set_val( get_max() );
+ set_value( get_max() );
accept_event();
} break;
@@ -164,8 +164,10 @@ void Slider::_notification(int p_what) {
if (orientation==VERTICAL) {
style->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(style->get_minimum_size().width+style->get_center_size().width,size.height)));
+ */
float areasize = size.height - grabber->get_size().height;
if (ticks>1) {
int tickarea = size.height - tick->get_height();
@@ -176,11 +178,13 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_unit_value()*areasize - grabber->get_size().height));
+ grabber->draw(ci,Point2i(size.width/2-grabber->get_size().width/2,size.height - get_as_ratio()*areasize - grabber->get_size().height));
} else {
style->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
- //if (mouse_inside||has_focus())
- // focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ /*
+ if (mouse_inside||has_focus())
+ focus->draw(ci,Rect2i(Point2i(),Size2i(size.width,style->get_minimum_size().height+style->get_center_size().height)));
+ */
float areasize = size.width - grabber->get_size().width;
if (ticks>1) {
@@ -192,7 +196,7 @@ void Slider::_notification(int p_what) {
}
}
- grabber->draw(ci,Point2i(get_unit_value()*areasize,size.height/2-grabber->get_size().height/2));
+ grabber->draw(ci,Point2i(get_as_ratio()*areasize,size.height/2-grabber->get_size().height/2));
}
} break;
@@ -231,12 +235,12 @@ void Slider::set_ticks_on_borders(bool _tob){
void Slider::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Slider::_input_event);
- ObjectTypeDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
+ ClassDB::bind_method(_MD("_gui_input"),&Slider::_gui_input);
+ ClassDB::bind_method(_MD("set_ticks","count"),&Slider::set_ticks);
+ ClassDB::bind_method(_MD("get_ticks"),&Slider::get_ticks);
- ObjectTypeDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
- ObjectTypeDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
+ ClassDB::bind_method(_MD("get_ticks_on_borders"),&Slider::get_ticks_on_borders);
+ ClassDB::bind_method(_MD("set_ticks_on_borders","ticks_on_border"),&Slider::set_ticks_on_borders);
ADD_PROPERTY( PropertyInfo( Variant::INT, "tick_count", PROPERTY_HINT_RANGE,"0,4096,1"), _SCS("set_ticks"), _SCS("get_ticks") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "ticks_on_borders" ), _SCS("set_ticks_on_borders"), _SCS("get_ticks_on_borders") );
diff --git a/scene/gui/slider.h b/scene/gui/slider.h
index cf009b9a75..89eb32737b 100644
--- a/scene/gui/slider.h
+++ b/scene/gui/slider.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Slider : public Range {
- OBJ_TYPE( Slider, Range );
+ GDCLASS( Slider, Range );
struct Grab {
int pos;
@@ -49,7 +49,7 @@ class Slider : public Range {
protected:
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
static void _bind_methods();
bool ticks_on_borders;
@@ -74,7 +74,7 @@ public:
class HSlider : public Slider {
- OBJ_TYPE( HSlider, Slider );
+ GDCLASS( HSlider, Slider );
public:
HSlider() : Slider(HORIZONTAL) { set_v_size_flags(0);}
@@ -82,7 +82,7 @@ public:
class VSlider : public Slider {
- OBJ_TYPE( VSlider, Slider );
+ GDCLASS( VSlider, Slider );
public:
VSlider() : Slider(VERTICAL) { set_h_size_flags(0);}
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 98e1a32aef..ec6be0d19d 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -39,7 +39,7 @@ Size2 SpinBox::get_minimum_size() const {
void SpinBox::_value_changed(double) {
- String value = String::num(get_val(),Math::step_decimals(get_step()));
+ String value = String::num(get_value(),Math::step_decimals(get_step()));
if (prefix!="")
value=prefix+" "+value;
if (suffix!="")
@@ -49,9 +49,14 @@ void SpinBox::_value_changed(double) {
void SpinBox::_text_entered(const String& p_string) {
- //if (!p_string.is_numeric())
- // return;
- set_val( p_string.to_double() );
+ /*
+ if (!p_string.is_numeric())
+ return;
+ */
+ String value = p_string;
+ if (prefix!="" && p_string.begins_with(prefix))
+ value = p_string.substr(prefix.length(), p_string.length()-prefix.length());
+ set_value( value.to_double() );
_value_changed(0);
}
@@ -73,7 +78,7 @@ void SpinBox::_range_click_timeout() {
if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
bool up = get_local_mouse_pos().y < (get_size().height/2);
- set_val( get_val() + (up?get_step():-get_step()));
+ set_value( get_value() + (up?get_step():-get_step()));
if (range_click_timer->is_one_shot()) {
range_click_timer->set_wait_time(0.075);
@@ -87,8 +92,11 @@ void SpinBox::_range_click_timeout() {
}
-void SpinBox::_input_event(const InputEvent& p_event) {
+void SpinBox::_gui_input(const InputEvent& p_event) {
+ if (!is_editable()) {
+ return;
+ }
if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed) {
const InputEventMouseButton &mb=p_event.mouse_button;
@@ -101,25 +109,30 @@ void SpinBox::_input_event(const InputEvent& p_event) {
case BUTTON_LEFT: {
- set_val( get_val() + (up?get_step():-get_step()));
+ set_value( get_value() + (up?get_step():-get_step()));
range_click_timer->set_wait_time(0.6);
range_click_timer->set_one_shot(true);
range_click_timer->start();
+ line_edit->grab_focus();
} break;
case BUTTON_RIGHT: {
- set_val( (up?get_max():get_min()) );
-
+ set_value( (up?get_max():get_min()) );
+ line_edit->grab_focus();
} break;
case BUTTON_WHEEL_UP: {
-
- set_val( get_val() + get_step() );
+ if (line_edit->has_focus()) {
+ set_value( get_value() + get_step() );
+ accept_event();
+ }
} break;
case BUTTON_WHEEL_DOWN: {
-
- set_val( get_val() - get_step() );
+ if (line_edit->has_focus()) {
+ set_value( get_value() - get_step() );
+ accept_event();
+ }
} break;
}
}
@@ -155,13 +168,13 @@ void SpinBox::_input_event(const InputEvent& p_event) {
drag.mouse_pos=cpos;
drag.base_val=CLAMP(drag.base_val + get_step() * diff_y, get_min(), get_max());
- set_val( drag.base_val);
+ set_value( drag.base_val);
} else if (drag.mouse_pos.distance_to(cpos)>2) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
drag.enabled=true;
- drag.base_val=get_val();
+ drag.base_val=get_value();
drag.mouse_pos=cpos;
drag.capture_pos=cpos;
@@ -240,19 +253,19 @@ bool SpinBox::is_editable() const {
void SpinBox::_bind_methods() {
- //ObjectTypeDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
- ObjectTypeDB::bind_method(_MD("_input_event"),&SpinBox::_input_event);
- ObjectTypeDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
- ObjectTypeDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
- ObjectTypeDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
- ObjectTypeDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
- ObjectTypeDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
- ObjectTypeDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
- ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
- ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
- ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
+ //ClassDB::bind_method(_MD("_value_changed"),&SpinBox::_value_changed);
+ ClassDB::bind_method(_MD("_gui_input"),&SpinBox::_gui_input);
+ ClassDB::bind_method(_MD("_text_entered"),&SpinBox::_text_entered);
+ ClassDB::bind_method(_MD("set_suffix","suffix"),&SpinBox::set_suffix);
+ ClassDB::bind_method(_MD("get_suffix"),&SpinBox::get_suffix);
+ ClassDB::bind_method(_MD("set_prefix","prefix"),&SpinBox::set_prefix);
+ ClassDB::bind_method(_MD("get_prefix"),&SpinBox::get_prefix);
+ ClassDB::bind_method(_MD("set_editable","editable"),&SpinBox::set_editable);
+ ClassDB::bind_method(_MD("is_editable"),&SpinBox::is_editable);
+ ClassDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
+ ClassDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
+ ClassDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
+ ClassDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable"));
@@ -271,8 +284,8 @@ SpinBox::SpinBox() {
line_edit->set_area_as_parent_rect();
//connect("value_changed",this,"_value_changed");
line_edit->connect("text_entered",this,"_text_entered",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
- line_edit->connect("input_event",this,"_line_edit_input");
+ line_edit->connect("focus_exited",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
+ line_edit->connect("gui_input",this,"_line_edit_input");
drag.enabled=false;
range_click_timer = memnew( Timer );
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index acaea822ab..9974ec47bc 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class SpinBox : public Range {
- OBJ_TYPE( SpinBox, Range );
+ GDCLASS( SpinBox, Range );
LineEdit *line_edit;
int last_w;
@@ -64,7 +64,7 @@ class SpinBox : public Range {
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 6b36a60ea2..a39ad2fe99 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -47,7 +47,7 @@ Control *SplitContainer::_getch(int p_idx) const {
for(int i=0;i<get_child_count();i++) {
Control *c=get_child(i)->cast_to<Control>();
- if (!c || !c->is_visible())
+ if (!c || !c->is_visible_in_tree())
continue;
if (c->is_set_as_toplevel())
continue;
@@ -299,7 +299,7 @@ void SplitContainer::_notification(int p_what) {
}
}
-void SplitContainer::_input_event(const InputEvent& p_event) {
+void SplitContainer::_gui_input(const InputEvent& p_event) {
if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility!=DRAGGER_VISIBLE)
return;
@@ -422,21 +422,21 @@ bool SplitContainer::is_collapsed() const {
void SplitContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&SplitContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
- ObjectTypeDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
+ ClassDB::bind_method(_MD("_gui_input"),&SplitContainer::_gui_input);
+ ClassDB::bind_method(_MD("set_split_offset","offset"),&SplitContainer::set_split_offset);
+ ClassDB::bind_method(_MD("get_split_offset"),&SplitContainer::get_split_offset);
- ObjectTypeDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
+ ClassDB::bind_method(_MD("set_collapsed","collapsed"),&SplitContainer::set_collapsed);
+ ClassDB::bind_method(_MD("is_collapsed"),&SplitContainer::is_collapsed);
- ObjectTypeDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
- ObjectTypeDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
+ ClassDB::bind_method(_MD("set_dragger_visibility","mode"),&SplitContainer::set_dragger_visibility);
+ ClassDB::bind_method(_MD("get_dragger_visibility"),&SplitContainer::get_dragger_visibility);
ADD_SIGNAL( MethodInfo("dragged",PropertyInfo(Variant::INT,"offset")));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"split/collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
- ADD_PROPERTY( PropertyInfo(Variant::INT,"split/dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"split_offset"),_SCS("set_split_offset"),_SCS("get_split_offset"));
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collapsed"),_SCS("set_collapsed"),_SCS("is_collapsed"));
+ ADD_PROPERTY( PropertyInfo(Variant::INT,"dragger_visibility",PROPERTY_HINT_ENUM,"Visible,Hidden,Hidden & Collapsed"),_SCS("set_dragger_visibility"),_SCS("get_dragger_visibility"));
BIND_CONSTANT( DRAGGER_VISIBLE );
BIND_CONSTANT( DRAGGER_HIDDEN );
diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h
index d2dc42165e..03b6b1a167 100644
--- a/scene/gui/split_container.h
+++ b/scene/gui/split_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
class SplitContainer : public Container {
- OBJ_TYPE(SplitContainer,Container);
+ GDCLASS(SplitContainer,Container);
public:
enum DraggerVisibility {
DRAGGER_VISIBLE,
@@ -59,7 +59,7 @@ private:
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
public:
@@ -86,7 +86,7 @@ VARIANT_ENUM_CAST(SplitContainer::DraggerVisibility);
class HSplitContainer : public SplitContainer {
- OBJ_TYPE(HSplitContainer,SplitContainer);
+ GDCLASS(HSplitContainer,SplitContainer);
public:
@@ -96,7 +96,7 @@ public:
class VSplitContainer : public SplitContainer {
- OBJ_TYPE(VSplitContainer,SplitContainer);
+ GDCLASS(VSplitContainer,SplitContainer);
public:
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 8557500488..52d26b29de 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -65,7 +65,7 @@ int TabContainer::_get_top_margin() const {
-void TabContainer::_input_event(const InputEvent& p_event) {
+void TabContainer::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON &&
p_event.mouse_button.pressed &&
@@ -680,7 +680,7 @@ Size2 TabContainer::get_minimum_size() const {
if (c->is_set_as_toplevel())
continue;
- if (!c->is_visible())
+ if (!c->is_visible_in_tree())
continue;
Size2 cms = c->get_combined_minimum_size();
@@ -714,24 +714,24 @@ Popup* TabContainer::get_popup() const {
void TabContainer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&TabContainer::_input_event);
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
- ObjectTypeDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
- ObjectTypeDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
- ObjectTypeDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
- ObjectTypeDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
-
- ObjectTypeDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
+ ClassDB::bind_method(_MD("_gui_input"),&TabContainer::_gui_input);
+ ClassDB::bind_method(_MD("get_tab_count"),&TabContainer::get_tab_count);
+ ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&TabContainer::set_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab"),&TabContainer::get_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab_control:Control"),&TabContainer::get_current_tab_control);
+ ClassDB::bind_method(_MD("get_tab_control:Control","idx"),&TabContainer::get_tab_control);
+ ClassDB::bind_method(_MD("set_tab_align","align"),&TabContainer::set_tab_align);
+ ClassDB::bind_method(_MD("get_tab_align"),&TabContainer::get_tab_align);
+ ClassDB::bind_method(_MD("set_tabs_visible","visible"),&TabContainer::set_tabs_visible);
+ ClassDB::bind_method(_MD("are_tabs_visible"),&TabContainer::are_tabs_visible);
+ ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&TabContainer::set_tab_title);
+ ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&TabContainer::get_tab_title);
+ ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&TabContainer::set_tab_icon);
+ ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&TabContainer::get_tab_icon);
+ ClassDB::bind_method(_MD("set_popup","popup:Popup"),&TabContainer::set_popup);
+ ClassDB::bind_method(_MD("get_popup:Popup"),&TabContainer::get_popup);
+
+ ClassDB::bind_method(_MD("_child_renamed_callback"),&TabContainer::_child_renamed_callback);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
ADD_SIGNAL(MethodInfo("pre_popup_pressed"));
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index 979ce927a0..8b6ca7704e 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,7 +34,7 @@
#include "scene/gui/popup.h"
class TabContainer : public Control {
- OBJ_TYPE( TabContainer, Control );
+ GDCLASS( TabContainer, Control );
public:
enum TabAlign {
@@ -61,7 +61,7 @@ private:
protected:
void _child_renamed_callback();
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
virtual void add_child_notify(Node *p_child);
virtual void remove_child_notify(Node *p_child);
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index eb060aa6b8..98d3f6230d 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -76,7 +76,7 @@ Size2 Tabs::get_minimum_size() const {
}
-void Tabs::_input_event(const InputEvent& p_event) {
+void Tabs::_gui_input(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_MOTION) {
@@ -649,19 +649,19 @@ void Tabs::set_tab_close_display_policy(CloseButtonDisplayPolicy p_policy) {
void Tabs::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tabs::_input_event);
- ObjectTypeDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
- ObjectTypeDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
- ObjectTypeDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
- ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
- ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
- ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
- ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
- ObjectTypeDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
- ObjectTypeDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
- ObjectTypeDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
+ ClassDB::bind_method(_MD("_gui_input"),&Tabs::_gui_input);
+ ClassDB::bind_method(_MD("get_tab_count"),&Tabs::get_tab_count);
+ ClassDB::bind_method(_MD("set_current_tab","tab_idx"),&Tabs::set_current_tab);
+ ClassDB::bind_method(_MD("get_current_tab"),&Tabs::get_current_tab);
+ ClassDB::bind_method(_MD("set_tab_title","tab_idx","title"),&Tabs::set_tab_title);
+ ClassDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
+ ClassDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
+ ClassDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
+ ClassDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
+ ClassDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
+ ClassDB::bind_method(_MD("set_tab_align","align"),&Tabs::set_tab_align);
+ ClassDB::bind_method(_MD("get_tab_align"),&Tabs::get_tab_align);
+ ClassDB::bind_method(_MD("ensure_tab_visible","idx"),&Tabs::ensure_tab_visible);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
ADD_SIGNAL(MethodInfo("right_button_pressed",PropertyInfo(Variant::INT,"tab")));
diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h
index 5a4533c3d2..9ba32297dc 100644
--- a/scene/gui/tabs.h
+++ b/scene/gui/tabs.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class Tabs : public Control {
- OBJ_TYPE( Tabs, Control );
+ GDCLASS( Tabs, Control );
public:
enum TabAlign {
@@ -92,7 +92,7 @@ private:
protected:
- void _input_event(const InputEvent& p_event);
+ void _gui_input(const InputEvent& p_event);
void _notification(int p_what);
static void _bind_methods();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 9db0a66395..8efff21fc9 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -347,7 +347,7 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
- v_scroll->set_val(cursor.line_ofs);
+ v_scroll->set_value(cursor.line_ofs);
} else {
cursor.line_ofs = 0;
@@ -359,7 +359,7 @@ void TextEdit::_update_scrollbars() {
h_scroll->show();
h_scroll->set_max(total_width);
h_scroll->set_page(visible_width);
- h_scroll->set_val(cursor.x_ofs);
+ h_scroll->set_value(cursor.x_ofs);
} else {
@@ -482,12 +482,20 @@ void TextEdit::_notification(int p_what) {
Color color = cache.font_color;
int in_region=-1;
+ if (line_length_guideline) {
+ int x=xmargin_beg+cache.font->get_char_size('0').width*line_length_guideline_col-cursor.x_ofs;
+ if (x>xmargin_beg && x<xmargin_end) {
+ Color guideline_color(color.r,color.g,color.b,color.a*0.25f);
+ VisualServer::get_singleton()->canvas_item_add_line(ci,Point2(x,0),Point2(x,cache.size.height),guideline_color);
+ }
+ }
+
if (syntax_coloring) {
- if (custom_bg_color.a>0.01) {
+ if (cache.background_color.a>0.01) {
Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0;
- VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color);
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),cache.background_color);
}
//compute actual region to start (may be inside say, a comment).
//slow in very large documments :( but ok for source!
@@ -685,6 +693,8 @@ void TextEdit::_notification(int p_what) {
// get the highlighted words
String highlighted_text = get_selection_text();
+ String line_num_padding = line_numbers_zero_padded ? "0" : " ";
+
for (int i=0;i<visible_rows;i++) {
int line=i+cursor.line_ofs;
@@ -750,7 +760,7 @@ void TextEdit::_notification(int p_what) {
if (cache.line_number_w) {
String fc = String::num(line+1);
while (fc.length() < line_number_char_count) {
- fc="0"+fc;
+ fc=line_num_padding+fc;
}
cache.font->draw(ci,Point2(cache.style_normal->get_margin(MARGIN_LEFT)+cache.breakpoint_gutter_width,ofs_y+cache.font->get_ascent()),fc,cache.line_number_color);
@@ -897,7 +907,7 @@ void TextEdit::_notification(int p_what) {
else if (in_function_name)
color=cache.function_color;
else if (is_symbol)
- color=symbol_color;
+ color=cache.symbol_color;
else if (is_number)
color=cache.number_color;
@@ -1245,15 +1255,19 @@ void TextEdit::_notification(int p_what) {
}
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->show_virtual_keyboard(get_text(),get_global_rect());
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ }
} break;
case NOTIFICATION_FOCUS_EXIT: {
if (OS::get_singleton()->has_virtual_keyboard())
OS::get_singleton()->hide_virtual_keyboard();
-
+ if (raised_from_completion) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ }
} break;
-
}
}
@@ -1454,13 +1468,13 @@ void TextEdit::_get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) co
r_col=col;
}
-void TextEdit::_input_event(const InputEvent& p_input_event) {
+void TextEdit::_gui_input(const InputEvent& p_gui_input) {
- switch(p_input_event.type) {
+ switch(p_gui_input.type) {
case InputEvent::MOUSE_BUTTON: {
- const InputEventMouseButton &mb=p_input_event.mouse_button;
+ const InputEventMouseButton &mb=p_gui_input.mouse_button;
if (completion_active && completion_rect.has_point(Point2(mb.x,mb.y))) {
@@ -1501,16 +1515,16 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (mb.pressed) {
if (mb.button_index==BUTTON_WHEEL_UP && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() -3 );
+ v_scroll->set_value( v_scroll->get_value() -3 );
}
if (mb.button_index==BUTTON_WHEEL_DOWN && !mb.mod.command) {
- v_scroll->set_val( v_scroll->get_val() +3 );
+ v_scroll->set_value( v_scroll->get_value() +3 );
}
if (mb.button_index==BUTTON_WHEEL_LEFT) {
- h_scroll->set_val( h_scroll->get_val() -3 );
+ h_scroll->set_value( h_scroll->get_value() -3 );
}
if (mb.button_index==BUTTON_WHEEL_RIGHT) {
- h_scroll->set_val( h_scroll->get_val() +3 );
+ h_scroll->set_value( h_scroll->get_value() +3 );
}
if (mb.button_index==BUTTON_LEFT) {
@@ -1651,7 +1665,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
update();
}
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.button_index==BUTTON_RIGHT && context_menu_enabled) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
menu->set_size(Vector2(1,1));
@@ -1671,7 +1685,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case InputEvent::MOUSE_MOTION: {
- const InputEventMouseMotion &mm=p_input_event.mouse_motion;
+ const InputEventMouseMotion &mm=p_gui_input.mouse_motion;
if (select_identifiers_enabled) {
if (mm.mod.command && mm.button_mask==0) {
@@ -1714,7 +1728,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
case InputEvent::KEY: {
- InputEventKey k=p_input_event.key;
+ InputEventKey k=p_gui_input.key;
#ifdef OSX_ENABLED
@@ -2542,7 +2556,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
case KEY_X: {
-
+ if (readonly) {
+ break;
+ }
if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false;
break;
@@ -2574,7 +2590,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
undo();
} break;
case KEY_V: {
-
+ if (readonly) {
+ break;
+ }
if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false;
break;
@@ -3018,7 +3036,7 @@ void TextEdit::adjust_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
@@ -3026,7 +3044,7 @@ void TextEdit::adjust_viewport_to_cursor() {
//printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line);
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
if (cursor.line>=(cursor.line_ofs+visible_rows))
@@ -3060,12 +3078,12 @@ void TextEdit::center_viewport_to_cursor() {
cursor.line_ofs=cursor.line;
int visible_width=cache.size.width-cache.style_normal->get_minimum_size().width-cache.line_number_w-cache.breakpoint_gutter_width;
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
visible_width-=v_scroll->get_combined_minimum_size().width;
visible_width-=20; // give it a little more space
int visible_rows = get_visible_rows();
- if (h_scroll->is_visible())
+ if (h_scroll->is_visible_in_tree())
visible_rows-=((h_scroll->get_combined_minimum_size().height-1)/get_row_height());
int max_ofs = text.size()-(scroll_past_end_of_file_enabled?1:visible_rows);
@@ -3187,10 +3205,10 @@ void TextEdit::_scroll_moved(double p_to_val) {
if (updating_scrolls)
return;
- if (h_scroll->is_visible())
- cursor.x_ofs=h_scroll->get_val();
- if (v_scroll->is_visible())
- cursor.line_ofs=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ cursor.x_ofs=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ cursor.line_ofs=v_scroll->get_value();
update();
}
@@ -3309,7 +3327,7 @@ void TextEdit::set_text(String p_text){
cursor_set_column(0);
update();
setting_text=false;
-
+ _text_changed_emit();
//get_range()->set(0);
};
@@ -3440,7 +3458,7 @@ void TextEdit::_reset_caret_blink_timer() {
void TextEdit::_toggle_draw_caret() {
draw_caret = !draw_caret;
- if (is_visible()) {
+ if (is_visible_in_tree() && has_focus() && window_has_focus) {
update();
}
}
@@ -3471,6 +3489,8 @@ void TextEdit::_update_caches() {
cache.word_highlighted_color=get_color("word_highlighted_color");
cache.search_result_color=get_color("search_result_color");
cache.search_result_border_color=get_color("search_result_border_color");
+ cache.symbol_color=get_color("symbol_color");
+ cache.background_color=get_color("background_color");
cache.line_spacing=get_constant("line_spacing");
cache.row_height = cache.font->get_height() + cache.line_spacing;
cache.tab_icon=get_icon("tab");
@@ -3482,15 +3502,8 @@ void TextEdit::_update_caches() {
void TextEdit::clear_colors() {
keywords.clear();
- color_regions.clear();;
+ color_regions.clear();
text.clear_caches();
- custom_bg_color=Color(0,0,0,0);
-}
-
-void TextEdit::set_custom_bg_color(const Color& p_color) {
-
- custom_bg_color=p_color;
- update();
}
void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) {
@@ -3508,12 +3521,6 @@ void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_ke
}
-void TextEdit::set_symbol_color(const Color& p_color) {
-
- symbol_color=p_color;
- update();
-}
-
void TextEdit::set_syntax_coloring(bool p_enabled) {
syntax_coloring=p_enabled;
@@ -3776,7 +3783,7 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
if (col > 0 && _is_text_char(p_search[col-1])) {
col = -1;
- } else if (_is_text_char(p_search[col+p_key.length()])) {
+ } else if ((col + p_key.length()) < p_search.length() && _is_text_char(p_search[col+p_key.length()])) {
col = -1;
}
}
@@ -3787,11 +3794,11 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
return col;
}
-DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
+PoolVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
int col,line;
if (search(p_key,p_search_flags,p_from_line,p_from_column,col,line)) {
- DVector<int> result;
+ PoolVector<int> result;
result.resize(2);
result.set(0,line);
result.set(1,col);
@@ -3799,7 +3806,7 @@ DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags,
} else {
- return DVector<int>();
+ return PoolVector<int>();
}
}
@@ -4148,21 +4155,21 @@ void TextEdit::tag_saved_version() {
int TextEdit::get_v_scroll() const {
- return v_scroll->get_val();
+ return v_scroll->get_value();
}
void TextEdit::set_v_scroll(int p_scroll) {
- v_scroll->set_val(p_scroll);
+ v_scroll->set_value(p_scroll);
cursor.line_ofs=p_scroll;
}
int TextEdit::get_h_scroll() const {
- return h_scroll->get_val();
+ return h_scroll->get_value();
}
void TextEdit::set_h_scroll(int p_scroll) {
- h_scroll->set_val(p_scroll);
+ h_scroll->set_value(p_scroll);
}
void TextEdit::set_completion(bool p_enabled,const Vector<String>& p_prefixes) {
@@ -4193,12 +4200,17 @@ void TextEdit::_confirm_completion() {
void TextEdit::_cancel_code_hint() {
+
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
completion_hint="";
update();
}
void TextEdit::_cancel_completion() {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 0);
+ raised_from_completion = false;
if (!completion_active)
return;
@@ -4218,7 +4230,6 @@ void TextEdit::_update_completion_candidates() {
String l = text[cursor.line];
int cofs = CLAMP(cursor.column,0,l.length());
-
String s;
//look for keywords first
@@ -4267,14 +4278,14 @@ void TextEdit::_update_completion_candidates() {
while(cofs>0 && l[cofs-1]>32 && _is_completable(l[cofs-1])) {
s=String::chr(l[cofs-1])+s;
- if (l[cofs-1]=='\'' || l[cofs-1]=='"')
+ if (l[cofs-1]=='\'' || l[cofs-1]=='"' || l[cofs-1]=='$')
break;
cofs--;
}
}
- 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_strings[0].begins_with("\"")) {
cancel = true;
}
@@ -4296,8 +4307,9 @@ void TextEdit::_update_completion_candidates() {
_cancel_completion();
return;
}
+
if (s.is_subsequence_ofi(completion_strings[i])) {
- // don't remove duplicates if no input is provided
+ // don't remove duplicates if no input is provided
if (s != "" && completion_options.find(completion_strings[i]) != -1) {
continue;
}
@@ -4333,6 +4345,7 @@ void TextEdit::_update_completion_candidates() {
if (completion_options.size()==0) {
//no options to complete, cancel
_cancel_completion();
+
return;
}
@@ -4344,7 +4357,7 @@ void TextEdit::_update_completion_candidates() {
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()));
+ //insert_text_at_cursor(completion_options[0].substr(s.length(),completion_options[0].length()-s.length()));
_cancel_completion();
return;
@@ -4378,6 +4391,8 @@ void TextEdit::query_code_comple() {
void TextEdit::set_code_hint(const String& p_hint) {
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_hint=p_hint;
completion_hint_offset=-0xFFFF;
update();
@@ -4385,7 +4400,8 @@ void TextEdit::set_code_hint(const String& p_hint) {
void TextEdit::code_complete(const Vector<String> &p_strings) {
-
+ VisualServer::get_singleton()->canvas_item_set_z(get_canvas_item(), 1);
+ raised_from_completion = true;
completion_strings=p_strings;
completion_active=true;
completion_current="";
@@ -4496,10 +4512,26 @@ void TextEdit::set_show_line_numbers(bool p_show) {
update();
}
+void TextEdit::set_line_numbers_zero_padded(bool p_zero_padded) {
+
+ line_numbers_zero_padded=p_zero_padded;
+ update();
+}
+
bool TextEdit::is_show_line_numbers_enabled() const {
return line_numbers;
}
+void TextEdit::set_show_line_length_guideline(bool p_show) {
+ line_length_guideline=p_show;
+ update();
+}
+
+void TextEdit::set_line_length_guideline_column(int p_column) {
+ line_length_guideline_col=p_column;
+ update();
+}
+
void TextEdit::set_draw_breakpoint_gutter(bool p_draw) {
draw_breakpoint_gutter = p_draw;
update();
@@ -4527,18 +4559,22 @@ void TextEdit::menu_option(int p_option) {
switch( p_option ) {
case MENU_CUT: {
-
- cut();
+ if (!readonly) {
+ cut();
+ }
} break;
case MENU_COPY: {
copy();
} break;
case MENU_PASTE: {
-
- paste();
+ if (!readonly) {
+ paste();
+ }
} break;
case MENU_CLEAR: {
- clear();
+ if (!readonly) {
+ clear();
+ }
} break;
case MENU_SELECT_ALL: {
select_all();
@@ -4561,6 +4597,9 @@ bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
return select_identifiers_enabled;
}
+void TextEdit::set_context_menu_enabled(bool p_enable) {
+ context_menu_enabled = p_enable;
+}
PopupMenu *TextEdit::get_menu() const {
return menu;
@@ -4569,90 +4608,90 @@ PopupMenu *TextEdit::get_menu() const {
void TextEdit::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_input_event"),&TextEdit::_input_event);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
- ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
- ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
- ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
- ObjectTypeDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
+ ClassDB::bind_method(_MD("_gui_input"),&TextEdit::_gui_input);
+ ClassDB::bind_method(_MD("_scroll_moved"),&TextEdit::_scroll_moved);
+ ClassDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
+ ClassDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
+ ClassDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
+ ClassDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
+ ClassDB::bind_method(_MD("_toggle_draw_caret"),&TextEdit::_toggle_draw_caret);
BIND_CONSTANT( SEARCH_MATCH_CASE );
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
BIND_CONSTANT( SEARCH_BACKWARDS );
/*
- ObjectTypeDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
- ObjectTypeDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
+ ClassDB::bind_method(_MD("delete_char"),&TextEdit::delete_char);
+ ClassDB::bind_method(_MD("delete_line"),&TextEdit::delete_line);
*/
- ObjectTypeDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
- ObjectTypeDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
-
- ObjectTypeDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
- ObjectTypeDB::bind_method(_MD("get_text"),&TextEdit::get_text);
- ObjectTypeDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
-
- ObjectTypeDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
-
- ObjectTypeDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
- ObjectTypeDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
- ObjectTypeDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
- ObjectTypeDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
- ObjectTypeDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
-
- ObjectTypeDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
- ObjectTypeDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
- ObjectTypeDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
-
- ObjectTypeDB::bind_method(_MD("cut"),&TextEdit::cut);
- ObjectTypeDB::bind_method(_MD("copy"),&TextEdit::copy);
- ObjectTypeDB::bind_method(_MD("paste"),&TextEdit::paste);
- ObjectTypeDB::bind_method(_MD("select_all"),&TextEdit::select_all);
- ObjectTypeDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
-
- ObjectTypeDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
- ObjectTypeDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
- ObjectTypeDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
- ObjectTypeDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
- ObjectTypeDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
- ObjectTypeDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
- ObjectTypeDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
- ObjectTypeDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
-
- ObjectTypeDB::bind_method(_MD("undo"),&TextEdit::undo);
- ObjectTypeDB::bind_method(_MD("redo"),&TextEdit::redo);
- ObjectTypeDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
-
- ObjectTypeDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
- ObjectTypeDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
- ObjectTypeDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
-
- ObjectTypeDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
- ObjectTypeDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
-
-
- ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
- ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
- ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
- ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
+ ClassDB::bind_method(_MD("set_text","text"),&TextEdit::set_text);
+ ClassDB::bind_method(_MD("insert_text_at_cursor","text"),&TextEdit::insert_text_at_cursor);
+
+ ClassDB::bind_method(_MD("get_line_count"),&TextEdit::get_line_count);
+ ClassDB::bind_method(_MD("get_text"),&TextEdit::get_text);
+ ClassDB::bind_method(_MD("get_line","line"),&TextEdit::get_line);
+
+ ClassDB::bind_method(_MD("cursor_set_column","column","adjust_viewport"),&TextEdit::cursor_set_column,DEFVAL(false));
+ ClassDB::bind_method(_MD("cursor_set_line","line","adjust_viewport"),&TextEdit::cursor_set_line,DEFVAL(false));
+
+ ClassDB::bind_method(_MD("cursor_get_column"),&TextEdit::cursor_get_column);
+ ClassDB::bind_method(_MD("cursor_get_line"),&TextEdit::cursor_get_line);
+ ClassDB::bind_method(_MD("cursor_set_blink_enabled", "enable"),&TextEdit::cursor_set_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_get_blink_enabled"),&TextEdit::cursor_get_blink_enabled);
+ ClassDB::bind_method(_MD("cursor_set_blink_speed", "blink_speed"),&TextEdit::cursor_set_blink_speed);
+ ClassDB::bind_method(_MD("cursor_get_blink_speed"),&TextEdit::cursor_get_blink_speed);
+ ClassDB::bind_method(_MD("cursor_set_block_mode", "enable"), &TextEdit::cursor_set_block_mode);
+ ClassDB::bind_method(_MD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode);
+
+ ClassDB::bind_method(_MD("set_readonly","enable"),&TextEdit::set_readonly);
+ ClassDB::bind_method(_MD("set_wrap","enable"),&TextEdit::set_wrap);
+ ClassDB::bind_method(_MD("set_max_chars","amount"),&TextEdit::set_max_chars);
+
+ ClassDB::bind_method(_MD("cut"),&TextEdit::cut);
+ ClassDB::bind_method(_MD("copy"),&TextEdit::copy);
+ ClassDB::bind_method(_MD("paste"),&TextEdit::paste);
+ ClassDB::bind_method(_MD("select_all"),&TextEdit::select_all);
+ ClassDB::bind_method(_MD("select","from_line","from_column","to_line","to_column"),&TextEdit::select);
+
+ ClassDB::bind_method(_MD("is_selection_active"),&TextEdit::is_selection_active);
+ ClassDB::bind_method(_MD("get_selection_from_line"),&TextEdit::get_selection_from_line);
+ ClassDB::bind_method(_MD("get_selection_from_column"),&TextEdit::get_selection_from_column);
+ ClassDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
+ ClassDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
+ ClassDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
+ ClassDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
+ ClassDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
+
+ ClassDB::bind_method(_MD("undo"),&TextEdit::undo);
+ ClassDB::bind_method(_MD("redo"),&TextEdit::redo);
+ ClassDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
+
+ ClassDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
+ ClassDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
+
+ ClassDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
+ ClassDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
+
+ ClassDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
+ ClassDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
+
+
+ ClassDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color);
+ ClassDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false));
+ ClassDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors);
+ ClassDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
+ ClassDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), _SCS("set_syntax_coloring"), _SCS("is_syntax_coloring_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), _SCS("set_show_line_numbers"), _SCS("is_show_line_numbers_enabled"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), _SCS("set_highlight_all_occurrences"), _SCS("is_highlight_all_occurrences_enabled"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/block_caret"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
+
+ ADD_GROUP("Caret","caret_");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), _SCS("cursor_set_block_mode"), _SCS("cursor_is_block_mode"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
ADD_SIGNAL(MethodInfo("cursor_changed"));
ADD_SIGNAL(MethodInfo("text_changed"));
@@ -4669,6 +4708,7 @@ void TextEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
+ GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec",3);
}
TextEdit::TextEdit() {
@@ -4692,8 +4732,8 @@ TextEdit::TextEdit() {
tab_size=4;
text.set_tab_size(tab_size);
text.clear();
- // text.insert(1,"Mongolia..");
- // text.insert(2,"PAIS GENEROSO!!");
+ //text.insert(1,"Mongolia..");
+ //text.insert(2,"PAIS GENEROSO!!");
text.set_color_regions(&color_regions);
h_scroll = memnew( HScrollBar );
@@ -4726,11 +4766,10 @@ TextEdit::TextEdit() {
caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
cursor_set_blink_enabled(false);
- custom_bg_color=Color(0,0,0,0);
idle_detect = memnew( Timer );
add_child(idle_detect);
idle_detect->set_one_shot(true);
- idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
+ idle_detect->set_wait_time(GLOBAL_GET("gui/timers/text_edit_idle_detect_sec"));
idle_detect->connect("timeout", this,"_push_current_op");
click_select_held = memnew( Timer );
@@ -4770,6 +4809,9 @@ TextEdit::TextEdit() {
completion_line_ofs=0;
tooltip_obj=NULL;
line_numbers=false;
+ line_numbers_zero_padded=false;
+ line_length_guideline=false;
+ line_length_guideline_col=80;
draw_breakpoint_gutter=false;
next_operation_is_complex=false;
scroll_past_end_of_file_enabled=false;
@@ -4781,6 +4823,9 @@ TextEdit::TextEdit() {
window_has_focus=true;
select_identifiers_enabled=false;
+ raised_from_completion = false;
+
+ context_menu_enabled=true;
menu = memnew( PopupMenu );
add_child(menu);
menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
@@ -4791,7 +4836,7 @@ TextEdit::TextEdit() {
menu->add_item(TTR("Clear"),MENU_CLEAR);
menu->add_separator();
menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
- menu->connect("item_pressed",this,"menu_option");
+ menu->connect("id_pressed",this,"menu_option");
}
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index cb49618f18..6113fd72c2 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -37,7 +37,7 @@
class TextEdit : public Control {
- OBJ_TYPE( TextEdit, Control );
+ GDCLASS( TextEdit, Control );
struct Cursor {
int last_fit_x;
@@ -95,6 +95,8 @@ class TextEdit : public Control {
Color word_highlighted_color;
Color search_result_color;
Color search_result_border_color;
+ Color symbol_color;
+ Color background_color;
int row_height;
int line_spacing;
@@ -187,9 +189,7 @@ class TextEdit : public Control {
//syntax coloring
- Color symbol_color;
HashMap<String,Color> keywords;
- Color custom_bg_color;
Vector<ColorRegion> color_regions;
@@ -232,6 +232,9 @@ class TextEdit : public Control {
bool text_changed_dirty;
bool undo_enabled;
bool line_numbers;
+ bool line_numbers_zero_padded;
+ bool line_length_guideline;
+ int line_length_guideline_col;
bool draw_breakpoint_gutter;
int breakpoint_gutter_width;
@@ -244,6 +247,8 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool raised_from_completion;
+
String hilighted_word;
uint64_t last_dblclk;
@@ -269,6 +274,8 @@ class TextEdit : public Control {
int search_result_line;
int search_result_col;
+ bool context_menu_enabled;
+
int get_visible_rows() const;
int get_char_count();
@@ -287,7 +294,7 @@ class TextEdit : public Control {
void _scroll_lines_up();
void _scroll_lines_down();
-// void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
+ //void mouse_motion(const Point& p_pos, const Point& p_rel, int p_button_mask);
Size2 get_minimum_size() const;
int get_row_height() const;
@@ -309,7 +316,7 @@ class TextEdit : public Control {
int _get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column);
- DVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
+ PoolVector<int> _search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const;
PopupMenu *menu;
@@ -319,8 +326,6 @@ class TextEdit : public Control {
void _confirm_completion();
void _update_completion_candidates();
- void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
-
protected:
virtual String get_tooltip(const Point2& p_pos) const;
@@ -328,7 +333,7 @@ protected:
void _insert_text(int p_line, int p_column,const String& p_text,int *r_end_line=NULL,int *r_end_char=NULL);
void _remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column);
void _insert_text_at_cursor(const String& p_text);
- void _input_event(const InputEvent& p_input);
+ void _gui_input(const InputEvent& p_input);
void _notification(int p_what);
void _consume_pair_symbol(CharType ch);
@@ -360,6 +365,8 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
+
//void delete_char();
//void delete_line();
@@ -464,8 +471,6 @@ public:
void add_keyword_color(const String& p_keyword,const Color& p_color);
void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false);
- void set_symbol_color(const Color& p_color);
- void set_custom_bg_color(const Color& p_color);
void clear_colors();
int get_v_scroll() const;
@@ -483,6 +488,11 @@ public:
void set_show_line_numbers(bool p_show);
bool is_show_line_numbers_enabled() const;
+ void set_line_numbers_zero_padded(bool p_zero_padded);
+
+ void set_show_line_length_guideline(bool p_show);
+ void set_line_length_guideline_column(int p_column);
+
void set_draw_breakpoint_gutter(bool p_draw);
bool is_drawing_breakpoint_gutter() const;
@@ -499,6 +509,7 @@ public:
void set_select_identifiers_on_hover(bool p_enable);
bool is_selecting_identifiers_on_hover_enabled() const;
+ void set_context_menu_enabled(bool p_enable);
PopupMenu *get_menu() const;
String get_text_for_completion();
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index df2f5edd48..03e37e9d9f 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -120,13 +120,13 @@ void TextureButton::_notification(int p_what) {
if (texdraw.is_valid()) {
Rect2 drect(Point2(),texdraw->get_size()*scale);
- draw_texture_rect(texdraw,drect,false,modulate);
+ draw_texture_rect(texdraw,drect,false);
}
if (has_focus() && focused.is_valid()) {
Rect2 drect(Point2(),focused->get_size()*scale);
- draw_texture_rect(focused,drect,false,modulate);
+ draw_texture_rect(focused,drect,false);
};
@@ -136,32 +136,30 @@ void TextureButton::_notification(int p_what) {
void TextureButton::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
- ObjectTypeDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
- ObjectTypeDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
- ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
- ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
- ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
- ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
- ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate);
-
- ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
- ObjectTypeDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
- ObjectTypeDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
- ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
- ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
- ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
- ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
- ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate);
-
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
- ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
- ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
+ ClassDB::bind_method(_MD("set_normal_texture","texture:Texture"),&TextureButton::set_normal_texture);
+ ClassDB::bind_method(_MD("set_pressed_texture","texture:Texture"),&TextureButton::set_pressed_texture);
+ ClassDB::bind_method(_MD("set_hover_texture","texture:Texture"),&TextureButton::set_hover_texture);
+ ClassDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
+ ClassDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
+ ClassDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
+ ClassDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
+
+ ClassDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
+ ClassDB::bind_method(_MD("get_pressed_texture:Texture"),&TextureButton::get_pressed_texture);
+ ClassDB::bind_method(_MD("get_hover_texture:Texture"),&TextureButton::get_hover_texture);
+ ClassDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
+ ClassDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
+ ClassDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
+ ClassDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
+
+ ADD_GROUP("Textures","texture_");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_pressed",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_pressed_texture"), _SCS("get_pressed_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_hover",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_hover_texture"), _SCS("get_hover_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
+ ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"texture_click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"texture_scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
}
@@ -241,17 +239,7 @@ Size2 TextureButton::get_texture_scale() const{
return scale;
}
-void TextureButton::set_modulate(const Color& p_modulate) {
- modulate=p_modulate;
- update();
-}
-
-Color TextureButton::get_modulate() const {
- return modulate;
-}
-
-
TextureButton::TextureButton() {
scale=Size2(1.0, 1.0);
- modulate=Color(1,1,1);
+
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 0556df8061..ef4d4d5b5b 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
#include "scene/resources/bit_mask.h"
class TextureButton : public BaseButton {
- OBJ_TYPE( TextureButton, BaseButton );
+ GDCLASS( TextureButton, BaseButton );
Ref<Texture> normal;
Ref<Texture> pressed;
@@ -42,8 +42,6 @@ class TextureButton : public BaseButton {
Ref<Texture> focused;
Ref<BitMap> click_mask;
Size2 scale;
- Color modulate;
-
protected:
@@ -71,9 +69,6 @@ public:
void set_texture_scale(Size2 p_scale);
Size2 get_texture_scale() const;
- void set_modulate(const Color& p_modulate);
- Color get_modulate() const;
-
TextureButton();
};
diff --git a/scene/gui/texture_progress.cpp b/scene/gui/texture_progress.cpp
index 2c576b6ba5..f6a33b5643 100644
--- a/scene/gui/texture_progress.cpp
+++ b/scene/gui/texture_progress.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -135,24 +135,24 @@ void TextureProgress::_notification(int p_what){
Size2 s = progress->get_size();
switch (mode) {
case FILL_LEFT_TO_RIGHT: {
- Rect2 region=Rect2(Point2(),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_RIGHT_TO_LEFT: {
- Rect2 region=Rect2(Point2(s.x-s.x*get_unit_value(),0),Size2(s.x*get_unit_value(),s.y));
+ Rect2 region=Rect2(Point2(s.x-s.x*get_as_ratio(),0),Size2(s.x*get_as_ratio(),s.y));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_TOP_TO_BOTTOM: {
- Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_BOTTOM_TO_TOP: {
- Rect2 region=Rect2(Point2(0,s.y-s.y*get_unit_value()),Size2(s.x,s.y*get_unit_value()));
+ Rect2 region=Rect2(Point2(0,s.y-s.y*get_as_ratio()),Size2(s.x,s.y*get_as_ratio()));
draw_texture_rect_region(progress,region,region);
} break;
case FILL_CLOCKWISE:
case FILL_COUNTER_CLOCKWISE: {
- float val=get_unit_value()*rad_max_degrees/360;
+ float val=get_as_ratio()*rad_max_degrees/360;
if (val==1) {
Rect2 region=Rect2(Point2(),s);
draw_texture_rect_region(progress,region,region);
@@ -192,7 +192,7 @@ void TextureProgress::_notification(int p_what){
}
} break;
default:
- draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)),Rect2(Point2(),Size2(s.x*get_unit_value(),s.y)));
+ draw_texture_rect_region(progress,Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)),Rect2(Point2(),Size2(s.x*get_as_ratio(),s.y)));
}
@@ -255,34 +255,36 @@ Point2 TextureProgress::get_radial_center_offset()
void TextureProgress::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
- ObjectTypeDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
+ ClassDB::bind_method(_MD("set_under_texture","tex"),&TextureProgress::set_under_texture);
+ ClassDB::bind_method(_MD("get_under_texture"),&TextureProgress::get_under_texture);
- ObjectTypeDB::bind_method(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
- ObjectTypeDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_texture);
+ ClassDB::bind_method(_MD("set_progress_texture","tex"),&TextureProgress::set_progress_texture);
+ ClassDB::bind_method(_MD("get_progress_texture"),&TextureProgress::get_progress_texture);
- ObjectTypeDB::bind_method(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
- ObjectTypeDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_texture);
+ ClassDB::bind_method(_MD("set_over_texture","tex"),&TextureProgress::set_over_texture);
+ ClassDB::bind_method(_MD("get_over_texture"),&TextureProgress::get_over_texture);
- ObjectTypeDB::bind_method(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
- ObjectTypeDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
+ ClassDB::bind_method(_MD("set_fill_mode","mode"),&TextureProgress::set_fill_mode);
+ ClassDB::bind_method(_MD("get_fill_mode"), &TextureProgress::get_fill_mode);
- ObjectTypeDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
- ObjectTypeDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
+ ClassDB::bind_method(_MD("set_radial_initial_angle","mode"),&TextureProgress::set_radial_initial_angle);
+ ClassDB::bind_method(_MD("get_radial_initial_angle"), &TextureProgress::get_radial_initial_angle);
- ObjectTypeDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
- ObjectTypeDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
+ ClassDB::bind_method(_MD("set_radial_center_offset","mode"),&TextureProgress::set_radial_center_offset);
+ ClassDB::bind_method(_MD("get_radial_center_offset"), &TextureProgress::get_radial_center_offset);
- ObjectTypeDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
- ObjectTypeDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
+ ClassDB::bind_method(_MD("set_fill_degrees","mode"),&TextureProgress::set_fill_degrees);
+ ClassDB::bind_method(_MD("get_fill_degrees"), &TextureProgress::get_fill_degrees);
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture/progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
- ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill/fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
- ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_fill/center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
+ ADD_GROUP("Textures","texture_");
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_under",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_under_texture"),_SCS("get_under_texture"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_over",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_over_texture"),_SCS("get_over_texture"));
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"texture_progress",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_progress_texture"),_SCS("get_progress_texture"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"fill_mode",PROPERTY_HINT_ENUM,"Left to Right,Right to Left,Top to Bottom,Bottom to Top,Clockwise,Counter Clockwise"),_SCS("set_fill_mode"),_SCS("get_fill_mode"));
+ ADD_GROUP("Radial Fill","radial_");
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_initial_angle",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_radial_initial_angle"),_SCS("get_radial_initial_angle"));
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"radial_fill_degrees",PROPERTY_HINT_RANGE,"0.0,360.0,0.1,slider"),_SCS("set_fill_degrees"),_SCS("get_fill_degrees"));
+ ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"radial_center_offset"),_SCS("set_radial_center_offset"),_SCS("get_radial_center_offset"));
BIND_CONSTANT( FILL_LEFT_TO_RIGHT );
BIND_CONSTANT( FILL_RIGHT_TO_LEFT );
diff --git a/scene/gui/texture_progress.h b/scene/gui/texture_progress.h
index a4bbd71e94..02794354ef 100644
--- a/scene/gui/texture_progress.h
+++ b/scene/gui/texture_progress.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,7 +33,7 @@
class TextureProgress : public Range {
- OBJ_TYPE( TextureProgress, Range );
+ GDCLASS( TextureProgress, Range );
Ref<Texture> under;
Ref<Texture> progress;
diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_rect.cpp
index 4aa45af863..cbb077ef5d 100644
--- a/scene/gui/texture_frame.cpp
+++ b/scene/gui/texture_rect.cpp
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* texture_frame.cpp */
+/* texture_rect.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -26,10 +26,10 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "texture_frame.h"
+#include "texture_rect.h"
#include "servers/visual_server.h"
-void TextureFrame::_notification(int p_what) {
+void TextureRect::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAW) {
@@ -40,22 +40,22 @@ void TextureFrame::_notification(int p_what) {
switch(stretch_mode) {
case STRETCH_SCALE_ON_EXPAND: {
Size2 s=expand?get_size():texture->get_size();
- draw_texture_rect(texture,Rect2(Point2(),s),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),s),false);
} break;
case STRETCH_SCALE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),false);
} break;
case STRETCH_TILE: {
- draw_texture_rect(texture,Rect2(Point2(),get_size()),true,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),get_size()),true);
} break;
case STRETCH_KEEP: {
- draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(Point2(),texture->get_size()),false);
} break;
case STRETCH_KEEP_CENTERED: {
Vector2 ofs = (get_size() - texture->get_size())/2;
- draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false,modulate);
+ draw_texture_rect(texture,Rect2(ofs,texture->get_size()),false);
} break;
case STRETCH_KEEP_ASPECT_CENTERED:
case STRETCH_KEEP_ASPECT: {
@@ -85,27 +85,24 @@ void TextureFrame::_notification(int p_what) {
}
}
-Size2 TextureFrame::get_minimum_size() const {
+Size2 TextureRect::get_minimum_size() const {
if (!expand && !texture.is_null())
return texture->get_size();
else
return Size2();
}
-void TextureFrame::_bind_methods() {
+void TextureRect::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_texture","texture"), & TextureFrame::set_texture );
- ObjectTypeDB::bind_method(_MD("get_texture"), & TextureFrame::get_texture );
- ObjectTypeDB::bind_method(_MD("set_modulate","modulate"), & TextureFrame::set_modulate );
- ObjectTypeDB::bind_method(_MD("get_modulate"), & TextureFrame::get_modulate );
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), & TextureFrame::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), & TextureFrame::has_expand );
- ObjectTypeDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureFrame::set_stretch_mode );
- ObjectTypeDB::bind_method(_MD("get_stretch_mode"), & TextureFrame::get_stretch_mode );
+ ClassDB::bind_method(_MD("set_texture","texture"), & TextureRect::set_texture );
+ ClassDB::bind_method(_MD("get_texture"), & TextureRect::get_texture );
+ ClassDB::bind_method(_MD("set_expand","enable"), & TextureRect::set_expand );
+ ClassDB::bind_method(_MD("has_expand"), & TextureRect::has_expand );
+ ClassDB::bind_method(_MD("set_stretch_mode","stretch_mode"), & TextureRect::set_stretch_mode );
+ ClassDB::bind_method(_MD("get_stretch_mode"), & TextureRect::get_stretch_mode );
ADD_PROPERTYNZ( PropertyInfo( Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), _SCS("set_texture"),_SCS("get_texture") );
- ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), _SCS("set_modulate"),_SCS("get_modulate") );
ADD_PROPERTYNZ( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
ADD_PROPERTYNO( PropertyInfo( Variant::INT, "stretch_mode",PROPERTY_HINT_ENUM,"Scale On Expand (Compat),Scale,Tile,Keep,Keep Centered,Keep Aspect,Keep Aspect Centered"), _SCS("set_stretch_mode"),_SCS("get_stretch_mode") );
@@ -120,65 +117,55 @@ void TextureFrame::_bind_methods() {
}
-void TextureFrame::set_texture(const Ref<Texture>& p_tex) {
+void TextureRect::set_texture(const Ref<Texture>& p_tex) {
texture=p_tex;
update();
- //if (texture.is_valid())
- // texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ /*
+ if (texture.is_valid())
+ texture->set_flags(texture->get_flags()&(~Texture::FLAG_REPEAT)); //remove repeat from texture, it looks bad in sprites
+ */
minimum_size_changed();
}
-Ref<Texture> TextureFrame::get_texture() const {
+Ref<Texture> TextureRect::get_texture() const {
return texture;
}
-void TextureFrame::set_modulate(const Color& p_tex) {
- modulate=p_tex;
- update();
-}
-
-Color TextureFrame::get_modulate() const{
-
- return modulate;
-}
-
-
-void TextureFrame::set_expand(bool p_expand) {
+void TextureRect::set_expand(bool p_expand) {
expand=p_expand;
update();
minimum_size_changed();
}
-bool TextureFrame::has_expand() const {
+bool TextureRect::has_expand() const {
return expand;
}
-void TextureFrame::set_stretch_mode(StretchMode p_mode) {
+void TextureRect::set_stretch_mode(StretchMode p_mode) {
stretch_mode=p_mode;
update();
}
-TextureFrame::StretchMode TextureFrame::get_stretch_mode() const {
+TextureRect::StretchMode TextureRect::get_stretch_mode() const {
return stretch_mode;
}
-TextureFrame::TextureFrame() {
+TextureRect::TextureRect() {
expand=false;
- modulate=Color(1,1,1,1);
- set_ignore_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_IGNORE);
stretch_mode=STRETCH_SCALE_ON_EXPAND;
}
-TextureFrame::~TextureFrame()
+TextureRect::~TextureRect()
{
}
diff --git a/scene/gui/texture_frame.h b/scene/gui/texture_rect.h
index 0b47202532..e95d742759 100644
--- a/scene/gui/texture_frame.h
+++ b/scene/gui/texture_rect.h
@@ -1,11 +1,11 @@
/*************************************************************************/
-/* texture_frame.h */
+/* texture_rect.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -33,9 +33,9 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class TextureFrame : public Control {
+class TextureRect : public Control {
- OBJ_TYPE(TextureFrame,Control);
+ GDCLASS(TextureRect,Control);
public:
enum StretchMode {
STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
@@ -49,7 +49,6 @@ public:
};
private:
bool expand;
- Color modulate;
Ref<Texture> texture;
StretchMode stretch_mode;
protected:
@@ -63,8 +62,6 @@ public:
void set_texture(const Ref<Texture>& p_tex);
Ref<Texture> get_texture() const;
- void set_modulate(const Color& p_tex);
- Color get_modulate() const;
void set_expand(bool p_expand);
bool has_expand() const;
@@ -72,10 +69,10 @@ public:
void set_stretch_mode(StretchMode p_mode);
StretchMode get_stretch_mode() const;
- TextureFrame();
- ~TextureFrame();
+ TextureRect();
+ ~TextureRect();
};
-VARIANT_ENUM_CAST( TextureFrame::StretchMode );
+VARIANT_ENUM_CAST( TextureRect::StretchMode );
#endif // TEXTURE_FRAME_H
diff --git a/scene/gui/tool_button.cpp b/scene/gui/tool_button.cpp
index fd27800384..817b506f10 100644
--- a/scene/gui/tool_button.cpp
+++ b/scene/gui/tool_button.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
diff --git a/scene/gui/tool_button.h b/scene/gui/tool_button.h
index f48d7d413c..ddeb34273b 100644
--- a/scene/gui/tool_button.h
+++ b/scene/gui/tool_button.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,7 +32,7 @@
#include "scene/gui/button.h"
class ToolButton : public Button {
- OBJ_TYPE(ToolButton,Button);
+ GDCLASS(ToolButton,Button);
public:
ToolButton();
};
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 20794b2faa..58c829690f 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -32,6 +32,7 @@
#include "os/keyboard.h"
#include "globals.h"
#include "os/input.h"
+#include "scene/main/viewport.h"
@@ -568,6 +569,15 @@ void TreeItem::set_button(int p_column,int p_idx,const Ref<Texture>& p_button){
}
+void TreeItem::set_button_color(int p_column,int p_idx,const Color& p_color) {
+
+ ERR_FAIL_INDEX( p_column, cells.size() );
+ ERR_FAIL_INDEX( p_idx, cells[p_column].buttons.size() );
+ cells[p_column].buttons[p_idx].color=p_color;
+ _changed_notify(p_column);
+
+}
+
void TreeItem::set_editable(int p_column,bool p_editable) {
ERR_FAIL_INDEX( p_column, cells.size() );
@@ -647,76 +657,76 @@ Color TreeItem::get_custom_bg_color(int p_column) const {
void TreeItem::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
- ObjectTypeDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
+ ClassDB::bind_method(_MD("set_cell_mode","column","mode"),&TreeItem::set_cell_mode);
+ ClassDB::bind_method(_MD("get_cell_mode","column"),&TreeItem::get_cell_mode);
- ObjectTypeDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
- ObjectTypeDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
+ ClassDB::bind_method(_MD("set_checked","column","checked"),&TreeItem::set_checked);
+ ClassDB::bind_method(_MD("is_checked","column"),&TreeItem::is_checked);
- ObjectTypeDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
- ObjectTypeDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
+ ClassDB::bind_method(_MD("set_text","column","text"),&TreeItem::set_text);
+ ClassDB::bind_method(_MD("get_text","column"),&TreeItem::get_text);
- ObjectTypeDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
- ObjectTypeDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
+ ClassDB::bind_method(_MD("set_icon","column","texture:Texture"),&TreeItem::set_icon);
+ ClassDB::bind_method(_MD("get_icon:Texture","column"),&TreeItem::get_icon);
- ObjectTypeDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
- ObjectTypeDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
+ ClassDB::bind_method(_MD("set_icon_region","column","region"),&TreeItem::set_icon_region);
+ ClassDB::bind_method(_MD("get_icon_region","column"),&TreeItem::get_icon_region);
- ObjectTypeDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
- ObjectTypeDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
+ ClassDB::bind_method(_MD("set_icon_max_width","column","width"),&TreeItem::set_icon_max_width);
+ ClassDB::bind_method(_MD("get_icon_max_width","column"),&TreeItem::get_icon_max_width);
- ObjectTypeDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
- ObjectTypeDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
- ObjectTypeDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
+ ClassDB::bind_method(_MD("set_range","column","value"),&TreeItem::set_range);
+ ClassDB::bind_method(_MD("get_range","column"),&TreeItem::get_range);
+ ClassDB::bind_method(_MD("set_range_config","column","min","max","step","expr"),&TreeItem::set_range_config,DEFVAL(false));
+ ClassDB::bind_method(_MD("get_range_config","column"),&TreeItem::_get_range_config);
- ObjectTypeDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
- ObjectTypeDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
+ ClassDB::bind_method(_MD("set_metadata","column","meta"),&TreeItem::set_metadata);
+ ClassDB::bind_method(_MD("get_metadata","column"),&TreeItem::get_metadata);
- ObjectTypeDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
+ ClassDB::bind_method(_MD("set_custom_draw","column","object","callback"),&TreeItem::set_custom_draw);
- ObjectTypeDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
- ObjectTypeDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
+ ClassDB::bind_method(_MD("set_collapsed","enable"),&TreeItem::set_collapsed);
+ ClassDB::bind_method(_MD("is_collapsed"),&TreeItem::is_collapsed);
- ObjectTypeDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
- ObjectTypeDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
- ObjectTypeDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
- ObjectTypeDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
+ ClassDB::bind_method(_MD("get_next:TreeItem"),&TreeItem::get_next);
+ ClassDB::bind_method(_MD("get_prev:TreeItem"),&TreeItem::get_prev);
+ ClassDB::bind_method(_MD("get_parent:TreeItem"),&TreeItem::get_parent);
+ ClassDB::bind_method(_MD("get_children:TreeItem"),&TreeItem::get_children);
- ObjectTypeDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
- ObjectTypeDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
+ ClassDB::bind_method(_MD("get_next_visible:TreeItem"),&TreeItem::get_next_visible);
+ ClassDB::bind_method(_MD("get_prev_visible:TreeItem"),&TreeItem::get_prev_visible);
- ObjectTypeDB::bind_method(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
+ ClassDB::bind_method(_MD("remove_child:TreeItem","child"),&TreeItem::_remove_child);
- ObjectTypeDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
- ObjectTypeDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
+ ClassDB::bind_method(_MD("set_selectable","column","selectable"),&TreeItem::set_selectable);
+ ClassDB::bind_method(_MD("is_selectable","column"),&TreeItem::is_selectable);
- ObjectTypeDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
- ObjectTypeDB::bind_method(_MD("select","column"),&TreeItem::select);
- ObjectTypeDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
+ ClassDB::bind_method(_MD("is_selected","column"),&TreeItem::is_selected);
+ ClassDB::bind_method(_MD("select","column"),&TreeItem::select);
+ ClassDB::bind_method(_MD("deselect","column"),&TreeItem::deselect);
- ObjectTypeDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
- ObjectTypeDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
+ ClassDB::bind_method(_MD("set_editable","column","enabled"),&TreeItem::set_editable);
+ ClassDB::bind_method(_MD("is_editable","column"),&TreeItem::is_editable);
- ObjectTypeDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
- ObjectTypeDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
+ ClassDB::bind_method(_MD("set_custom_color","column","color"),&TreeItem::set_custom_color);
+ ClassDB::bind_method(_MD("clear_custom_color","column"),&TreeItem::clear_custom_color);
- ObjectTypeDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
+ ClassDB::bind_method(_MD("set_custom_bg_color","column","color","just_outline"),&TreeItem::set_custom_bg_color,DEFVAL(false));
+ ClassDB::bind_method(_MD("clear_custom_bg_color","column"),&TreeItem::clear_custom_bg_color);
+ ClassDB::bind_method(_MD("get_custom_bg_color","column"),&TreeItem::get_custom_bg_color);
- ObjectTypeDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
- ObjectTypeDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
- ObjectTypeDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
- ObjectTypeDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
- ObjectTypeDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
- ObjectTypeDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
+ ClassDB::bind_method(_MD("add_button","column","button:Texture","button_idx","disabled"),&TreeItem::add_button,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("get_button_count","column"),&TreeItem::get_button_count);
+ ClassDB::bind_method(_MD("get_button:Texture","column","button_idx"),&TreeItem::get_button);
+ ClassDB::bind_method(_MD("set_button","column","button_idx","button:Texture"),&TreeItem::set_button);
+ ClassDB::bind_method(_MD("erase_button","column","button_idx"),&TreeItem::erase_button);
+ ClassDB::bind_method(_MD("is_button_disabled","column","button_idx"),&TreeItem::is_button_disabled);
- ObjectTypeDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
- ObjectTypeDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
+ ClassDB::bind_method(_MD("set_tooltip","column","tooltip"),&TreeItem::set_tooltip);
+ ClassDB::bind_method(_MD("get_tooltip","column"),&TreeItem::get_tooltip);
- ObjectTypeDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
- ObjectTypeDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
+ ClassDB::bind_method(_MD("move_to_top"),&TreeItem::move_to_top);
+ ClassDB::bind_method(_MD("move_to_bottom"),&TreeItem::move_to_bottom);
BIND_CONSTANT( CELL_MODE_STRING );
BIND_CONSTANT( CELL_MODE_CHECK );
@@ -829,6 +839,8 @@ void Tree::update_cache() {
cache.guide_width=get_constant("guide_width");
cache.draw_relationship_lines=get_constant("draw_relationship_lines");
cache.relationship_line_color=get_color("relationship_line_color");
+ cache.scroll_border=get_constant("scroll_border");
+ cache.scroll_speed=get_constant("scroll_speed");
cache.title_button = get_stylebox("title_button_normal");
cache.title_button_pressed = get_stylebox("title_button_pressed");
@@ -937,8 +949,10 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons
}
-// if (p_tool)
-// rect.size.x-=Math::floor(rect.size.y/2);
+ /*
+ if (p_tool)
+ rect.size.x-=Math::floor(rect.size.y/2);
+ */
Ref<Font> font = cache.font;
@@ -1017,7 +1031,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
}
//draw separation.
-// if (p_item->get_parent()!=root || !hide_root)
+ //if (p_item->get_parent()!=root || !hide_root)
Ref<Font> font = cache.font;
@@ -1058,7 +1072,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
o.y+=(label_h-s.height)/2;
o+=cache.button_pressed->get_offset();
- b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):Color(1,1,1,1));
+ b->draw(ci,o,p_item->cells[i].buttons[j].disabled?Color(1,1,1,0.5):p_item->cells[i].buttons[j].color);
w-=s.width+cache.button_margin;
bw+=s.width+cache.button_margin;
}
@@ -1103,7 +1117,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
} else {
cache.selected->draw(ci,r );
}
- if (text_editor->is_visible()){
+ if (text_editor->is_visible_in_tree()){
text_editor->set_pos(get_global_pos() + r.pos);
}
}
@@ -1250,7 +1264,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
} break;
case TreeItem::CELL_MODE_CUSTOM: {
- // int option = (int)p_item->cells[i].val;
+ //int option = (int)p_item->cells[i].val;
@@ -1328,7 +1342,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
int root_ofs = children_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
int parent_ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h/2)-cache.offset+p_draw_ofs;
- if (c->get_children() > 0)
+ if (c->get_children() != NULL)
root_pos -= Point2i(cache.arrow->get_width(),0);
Point2i parent_pos = Point2i(parent_ofs - cache.arrow->get_width()/2, p_pos.y + label_h/2 + cache.arrow->get_height()/2)-cache.offset+p_draw_ofs;
@@ -1393,11 +1407,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (select_mode==SELECT_ROW) {
-
- if (p_selected==p_current) {
-
- if (!c.selected) {
-
+ if (p_selected==p_current && !c.selected) {
c.selected=true;
selected_item=p_selected;
selected_col=0;
@@ -1406,25 +1416,20 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
emit_signal("item_selected");
emitted_row=true;
}
- //if (p_col==i)
- // p_current->selected_signal.call(p_col);
- }
+ /*
+ if (p_col==i)
+ p_current->selected_signal.call(p_col);
+ */
- } else {
-
- if (c.selected) {
+ } else if (c.selected) {
c.selected=false;
//p_current->deselected_signal.call(p_col);
- }
-
}
-
} else if (select_mode==SELECT_SINGLE || select_mode==SELECT_MULTI) {
if (!r_in_range && &selected_cell==&c) {
-
if (!selected_cell.selected) {
selected_cell.selected=true;
@@ -1435,6 +1440,8 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
emit_signal("cell_selected");
if (select_mode==SELECT_MULTI)
emit_signal("multi_selected",p_current,i,true);
+ else if(select_mode == SELECT_SINGLE)
+ emit_signal("item_selected");
} else if (select_mode==SELECT_MULTI && (selected_item!=p_selected || selected_col!=i)) {
@@ -1669,9 +1676,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
}
}
- //if (!c.selected && select_mode==SELECT_MULTI) {
- // emit_signal("multi_selected",p_item,col,true);
- //}
+ /*
+ if (!c.selected && select_mode==SELECT_MULTI) {
+ emit_signal("multi_selected",p_item,col,true);
+ }
+ */
update();
}
@@ -1701,16 +1710,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
} break;
case TreeItem::CELL_MODE_CHECK: {
- Ref<Texture> checked = cache.checked;
bring_up_editor=false; //checkboxes are not edited with editor
- if (x>=0 && x<= checked->get_width()+cache.hseparation ) {
-
-
- p_item->set_checked(col,!c.checked);
- item_edited(col,p_item);
- click_handled=true;
- //p_item->edited_signal.call(col);
- }
+ p_item->set_checked(col, !c.checked);
+ item_edited(col, p_item);
+ click_handled = true;
+ //p_item->edited_signal.call(col);
} break;
case TreeItem::CELL_MODE_RANGE:
@@ -1957,7 +1961,7 @@ void Tree::popup_select(int p_option) {
-void Tree::_input_event(InputEvent p_event) {
+void Tree::_gui_input(InputEvent p_event) {
switch (p_event.type) {
@@ -1999,7 +2003,7 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case KEY_LEFT: {
-// TreeItem *next = NULL;
+ //TreeItem *next = NULL;
if (!selected_item)
break;
if (select_mode==SELECT_ROW)
@@ -2029,7 +2033,7 @@ void Tree::_input_event(InputEvent p_event) {
next=selected_item->get_next_visible();
-// if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
+ //if (diff < uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000))) {
if (last_keypress!=0) {
//incr search next
int col;
@@ -2279,10 +2283,10 @@ void Tree::_input_event(InputEvent p_event) {
mpos.y-=_get_title_button_height();
if (mpos.y>=0) {
- if (h_scroll->is_visible())
- mpos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- mpos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ mpos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ mpos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,mpos,col,h,section);
@@ -2331,7 +2335,7 @@ void Tree::_input_event(InputEvent p_event) {
drag_accum-=b.relative_y;
- v_scroll->set_val(drag_from+drag_accum);
+ v_scroll->set_value(drag_from+drag_accum);
drag_speed=-b.speed_y;
}
@@ -2365,19 +2369,11 @@ void Tree::_input_event(InputEvent p_event) {
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
warp_mouse(range_drag_capture_pos);
} else {
-
- if (delayed_text_editor) {
- uint64_t diff = OS::get_singleton()->get_ticks_msec() - first_selection_time;
- if (diff >= 400 && diff <= 800)
- edit_selected();
- // fast double click
- else if (diff < 400) {
- emit_signal("item_double_clicked");
- }
-
- first_selection_time = OS::get_singleton()->get_ticks_msec();
- } else {
+ Rect2 rect = get_selected()->get_meta("__focus_rect");
+ if (rect.has_point(Point2(p_event.mouse_button.x,p_event.mouse_button.y))) {
edit_selected();
+ } else {
+ emit_signal("item_double_clicked");
}
}
pressing_for_editor=false;
@@ -2415,6 +2411,9 @@ void Tree::_input_event(InputEvent p_event) {
}
+ if (range_drag_enabled)
+ break;
+
switch(b.button_index) {
case BUTTON_RIGHT:
case BUTTON_LEFT: {
@@ -2477,8 +2476,8 @@ void Tree::_input_event(InputEvent p_event) {
if (!click_handled) {
drag_speed=0;
drag_accum=0;
-// last_drag_accum=0;
- drag_from=v_scroll->get_val();
+ //last_drag_accum=0;
+ drag_from=v_scroll->get_value();
drag_touching=OS::get_singleton()->has_touchscreen_ui_hint();
drag_touching_deaccel=false;
if (drag_touching) {
@@ -2490,11 +2489,11 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case BUTTON_WHEEL_UP: {
- v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
+ v_scroll->set_value( v_scroll->get_value()-v_scroll->get_page()/8 );
} break;
case BUTTON_WHEEL_DOWN: {
- v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
+ v_scroll->set_value( v_scroll->get_value()+v_scroll->get_page()/8 );
} break;
}
@@ -2573,8 +2572,8 @@ bool Tree::edit_selected() {
value_editor->set_min( c.min );
value_editor->set_max( c.max );
value_editor->set_step( c.step );
- value_editor->set_val( c.val );
- value_editor->set_exp_unit_value( c.expr );
+ value_editor->set_value( c.val );
+ value_editor->set_exp_ratio( c.expr );
updating_value_editor=false;
}
@@ -2633,7 +2632,7 @@ void Tree::update_scrollbars() {
v_scroll->show();
v_scroll->set_max(min.height);
v_scroll->set_page(size.height - hmin.height - tbh);
- cache.offset.y=v_scroll->get_val();
+ cache.offset.y=v_scroll->get_value();
}
if (min.width < size.width - vmin.width) {
@@ -2645,7 +2644,7 @@ void Tree::update_scrollbars() {
h_scroll->show();
h_scroll->set_max(min.width);
h_scroll->set_page(size.width - vmin.width);
- cache.offset.x=h_scroll->get_val();
+ cache.offset.x=h_scroll->get_value();
}
}
@@ -2681,11 +2680,17 @@ void Tree::_notification(int p_what) {
if (p_what==NOTIFICATION_DRAG_END) {
drop_mode_flags=0;
+ scrolling = false;
+ set_fixed_process(false);
update();
}
if (p_what==NOTIFICATION_DRAG_BEGIN) {
single_select_defer=NULL;
+ if (cache.scroll_speed > 0 && get_rect().has_point(get_viewport()->get_mouse_pos() - get_global_pos())) {
+ scrolling = true;
+ set_fixed_process(true);
+ }
}
if (p_what==NOTIFICATION_FIXED_PROCESS) {
@@ -2693,7 +2698,7 @@ void Tree::_notification(int p_what) {
if (drag_touching_deaccel) {
- float pos = v_scroll->get_val();
+ float pos = v_scroll->get_value();
pos+=drag_speed*get_fixed_process_delta_time();
bool turnoff=false;
@@ -2710,7 +2715,7 @@ void Tree::_notification(int p_what) {
}
- v_scroll->set_val(pos);
+ v_scroll->set_value(pos);
float sgn = drag_speed<0? -1 : 1;
float val = Math::abs(drag_speed);
val-=1000*get_fixed_process_delta_time();
@@ -2731,6 +2736,28 @@ void Tree::_notification(int p_what) {
}
}
+
+ if (scrolling) {
+ Point2 point = get_viewport()->get_mouse_pos() - get_global_pos();
+ if (point.x < cache.scroll_border) {
+ point.x -= cache.scroll_border;
+ } else if (point.x > get_size().width - cache.scroll_border) {
+ point.x -= get_size().width - cache.scroll_border;
+ } else {
+ point.x = 0;
+ }
+ if (point.y < cache.scroll_border) {
+ point.y -= cache.scroll_border;
+ } else if (point.y > get_size().height - cache.scroll_border) {
+ point.y -= get_size().height - cache.scroll_border;
+ } else {
+ point.y = 0;
+ }
+ point *= cache.scroll_speed * get_fixed_process_delta_time();
+ point += get_scroll();
+ h_scroll->set_value(point.x);
+ v_scroll->set_value(point.y);
+ }
}
if (p_what==NOTIFICATION_DRAW) {
@@ -2739,8 +2766,6 @@ void Tree::_notification(int p_what) {
update_scrollbars();
RID ci = get_canvas_item();
- VisualServer::get_singleton()->canvas_item_set_clip(ci,true);
-
Ref<StyleBox> bg = cache.bg;
Ref<StyleBox> bg_focus = get_stylebox("bg_focus");
@@ -2768,13 +2793,10 @@ void Tree::_notification(int p_what) {
}
int ofs=0;
-// int from_y=exposed.pos.y+bg->get_margin(MARGIN_TOP);
-// int size_y=exposed.size.height-bg->get_minimum_size().height;
for (int i=0;i<(columns.size()-1-1);i++) {
ofs+=get_column_width(i);
- //get_painter()->draw_fill_rect( Point2(ofs+cache.hseparation/2, from_y), Size2( 1, size_y ),color( COLOR_TREE_GRID) );
}
if (show_column_titles) {
@@ -2895,8 +2917,6 @@ void Tree::item_selected(int p_column,TreeItem *p_item) {
p_item->cells[p_column].selected=true;
//emit_signal("multi_selected",p_item,p_column,true); - NO this is for TreeItem::select
- if (delayed_text_editor)
- first_selection_time = OS::get_singleton()->get_ticks_msec();
} else {
@@ -2907,8 +2927,7 @@ void Tree::item_selected(int p_column,TreeItem *p_item) {
void Tree::item_deselected(int p_column,TreeItem *p_item) {
- if (select_mode==SELECT_MULTI) {
-
+ if (select_mode==SELECT_MULTI || select_mode == SELECT_SINGLE) {
p_item->cells[p_column].selected=false;
}
update();
@@ -3000,8 +3019,10 @@ int Tree::get_edited_column() const {
TreeItem* Tree::get_next_selected( TreeItem* p_item) {
- //if (!p_item)
- // return NULL;
+ /*
+ if (!p_item)
+ return NULL;
+ */
if (!root)
return NULL;
@@ -3053,7 +3074,7 @@ int Tree::get_column_width(int p_column) const {
int expand_area=get_size().width-(bg->get_margin(MARGIN_LEFT)+bg->get_margin(MARGIN_RIGHT));
- if (v_scroll->is_visible())
+ if (v_scroll->is_visible_in_tree())
expand_area-=v_scroll->get_combined_minimum_size().width;
int expanding_columns=0;
@@ -3169,10 +3190,10 @@ void Tree::ensure_cursor_is_visible() {
int h = compute_item_height(selected)+cache.vseparation;
int screenh=get_size().height-h_scroll->get_combined_minimum_size().height;
- if (ofs+h>v_scroll->get_val()+screenh)
+ if (ofs+h>v_scroll->get_value()+screenh)
v_scroll->call_deferred("set_val", ofs-screenh+h);
- else if (ofs < v_scroll->get_val())
- v_scroll->set_val(ofs);
+ else if (ofs < v_scroll->get_value())
+ v_scroll->set_value(ofs);
}
int Tree::get_pressed_button() const {
@@ -3238,10 +3259,10 @@ String Tree::get_column_title(int p_column) const {
Point2 Tree::get_scroll() const {
Point2 ofs;
- if (h_scroll->is_visible())
- ofs.x=h_scroll->get_val();
- if (v_scroll->is_visible())
- ofs.y=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ ofs.x=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ ofs.y=v_scroll->get_value();
return ofs;
}
@@ -3284,7 +3305,7 @@ void Tree::_do_incr_search(const String& p_add) {
uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec
uint64_t diff = time - last_keypress;
- if (diff > uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000)))
+ if (diff > uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000)))
incr_search=p_add;
else
incr_search+=p_add;
@@ -3379,10 +3400,10 @@ int Tree::get_column_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -1;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3406,10 +3427,10 @@ int Tree::get_drop_section_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return -100;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3433,10 +3454,10 @@ TreeItem* Tree::get_item_at_pos(const Point2& p_pos) const {
if (pos.y<0)
return NULL;
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3461,10 +3482,10 @@ String Tree::get_tooltip(const Point2& p_pos) const {
if (pos.y<0)
return Control::get_tooltip(p_pos);
- if (h_scroll->is_visible())
- pos.x+=h_scroll->get_val();
- if (v_scroll->is_visible())
- pos.y+=v_scroll->get_val();
+ if (h_scroll->is_visible_in_tree())
+ pos.x+=h_scroll->get_value();
+ if (v_scroll->is_visible_in_tree())
+ pos.y+=v_scroll->get_value();
int col,h,section;
TreeItem *it = _find_item_at_pos(root,pos,col,h,section);
@@ -3546,74 +3567,61 @@ bool Tree::get_allow_rmb_select() const{
}
-void Tree::set_delayed_text_editor(bool enabled) {
- delayed_text_editor = enabled;
-}
-
-bool Tree::is_delayed_text_editor_enabled() const {
- return delayed_text_editor;
-}
-
-
void Tree::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
- ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event);
- ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
- ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
- ObjectTypeDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
- ObjectTypeDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
- ObjectTypeDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
-
- ObjectTypeDB::bind_method(_MD("clear"),&Tree::clear);
- ObjectTypeDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
-
- ObjectTypeDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
- ObjectTypeDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
- ObjectTypeDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
- ObjectTypeDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
+ ClassDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
+ ClassDB::bind_method(_MD("_gui_input"),&Tree::_gui_input);
+ ClassDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
+ ClassDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
+ ClassDB::bind_method(_MD("_text_editor_modal_close"),&Tree::_text_editor_modal_close);
+ ClassDB::bind_method(_MD("_value_editor_changed"),&Tree::value_editor_changed);
+ ClassDB::bind_method(_MD("_scroll_moved"),&Tree::_scroll_moved);
- ObjectTypeDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
- ObjectTypeDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
- ObjectTypeDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
- ObjectTypeDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
- ObjectTypeDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
- ObjectTypeDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
+ ClassDB::bind_method(_MD("clear"),&Tree::clear);
+ ClassDB::bind_method(_MD("create_item:TreeItem","parent:TreeItem"),&Tree::_create_item,DEFVAL(Variant()));
- ObjectTypeDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
- ObjectTypeDB::bind_method(_MD("get_columns"),&Tree::get_columns);
+ ClassDB::bind_method(_MD("get_root:TreeItem"),&Tree::get_root);
+ ClassDB::bind_method(_MD("set_column_min_width","column","min_width"),&Tree::set_column_min_width);
+ ClassDB::bind_method(_MD("set_column_expand","column","expand"),&Tree::set_column_expand);
+ ClassDB::bind_method(_MD("get_column_width","column"),&Tree::get_column_width);
- ObjectTypeDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
- ObjectTypeDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
- ObjectTypeDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
- ObjectTypeDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
- ObjectTypeDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
- ObjectTypeDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
+ ClassDB::bind_method(_MD("set_hide_root","enable"),&Tree::set_hide_root);
+ ClassDB::bind_method(_MD("get_next_selected:TreeItem","from:TreeItem"),&Tree::_get_next_selected);
+ ClassDB::bind_method(_MD("get_selected:TreeItem"),&Tree::get_selected);
+ ClassDB::bind_method(_MD("get_selected_column"),&Tree::get_selected_column);
+ ClassDB::bind_method(_MD("get_pressed_button"),&Tree::get_pressed_button);
+ ClassDB::bind_method(_MD("set_select_mode","mode"),&Tree::set_select_mode);
- ObjectTypeDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
+ ClassDB::bind_method(_MD("set_columns","amount"),&Tree::set_columns);
+ ClassDB::bind_method(_MD("get_columns"),&Tree::get_columns);
- ObjectTypeDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
+ ClassDB::bind_method(_MD("get_edited:TreeItem"),&Tree::get_edited);
+ ClassDB::bind_method(_MD("get_edited_column"),&Tree::get_edited_column);
+ ClassDB::bind_method(_MD("get_custom_popup_rect"),&Tree::get_custom_popup_rect);
+ ClassDB::bind_method(_MD("get_item_area_rect","item:TreeItem","column"),&Tree::_get_item_rect,DEFVAL(-1));
+ ClassDB::bind_method(_MD("get_item_at_pos:TreeItem","pos"),&Tree::get_item_at_pos);
+ ClassDB::bind_method(_MD("get_column_at_pos","pos"),&Tree::get_column_at_pos);
- ObjectTypeDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
- ObjectTypeDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
- ObjectTypeDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
+ ClassDB::bind_method(_MD("ensure_cursor_is_visible"),&Tree::ensure_cursor_is_visible);
- ObjectTypeDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
- ObjectTypeDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
+ ClassDB::bind_method(_MD("set_column_titles_visible","visible"),&Tree::set_column_titles_visible);
+ ClassDB::bind_method(_MD("are_column_titles_visible"),&Tree::are_column_titles_visible);
- ObjectTypeDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
- ObjectTypeDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ClassDB::bind_method(_MD("set_column_title","column","title"),&Tree::set_column_title);
+ ClassDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
+ ClassDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
- ObjectTypeDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
+ ClassDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
+ ClassDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
- ObjectTypeDB::bind_method(_MD("set_delayed_text_editor","enable"),&Tree::set_delayed_text_editor);
- ObjectTypeDB::bind_method(_MD("is_delayed_text_editor_enabled"),&Tree::is_delayed_text_editor_enabled);
+ ClassDB::bind_method(_MD("set_drop_mode_flags","flags"),&Tree::set_drop_mode_flags);
+ ClassDB::bind_method(_MD("get_drop_mode_flags"),&Tree::get_drop_mode_flags);
+ ClassDB::bind_method(_MD("set_allow_rmb_select","allow"),&Tree::set_allow_rmb_select);
+ ClassDB::bind_method(_MD("get_allow_rmb_select"),&Tree::get_allow_rmb_select);
- ObjectTypeDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
- ObjectTypeDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(_MD("set_single_select_cell_editing_only_when_already_selected","enable"),&Tree::set_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(_MD("get_single_select_cell_editing_only_when_already_selected"),&Tree::get_single_select_cell_editing_only_when_already_selected);
ADD_SIGNAL( MethodInfo("item_selected"));
ADD_SIGNAL( MethodInfo("cell_selected"));
@@ -3682,8 +3690,8 @@ Tree::Tree() {
h_scroll->connect("value_changed", this,"_scroll_moved");
v_scroll->connect("value_changed", this,"_scroll_moved");
text_editor->connect("text_entered", this,"_text_editor_enter");
- text_editor->connect("modal_close", this,"_text_editor_modal_close");
- popup_menu->connect("item_pressed", this,"_popup_select");
+ text_editor->connect("modal_closed", this,"_text_editor_modal_close");
+ popup_menu->connect("id_pressed", this,"_popup_select");
value_editor->connect("value_changed", this,"_value_editor_changed");
value_editor->set_as_toplevel(true);
@@ -3706,7 +3714,7 @@ Tree::Tree() {
blocked=0;
cursor_can_exit_tree=true;
- set_stop_mouse(true);
+ set_mouse_filter(MOUSE_FILTER_STOP);
drag_speed=0;
drag_touching=false;
@@ -3726,8 +3734,7 @@ Tree::Tree() {
allow_rmb_select=false;
- first_selection_time = 0;
- delayed_text_editor = false;
+ set_clip_contents(true);
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 2124dce749..d715ff4772 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -45,7 +45,7 @@ class Tree;
class TreeItem : public Object {
- OBJ_TYPE(TreeItem,Object);
+ GDCLASS(TreeItem,Object);
public:
enum TreeCellMode {
@@ -93,7 +93,8 @@ friend class Tree;
int id;
bool disabled;
Ref<Texture> texture;
- Button() { id=0; disabled=false; }
+ Color color;
+ Button() { id=0; disabled=false; color=Color(1,1,1,1); }
};
Vector< Button > buttons;
@@ -189,6 +190,7 @@ public:
int get_button_by_id(int p_column,int p_id) const;
bool is_button_disabled(int p_column,int p_idx) const;
void set_button(int p_column,int p_idx,const Ref<Texture>& p_button);
+ void set_button_color(int p_column,int p_idx,const Color& p_color);
/* range works for mode number or mode combo */
@@ -255,7 +257,7 @@ VARIANT_ENUM_CAST( TreeItem::TreeCellMode );
class Tree : public Control {
- OBJ_TYPE( Tree, Control );
+ GDCLASS( Tree, Control );
public:
enum SelectMode {
SELECT_SINGLE,
@@ -332,7 +334,7 @@ friend class TreeItem;
int compute_item_height(TreeItem *p_item) const;
int get_item_height(TreeItem *p_item) const;
-// void 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);
+ //void 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);
void draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color);
int draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item);
void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL,bool p_force_deselect=false);
@@ -343,7 +345,7 @@ friend class TreeItem;
void popup_select(int p_option);
- void _input_event(InputEvent p_event);
+ void _gui_input(InputEvent p_event);
void _notification(int p_what);
Size2 get_minimum_size() const;
@@ -390,6 +392,8 @@ friend class TreeItem;
int button_margin;
Point2 offset;
int draw_relationship_lines;
+ int scroll_border;
+ int scroll_speed;
enum ClickType {
CLICK_NONE,
@@ -437,9 +441,6 @@ friend class TreeItem;
float last_drag_time;
float time_since_motion;*/
- bool delayed_text_editor;
- uint64_t first_selection_time;
-
float drag_speed;
float drag_from;
float drag_accum;
@@ -448,6 +449,7 @@ friend class TreeItem;
bool drag_touching_deaccel;
bool click_handled;
bool allow_rmb_select;
+ bool scrolling;
bool force_select_on_already_selected;
@@ -534,9 +536,6 @@ public:
void set_value_evaluator(ValueEvaluator *p_evaluator);
- void set_delayed_text_editor(bool enabled);
- bool is_delayed_text_editor_enabled() const;
-
Tree();
~Tree();
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index 1be847929d..4c177ea53c 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -121,7 +121,7 @@ void VideoPlayer::_notification(int p_notification) {
}
} break;
- case NOTIFICATION_PROCESS: {
+ case NOTIFICATION_INTERNAL_PROCESS: {
if (stream.is_null())
return;
@@ -233,7 +233,7 @@ void VideoPlayer::play() {
return;
playback->stop();
playback->play();
- set_process(true);
+ set_process_internal(true);
AudioServer::get_singleton()->stream_set_active(stream_rid,true);
AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
last_audio_time=0;
@@ -248,8 +248,8 @@ void VideoPlayer::stop() {
playback->stop();
AudioServer::get_singleton()->stream_set_active(stream_rid,false);
- resampler.clear();
- set_process(false);
+ resampler.flush();
+ set_process_internal(false);
last_audio_time=0;
};
@@ -266,7 +266,7 @@ void VideoPlayer::set_paused(bool p_paused) {
paused=p_paused;
if (playback.is_valid()) {
playback->set_paused(p_paused);
- set_process(!p_paused);
+ set_process_internal(!p_paused);
};
last_audio_time = 0;
};
@@ -357,47 +357,47 @@ bool VideoPlayer::has_autoplay() const {
void VideoPlayer::_bind_methods() {
- ObjectTypeDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
- ObjectTypeDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
+ ClassDB::bind_method(_MD("set_stream","stream:VideoStream"),&VideoPlayer::set_stream);
+ ClassDB::bind_method(_MD("get_stream:VideoStream"),&VideoPlayer::get_stream);
- ObjectTypeDB::bind_method(_MD("play"),&VideoPlayer::play);
- ObjectTypeDB::bind_method(_MD("stop"),&VideoPlayer::stop);
+ ClassDB::bind_method(_MD("play"),&VideoPlayer::play);
+ ClassDB::bind_method(_MD("stop"),&VideoPlayer::stop);
- ObjectTypeDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
+ ClassDB::bind_method(_MD("is_playing"),&VideoPlayer::is_playing);
- ObjectTypeDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
- ObjectTypeDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
+ ClassDB::bind_method(_MD("set_paused","paused"),&VideoPlayer::set_paused);
+ ClassDB::bind_method(_MD("is_paused"),&VideoPlayer::is_paused);
- ObjectTypeDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
- ObjectTypeDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
+ ClassDB::bind_method(_MD("set_volume","volume"),&VideoPlayer::set_volume);
+ ClassDB::bind_method(_MD("get_volume"),&VideoPlayer::get_volume);
- ObjectTypeDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
- ObjectTypeDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
+ ClassDB::bind_method(_MD("set_volume_db","db"),&VideoPlayer::set_volume_db);
+ ClassDB::bind_method(_MD("get_volume_db"),&VideoPlayer::get_volume_db);
- ObjectTypeDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
- ObjectTypeDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
+ ClassDB::bind_method(_MD("set_audio_track","track"),&VideoPlayer::set_audio_track);
+ ClassDB::bind_method(_MD("get_audio_track"),&VideoPlayer::get_audio_track);
- ObjectTypeDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
+ ClassDB::bind_method(_MD("get_stream_name"),&VideoPlayer::get_stream_name);
- ObjectTypeDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
+ ClassDB::bind_method(_MD("get_stream_pos"),&VideoPlayer::get_stream_pos);
- ObjectTypeDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
- ObjectTypeDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
+ ClassDB::bind_method(_MD("set_autoplay","enabled"),&VideoPlayer::set_autoplay);
+ ClassDB::bind_method(_MD("has_autoplay"),&VideoPlayer::has_autoplay);
- ObjectTypeDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
- ObjectTypeDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
+ ClassDB::bind_method(_MD("set_expand","enable"), &VideoPlayer::set_expand );
+ ClassDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
- ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
+ ClassDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
+ ClassDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
- ObjectTypeDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
+ ClassDB::bind_method(_MD("get_video_texture:Texture"), &VideoPlayer::get_video_texture );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
-// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
- ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
- ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
+ ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
+ //ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
+ ADD_PROPERTY( PropertyInfo(Variant::REAL, "volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL, "paused"), _SCS("set_paused"), _SCS("is_paused") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
}
@@ -426,5 +426,6 @@ VideoPlayer::~VideoPlayer() {
if (stream_rid.is_valid())
AudioServer::get_singleton()->free(stream_rid);
+ resampler.clear(); //Not necessary here, but make in consistent with other "stream_player" classes
};
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index 9ce1ba78f4..694cb253a4 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -5,7 +5,7 @@
/* GODOT ENGINE */
/* http://www.godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -35,7 +35,7 @@
class VideoPlayer : public Control {
- OBJ_TYPE(VideoPlayer,Control);
+ GDCLASS(VideoPlayer,Control);
struct InternalStream : public AudioServer::AudioStream {
VideoPlayer *player;
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
new file mode 100644
index 0000000000..9e89de66dd
--- /dev/null
+++ b/scene/gui/viewport_container.cpp
@@ -0,0 +1,103 @@
+#include "viewport_container.h"
+#include "scene/main/viewport.h"
+Size2 ViewportContainer::get_minimum_size() const {
+
+
+ if (stretch)
+ return Size2();
+ Size2 ms;
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ Size2 minsize = c->get_size();
+ ms.width = MAX(ms.width , minsize.width);
+ ms.height = MAX(ms.height , minsize.height);
+ }
+
+ return ms;
+
+}
+
+
+void ViewportContainer::set_stretch(bool p_enable) {
+
+ stretch=p_enable;
+ queue_sort();
+ update();
+
+}
+
+bool ViewportContainer::is_stretch_enabled() const {
+
+ return stretch;
+}
+
+
+void ViewportContainer::_notification(int p_what) {
+
+
+ if (p_what==NOTIFICATION_RESIZED) {
+
+ if (!stretch)
+ return;
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ c->set_size(get_size());
+ }
+ }
+
+ if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+
+ for(int i=0;i<get_child_count();i++) {
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+
+ if (is_visible_in_tree())
+ c->set_update_mode(Viewport::UPDATE_ALWAYS);
+ else
+ c->set_update_mode(Viewport::UPDATE_DISABLED);
+ }
+
+ }
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ for(int i=0;i<get_child_count();i++) {
+
+
+ Viewport *c = get_child(i)->cast_to<Viewport>();
+ if (!c)
+ continue;
+
+ if (stretch)
+ draw_texture_rect(c->get_texture(),Rect2(Vector2(),get_size()*Size2(1,-1)));
+ else
+ draw_texture_rect(c->get_texture(),Rect2(Vector2(),c->get_size()*Size2(1,-1)));
+ }
+ }
+
+}
+
+void ViewportContainer::_bind_methods() {
+
+ ClassDB::bind_method(_MD("set_stretch","enable"),&ViewportContainer::set_stretch);
+ ClassDB::bind_method(_MD("is_stretch_enabled"),&ViewportContainer::is_stretch_enabled);
+
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"stretch"),_SCS("set_stretch"),_SCS("is_stretch_enabled"));
+}
+
+ViewportContainer::ViewportContainer() {
+
+ stretch=false;
+}
diff --git a/scene/gui/viewport_container.h b/scene/gui/viewport_container.h
new file mode 100644
index 0000000000..632c54f2f4
--- /dev/null
+++ b/scene/gui/viewport_container.h
@@ -0,0 +1,25 @@
+#ifndef VIEWPORTCONTAINER_H
+#define VIEWPORTCONTAINER_H
+
+#include "scene/gui/container.h"
+
+class ViewportContainer : public Container {
+
+ GDCLASS( ViewportContainer, Container );
+
+ bool stretch;
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_stretch(bool p_enable);
+ bool is_stretch_enabled() const;
+
+ virtual Size2 get_minimum_size() const;
+
+ ViewportContainer();
+};
+
+#endif // VIEWPORTCONTAINER_H