summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-02-01 21:32:47 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-02-01 21:32:47 -0300
commitddf21735ba202bb2668205c055a37a5e8f55b8e9 (patch)
tree69647f43823dff239172e329a804fc277bb3817a /scene
parent9386b764978eb0be91e7a4a95340e2c1e9560405 (diff)
-remove the !inside_tree error, fixes grab focus error, closes #3521
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/color_picker.cpp33
-rw-r--r--scene/gui/color_picker.h3
2 files changed, 33 insertions, 3 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 862a5d6bcb..7b553543b6 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -64,7 +64,18 @@ void ColorPicker::_notification(int p_what) {
case NOTIFICATION_ENTER_TREE: {
btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
+ update_material(uv_material, color);
+ update_material(w_material, color);
+
+ uv_edit->get_child(0)->cast_to<Control>()->update();
+ w_edit->get_child(0)->cast_to<Control>()->update();
+ _update_color();
}
+
+ case NOTIFICATION_VISIBILITY_CHANGED: {
+ c_text->call_deferred("grab_focus");
+ c_text->call_deferred("select");
+ } break;
}
}
@@ -88,8 +99,13 @@ void ColorPicker::set_color(const Color& p_color) {
h=color.get_h();
s=color.get_s();
v=color.get_v();
+
+ if (!is_inside_tree())
+ return;
+
update_material(uv_material, color);
update_material(w_material, color);
+
uv_edit->get_child(0)->cast_to<Control>()->update();
w_edit->get_child(0)->cast_to<Control>()->update();
_update_color();
@@ -100,6 +116,10 @@ void ColorPicker::set_edit_alpha(bool p_show) {
edit_alpha=p_show;
_update_controls();
+
+ if (!is_inside_tree())
+ return;
+
_update_color();
sample->update();
}
@@ -136,6 +156,10 @@ void ColorPicker::_html_entered(const String& p_html) {
return;
color = Color::html(p_html);
+
+ if (!is_inside_tree())
+ return;
+
_update_color();
emit_signal("color_changed",color);
}
@@ -163,8 +187,6 @@ void ColorPicker::_update_color() {
} else {
c_text->set_text(color.to_html(edit_alpha && color.a<1));
}
- c_text->grab_focus();
- c_text->select();
sample->update();
updating=false;
@@ -225,6 +247,9 @@ void ColorPicker::set_raw_mode(bool p_enabled) {
if (btn_mode->is_pressed()!=p_enabled)
btn_mode->set_pressed(p_enabled);
+ if (!is_inside_tree())
+ return;
+
_update_controls();
_update_color();
}
@@ -531,7 +556,7 @@ ColorPicker::ColorPicker() :
_update_controls();
- _update_color();
+ //_update_color();
updating=false;
uv_material.instance();
@@ -594,6 +619,8 @@ void ColorPickerButton::pressed() {
popup->set_pos(get_global_pos()-Size2(0,ms.height));
popup->set_size(ms);
popup->popup();
+
+
}
void ColorPickerButton::_notification(int p_what) {
diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h
index 59668ebac1..35f4ae7a99 100644
--- a/scene/gui/color_picker.h
+++ b/scene/gui/color_picker.h
@@ -89,6 +89,9 @@ private:
void _screen_input(const InputEvent& p_input);
void _add_preset_pressed();
void _screen_pick_pressed();
+
+friend class ColorPicker;
+
protected:
void _notification(int);