mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Merge pull request #98368 from KoBeWi/color_picking_active_your_color_is_now_being_picked_please_pick_your_color
Fix legacy picking label bounds
This commit is contained in:
commit
6bd24cbad2
@ -1557,19 +1557,16 @@ void ColorPicker::_pick_button_pressed_legacy() {
|
||||
picker_texture_rect->set_default_cursor_shape(CURSOR_POINTING_HAND);
|
||||
picker_texture_rect->connect(SceneStringName(gui_input), callable_mp(this, &ColorPicker::_picker_texture_input));
|
||||
|
||||
picker_preview = memnew(Panel);
|
||||
picker_preview->set_anchors_preset(Control::PRESET_CENTER_TOP);
|
||||
picker_preview->set_mouse_filter(MOUSE_FILTER_IGNORE);
|
||||
picker_window->add_child(picker_preview);
|
||||
|
||||
picker_preview_label = memnew(Label);
|
||||
picker_preview->set_anchors_preset(Control::PRESET_CENTER_TOP);
|
||||
picker_preview_label->set_anchors_preset(Control::PRESET_CENTER_TOP);
|
||||
picker_preview_label->set_text(ETR("Color Picking active"));
|
||||
picker_preview->add_child(picker_preview_label);
|
||||
|
||||
picker_preview_style_box = (Ref<StyleBoxFlat>)memnew(StyleBoxFlat);
|
||||
picker_preview_style_box.instantiate();
|
||||
picker_preview_style_box->set_bg_color(Color(1.0, 1.0, 1.0));
|
||||
picker_preview->add_theme_style_override(SceneStringName(panel), picker_preview_style_box);
|
||||
picker_preview_style_box->set_content_margin_all(4.0);
|
||||
picker_preview_label->add_theme_style_override(CoreStringName(normal), picker_preview_style_box);
|
||||
|
||||
picker_window->add_child(picker_preview_label);
|
||||
}
|
||||
|
||||
Rect2i screen_rect;
|
||||
@ -1611,7 +1608,7 @@ void ColorPicker::_pick_button_pressed_legacy() {
|
||||
}
|
||||
|
||||
picker_window->set_size(screen_rect.size);
|
||||
picker_preview->set_size(screen_rect.size / 10.0); // 10% of size in each axis.
|
||||
picker_preview_label->set_custom_minimum_size(screen_rect.size / 10); // 10% of size in each axis.
|
||||
picker_window->popup();
|
||||
}
|
||||
|
||||
@ -1634,7 +1631,7 @@ void ColorPicker::_picker_texture_input(const Ref<InputEvent> &p_event) {
|
||||
Vector2 ofs = mev->get_position();
|
||||
picker_color = img->get_pixel(ofs.x, ofs.y);
|
||||
picker_preview_style_box->set_bg_color(picker_color);
|
||||
picker_preview_label->set_self_modulate(picker_color.get_luminance() < 0.5 ? Color(1.0f, 1.0f, 1.0f) : Color(0.0f, 0.0f, 0.0f));
|
||||
picker_preview_label->add_theme_color_override(SceneStringName(font_color), picker_color.get_luminance() < 0.5 ? Color(1.0f, 1.0f, 1.0f) : Color(0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,6 @@ private:
|
||||
Popup *picker_window = nullptr;
|
||||
// Legacy color picking.
|
||||
TextureRect *picker_texture_rect = nullptr;
|
||||
Panel *picker_preview = nullptr;
|
||||
Label *picker_preview_label = nullptr;
|
||||
Ref<StyleBoxFlat> picker_preview_style_box;
|
||||
Color picker_color;
|
||||
|
Loading…
Reference in New Issue
Block a user