mirror of https://github.com/godotengine/godot
`ColorPicker` remove unused children and fix sample bugs.
Remove an unused `VBoxContainer`. Remove 3 unused children from grid (Label, Slider, SpinBox). Ignore sample input when old color is not displayed. Fix current color overbright position.
This commit is contained in:
parent
36a62d0c6a
commit
6caadd57a9
|
|
@ -1258,6 +1258,10 @@ void ColorPicker::_update_text_value() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
|
void ColorPicker::_sample_input(const Ref<InputEvent> &p_event) {
|
||||||
|
if (!display_old_color) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const Ref<InputEventMouseButton> mb = p_event;
|
const Ref<InputEventMouseButton> mb = p_event;
|
||||||
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::LEFT) {
|
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));
|
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) {
|
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.
|
// 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(current_mode, true);
|
||||||
mode_popup->set_item_checked(MODE_MAX + 1, true);
|
mode_popup->set_item_checked(MODE_MAX + 1, true);
|
||||||
mode_popup->connect(SceneStringName(id_pressed), callable_mp(this, &ColorPicker::_set_mode_popup_value));
|
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);
|
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_h_size_flags(SIZE_EXPAND_FILL);
|
||||||
slider_gc->set_columns(3);
|
slider_gc->set_columns(3);
|
||||||
|
|
||||||
|
|
@ -2291,7 +2288,7 @@ ColorPicker::ColorPicker() {
|
||||||
|
|
||||||
hex_hbc = memnew(HBoxContainer);
|
hex_hbc = memnew(HBoxContainer);
|
||||||
hex_hbc->set_alignment(ALIGNMENT_BEGIN);
|
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"))));
|
hex_hbc->add_child(memnew(Label(ETR("Hex"))));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
class AspectRatioContainer;
|
class AspectRatioContainer;
|
||||||
class ColorMode;
|
class ColorMode;
|
||||||
class ColorPickerShape;
|
class ColorPickerShape;
|
||||||
|
class FileDialog;
|
||||||
class GridContainer;
|
class GridContainer;
|
||||||
class HSlider;
|
class HSlider;
|
||||||
class Label;
|
class Label;
|
||||||
|
|
@ -49,7 +50,6 @@ class PopupMenu;
|
||||||
class SpinBox;
|
class SpinBox;
|
||||||
class StyleBoxFlat;
|
class StyleBoxFlat;
|
||||||
class TextureRect;
|
class TextureRect;
|
||||||
class FileDialog;
|
|
||||||
|
|
||||||
class ColorPresetButton : public BaseButton {
|
class ColorPresetButton : public BaseButton {
|
||||||
GDCLASS(ColorPresetButton, BaseButton);
|
GDCLASS(ColorPresetButton, BaseButton);
|
||||||
|
|
@ -104,7 +104,7 @@ public:
|
||||||
SHAPE_MAX
|
SHAPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int SLIDER_COUNT = 4;
|
static const int SLIDER_COUNT = 3;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class MenuOption {
|
enum class MenuOption {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue