Beispiel #1
0
void ColorPicker::_notification(int p_what) {


	switch(p_what) {
		case NOTIFICATION_THEME_CHANGED: {
			uv_material->set_shader(get_shader("uv_editor"));
			w_material->set_shader(get_shader("w_editor"));
			update_material(uv_material,color,h,s,v);
			update_material(w_material,color,h,s,v);
			_update_controls();
		} break;

		case NOTIFICATION_ENTER_TREE: {
			btn_pick->set_icon(get_icon("screen_picker", "ColorPicker"));
			update_material(uv_material, color,h,s,v);
			update_material(w_material, color,h,s,v);

			uv_edit->get_child(0)->cast_to<Control>()->update();
			w_edit->get_child(0)->cast_to<Control>()->update();
			_update_color();
		}

		case NOTIFICATION_VISIBILITY_CHANGED: {
			c_text->call_deferred("grab_focus");
			c_text->call_deferred("select");
		} break;
	}
}
Beispiel #2
0
void ColorPicker::set_color(const Color& p_color) {

	color=p_color;
	h=color.get_h();
	s=color.get_s();
	v=color.get_v();

	if (!is_inside_tree())
		return;

	update_material(uv_material, color);
	update_material(w_material, color);

	uv_edit->get_child(0)->cast_to<Control>()->update();
	w_edit->get_child(0)->cast_to<Control>()->update();
	_update_color();

}
Beispiel #3
0
void ColorPicker::_value_changed(double) {

	if (updating)
		return;

	for(int i=0;i<3;i++) {
		color.components[i] = scroll[i]->get_val()/(raw_mode_enabled?1.0:255.0);
	}
	color.components[3] = scroll[3]->get_val()/255.0;

	update_material(uv_material,color);
	update_material(w_material,color);

	c_text->set_text(color.to_html(edit_alpha && color.a<1));

	sample->update();

	emit_signal("color_changed",color);

}