diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 3d3fecc8f90..da26c84e45c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -65,6 +65,9 @@ void CustomPropertyEditor::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2( 10,10,60, get_size().height-20 ), v ); }*/ } + if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) { + hide(); + } } void CustomPropertyEditor::_menu_option(int p_which) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index bc1b16bea81..ee6af21dbdb 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -48,7 +48,15 @@ void ColorPicker::_notification(int p_what) { btn_pick->set_icon(get_icon("screen_picker", "ColorPicker")); _update_color(); - } + } break; + + case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: { + if (screen != NULL) { + if (screen->is_visible()) { + screen->hide(); + } + } + } break; } } @@ -84,9 +92,6 @@ void ColorPicker::set_pick_color(const Color &p_color) { if (!is_inside_tree()) return; - return; //it crashes, so returning - uv_edit->get_child(0)->cast_to()->update(); - w_edit->get_child(0)->cast_to()->update(); _update_color(); } @@ -427,19 +432,12 @@ void ColorPicker::_screen_input(const Ref &ev) { Viewport *r = get_tree()->get_root(); if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y))) return; - Ref img; //= r->get_screen_capture(); - if (!img.is_null()) { - last_capture = img; - //r->queue_screen_capture(); - } - if (last_capture.is_valid() && !last_capture->empty()) { - int pw = last_capture->get_format() == Image::FORMAT_RGBA8 ? 4 : 3; - int ofs = (mev->get_global_position().y * last_capture->get_width() + mev->get_global_position().x) * pw; - - PoolVector::Read r = last_capture->get_data().read(); - - Color c(r[ofs + 0] / 255.0, r[ofs + 1] / 255.0, r[ofs + 2] / 255.0); - + Ref img = r->get_texture()->get_data(); + if (img.is_valid() && !img->empty()) { + img->lock(); + Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position(); + Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y); + img->unlock(); set_pick_color(c); } } @@ -456,11 +454,11 @@ void ColorPicker::_screen_pick_pressed() { r->add_child(screen); screen->set_as_toplevel(true); screen->set_area_as_parent_rect(); + screen->set_default_cursor_shape(CURSOR_POINTING_HAND); screen->connect("gui_input", this, "_screen_input"); } screen->raise(); screen->show_modal(); - // r->queue_screen_capture(); } void ColorPicker::_bind_methods() { @@ -632,6 +630,10 @@ void ColorPickerButton::_notification(int p_what) { Ref normal = get_stylebox("normal"); draw_rect(Rect2(normal->get_offset(), get_size() - normal->get_minimum_size()), picker->get_pick_color()); } + + if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST) { + popup->hide(); + } } void ColorPickerButton::set_pick_color(const Color &p_color) { diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index ca47c3a5f4e..de624fd029c 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -47,7 +47,6 @@ class ColorPicker : public BoxContainer { private: Control *screen; - Ref last_capture; Control *uv_edit; Control *w_edit; TextureRect *sample;