|
@@ -50,6 +50,19 @@ void ColorPicker::_notification(int p_what) {
|
|
_update_color();
|
|
_update_color();
|
|
} break;
|
|
} break;
|
|
|
|
|
|
|
|
+ case NOTIFICATION_PARENTED: {
|
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
|
+ set_margin((Margin)i, get_constant("margin"));
|
|
|
|
+ } break;
|
|
|
|
+
|
|
|
|
+ case NOTIFICATION_VISIBILITY_CHANGED: {
|
|
|
|
+ if (get_parent()) {
|
|
|
|
+ Popup *p = get_parent()->cast_to<Popup>();
|
|
|
|
+ if (p)
|
|
|
|
+ p->set_size(Size2(get_combined_minimum_size().width + get_constant("margin") * 2, get_combined_minimum_size().height + get_constant("margin") * 2));
|
|
|
|
+ }
|
|
|
|
+ } break;
|
|
|
|
+
|
|
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
|
|
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {
|
|
if (screen != NULL) {
|
|
if (screen != NULL) {
|
|
if (screen->is_visible()) {
|
|
if (screen->is_visible()) {
|
|
@@ -254,13 +267,13 @@ void ColorPicker::_update_text_value() {
|
|
}
|
|
}
|
|
|
|
|
|
void ColorPicker::_sample_draw() {
|
|
void ColorPicker::_sample_draw() {
|
|
- sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, 20)), color);
|
|
|
|
|
|
+ sample->draw_rect(Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95)), color);
|
|
}
|
|
}
|
|
|
|
|
|
-void ColorPicker::_hsv_draw(int p_wich, Control *c) {
|
|
|
|
|
|
+void ColorPicker::_hsv_draw(int p_which, Control *c) {
|
|
if (!c)
|
|
if (!c)
|
|
return;
|
|
return;
|
|
- if (p_wich == 0) {
|
|
|
|
|
|
+ if (p_which == 0) {
|
|
Vector<Point2> points;
|
|
Vector<Point2> points;
|
|
points.push_back(Vector2());
|
|
points.push_back(Vector2());
|
|
points.push_back(Vector2(c->get_size().x, 0));
|
|
points.push_back(Vector2(c->get_size().x, 0));
|
|
@@ -291,7 +304,7 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) {
|
|
c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted());
|
|
c->draw_line(Point2(x, 0), Point2(x, c->get_size().y), col.inverted());
|
|
c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
|
|
c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted());
|
|
c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2);
|
|
c->draw_line(Point2(x, y), Point2(x, y), Color(1, 1, 1), 2);
|
|
- } else if (p_wich == 1) {
|
|
|
|
|
|
+ } else if (p_which == 1) {
|
|
Ref<Texture> hue = get_icon("color_hue", "ColorPicker");
|
|
Ref<Texture> hue = get_icon("color_hue", "ColorPicker");
|
|
c->draw_texture_rect(hue, Rect2(Point2(), c->get_size()));
|
|
c->draw_texture_rect(hue, Rect2(Point2(), c->get_size()));
|
|
int y = c->get_size().y - c->get_size().y * (1.0 - h);
|
|
int y = c->get_size().y - c->get_size().y * (1.0 - h);
|
|
@@ -512,23 +525,18 @@ ColorPicker::ColorPicker()
|
|
uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
|
|
uv_edit->set_mouse_filter(MOUSE_FILTER_PASS);
|
|
uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
uv_edit->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
uv_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
- Vector<Variant> args = Vector<Variant>();
|
|
|
|
- args.push_back(0);
|
|
|
|
- args.push_back(uv_edit);
|
|
|
|
- uv_edit->connect("draw", this, "_hsv_draw", args);
|
|
|
|
|
|
+ uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height")));
|
|
|
|
+ uv_edit->connect("draw", this, "_hsv_draw", make_binds(0, uv_edit));
|
|
|
|
|
|
add_child(hb_edit);
|
|
add_child(hb_edit);
|
|
|
|
|
|
w_edit = memnew(Control);
|
|
w_edit = memnew(Control);
|
|
//w_edit->set_ignore_mouse(false);
|
|
//w_edit->set_ignore_mouse(false);
|
|
- w_edit->set_custom_minimum_size(Size2(30, 0));
|
|
|
|
|
|
+ w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0));
|
|
w_edit->set_h_size_flags(SIZE_FILL);
|
|
w_edit->set_h_size_flags(SIZE_FILL);
|
|
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
w_edit->set_v_size_flags(SIZE_EXPAND_FILL);
|
|
w_edit->connect("gui_input", this, "_w_input");
|
|
w_edit->connect("gui_input", this, "_w_input");
|
|
- args.clear();
|
|
|
|
- args.push_back(1);
|
|
|
|
- args.push_back(w_edit);
|
|
|
|
- w_edit->connect("draw", this, "_hsv_draw", args);
|
|
|
|
|
|
+ w_edit->connect("draw", this, "_hsv_draw", make_binds(1, w_edit));
|
|
|
|
|
|
hb_edit->add_child(uv_edit);
|
|
hb_edit->add_child(uv_edit);
|
|
hb_edit->add_child(memnew(VSeparator));
|
|
hb_edit->add_child(memnew(VSeparator));
|
|
@@ -549,10 +557,12 @@ ColorPicker::ColorPicker()
|
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
|
HBoxContainer *hbc = memnew(HBoxContainer);
|
|
|
|
|
|
labels[i] = memnew(Label(lt[i]));
|
|
labels[i] = memnew(Label(lt[i]));
|
|
- labels[i]->set_custom_minimum_size(Size2(10, 0));
|
|
|
|
|
|
+ labels[i]->set_custom_minimum_size(Size2(get_constant("label_width"), 0));
|
|
|
|
+ labels[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
|
|
hbc->add_child(labels[i]);
|
|
hbc->add_child(labels[i]);
|
|
|
|
|
|
scroll[i] = memnew(HSlider);
|
|
scroll[i] = memnew(HSlider);
|
|
|
|
+ scroll[i]->set_v_size_flags(SIZE_SHRINK_CENTER);
|
|
hbc->add_child(scroll[i]);
|
|
hbc->add_child(scroll[i]);
|
|
|
|
|
|
values[i] = memnew(SpinBox);
|
|
values[i] = memnew(SpinBox);
|
|
@@ -571,7 +581,7 @@ ColorPicker::ColorPicker()
|
|
HBoxContainer *hhb = memnew(HBoxContainer);
|
|
HBoxContainer *hhb = memnew(HBoxContainer);
|
|
|
|
|
|
btn_mode = memnew(CheckButton);
|
|
btn_mode = memnew(CheckButton);
|
|
- btn_mode->set_text(TTR("RAW Mode"));
|
|
|
|
|
|
+ btn_mode->set_text(TTR("Raw Mode"));
|
|
btn_mode->connect("toggled", this, "set_raw_mode");
|
|
btn_mode->connect("toggled", this, "set_raw_mode");
|
|
hhb->add_child(btn_mode);
|
|
hhb->add_child(btn_mode);
|
|
vbr->add_child(hhb);
|
|
vbr->add_child(hhb);
|
|
@@ -617,9 +627,7 @@ void ColorPickerButton::_color_changed(const Color &p_color) {
|
|
|
|
|
|
void ColorPickerButton::pressed() {
|
|
void ColorPickerButton::pressed() {
|
|
|
|
|
|
- Size2 ms = Size2(300, picker->get_combined_minimum_size().height + 10);
|
|
|
|
- popup->set_position(get_global_position() - Size2(0, ms.height));
|
|
|
|
- popup->set_size(ms);
|
|
|
|
|
|
+ popup->set_position(get_global_position() - picker->get_combined_minimum_size());
|
|
popup->popup();
|
|
popup->popup();
|
|
picker->set_focus_on_line_edit();
|
|
picker->set_focus_on_line_edit();
|
|
}
|
|
}
|