Example #1
0
EditorAssetLibraryItem::EditorAssetLibraryItem() {

	Ref<StyleBoxEmpty> border;
	border.instance();
	/*border->set_default_margin(MARGIN_LEFT,5);
	border->set_default_margin(MARGIN_RIGHT,5);
	border->set_default_margin(MARGIN_BOTTOM,5);
	border->set_default_margin(MARGIN_TOP,5);*/
	add_style_override("panel",border);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);

	icon = memnew( TextureButton );
	icon->set_default_cursor_shape(CURSOR_POINTING_HAND);
	icon->connect("pressed",this,"_asset_clicked");

	hb->add_child(icon);

	VBoxContainer *vb = memnew( VBoxContainer );

	hb->add_child(vb);
	vb->set_h_size_flags(SIZE_EXPAND_FILL);

	title = memnew( LinkButton );
	title->set_text("My Awesome Addon");
	title->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_asset_clicked");
	vb->add_child(title);


	category = memnew( LinkButton );
	category->set_text("Editor Tools");
	category->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_category_clicked");
	vb->add_child(category);

	author = memnew( LinkButton );
	author->set_text("Johny Tolengo");
	author->set_underline_mode(LinkButton::UNDERLINE_MODE_ON_HOVER);
	title->connect("pressed",this,"_author_clicked");
	vb->add_child(author);

	HBoxContainer *rating_hb = memnew( HBoxContainer );
	vb->add_child(rating_hb);

	for(int i=0;i<5;i++) {
		stars[i]=memnew(TextureFrame);
		rating_hb->add_child(stars[i]);
	}
	price = memnew( Label );
	price->set_text("Free");
	vb->add_child(price);

	set_custom_minimum_size(Size2(250,100));
	set_h_size_flags(SIZE_EXPAND_FILL);

	set_stop_mouse(false);
}
Example #2
0
MeshEditor::MeshEditor() {

	viewport = memnew( Viewport );
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_process_input(false);

	camera = memnew( Camera );
	camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
	camera->set_perspective(45,0.1,10);
	viewport->add_child(camera);

	light1 = memnew( DirectionalLight );
	light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
	viewport->add_child(light1);

	light2 = memnew( DirectionalLight );
	light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
	light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
	light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
	viewport->add_child(light2);

	mesh_instance = memnew( MeshInstance );
	viewport->add_child(mesh_instance);



	set_custom_minimum_size(Size2(1,150));

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_area_as_parent_rect(2);

	hb->add_spacer();

	VBoxContainer *vb_light = memnew( VBoxContainer );
	hb->add_child(vb_light);

	light_1_switch = memnew( TextureButton );
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));

	light_2_switch = memnew( TextureButton );
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));

	first_enter=true;

	rot_x=0;
	rot_y=0;


}
MeshEditor::MeshEditor() {

	viewport = memnew(Viewport);
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_disable_input(true);
	set_stretch(true);

	camera = memnew(Camera);
	camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
	camera->set_perspective(45, 0.1, 10);
	viewport->add_child(camera);

	light1 = memnew(DirectionalLight);
	light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
	viewport->add_child(light1);

	light2 = memnew(DirectionalLight);
	light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
	light2->set_color(Color(0.7, 0.7, 0.7));
	viewport->add_child(light2);

	rotation = memnew(Spatial);
	viewport->add_child(rotation);
	mesh_instance = memnew(MeshInstance);
	rotation->add_child(mesh_instance);

	set_custom_minimum_size(Size2(1, 150) * EDSCALE);

	HBoxContainer *hb = memnew(HBoxContainer);
	add_child(hb);
	hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);

	hb->add_spacer();

	VBoxContainer *vb_light = memnew(VBoxContainer);
	hb->add_child(vb_light);

	light_1_switch = memnew(TextureButton);
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));

	light_2_switch = memnew(TextureButton);
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));

	first_enter = true;

	rot_x = 0;
	rot_y = 0;
}
MaterialEditor::MaterialEditor() {

	viewport = memnew( Viewport );
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	add_child(viewport);
	viewport->set_disable_input(true);

	camera = memnew( Camera );
	camera->set_transform(Transform(Matrix3(),Vector3(0,0,3)));
	camera->set_perspective(45,0.1,10);
	viewport->add_child(camera);

	light1 = memnew( DirectionalLight );
	light1->set_transform(Transform().looking_at(Vector3(-1,-1,-1),Vector3(0,1,0)));
	viewport->add_child(light1);

	light2 = memnew( DirectionalLight );
	light2->set_transform(Transform().looking_at(Vector3(0,1,0),Vector3(0,0,1)));
	light2->set_color(Light::COLOR_DIFFUSE,Color(0.7,0.7,0.7));
	light2->set_color(Light::COLOR_SPECULAR,Color(0.7,0.7,0.7));
	viewport->add_child(light2);

	sphere_instance = memnew( MeshInstance );
	viewport->add_child(sphere_instance);

	box_instance = memnew( MeshInstance );
	viewport->add_child(box_instance);

	Transform box_xform;
	box_xform.basis.rotate(Vector3(1,0,0),Math::deg2rad(25));
	box_xform.basis = box_xform.basis * Matrix3().rotated(Vector3(0,1,0),Math::deg2rad(25));
	box_xform.basis.scale(Vector3(0.8,0.8,0.8));
	box_instance->set_transform(box_xform);

	{

		sphere_mesh.instance();


		int lats=32;
		int lons=32;
		float radius=1.0;

		PoolVector<Vector3> vertices;
		PoolVector<Vector3> normals;
		PoolVector<Vector2> uvs;
		PoolVector<float> tangents;
		Matrix3 tt = Matrix3(Vector3(0,1,0),Math_PI*0.5);

		for(int i = 1; i <= lats; i++) {
			double lat0 = Math_PI * (-0.5 + (double) (i - 1) / lats);
			double z0  = Math::sin(lat0);
			double zr0 =  Math::cos(lat0);

			double lat1 = Math_PI * (-0.5 + (double) i / lats);
			double z1 = Math::sin(lat1);
			double zr1 = Math::cos(lat1);

			for(int j = lons; j >= 1; j--) {

				double lng0 = 2 * Math_PI * (double) (j - 1) / lons;
				double x0 = Math::cos(lng0);
				double y0 = Math::sin(lng0);

				double lng1 = 2 * Math_PI * (double) (j) / lons;
				double x1 = Math::cos(lng1);
				double y1 = Math::sin(lng1);


				Vector3 v[4]={
					Vector3(x1 * zr0, z0, y1 *zr0),
					Vector3(x1 * zr1, z1, y1 *zr1),
					Vector3(x0 * zr1, z1, y0 *zr1),
					Vector3(x0 * zr0, z0, y0 *zr0)
				};

	#define ADD_POINT(m_idx) \
		normals.push_back(v[m_idx]);\
		vertices.push_back(v[m_idx]*radius);\
		{ Vector2 uv(Math::atan2(v[m_idx].x,v[m_idx].z),Math::atan2(-v[m_idx].y,v[m_idx].z));\
		  uv/=Math_PI;\
		  uv*=4.0;\
		  uv=uv*0.5+Vector2(0.5,0.5);\
		  uvs.push_back(uv);\
		 }\
		 { Vector3 t = tt.xform(v[m_idx]);\
		   tangents.push_back(t.x);\
		   tangents.push_back(t.y);\
		   tangents.push_back(t.z);\
		   tangents.push_back(1.0);\
		  }



				ADD_POINT(0);
				ADD_POINT(1);
				ADD_POINT(2);

				ADD_POINT(2);
				ADD_POINT(3);
				ADD_POINT(0);
			}
		}

		Array arr;
		arr.resize(VS::ARRAY_MAX);
		arr[VS::ARRAY_VERTEX]=vertices;
		arr[VS::ARRAY_NORMAL]=normals;
		arr[VS::ARRAY_TANGENT]=tangents;
		arr[VS::ARRAY_TEX_UV]=uvs;

		sphere_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,arr);

		sphere_instance->set_mesh(sphere_mesh);

	}
	{


		box_mesh.instance();

		PoolVector<Vector3> vertices;
		PoolVector<Vector3> normals;
		PoolVector<float> tangents;
		PoolVector<Vector3> uvs;

		int vtx_idx=0;
	#define ADD_VTX(m_idx);\
		vertices.push_back( face_points[m_idx] );\
		normals.push_back( normal_points[m_idx] );\
		tangents.push_back( normal_points[m_idx][1] );\
		tangents.push_back( normal_points[m_idx][2] );\
		tangents.push_back( normal_points[m_idx][0] );\
		tangents.push_back( 1.0 );\
		uvs.push_back( Vector3(uv_points[m_idx*2+0],uv_points[m_idx*2+1],0) );\
		vtx_idx++;\

		for (int i=0;i<6;i++) {


			Vector3 face_points[4];
			Vector3 normal_points[4];
			float uv_points[8]={0,0,0,1,1,1,1,0};

			for (int j=0;j<4;j++) {

				float v[3];
				v[0]=1.0;
				v[1]=1-2*((j>>1)&1);
				v[2]=v[1]*(1-2*(j&1));

				for (int k=0;k<3;k++) {

					if (i<3)
						face_points[j][(i+k)%3]=v[k]*(i>=3?-1:1);
					else
						face_points[3-j][(i+k)%3]=v[k]*(i>=3?-1:1);
				}
				normal_points[j]=Vector3();
				normal_points[j][i%3]=(i>=3?-1:1);
			}

		//tri 1
			ADD_VTX(0);
			ADD_VTX(1);
			ADD_VTX(2);
		//tri 2
			ADD_VTX(2);
			ADD_VTX(3);
			ADD_VTX(0);

		}



		Array d;
		d.resize(VS::ARRAY_MAX);
		d[VisualServer::ARRAY_NORMAL]= normals ;
		d[VisualServer::ARRAY_TANGENT]= tangents ;
		d[VisualServer::ARRAY_TEX_UV]= uvs ;
		d[VisualServer::ARRAY_VERTEX]= vertices ;

		PoolVector<int> indices;
		indices.resize(vertices.size());
		for(int i=0;i<vertices.size();i++)
			indices.set(i,i);
		d[VisualServer::ARRAY_INDEX]=indices;

		box_mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES,d);
		box_instance->set_mesh(box_mesh);
		box_instance->hide();



	}

	set_custom_minimum_size(Size2(1,150)*EDSCALE);

	HBoxContainer *hb = memnew( HBoxContainer );
	add_child(hb);
	hb->set_area_as_parent_rect(2);

	VBoxContainer *vb_shape = memnew( VBoxContainer );
	hb->add_child(vb_shape);

	sphere_switch = memnew( TextureButton );
	sphere_switch->set_toggle_mode(true);
	sphere_switch->set_pressed(true);
	vb_shape->add_child(sphere_switch);
	sphere_switch->connect("pressed",this,"_button_pressed",varray(sphere_switch));

	box_switch = memnew( TextureButton );
	box_switch->set_toggle_mode(true);
	box_switch->set_pressed(false);
	vb_shape->add_child(box_switch);
	box_switch->connect("pressed",this,"_button_pressed",varray(box_switch));

	hb->add_spacer();

	VBoxContainer *vb_light = memnew( VBoxContainer );
	hb->add_child(vb_light);

	light_1_switch = memnew( TextureButton );
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed",this,"_button_pressed",varray(light_1_switch));

	light_2_switch = memnew( TextureButton );
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed",this,"_button_pressed",varray(light_2_switch));

	first_enter=true;

}
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {

	HBoxContainer *hb = memnew(HBoxContainer);
	add_child(hb);
	icon = memnew(TextureRect);
	hb->add_child(icon);

	VBoxContainer *vb = memnew(VBoxContainer);
	hb->add_child(vb);
	vb->set_h_size_flags(SIZE_EXPAND_FILL);

	HBoxContainer *title_hb = memnew(HBoxContainer);
	vb->add_child(title_hb);
	title = memnew(Label);
	title_hb->add_child(title);
	title->set_h_size_flags(SIZE_EXPAND_FILL);

	dismiss = memnew(TextureButton);
	dismiss->connect("pressed", this, "_close");
	title_hb->add_child(dismiss);

	title->set_clip_text(true);

	vb->add_spacer();

	status = memnew(Label("Idle"));
	vb->add_child(status);
	status->add_color_override("font_color", Color(0.5, 0.5, 0.5));
	progress = memnew(ProgressBar);
	vb->add_child(progress);

	HBoxContainer *hb2 = memnew(HBoxContainer);
	vb->add_child(hb2);
	hb2->add_spacer();

	install = memnew(Button);
	install->set_text("Install");
	install->set_disabled(true);
	install->connect("pressed", this, "_install");

	retry = memnew(Button);
	retry->set_text("Retry");
	retry->connect("pressed", this, "_make_request");

	hb2->add_child(retry);
	hb2->add_child(install);
	set_custom_minimum_size(Size2(250, 0));

	download = memnew(HTTPRequest);
	add_child(download);
	download->connect("request_completed", this, "_http_download_completed");

	download_error = memnew(AcceptDialog);
	add_child(download_error);
	download_error->set_title("Download Error");

	asset_installer = memnew(EditorAssetInstaller);
	add_child(asset_installer);

	prev_status = -1;

	external_install = false;
}
EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {

	buses = p_buses;
	updating_bus = false;
	is_master = p_is_master;

	set_tooltip(TTR("Audio Bus, Drag and Drop to rearrange."));

	VBoxContainer *vb = memnew(VBoxContainer);
	add_child(vb);

	set_v_size_flags(SIZE_EXPAND_FILL);
	set_custom_minimum_size(Size2(100, 0) * EDSCALE);

	track_name = memnew(LineEdit);
	track_name->connect("text_entered", this, "_name_changed");
	track_name->connect("focus_exited", this, "_name_focus_exit");
	vb->add_child(track_name);

	HBoxContainer *hbc = memnew(HBoxContainer);
	vb->add_child(hbc);
	solo = memnew(ToolButton);
	solo->set_toggle_mode(true);
	solo->set_tooltip(TTR("Solo"));
	solo->set_focus_mode(FOCUS_NONE);
	solo->connect("pressed", this, "_solo_toggled");
	hbc->add_child(solo);
	mute = memnew(ToolButton);
	mute->set_toggle_mode(true);
	mute->set_tooltip(TTR("Mute"));
	mute->set_focus_mode(FOCUS_NONE);
	mute->connect("pressed", this, "_mute_toggled");
	hbc->add_child(mute);
	bypass = memnew(ToolButton);
	bypass->set_toggle_mode(true);
	bypass->set_tooltip(TTR("Bypass"));
	bypass->set_focus_mode(FOCUS_NONE);
	bypass->connect("pressed", this, "_bypass_toggled");
	hbc->add_child(bypass);
	hbc->add_spacer();

	bus_options = memnew(MenuButton);
	bus_options->set_h_size_flags(SIZE_SHRINK_END);
	bus_options->set_anchor(MARGIN_RIGHT, 0.0);
	bus_options->set_tooltip(TTR("Bus options"));
	hbc->add_child(bus_options);

	Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty);
	for (int i = 0; i < hbc->get_child_count(); i++) {
		Control *child = Object::cast_to<Control>(hbc->get_child(i));
		child->add_style_override("normal", sbempty);
		child->add_style_override("hover", sbempty);
		child->add_style_override("focus", sbempty);
		child->add_style_override("pressed", sbempty);
	}

	vb->add_child(memnew(HSeparator));

	HBoxContainer *hb = memnew(HBoxContainer);
	vb->add_child(hb);
	slider = memnew(VSlider);
	slider->set_min(-80);
	slider->set_max(24);
	slider->set_step(0.1);

	slider->connect("value_changed", this, "_volume_db_changed");
	hb->add_child(slider);

	cc = 0;
	for (int i = 0; i < CHANNELS_MAX; i++) {
		channel[i].vu_l = memnew(TextureProgress);
		channel[i].vu_l->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
		hb->add_child(channel[i].vu_l);
		channel[i].vu_l->set_min(-80);
		channel[i].vu_l->set_max(24);
		channel[i].vu_l->set_step(0.1);

		channel[i].vu_r = memnew(TextureProgress);
		channel[i].vu_r->set_fill_mode(TextureProgress::FILL_BOTTOM_TO_TOP);
		hb->add_child(channel[i].vu_r);
		channel[i].vu_r->set_min(-80);
		channel[i].vu_r->set_max(24);
		channel[i].vu_r->set_step(0.1);

		channel[i].peak_l = 0.0f;
		channel[i].peak_r = 0.0f;
	}

	scale = memnew(TextureRect);
	hb->add_child(scale);

	effects = memnew(Tree);
	effects->set_hide_root(true);
	effects->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
	effects->set_hide_folding(true);
	effects->set_v_size_flags(SIZE_EXPAND_FILL);
	vb->add_child(effects);
	effects->connect("item_edited", this, "_effect_edited");
	effects->connect("cell_selected", this, "_effect_selected");
	effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
	effects->set_drag_forwarding(this);
	effects->connect("item_rmb_selected", this, "_effect_rmb");
	effects->set_allow_rmb_select(true);
	effects->set_focus_mode(FOCUS_CLICK);
	effects->set_allow_reselect(true);

	send = memnew(OptionButton);
	send->set_clip_text(true);
	send->connect("item_selected", this, "_send_selected");
	vb->add_child(send);

	set_focus_mode(FOCUS_CLICK);

	effect_options = memnew(PopupMenu);
	effect_options->connect("index_pressed", this, "_effect_add");
	add_child(effect_options);
	List<StringName> effects;
	ClassDB::get_inheriters_from_class("AudioEffect", &effects);
	effects.sort_custom<StringName::AlphCompare>();
	for (List<StringName>::Element *E = effects.front(); E; E = E->next()) {
		if (!ClassDB::can_instance(E->get()))
			continue;

		Ref<Texture> icon = EditorNode::get_singleton()->get_class_icon(E->get());
		String name = E->get().operator String().replace("AudioEffect", "");
		effect_options->add_item(name);
		effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get());
		effect_options->set_item_icon(effect_options->get_item_count() - 1, icon);
	}

	bus_popup = bus_options->get_popup();
	bus_popup->add_item(TTR("Duplicate"));
	bus_popup->add_item(TTR("Delete"));
	bus_popup->set_item_disabled(1, is_master);
	bus_popup->add_item(TTR("Reset Volume"));
	bus_popup->connect("index_pressed", this, "_bus_popup_pressed");

	delete_effect_popup = memnew(PopupMenu);
	delete_effect_popup->add_item(TTR("Delete Effect"));
	add_child(delete_effect_popup);
	delete_effect_popup->connect("index_pressed", this, "_delete_effect_pressed");
}
Example #7
0
FindInFilesDialog::FindInFilesDialog() {

	set_custom_minimum_size(Size2(400, 190));
	set_resizable(true);
	set_title(TTR("Find in files"));

	VBoxContainer *vbc = memnew(VBoxContainer);
	vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
	add_child(vbc);

	GridContainer *gc = memnew(GridContainer);
	gc->set_columns(2);
	vbc->add_child(gc);

	Label *find_label = memnew(Label);
	find_label->set_text(TTR("Find: "));
	gc->add_child(find_label);

	_search_text_line_edit = memnew(LineEdit);
	_search_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
	_search_text_line_edit->connect("text_changed", this, "_on_search_text_modified");
	_search_text_line_edit->connect("text_entered", this, "_on_search_text_entered");
	gc->add_child(_search_text_line_edit);

	{
		Control *placeholder = memnew(Control);
		gc->add_child(placeholder);
	}

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		_whole_words_checkbox = memnew(CheckBox);
		_whole_words_checkbox->set_text(TTR("Whole words"));
		_whole_words_checkbox->set_pressed(true);
		hbc->add_child(_whole_words_checkbox);

		_match_case_checkbox = memnew(CheckBox);
		_match_case_checkbox->set_text(TTR("Match case"));
		_match_case_checkbox->set_pressed(true);
		hbc->add_child(_match_case_checkbox);

		gc->add_child(hbc);
	}

	Label *folder_label = memnew(Label);
	folder_label->set_text(TTR("Folder: "));
	gc->add_child(folder_label);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		Label *prefix_label = memnew(Label);
		prefix_label->set_text(ROOT_PREFIX);
		hbc->add_child(prefix_label);

		_folder_line_edit = memnew(LineEdit);
		_folder_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(_folder_line_edit);

		Button *folder_button = memnew(Button);
		folder_button->set_text("...");
		folder_button->connect("pressed", this, "_on_folder_button_pressed");
		hbc->add_child(folder_button);

		_folder_dialog = memnew(FileDialog);
		_folder_dialog->set_mode(FileDialog::MODE_OPEN_DIR);
		_folder_dialog->connect("dir_selected", this, "_on_folder_selected");
		add_child(_folder_dialog);

		gc->add_child(hbc);
	}

	Label *filter_label = memnew(Label);
	filter_label->set_text(TTR("Filter: "));
	gc->add_child(filter_label);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		Vector<String> exts;
		exts.push_back("gd");
		exts.push_back("cs");

		for (int i = 0; i < exts.size(); ++i) {
			CheckBox *cb = memnew(CheckBox);
			cb->set_text(exts[i]);
			cb->set_pressed(true);
			hbc->add_child(cb);
			_filters.push_back(cb);
		}

		gc->add_child(hbc);
	}

	{
		Control *placeholder = memnew(Control);
		placeholder->set_custom_minimum_size(Size2(0, EDSCALE * 16));
		vbc->add_child(placeholder);
	}

	{
		HBoxContainer *hbc = memnew(HBoxContainer);
		hbc->set_alignment(HBoxContainer::ALIGN_CENTER);

		_find_button = memnew(Button);
		_find_button->set_text(TTR("Find..."));
		_find_button->connect("pressed", this, "_on_find_button_pressed");
		_find_button->set_disabled(true);
		hbc->add_child(_find_button);

		{
			Control *placeholder = memnew(Control);
			placeholder->set_custom_minimum_size(Size2(EDSCALE * 16, 0));
			hbc->add_child(placeholder);
		}

		_replace_button = memnew(Button);
		_replace_button->set_text(TTR("Replace..."));
		_replace_button->connect("pressed", this, "_on_replace_button_pressed");
		_replace_button->set_disabled(true);
		hbc->add_child(_replace_button);

		{
			Control *placeholder = memnew(Control);
			placeholder->set_custom_minimum_size(Size2(EDSCALE * 16, 0));
			hbc->add_child(placeholder);
		}

		Button *cancel_button = memnew(Button);
		cancel_button->set_text(TTR("Cancel"));
		cancel_button->connect("pressed", this, "hide");
		hbc->add_child(cancel_button);

		vbc->add_child(hbc);
	}
}
AnimationNodeStateMachineEditor::AnimationNodeStateMachineEditor() {

	singleton = this;
	updating = false;

	HBoxContainer *top_hb = memnew(HBoxContainer);
	add_child(top_hb);

	goto_parent_hbox = memnew(HBoxContainer);
	goto_parent = memnew(ToolButton);
	goto_parent->connect("pressed", this, "_goto_parent", varray(), CONNECT_DEFERRED);
	goto_parent_hbox->add_child(goto_parent);
	goto_parent_hbox->add_child(memnew(VSeparator));
	top_hb->add_child(goto_parent_hbox);

	Ref<ButtonGroup> bg;
	bg.instance();

	tool_select = memnew(ToolButton);
	top_hb->add_child(tool_select);
	tool_select->set_toggle_mode(true);
	tool_select->set_button_group(bg);
	tool_select->set_pressed(true);
	tool_select->set_tooltip(TTR("Select and move nodes.\nRMB to add new nodes.\nShift+LMB to create connections."));
	tool_select->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);

	tool_create = memnew(ToolButton);
	top_hb->add_child(tool_create);
	tool_create->set_toggle_mode(true);
	tool_create->set_button_group(bg);
	tool_create->set_tooltip(TTR("Create new nodes."));
	tool_create->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);

	tool_connect = memnew(ToolButton);
	top_hb->add_child(tool_connect);
	tool_connect->set_toggle_mode(true);
	tool_connect->set_button_group(bg);
	tool_connect->set_tooltip(TTR("Connect nodes."));
	tool_connect->connect("pressed", this, "_update_mode", varray(), CONNECT_DEFERRED);

	tool_erase_hb = memnew(HBoxContainer);
	top_hb->add_child(tool_erase_hb);
	tool_erase_hb->add_child(memnew(VSeparator));
	tool_erase = memnew(ToolButton);
	tool_erase->set_tooltip(TTR("Remove selected node or transition"));
	tool_erase_hb->add_child(tool_erase);
	tool_erase->connect("pressed", this, "_erase_selected");
	tool_erase->set_disabled(true);

	tool_erase_hb->add_child(memnew(VSeparator));

	tool_autoplay = memnew(ToolButton);
	tool_autoplay->set_tooltip(TTR("Toggle autoplay this animation on start, restart or seek to zero."));
	tool_erase_hb->add_child(tool_autoplay);
	tool_autoplay->connect("pressed", this, "_autoplay_selected");
	tool_autoplay->set_disabled(true);

	tool_end = memnew(ToolButton);
	tool_end->set_tooltip(TTR("Set the end animation. This is useful for sub-transitions."));
	tool_erase_hb->add_child(tool_end);
	tool_end->connect("pressed", this, "_end_selected");
	tool_end->set_disabled(true);

	top_hb->add_child(memnew(VSeparator));
	top_hb->add_child(memnew(Label(TTR("Transition: "))));
	transition_mode = memnew(OptionButton);
	top_hb->add_child(transition_mode);

	top_hb->add_spacer();

	top_hb->add_child(memnew(Label("Play Mode:")));
	play_mode = memnew(OptionButton);
	top_hb->add_child(play_mode);

	GridContainer *main_grid = memnew(GridContainer);
	main_grid->set_columns(2);
	add_child(main_grid);
	main_grid->set_v_size_flags(SIZE_EXPAND_FILL);

	panel = memnew(PanelContainer);
	panel->set_clip_contents(true);
	main_grid->add_child(panel);
	panel->set_h_size_flags(SIZE_EXPAND_FILL);

	state_machine_draw = memnew(Control);
	state_machine_draw->connect("gui_input", this, "_state_machine_gui_input");
	state_machine_draw->connect("draw", this, "_state_machine_draw");
	state_machine_draw->set_focus_mode(FOCUS_ALL);

	state_machine_play_pos = memnew(Control);
	state_machine_draw->add_child(state_machine_play_pos);
	state_machine_play_pos->set_mouse_filter(MOUSE_FILTER_PASS); //pass all to parent
	state_machine_play_pos->set_anchors_and_margins_preset(PRESET_WIDE);
	state_machine_play_pos->connect("draw", this, "_state_machine_pos_draw");

	panel->add_child(state_machine_draw);
	panel->set_v_size_flags(SIZE_EXPAND_FILL);

	v_scroll = memnew(VScrollBar);
	main_grid->add_child(v_scroll);
	v_scroll->connect("value_changed", this, "_scroll_changed");

	h_scroll = memnew(HScrollBar);
	main_grid->add_child(h_scroll);
	h_scroll->connect("value_changed", this, "_scroll_changed");

	main_grid->add_child(memnew(Control)); //empty bottom right

	error_panel = memnew(PanelContainer);
	add_child(error_panel);
	error_label = memnew(Label);
	error_panel->add_child(error_label);
	error_label->set_text("eh");

	undo_redo = EditorNode::get_singleton()->get_undo_redo();

	set_custom_minimum_size(Size2(0, 300 * EDSCALE));

	menu = memnew(PopupMenu);
	add_child(menu);
	menu->connect("index_pressed", this, "_add_menu_type");

	animations_menu = memnew(PopupMenu);
	menu->add_child(animations_menu);
	animations_menu->set_name("animations");
	animations_menu->connect("index_pressed", this, "_add_animation_type");

	name_edit = memnew(LineEdit);
	state_machine_draw->add_child(name_edit);
	name_edit->hide();
	name_edit->connect("text_entered", this, "_name_edited");
	name_edit->set_as_toplevel(true);

	over_text = false;

	over_node_what = -1;
	dragging_selected_attempt = false;
	connecting = false;

	last_active = false;

	error_time = 0;
}
Example #9
0
RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor, UndoRedo *p_undo_redo) {

	scene_tree_editor = p_scene_tree_editor;
	undo_redo = p_undo_redo;
	preview_node = NULL;

	set_title(TTR("Batch Rename"));

	VBoxContainer *vbc = memnew(VBoxContainer);
	add_child(vbc);

	// -- Search/Replace Area

	GridContainer *grd_main = memnew(GridContainer);
	grd_main->set_columns(2);
	grd_main->set_v_size_flags(SIZE_EXPAND_FILL);
	vbc->add_child(grd_main);

	// ---- 1st & 2nd row

	Label *lbl_search = memnew(Label);
	lbl_search->set_text(TTR("Search"));

	lne_search = memnew(LineEdit);
	lne_search->set_placeholder(TTR("Search"));
	lne_search->set_name("lne_search");
	lne_search->set_h_size_flags(SIZE_EXPAND_FILL);

	Label *lbl_replace = memnew(Label);
	lbl_replace->set_text(TTR("Replace"));

	lne_replace = memnew(LineEdit);
	lne_replace->set_placeholder(TTR("Replace"));
	lne_replace->set_name("lne_replace");
	lne_replace->set_h_size_flags(SIZE_EXPAND_FILL);

	grd_main->add_child(lbl_search);
	grd_main->add_child(lbl_replace);
	grd_main->add_child(lne_search);
	grd_main->add_child(lne_replace);

	// ---- 3rd & 4th row

	Label *lbl_prefix = memnew(Label);
	lbl_prefix->set_text(TTR("Prefix"));

	lne_prefix = memnew(LineEdit);
	lne_prefix->set_placeholder(TTR("Prefix"));
	lne_prefix->set_name("lne_prefix");
	lne_prefix->set_h_size_flags(SIZE_EXPAND_FILL);

	Label *lbl_suffix = memnew(Label);
	lbl_suffix->set_text(TTR("Suffix"));

	lne_suffix = memnew(LineEdit);
	lne_suffix->set_placeholder(TTR("Suffix"));
	lne_suffix->set_name("lne_suffix");
	lne_suffix->set_h_size_flags(SIZE_EXPAND_FILL);

	grd_main->add_child(lbl_prefix);
	grd_main->add_child(lbl_suffix);
	grd_main->add_child(lne_prefix);
	grd_main->add_child(lne_suffix);

	// -- Feature Tabs

	const int feature_min_height = 160;

	Ref<Theme> collapse_theme = create_editor_theme();
	collapse_theme->set_icon("checked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowDown", "EditorIcons"));
	collapse_theme->set_icon("unchecked", "CheckBox", collapse_theme->get_icon("GuiTreeArrowRight", "EditorIcons"));

	CheckBox *chk_collapse_features = memnew(CheckBox);
	chk_collapse_features->set_text(TTR("Advanced options"));
	chk_collapse_features->set_theme(collapse_theme);
	chk_collapse_features->set_focus_mode(FOCUS_NONE);
	vbc->add_child(chk_collapse_features);

	tabc_features = memnew(TabContainer);
	tabc_features->set_tab_align(TabContainer::ALIGN_LEFT);
	vbc->add_child(tabc_features);

	// ---- Tab Substitute

	VBoxContainer *vbc_substitute = memnew(VBoxContainer);
	vbc_substitute->set_h_size_flags(SIZE_EXPAND_FILL);
	vbc_substitute->set_custom_minimum_size(Size2(0, feature_min_height));

	vbc_substitute->set_name(TTR("Substitute"));
	tabc_features->add_child(vbc_substitute);

	cbut_substitute = memnew(CheckButton);
	cbut_substitute->set_text(TTR("Substitute"));
	vbc_substitute->add_child(cbut_substitute);

	GridContainer *grd_substitute = memnew(GridContainer);
	grd_substitute->set_columns(3);
	vbc_substitute->add_child(grd_substitute);

	// Name

	but_insert_name = memnew(Button);
	but_insert_name->set_text("NAME");
	but_insert_name->set_tooltip(String("${NAME}\n") + TTR("Node name"));
	but_insert_name->set_focus_mode(FOCUS_NONE);
	but_insert_name->connect("pressed", this, "_insert_text", make_binds("${NAME}"));
	but_insert_name->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_name);

	// Parent

	but_insert_parent = memnew(Button);
	but_insert_parent->set_text("PARENT");
	but_insert_parent->set_tooltip(String("${PARENT}\n") + TTR("Node's parent name, if available"));
	but_insert_parent->set_focus_mode(FOCUS_NONE);
	but_insert_parent->connect("pressed", this, "_insert_text", make_binds("${PARENT}"));
	but_insert_parent->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_parent);

	// Type

	but_insert_type = memnew(Button);
	but_insert_type->set_text("TYPE");
	but_insert_type->set_tooltip(String("${TYPE}\n") + TTR("Node type"));
	but_insert_type->set_focus_mode(FOCUS_NONE);
	but_insert_type->connect("pressed", this, "_insert_text", make_binds("${TYPE}"));
	but_insert_type->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_type);

	// Scene

	but_insert_scene = memnew(Button);
	but_insert_scene->set_text("SCENE");
	but_insert_scene->set_tooltip(String("${SCENE}\n") + TTR("Current scene name"));
	but_insert_scene->set_focus_mode(FOCUS_NONE);
	but_insert_scene->connect("pressed", this, "_insert_text", make_binds("${SCENE}"));
	but_insert_scene->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_scene);

	// Root

	but_insert_root = memnew(Button);
	but_insert_root->set_text("ROOT");
	but_insert_root->set_tooltip(String("${ROOT}\n") + TTR("Root node name"));
	but_insert_root->set_focus_mode(FOCUS_NONE);
	but_insert_root->connect("pressed", this, "_insert_text", make_binds("${ROOT}"));
	but_insert_root->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_root);

	// Count

	but_insert_count = memnew(Button);
	but_insert_count->set_text("COUNTER");
	but_insert_count->set_tooltip(String("${COUNTER}\n") + TTR("Sequential integer counter.\nCompare counter options."));
	but_insert_count->set_focus_mode(FOCUS_NONE);
	but_insert_count->connect("pressed", this, "_insert_text", make_binds("${COUNTER}"));
	but_insert_count->set_h_size_flags(SIZE_EXPAND_FILL);
	grd_substitute->add_child(but_insert_count);

	chk_per_level_counter = memnew(CheckBox);
	chk_per_level_counter->set_text(TTR("Per Level counter"));
	chk_per_level_counter->set_tooltip(TTR("If set the counter restarts for each group of child nodes"));
	vbc_substitute->add_child(chk_per_level_counter);

	HBoxContainer *hbc_count_options = memnew(HBoxContainer);
	vbc_substitute->add_child(hbc_count_options);

	Label *lbl_count_start = memnew(Label);
	lbl_count_start->set_text(TTR("Start"));
	lbl_count_start->set_tooltip(TTR("Initial value for the counter"));
	hbc_count_options->add_child(lbl_count_start);

	spn_count_start = memnew(SpinBox);
	spn_count_start->set_tooltip(TTR("Initial value for the counter"));
	spn_count_start->set_step(1);
	spn_count_start->set_min(0);
	hbc_count_options->add_child(spn_count_start);

	Label *lbl_count_step = memnew(Label);
	lbl_count_step->set_text(TTR("Step"));
	lbl_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node"));
	hbc_count_options->add_child(lbl_count_step);

	spn_count_step = memnew(SpinBox);
	spn_count_step->set_tooltip(TTR("Ammount by which counter is incremented for each node"));
	spn_count_step->set_step(1);
	hbc_count_options->add_child(spn_count_step);

	Label *lbl_count_padding = memnew(Label);
	lbl_count_padding->set_text(TTR("Padding"));
	lbl_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros."));
	hbc_count_options->add_child(lbl_count_padding);

	spn_count_padding = memnew(SpinBox);
	spn_count_padding->set_tooltip(TTR("Minium number of digits for the counter.\nMissing digits are padded with leading zeros."));
	spn_count_padding->set_step(1);
	hbc_count_options->add_child(spn_count_padding);

	// ---- Tab RegEx

	VBoxContainer *vbc_regex = memnew(VBoxContainer);
	vbc_regex->set_h_size_flags(SIZE_EXPAND_FILL);
	vbc_regex->set_name(TTR("Regular Expressions"));
	vbc_regex->set_custom_minimum_size(Size2(0, feature_min_height));
	tabc_features->add_child(vbc_regex);

	cbut_regex = memnew(CheckButton);
	cbut_regex->set_text(TTR("Regular Expressions"));
	vbc_regex->add_child(cbut_regex);

	// ---- Tab Process

	VBoxContainer *vbc_process = memnew(VBoxContainer);
	vbc_process->set_h_size_flags(SIZE_EXPAND_FILL);
	vbc_process->set_name(TTR("Post-Process"));
	vbc_process->set_custom_minimum_size(Size2(0, feature_min_height));
	tabc_features->add_child(vbc_process);

	cbut_process = memnew(CheckButton);
	cbut_process->set_text(TTR("Post-Process"));
	vbc_process->add_child(cbut_process);

	// ------ Style

	HBoxContainer *hbc_style = memnew(HBoxContainer);
	vbc_process->add_child(hbc_style);

	Label *lbl_style = memnew(Label);
	lbl_style->set_text(TTR("Style"));
	hbc_style->add_child(lbl_style);

	opt_style = memnew(OptionButton);
	opt_style->add_item(TTR("Keep"));
	opt_style->add_item(TTR("CamelCase to under_scored"));
	opt_style->add_item(TTR("under_scored to CamelCase"));
	hbc_style->add_child(opt_style);

	// ------ Case

	HBoxContainer *hbc_case = memnew(HBoxContainer);
	vbc_process->add_child(hbc_case);

	Label *lbl_case = memnew(Label);
	lbl_case->set_text(TTR("Case"));
	hbc_case->add_child(lbl_case);

	opt_case = memnew(OptionButton);
	opt_case->add_item(TTR("Keep"));
	opt_case->add_item(TTR("To Lowercase"));
	opt_case->add_item(TTR("To Uppercase"));
	hbc_case->add_child(opt_case);

	// -- Preview

	HSeparator *sep_preview = memnew(HSeparator);
	sep_preview->set_custom_minimum_size(Size2(10, 20));
	vbc->add_child(sep_preview);

	lbl_preview_title = memnew(Label);
	lbl_preview_title->set_text(TTR("Preview"));
	vbc->add_child(lbl_preview_title);

	lbl_preview = memnew(Label);
	lbl_preview->set_text("");
	lbl_preview->add_color_override("font_color", Color(1, 0.5f, 0, 1));
	vbc->add_child(lbl_preview);

	// ---- Dialog related

	set_custom_minimum_size(Size2(383, 0));
	set_as_toplevel(true);
	get_ok()->set_text(TTR("Rename"));
	Button *but_reset = add_button(TTR("Reset"));

	eh.errfunc = _error_handler;
	eh.userdata = this;

	// ---- Connections

	chk_collapse_features->connect("toggled", this, "_features_toggled");

	// Substitite Buttons

	lne_search->connect("focus_entered", this, "_update_substitute");
	lne_search->connect("focus_exited", this, "_update_substitute");
	lne_replace->connect("focus_entered", this, "_update_substitute");
	lne_replace->connect("focus_exited", this, "_update_substitute");
	lne_prefix->connect("focus_entered", this, "_update_substitute");
	lne_prefix->connect("focus_exited", this, "_update_substitute");
	lne_suffix->connect("focus_entered", this, "_update_substitute");
	lne_suffix->connect("focus_exited", this, "_update_substitute");

	// Preview

	lne_prefix->connect("text_changed", this, "_update_preview");
	lne_suffix->connect("text_changed", this, "_update_preview");
	lne_search->connect("text_changed", this, "_update_preview");
	lne_replace->connect("text_changed", this, "_update_preview");
	spn_count_start->connect("value_changed", this, "_update_preview_int");
	spn_count_step->connect("value_changed", this, "_update_preview_int");
	spn_count_padding->connect("value_changed", this, "_update_preview_int");
	opt_style->connect("item_selected", this, "_update_preview_int");
	opt_case->connect("item_selected", this, "_update_preview_int");
	cbut_substitute->connect("pressed", this, "_update_preview", varray(""));
	cbut_regex->connect("pressed", this, "_update_preview", varray(""));
	cbut_process->connect("pressed", this, "_update_preview", varray(""));

	but_reset->connect("pressed", this, "reset");

	reset();
	_features_toggled(false);
}
Example #10
0
MaterialEditor::MaterialEditor() {

	vc = memnew(ViewportContainer);
	vc->set_stretch(true);
	add_child(vc);
	vc->set_anchors_and_margins_preset(PRESET_WIDE);
	viewport = memnew(Viewport);
	Ref<World> world;
	world.instance();
	viewport->set_world(world); //use own world
	vc->add_child(viewport);
	viewport->set_disable_input(true);
	viewport->set_transparent_background(true);
	viewport->set_msaa(Viewport::MSAA_4X);

	camera = memnew(Camera);
	camera->set_transform(Transform(Basis(), Vector3(0, 0, 3)));
	camera->set_perspective(45, 0.1, 10);
	camera->make_current();
	viewport->add_child(camera);

	light1 = memnew(DirectionalLight);
	light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
	viewport->add_child(light1);

	light2 = memnew(DirectionalLight);
	light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
	light2->set_color(Color(0.7, 0.7, 0.7));
	viewport->add_child(light2);

	sphere_instance = memnew(MeshInstance);
	viewport->add_child(sphere_instance);

	box_instance = memnew(MeshInstance);
	viewport->add_child(box_instance);

	Transform box_xform;
	box_xform.basis.rotate(Vector3(1, 0, 0), Math::deg2rad(25.0));
	box_xform.basis = box_xform.basis * Basis().rotated(Vector3(0, 1, 0), Math::deg2rad(-25.0));
	box_xform.basis.scale(Vector3(0.8, 0.8, 0.8));
	box_xform.origin.y = 0.2;
	box_instance->set_transform(box_xform);

	sphere_mesh.instance();
	sphere_instance->set_mesh(sphere_mesh);
	box_mesh.instance();
	box_instance->set_mesh(box_mesh);
	box_instance->hide();

	set_custom_minimum_size(Size2(1, 150) * EDSCALE);

	HBoxContainer *hb = memnew(HBoxContainer);
	add_child(hb);
	hb->set_anchors_and_margins_preset(Control::PRESET_WIDE, Control::PRESET_MODE_MINSIZE, 2);

	VBoxContainer *vb_shape = memnew(VBoxContainer);
	hb->add_child(vb_shape);

	sphere_switch = memnew(TextureButton);
	sphere_switch->set_toggle_mode(true);
	sphere_switch->set_pressed(true);
	vb_shape->add_child(sphere_switch);
	sphere_switch->connect("pressed", this, "_button_pressed", varray(sphere_switch));

	box_switch = memnew(TextureButton);
	box_switch->set_toggle_mode(true);
	box_switch->set_pressed(false);
	vb_shape->add_child(box_switch);
	box_switch->connect("pressed", this, "_button_pressed", varray(box_switch));

	hb->add_spacer();

	VBoxContainer *vb_light = memnew(VBoxContainer);
	hb->add_child(vb_light);

	light_1_switch = memnew(TextureButton);
	light_1_switch->set_toggle_mode(true);
	vb_light->add_child(light_1_switch);
	light_1_switch->connect("pressed", this, "_button_pressed", varray(light_1_switch));

	light_2_switch = memnew(TextureButton);
	light_2_switch->set_toggle_mode(true);
	vb_light->add_child(light_2_switch);
	light_2_switch->connect("pressed", this, "_button_pressed", varray(light_2_switch));

	first_enter = true;
}
AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
	singleton = this;
	updating = false;

	HBoxContainer *top_hb = memnew(HBoxContainer);
	add_child(top_hb);

	Ref<ButtonGroup> bg;
	bg.instance();

	tool_blend = memnew(ToolButton);
	tool_blend->set_toggle_mode(true);
	tool_blend->set_button_group(bg);
	top_hb->add_child(tool_blend);
	tool_blend->set_pressed(true);
	tool_blend->set_tooltip(TTR("Set the blending position within the space"));
	tool_blend->connect("pressed", this, "_tool_switch", varray(3));

	tool_select = memnew(ToolButton);
	tool_select->set_toggle_mode(true);
	tool_select->set_button_group(bg);
	top_hb->add_child(tool_select);
	tool_select->set_tooltip(TTR("Select and move points, create points with RMB."));
	tool_select->connect("pressed", this, "_tool_switch", varray(0));

	tool_create = memnew(ToolButton);
	tool_create->set_toggle_mode(true);
	tool_create->set_button_group(bg);
	top_hb->add_child(tool_create);
	tool_create->set_tooltip(TTR("Create points."));
	tool_create->connect("pressed", this, "_tool_switch", varray(1));

	tool_erase_sep = memnew(VSeparator);
	top_hb->add_child(tool_erase_sep);
	tool_erase = memnew(ToolButton);
	top_hb->add_child(tool_erase);
	tool_erase->set_tooltip(TTR("Erase points."));
	tool_erase->connect("pressed", this, "_erase_selected");

	top_hb->add_child(memnew(VSeparator));

	snap = memnew(ToolButton);
	snap->set_toggle_mode(true);
	top_hb->add_child(snap);
	snap->set_pressed(true);
	snap->set_tooltip(TTR("Enable snap and show grid."));
	snap->connect("pressed", this, "_snap_toggled");

	snap_value = memnew(SpinBox);
	top_hb->add_child(snap_value);
	snap_value->set_min(0.01);
	snap_value->set_step(0.01);
	snap_value->set_max(1000);

	edit_hb = memnew(HBoxContainer);
	top_hb->add_child(edit_hb);
	edit_hb->add_child(memnew(VSeparator));
	edit_hb->add_child(memnew(Label(TTR("Point"))));

	edit_value = memnew(SpinBox);
	edit_hb->add_child(edit_value);
	edit_value->set_min(-1000);
	edit_value->set_max(1000);
	edit_value->set_step(0.01);
	edit_value->connect("value_changed", this, "_edit_point_pos");

	open_editor = memnew(Button);
	edit_hb->add_child(open_editor);
	open_editor->set_text(TTR("Open Editor"));
	open_editor->connect("pressed", this, "_open_editor", varray(), CONNECT_DEFERRED);

	edit_hb->hide();
	open_editor->hide();

	VBoxContainer *main_vb = memnew(VBoxContainer);
	add_child(main_vb);
	main_vb->set_v_size_flags(SIZE_EXPAND_FILL);

	panel = memnew(PanelContainer);
	panel->set_clip_contents(true);
	main_vb->add_child(panel);
	panel->set_h_size_flags(SIZE_EXPAND_FILL);
	panel->set_v_size_flags(SIZE_EXPAND_FILL);

	blend_space_draw = memnew(Control);
	blend_space_draw->connect("gui_input", this, "_blend_space_gui_input");
	blend_space_draw->connect("draw", this, "_blend_space_draw");
	blend_space_draw->set_focus_mode(FOCUS_ALL);

	panel->add_child(blend_space_draw);

	{
		HBoxContainer *bottom_hb = memnew(HBoxContainer);
		main_vb->add_child(bottom_hb);
		bottom_hb->set_h_size_flags(SIZE_EXPAND_FILL);

		min_value = memnew(SpinBox);
		min_value->set_max(0);
		min_value->set_min(-10000);
		min_value->set_step(0.01);

		max_value = memnew(SpinBox);
		max_value->set_max(10000);
		max_value->set_min(0.01);
		max_value->set_step(0.01);

		label_value = memnew(LineEdit);
		label_value->set_expand_to_text_length(true);

		// now add

		bottom_hb->add_child(min_value);
		bottom_hb->add_spacer();
		bottom_hb->add_child(label_value);
		bottom_hb->add_spacer();
		bottom_hb->add_child(max_value);
	}

	snap_value->connect("value_changed", this, "_config_changed");
	min_value->connect("value_changed", this, "_config_changed");
	max_value->connect("value_changed", this, "_config_changed");
	label_value->connect("text_changed", this, "_labels_changed");

	error_panel = memnew(PanelContainer);
	add_child(error_panel);

	error_label = memnew(Label);
	error_panel->add_child(error_label);
	error_label->set_text("hmmm");

	undo_redo = EditorNode::get_singleton()->get_undo_redo();

	menu = memnew(PopupMenu);
	add_child(menu);
	menu->connect("id_pressed", this, "_add_menu_type");

	animations_menu = memnew(PopupMenu);
	menu->add_child(animations_menu);
	animations_menu->set_name("animations");
	animations_menu->connect("index_pressed", this, "_add_animation_type");

	open_file = memnew(EditorFileDialog);
	add_child(open_file);
	open_file->set_title(TTR("Open Animation Node"));
	open_file->set_mode(EditorFileDialog::MODE_OPEN_FILE);
	open_file->connect("file_selected", this, "_file_opened");
	undo_redo = EditorNode::get_singleton()->get_undo_redo();

	selected_point = -1;
	dragging_selected = false;
	dragging_selected_attempt = false;

	set_custom_minimum_size(Size2(0, 150 * EDSCALE));
}
Example #12
0
FindInFilesDialog::FindInFilesDialog() {

	set_custom_minimum_size(Size2(500 * EDSCALE, 0));
	set_title(TTR("Find in Files"));

	VBoxContainer *vbc = memnew(VBoxContainer);
	vbc->set_anchor_and_margin(MARGIN_LEFT, ANCHOR_BEGIN, 8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -8 * EDSCALE);
	vbc->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, -8 * EDSCALE);
	add_child(vbc);

	GridContainer *gc = memnew(GridContainer);
	gc->set_columns(2);
	vbc->add_child(gc);

	Label *find_label = memnew(Label);
	find_label->set_text(TTR("Find:"));
	gc->add_child(find_label);

	_search_text_line_edit = memnew(LineEdit);
	_search_text_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
	_search_text_line_edit->connect("text_changed", this, "_on_search_text_modified");
	_search_text_line_edit->connect("text_entered", this, "_on_search_text_entered");
	gc->add_child(_search_text_line_edit);

	gc->add_child(memnew(Control)); // Space to maintain the grid aligned.

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		_whole_words_checkbox = memnew(CheckBox);
		_whole_words_checkbox->set_text(TTR("Whole Words"));
		hbc->add_child(_whole_words_checkbox);

		_match_case_checkbox = memnew(CheckBox);
		_match_case_checkbox->set_text(TTR("Match Case"));
		hbc->add_child(_match_case_checkbox);

		gc->add_child(hbc);
	}

	Label *folder_label = memnew(Label);
	folder_label->set_text(TTR("Folder:"));
	gc->add_child(folder_label);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		Label *prefix_label = memnew(Label);
		prefix_label->set_text("res://");
		hbc->add_child(prefix_label);

		_folder_line_edit = memnew(LineEdit);
		_folder_line_edit->set_h_size_flags(SIZE_EXPAND_FILL);
		hbc->add_child(_folder_line_edit);

		Button *folder_button = memnew(Button);
		folder_button->set_text("...");
		folder_button->connect("pressed", this, "_on_folder_button_pressed");
		hbc->add_child(folder_button);

		_folder_dialog = memnew(FileDialog);
		_folder_dialog->set_mode(FileDialog::MODE_OPEN_DIR);
		_folder_dialog->connect("dir_selected", this, "_on_folder_selected");
		add_child(_folder_dialog);

		gc->add_child(hbc);
	}

	Label *filter_label = memnew(Label);
	filter_label->set_text(TTR("Filters:"));
	gc->add_child(filter_label);

	{
		HBoxContainer *hbc = memnew(HBoxContainer);

		// TODO: Unhardcode this.
		Vector<String> exts;
		exts.push_back("gd");
		if (Engine::get_singleton()->has_singleton("GodotSharp"))
			exts.push_back("cs");
		exts.push_back("shader");

		for (int i = 0; i < exts.size(); ++i) {
			CheckBox *cb = memnew(CheckBox);
			cb->set_text(exts[i]);
			cb->set_pressed(true);
			hbc->add_child(cb);
			_filters.push_back(cb);
		}

		gc->add_child(hbc);
	}

	_find_button = add_button(TTR("Find..."), false, "find");
	_find_button->set_disabled(true);

	_replace_button = add_button(TTR("Replace..."), false, "replace");
	_replace_button->set_disabled(true);

	Button *cancel_button = get_ok();
	cancel_button->set_text(TTR("Cancel"));
}