Skip to content

Commit ecc8d28

Browse files
committed
Merge pull request godotengine#101100 from WhalesState/color-picker-1
`ColorPicker` remove unused children and fix sample bugs.
2 parents 24fb28a + 6caadd5 commit ecc8d28

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

scene/gui/color_picker.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ void ColorPicker::_update_text_value() {
12581258
}
12591259

12601260
void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
1261+
if (!display_old_color) {
1262+
return;
1263+
}
1264+
12611265
const Ref<InputEventMouseButton> mb = p_event;
12621266
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
12631267
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() {
13101314

13111315
if (color.r > 1 || color.g > 1 || color.b > 1) {
13121316
// Draw an indicator to denote that the new color is "overbright" and can't be displayed accurately in the preview.
1313-
sample->draw_texture(theme_cache.overbright_indicator, Point2(uv_edit->get_size().width * 0.5, 0));
1317+
sample->draw_texture(theme_cache.overbright_indicator, Point2(display_old_color ? sample->get_size().width * 0.5 : 0, 0));
13141318
}
13151319
}
13161320

@@ -2269,17 +2273,10 @@ ColorPicker::ColorPicker() {
22692273
mode_popup->set_item_checked(current_mode, true);
22702274
mode_popup->set_item_checked(MODE_MAX + 1, true);
22712275
mode_popup->connect(SceneStringName(id_pressed), callable_mp(this, &ColorPicker::_set_mode_popup_value));
2272-
VBoxContainer *vbl = memnew(VBoxContainer);
2273-
real_vbox->add_child(vbl);
2274-
2275-
VBoxContainer *vbr = memnew(VBoxContainer);
2276-
2277-
real_vbox->add_child(vbr);
2278-
vbr->set_h_size_flags(SIZE_EXPAND_FILL);
22792276

22802277
slider_gc = memnew(GridContainer);
22812278

2282-
vbr->add_child(slider_gc);
2279+
real_vbox->add_child(slider_gc);
22832280
slider_gc->set_h_size_flags(SIZE_EXPAND_FILL);
22842281
slider_gc->set_columns(3);
22852282

@@ -2291,7 +2288,7 @@ ColorPicker::ColorPicker() {
22912288

22922289
hex_hbc = memnew(HBoxContainer);
22932290
hex_hbc->set_alignment(ALIGNMENT_BEGIN);
2294-
vbr->add_child(hex_hbc);
2291+
real_vbox->add_child(hex_hbc);
22952292

22962293
hex_hbc->add_child(memnew(Label(ETR("Hex"))));
22972294

scene/gui/color_picker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
class AspectRatioContainer;
3939
class ColorMode;
4040
class ColorPickerShape;
41+
class FileDialog;
4142
class GridContainer;
4243
class HSlider;
4344
class Label;
@@ -49,7 +50,6 @@ class PopupMenu;
4950
class SpinBox;
5051
class StyleBoxFlat;
5152
class TextureRect;
52-
class FileDialog;
5353

5454
class ColorPresetButton : public BaseButton {
5555
GDCLASS(ColorPresetButton, BaseButton);
@@ -104,7 +104,7 @@ class ColorPicker : public VBoxContainer {
104104
SHAPE_MAX
105105
};
106106

107-
static const int SLIDER_COUNT = 4;
107+
static const int SLIDER_COUNT = 3;
108108

109109
private:
110110
enum class MenuOption {

0 commit comments

Comments
 (0)