Merge pull request #101100 from WhalesState/color-picker-1

`ColorPicker` remove unused children and fix sample bugs.
This commit is contained in:
Thaddeus Crews 2025-01-20 10:05:44 -06:00
commit ecc8d2812e
No known key found for this signature in database
GPG key ID: 62181B86FE9E5D84
2 changed files with 9 additions and 12 deletions

View file

@ -1258,6 +1258,10 @@ void ColorPicker::_update_text_value() {
}
void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
if (!display_old_color) {
return;
}
const Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
const Rect2 rect_old = Rect2(Point2(), Size2(sample->get_size().width * 0.5, sample->get_size().height * 0.95));
@ -1310,7 +1314,7 @@ void ColorPicker::_sample_draw() {
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the new color is "overbright" and can't be displayed accurately in the preview.
sample->draw_texture(theme_cache.overbright_indicator, Point2(uv_edit->get_size().width * 0.5, 0));
sample->draw_texture(theme_cache.overbright_indicator, Point2(display_old_color ? sample->get_size().width * 0.5 : 0, 0));
}
}
@ -2269,17 +2273,10 @@ ColorPicker::ColorPicker() {
mode_popup->set_item_checked(current_mode, true);
mode_popup->set_item_checked(MODE_MAX + 1, true);
mode_popup->connect(SceneStringName(id_pressed), callable_mp(this, &ColorPicker::_set_mode_popup_value));
VBoxContainer *vbl = memnew(VBoxContainer);
real_vbox->add_child(vbl);
VBoxContainer *vbr = memnew(VBoxContainer);
real_vbox->add_child(vbr);
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
slider_gc = memnew(GridContainer);
vbr->add_child(slider_gc);
real_vbox->add_child(slider_gc);
slider_gc->set_h_size_flags(SIZE_EXPAND_FILL);
slider_gc->set_columns(3);
@ -2291,7 +2288,7 @@ ColorPicker::ColorPicker() {
hex_hbc = memnew(HBoxContainer);
hex_hbc->set_alignment(ALIGNMENT_BEGIN);
vbr->add_child(hex_hbc);
real_vbox->add_child(hex_hbc);
hex_hbc->add_child(memnew(Label(ETR("Hex"))));

View file

@ -38,6 +38,7 @@
class AspectRatioContainer;
class ColorMode;
class ColorPickerShape;
class FileDialog;
class GridContainer;
class HSlider;
class Label;
@ -49,7 +50,6 @@ class PopupMenu;
class SpinBox;
class StyleBoxFlat;
class TextureRect;
class FileDialog;
class ColorPresetButton : public BaseButton {
GDCLASS(ColorPresetButton, BaseButton);
@ -104,7 +104,7 @@ public:
SHAPE_MAX
};
static const int SLIDER_COUNT = 4;
static const int SLIDER_COUNT = 3;
private:
enum class MenuOption {