コード例 #1
0
ファイル: base_button.cpp プロジェクト: lonesurvivor/godot
void BaseButton::set_disabled(bool p_disabled) {

	status.disabled = p_disabled;
	update();
	_change_notify("disabled");
	if (p_disabled)
		set_focus_mode(FOCUS_NONE);
	else
		set_focus_mode(enabled_focus_mode);
}
コード例 #2
0
ファイル: rich_text_label.cpp プロジェクト: icarito/godot
void RichTextLabel::set_selection_enabled(bool p_enabled) {

	selection.enabled=p_enabled;
	if (!p_enabled) {
		if (selection.active) {
			selection.active=false;
			update();
		}
		set_focus_mode(FOCUS_NONE);
	} else {
		set_focus_mode(FOCUS_ALL);
	}

}
コード例 #3
0
EditorSpinSlider::EditorSpinSlider() {

	grabbing_spinner_attempt = false;
	grabbing_spinner = false;

	set_focus_mode(FOCUS_ALL);
	updown_offset = -1;
	hover_updown = false;
	grabber = memnew(TextureRect);
	add_child(grabber);
	grabber->hide();
	grabber->set_as_toplevel(true);
	grabber->set_mouse_filter(MOUSE_FILTER_STOP);
	grabber->connect("mouse_entered", this, "_grabber_mouse_entered");
	grabber->connect("mouse_exited", this, "_grabber_mouse_exited");
	grabber->connect("gui_input", this, "_grabber_gui_input");
	mouse_over_spin = false;
	mouse_over_grabber = false;
	grabbing_grabber = false;
	grabber_range = 1;
	value_input = memnew(LineEdit);
	add_child(value_input);
	value_input->set_as_toplevel(true);
	value_input->hide();
	value_input->connect("modal_closed", this, "_value_input_closed");
	value_input->connect("text_entered", this, "_value_input_entered");
	hide_slider = false;
	read_only = false;
}
コード例 #4
0
ファイル: item_list.cpp プロジェクト: codingabc/godot
ItemList::ItemList() {

	current = -1;

	select_mode = SELECT_SINGLE;
	icon_mode = ICON_MODE_LEFT;

	fixed_column_width = 0;
	same_column_width = false;
	max_text_lines = 1;
	max_columns = 1;
	auto_height = false;
	auto_height_value = 0.0f;

	scroll_bar = memnew(VScrollBar);
	add_child(scroll_bar);

	shape_changed = true;
	scroll_bar->connect("value_changed", this, "_scroll_changed");

	set_focus_mode(FOCUS_ALL);
	current_columns = 1;
	search_time_msec = 0;
	ensure_selected_visible = false;
	defer_select_single = -1;
	allow_rmb_select = false;

	icon_scale = 1.0f;
}
コード例 #5
0
CurveEditor::CurveEditor() {
	_selected_point = -1;
	_hover_point = -1;
	_selected_tangent = TANGENT_NONE;
	_hover_radius = 6;
	_tangents_length = 40;
	_dragging = false;
	_has_undo_data = false;

	set_focus_mode(FOCUS_ALL);
	set_clip_contents(true);

	_context_menu = memnew(PopupMenu);
	_context_menu->connect("id_pressed", this, "_on_context_menu_item_selected");
	add_child(_context_menu);

	_presets_menu = memnew(PopupMenu);
	_presets_menu->set_name("_presets_menu");
	_presets_menu->add_item(TTR("Flat0"), PRESET_FLAT0);
	_presets_menu->add_item(TTR("Flat1"), PRESET_FLAT1);
	_presets_menu->add_item(TTR("Linear"), PRESET_LINEAR);
	_presets_menu->add_item(TTR("Ease in"), PRESET_EASE_IN);
	_presets_menu->add_item(TTR("Ease out"), PRESET_EASE_OUT);
	_presets_menu->add_item(TTR("Smoothstep"), PRESET_SMOOTHSTEP);
	_presets_menu->connect("id_pressed", this, "_on_preset_item_selected");
	_context_menu->add_child(_presets_menu);
}
コード例 #6
0
ファイル: base_button.cpp プロジェクト: lonesurvivor/godot
void BaseButton::set_enabled_focus_mode(FocusMode p_mode) {

	enabled_focus_mode = p_mode;
	if (!status.disabled) {
		set_focus_mode( p_mode );
	}
}
コード例 #7
0
ファイル: graph_edit.cpp プロジェクト: Scrik/godot
GraphEdit::GraphEdit() {
	set_focus_mode(FOCUS_ALL);

	top_layer=NULL;
	top_layer=memnew(GraphEditFilter(this));
	add_child(top_layer);
	top_layer->set_stop_mouse(false);
	top_layer->set_area_as_parent_rect();
	top_layer->connect("draw",this,"_top_layer_draw");
	top_layer->set_stop_mouse(false);
	top_layer->connect("input_event",this,"_top_layer_input");

	h_scroll = memnew(HScrollBar);
	h_scroll->set_name("_h_scroll");
	top_layer->add_child(h_scroll);

	v_scroll = memnew(VScrollBar);
	v_scroll->set_name("_v_scroll");
	top_layer->add_child(v_scroll);
	updating=false;
	connecting=false;
	right_disconnects=false;

	box_selecting = false;
	dragging = false;

	h_scroll->connect("value_changed", this,"_scroll_moved");
	v_scroll->connect("value_changed", this,"_scroll_moved");
}
コード例 #8
0
ファイル: button_array.cpp プロジェクト: BradWBeer/godot
ButtonArray::ButtonArray(Orientation p_orientation) {

	orientation=p_orientation;
	selected=-1;
	set_focus_mode(FOCUS_ALL);
	hover=-1;
	min_button_size = -1;
}
コード例 #9
0
ファイル: slider.cpp プロジェクト: AutonomicStudios/godot
Slider::Slider(Orientation p_orientation) {
	orientation=p_orientation;
	mouse_inside=false;
	grab.active=false;
	ticks=0;
	custom_step=-1;
	set_focus_mode(FOCUS_ALL);
}
コード例 #10
0
PlaybackButton::PlaybackButton(Type p_type,bool p_no_minsize)
{
	
	no_minsize=p_no_minsize;
	type=p_type;
	
	set_focus_mode( FOCUS_NONE ); //can't focus this, sorry
	set_fill_vertical( false );
}
コード例 #11
0
TrackEditorPattern::TrackEditorPattern(PatternTrack *p_track) : TrackEditor(p_track) {

	song = Editor::get_singleton()->get_song();
	track = p_track;

	set_bg_on_updates(false);

	set_focus_mode(GUI::FOCUS_CLICK);
	
}
コード例 #12
0
MenuButton::MenuButton() {
	

	set_flat(true);
	set_focus_mode(FOCUS_NONE);
	popup = memnew( PopupMenu );
	popup->hide();
	add_child(popup);
	popup->set_as_toplevel(true);
	set_process_unhandled_key_input(true);
	set_click_on_press(true);
}
コード例 #13
0
ファイル: base_button.cpp プロジェクト: Ranakhamis/godot
BaseButton::BaseButton() {

	toggle_mode = false;
	status.pressed = false;
	status.press_attempt = false;
	status.hovering = false;
	status.pressing_inside = false;
	status.disabled = false;
	status.pressing_button = 0;
	set_focus_mode(FOCUS_ALL);
	enabled_focus_mode = FOCUS_ALL;
	action_mode = ACTION_MODE_BUTTON_RELEASE;
}
コード例 #14
0
ColorRampEdit::ColorRampEdit(){
	grabbed=-1;
	grabbing=false;
	set_focus_mode(FOCUS_ALL);

	popup = memnew( PopupPanel );
	picker = memnew( ColorPicker );
	popup->add_child(picker);
	popup->set_child_rect(picker);
	add_child(popup);

	checker = Ref<ImageTexture>(memnew( ImageTexture ));
	checker->create_from_image( Image(checker_bg_png),ImageTexture::FLAG_REPEAT );
}
コード例 #15
0
ファイル: popup_menu.cpp プロジェクト: dreamsxin/godot
PopupMenu::PopupMenu() {

	idcount=0;
	mouse_over=-1;
	
	set_focus_mode(FOCUS_ALL);
	set_as_toplevel(true);

	submenu_timer = memnew( Timer );
	submenu_timer->set_wait_time(0.3);
	submenu_timer->set_one_shot(true);
	submenu_timer->connect("timeout",this,"_submenu_timeout");
	add_child(submenu_timer);
}
コード例 #16
0
ファイル: popup_menu.cpp プロジェクト: rrrfffrrr/godot
PopupMenu::PopupMenu() {

	mouse_over = -1;

	set_focus_mode(FOCUS_ALL);
	set_as_toplevel(true);
	set_hide_on_item_selection(true);
	set_hide_on_checkable_item_selection(true);

	submenu_timer = memnew(Timer);
	submenu_timer->set_wait_time(0.3);
	submenu_timer->set_one_shot(true);
	submenu_timer->connect("timeout", this, "_submenu_timeout");
	add_child(submenu_timer);
}
コード例 #17
0
ファイル: base_button.cpp プロジェクト: 3miu/godot
BaseButton::BaseButton() {
	
	toggle_mode=false;
	status.pressed=false;
	status.press_attempt=false;
	status.hovering=false;
	status.pressing_inside=false;
	status.disabled = false;
	status.click_on_press=false;
	status.pressing_button=0;
	set_focus_mode( FOCUS_ALL );
	group=NULL;

		
}
コード例 #18
0
ファイル: base_button.cpp プロジェクト: ialex32x/godot
BaseButton::BaseButton() {

	toggle_mode = false;
	shortcut_in_tooltip = true;
	status.pressed = false;
	status.press_attempt = false;
	status.hovering = false;
	status.pressing_inside = false;
	status.disabled = false;
	status.pressing_button = 0;
	set_focus_mode(FOCUS_ALL);
	enabled_focus_mode = FOCUS_ALL;
	action_mode = ACTION_MODE_BUTTON_RELEASE;
	button_mask = BUTTON_MASK_LEFT;
}
コード例 #19
0
SampleInstrumentTable::SampleInstrumentTable(Editor *p_editor)  {

	set_bg_on_updates( false );	
	row_offset=0;
	cursor_x=0;
	cursor_y=0;
	editor=p_editor;
	instrument=NULL;
	range=0;

	set_focus_mode(FOCUS_ALL);
	//set_
	
	//QToolTip::add( this, "Shorcuts:\n\n'.' - Clear field\nR - Repeat last field.\nAlt+Q Raise all notes a semitone.\nAlt+A Lower all notes a semitone.\nAlt+S Set all samples to last entered one.");

}
コード例 #20
0
ファイル: base_button.cpp プロジェクト: MattUV/godot
BaseButton::BaseButton() {

	toggle_mode = false;
	status.pressed = false;
	status.press_attempt = false;
	status.hovering = false;
	status.pressing_inside = false;
	status.disabled = false;
	status.pressing_button = 0;
	set_focus_mode(FOCUS_ALL);
	enabled_focus_mode = FOCUS_ALL;
	action_mode = ACTION_MODE_BUTTON_RELEASE;

	if (button_group.is_valid()) {
		button_group->buttons.erase(this);
	}
}
コード例 #21
0
ファイル: popup_menu.cpp プロジェクト: kubecz3k/godot
PopupMenu::PopupMenu() {

	mouse_over = -1;
	submenu_over = -1;
	initial_button_mask = 0;
	during_grabbed_click = false;

	set_focus_mode(FOCUS_ALL);
	set_as_toplevel(true);
	set_hide_on_item_selection(true);
	set_hide_on_checkable_item_selection(true);
	set_hide_on_multistate_item_selection(false);

	submenu_timer = memnew(Timer);
	submenu_timer->set_wait_time(0.3);
	submenu_timer->set_one_shot(true);
	submenu_timer->connect("timeout", this, "_submenu_timeout");
	add_child(submenu_timer);
}
コード例 #22
0
ControlEditor::ControlEditor(EditorNode *p_editor) {

	editor=p_editor;
	h_scroll = memnew( HScrollBar );
	v_scroll = memnew( VScrollBar );

	add_child(h_scroll);
	add_child(v_scroll);
	h_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),true);
	v_scroll->connect("value_changed", this,"_update_scroll",Vector<Variant>(),true);


	updating_scroll=false;
	set_focus_mode(FOCUS_ALL);
	handle_len=10;

	popup=memnew( PopupMenu );
	popup->add_check_item(TTR("Use Snap"));
	popup->add_item(TTR("Configure Snap.."));
	add_child(popup);

	snap_dialog = memnew( ConfirmationDialog );
	snap_dialog->get_ok()->hide();
	snap_dialog->get_cancel()->set_text(TTR("Close"));
	add_child(snap_dialog);

	Label *l = memnew(Label);
	l->set_text(TTR("Snap:"));
	l->set_pos(Point2(5,5));
	snap_dialog->add_child(l);

	snap_val=memnew(LineEdit);
	snap_val->set_text("5");
	snap_val->set_anchor(MARGIN_RIGHT,ANCHOR_END);
	snap_val->set_begin(Point2(15,25));
	snap_val->set_end(Point2(10,25));
	snap_dialog->add_child(snap_val);

	popup->connect("item_pressed", this,"_popup_callback");
	current_window=NULL;

	zoom=0.5;
}
コード例 #23
0
ファイル: line_edit.cpp プロジェクト: SPTelur/godot
LineEdit::LineEdit() {

align = ALIGN_LEFT;
cached_width = 0;
cursor_pos=0;
window_pos=0;
window_has_focus=true;
max_length = 0;
pass=false;
placeholder_alpha=0.6;

selection_clear();
set_focus_mode( FOCUS_ALL );
editable=true;
set_default_cursor_shape(CURSOR_IBEAM);
set_stop_mouse(true);

draw_caret=true;
caret_blink_enabled=false;
caret_blink_timer = memnew(Timer);
add_child(caret_blink_timer);
caret_blink_timer->set_wait_time(0.65);
caret_blink_timer->connect("timeout", this,"_toggle_draw_caret");
cursor_set_blink_enabled(false);

menu = memnew( PopupMenu );
add_child(menu);
menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
menu->add_item(TTR("Copy"),MENU_COPY,KEY_MASK_CMD|KEY_C);
menu->add_item(TTR("Paste"),MENU_PASTE,KEY_MASK_CMD|KEY_V);
menu->add_separator();
menu->add_item(TTR("Select All"),MENU_SELECT_ALL,KEY_MASK_CMD|KEY_A);
menu->add_item(TTR("Clear"),MENU_CLEAR);
menu->add_separator();
menu->add_item(TTR("Undo"),MENU_UNDO,KEY_MASK_CMD|KEY_Z);
menu->connect("item_pressed",this,"menu_option");
expand_to_text_length=false;


}
コード例 #24
0
ShaderEditor::ShaderEditor() {

	set_focus_mode(FOCUS_ALL);

	Panel* menu_panel = memnew( Panel );
	menu_panel->set_anchor( MARGIN_RIGHT, Control::ANCHOR_END );
	menu_panel->set_end( Point2(0,22) );

	add_child( menu_panel );

	PopupMenu *p;
	List<PropertyInfo> defaults;

	MenuButton* node_menu = memnew( MenuButton );
	node_menu->set_text("Graph");
	node_menu->set_pos( Point2( 5,0) );
	menu_panel->add_child( node_menu );

	p=node_menu->get_popup();
	p->add_item("Add Node",GRAPH_ADD_NODE);
	p->add_separator();
	p->add_item("Clear",GRAPH_CLEAR);
	p->connect("item_pressed", this,"_node_menu_item");

	MenuButton* vertex_menu = memnew( MenuButton );
	vertex_menu->set_text("Vertex");
	vertex_menu->set_pos( Point2( 49,0) );
	menu_panel->add_child( vertex_menu );

	p=vertex_menu->get_popup();
	defaults.clear();
	VisualServer::shader_get_default_input_nodes(VisualServer::SHADER_VERTEX,&defaults);

	int id=0;
	for(int i=0;i<defaults.size();i++) {

		p->add_item("In: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}
	p->add_separator();
	id++;

	defaults.clear();
	VisualServer::shader_get_default_output_nodes(VisualServer::SHADER_VERTEX,&defaults);

	for(int i=0;i<defaults.size();i++) {

		p->add_item("Out: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}

	vertex_popup=p;
	vertex_popup->connect("item_pressed", this,"_vertex_item");
	MenuButton* fragment_menu = memnew( MenuButton );
	fragment_menu->set_text("Fragment");
	fragment_menu->set_pos( Point2( 95 ,0) );
	menu_panel->add_child( fragment_menu );

	p=fragment_menu->get_popup();
	defaults.clear();
	VisualServer::shader_get_default_input_nodes(VisualServer::SHADER_FRAGMENT,&defaults);
	id=0;
	for(int i=0;i<defaults.size();i++) {

		p->add_item("In: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}
	p->add_separator();
	id++;
	defaults.clear();
	VisualServer::shader_get_default_output_nodes(VisualServer::SHADER_FRAGMENT,&defaults);

	for(int i=0;i<defaults.size();i++) {

		p->add_item("Out: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}

	fragment_popup=p;
	fragment_popup->connect("item_pressed", this,"_fragment_item");

	MenuButton* post_menu = memnew( MenuButton );
	post_menu->set_text("Post");
	post_menu->set_pos( Point2( 161,0) );
	menu_panel->add_child( post_menu );

	p=post_menu->get_popup();
	defaults.clear();
	VisualServer::shader_get_default_input_nodes(VisualServer::SHADER_POST_PROCESS,&defaults);
	id=0;
	for(int i=0;i<defaults.size();i++) {

		p->add_item("In: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}
	p->add_separator();
	id++;

	defaults.clear();
	VisualServer::shader_get_default_output_nodes(VisualServer::SHADER_POST_PROCESS,&defaults);

	for(int i=0;i<defaults.size();i++) {

		p->add_item("Out: "+defaults[i].name+(defaults[i].type==Variant::VECTOR3?" (vec3)":" (real)"),id++);
	}

	post_popup=p;
	post_popup->connect("item_pressed", this,"_post_item");


	/* add popup */

	add_popup = memnew( Popup );
	add_child(add_popup);
	add_popup->set_as_toplevel(true);
	Panel *add_panel = memnew( Panel );
	add_popup->add_child(add_panel);
	add_panel->set_area_as_parent_rect();

	Label *add_label = memnew (Label );
	add_label->set_pos(Point2(5,5));
	add_label->set_text("Available Nodes:");
	add_panel->add_child(add_label);


	add_types = memnew( Tree );
	add_types->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	add_types->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
	add_types->set_begin( Point2( 20,25 ) );
	add_types->set_end( Point2( 10, 30 ) );
	add_types->set_hide_root(true);
	add_types->set_columns(4);
	add_types->set_select_mode(Tree::SELECT_ROW);


	TreeItem *add_types_root = add_types->create_item(NULL);
	TreeItem *info_item = add_types->create_item(add_types_root);

	for(int i=0;i<VisualServer::NODE_TYPE_MAX;i++) {

		TreeItem *item = add_types->create_item(add_types_root);
		PropertyInfo prop = VisualServer::shader_node_get_type_info((VisualServer::ShaderNodeType)i);
		item->set_text(0,prop.name);
		item->set_text(1,itos(VisualServer::shader_get_input_count((VisualServer::ShaderNodeType)i)));
		item->set_text(2,itos(VisualServer::shader_get_output_count((VisualServer::ShaderNodeType)i)));
		String hint = (prop.type==Variant::_RID)?prop.hint_string:Variant::get_type_name(prop.type);
		item->set_text(3,hint);
		item->set_metadata(0,i);
	}
	info_item->set_text(0,"::NODE::");
	info_item->set_custom_color(0,Color(0.6,0.1,0.1));
	info_item->set_text(1,"::INPUTS::");
	info_item->set_custom_color(1,Color(0.6,0.1,0.1));
	info_item->set_text(2,"::OUTPUTS::");
	info_item->set_custom_color(2,Color(0.6,0.1,0.1));
	info_item->set_text(3,"::PARAM::");
	info_item->set_custom_color(3,Color(0.6,0.1,0.1));
	info_item->set_selectable(0,false);
	info_item->set_selectable(1,false);
	info_item->set_selectable(2,false);
	info_item->set_selectable(3,false);

	add_panel->add_child(add_types);

	add_confirm = memnew( Button );
	add_confirm->set_anchor( MARGIN_LEFT, ANCHOR_END );
	add_confirm->set_anchor( MARGIN_TOP, ANCHOR_END );
	add_confirm->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	add_confirm->set_anchor( MARGIN_BOTTOM, ANCHOR_END );
	add_confirm->set_begin( Point2( 75, 29 ) );
	add_confirm->set_end( Point2( 10, 15 ) );
	add_confirm->set_text("Add");
	add_panel->add_child(add_confirm);
	add_confirm->connect("pressed", this,"_node_add_callback");

	last_id=1;
	last_x=20;
	last_y=20;

	property_editor = memnew( CustomPropertyEditor );
	add_child(property_editor);
	property_editor->connect("variant_changed", this,"_node_param_changed");

	h_scroll = memnew( HScrollBar );
	v_scroll = memnew( VScrollBar );

	add_child(h_scroll);
	add_child(v_scroll);

	h_scroll->connect("value_changed", this,"_scroll_moved");
	v_scroll->connect("value_changed", this,"_scroll_moved");

	node_popup= memnew(PopupMenu );
	add_child(node_popup);
	node_popup->set_as_toplevel(true);

	node_popup->connect("item_pressed", this,"_node_menu_item");

}
コード例 #25
0
AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor) {
	editor=p_editor;
	singleton=this;

	updating=false;

	set_focus_mode(FOCUS_ALL);

	player=NULL;
	add_style_override("panel", get_stylebox("panel","Panel"));


	Label * l;

	/*l= memnew( Label );
	l->set_text("Animation Player:");
	add_child(l);*/

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


	add_anim = memnew( ToolButton );
	add_anim->set_tooltip("Create new animation in player.");

	hb->add_child(add_anim);


	load_anim = memnew( ToolButton );
	load_anim->set_tooltip("Load an animation from disk.");
	hb->add_child(load_anim);

	save_anim = memnew(MenuButton);
	save_anim->set_tooltip("Save the current animation");
	save_anim->get_popup()->add_item("Save", ANIM_SAVE);
	save_anim->get_popup()->add_item("Save As..", ANIM_SAVE_AS);
	save_anim->set_focus_mode(Control::FOCUS_NONE);
	hb->add_child(save_anim);

	accept = memnew(AcceptDialog);
	add_child(accept);
	accept->connect("confirmed", this, "_menu_confirm_current");

	duplicate_anim = memnew( ToolButton );
	hb->add_child(duplicate_anim);
	duplicate_anim->set_tooltip("Duplicate Animation");

	rename_anim = memnew( ToolButton );
	hb->add_child(rename_anim);
	rename_anim->set_tooltip("Rename Animation");

	remove_anim = memnew( ToolButton );

	hb->add_child(remove_anim);
	remove_anim->set_tooltip("Remove Animation");


	animation = memnew( OptionButton );
	hb->add_child(animation);
	animation->set_h_size_flags(SIZE_EXPAND_FILL);
	animation->set_tooltip("Display list of animations in player.");

	autoplay = memnew( ToolButton );
	hb->add_child(autoplay);
	autoplay->set_tooltip("Autoplay On Load");



	blend_anim = memnew( ToolButton );
	hb->add_child(blend_anim);
	blend_anim->set_tooltip("Edit Target Blend Times");

	tool_anim = memnew( MenuButton);
	//tool_anim->set_flat(false);
	tool_anim->set_tooltip("Animation Tools");
	tool_anim->get_popup()->add_item("Copy Animation",TOOL_COPY_ANIM);
	tool_anim->get_popup()->add_item("Paste Animation",TOOL_PASTE_ANIM);
	//tool_anim->get_popup()->add_separator();
	//tool_anim->get_popup()->add_item("Edit Anim Resource",TOOL_PASTE_ANIM);
	hb->add_child(tool_anim);


	edit_anim = memnew( ToolButton );
	edit_anim->set_toggle_mode(true);
	hb->add_child(edit_anim);
	edit_anim->set_tooltip("Open animation editor.\nProperty editor will displays all editable keys too.");


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

	play_bw_from = memnew( ToolButton );
	play_bw_from->set_tooltip("Play backwards selected animation from current pos. (A)");
	hb->add_child(play_bw_from);

	play_bw = memnew( ToolButton );
	play_bw->set_tooltip("Play backwards selected animation from end. (Shift+A)");
	hb->add_child(play_bw);

	stop = memnew( ToolButton );
	stop->set_toggle_mode(true);
	hb->add_child(stop);
	stop->set_tooltip("Stop animation playback. (S)");

	play = memnew( ToolButton );
	play->set_tooltip("Play selected animation from start. (Shift+D)");
	hb->add_child(play);


	play_from = memnew( ToolButton );
	play_from->set_tooltip("Play selected animation from current pos. (D)");
	hb->add_child(play_from);



	//pause = memnew( Button );
	//pause->set_toggle_mode(true);
	//hb->add_child(pause);

	seek = memnew( HSlider );
	seek->set_val(0);
	seek->set_step(0.01);
	hb->add_child(seek);
	seek->set_h_size_flags(SIZE_EXPAND_FILL);
	seek->set_stretch_ratio(8);
	seek->set_tooltip("Seek animation (when stopped).");

	frame = memnew( SpinBox );
	hb->add_child(frame);
	frame->set_h_size_flags(SIZE_EXPAND_FILL);
	frame->set_stretch_ratio(2);
	frame->set_tooltip("Animation position (in seconds).");
	seek->share(frame);



	scale = memnew( LineEdit );
	hb->add_child(scale);
	scale->set_h_size_flags(SIZE_EXPAND_FILL);
	scale->set_stretch_ratio(1);
	scale->set_tooltip("Scale animation playback globally for the node.");
	scale->hide();

	resource_edit_anim= memnew( Button );
	hb->add_child(resource_edit_anim);
	resource_edit_anim->hide();


	file = memnew(EditorFileDialog);
	add_child(file);

	name_dialog = memnew( ConfirmationDialog );
	name_dialog->set_title("Create New Animation");
	name_dialog->set_hide_on_ok(false);
	add_child(name_dialog);
	name = memnew( LineEdit );
	name_dialog->add_child(name);
	name->set_pos(Point2(18,30));
	name->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,10);
	name_dialog->register_text_enter(name);


	l = memnew( Label );
	l->set_text("Animation Name:");
	l->set_pos( Point2(10,10) );

	name_dialog->add_child(l);
	name_title=l;

	error_dialog = memnew( ConfirmationDialog );
	error_dialog->get_ok()->set_text("Close");
	//error_dialog->get_cancel()->set_text("Close");
	error_dialog->set_text("Error!");
	add_child(error_dialog);

	name_dialog->connect("confirmed", this,"_animation_name_edited");
	
	blend_editor.dialog = memnew( AcceptDialog );
	add_child(blend_editor.dialog);
	blend_editor.dialog->get_ok()->set_text("Close");
	blend_editor.dialog->set_hide_on_ok(true);
	VBoxContainer *blend_vb = memnew( VBoxContainer);
	blend_editor.dialog->add_child(blend_vb);
	blend_editor.dialog->set_child_rect(blend_vb);
	blend_editor.tree = memnew( Tree );
	blend_editor.tree->set_columns(2);
	blend_vb->add_margin_child("Blend Times: ",blend_editor.tree,true);
	blend_editor.next = memnew( LineEdit );
	blend_vb->add_margin_child("Next (Auto Queue):",blend_editor.next);
	blend_editor.dialog->set_title("Cross-Animation Blend Times");
	updating_blends=false;

	blend_editor.tree->connect("item_edited",this,"_blend_edited");
	

	autoplay->connect("pressed", this,"_autoplay_pressed");
	autoplay->set_toggle_mode(true);
	play->connect("pressed", this,"_play_pressed");
	play_from->connect("pressed", this,"_play_from_pressed");
	play_bw->connect("pressed", this,"_play_bw_pressed");
	play_bw_from->connect("pressed", this,"_play_bw_from_pressed");
	stop->connect("pressed", this,"_stop_pressed");
	//pause->connect("pressed", this,"_pause_pressed");
	add_anim->connect("pressed", this,"_animation_new");
	rename_anim->connect("pressed", this,"_animation_rename");
	load_anim->connect("pressed", this,"_animation_load");
	duplicate_anim->connect("pressed", this,"_animation_duplicate");
	//frame->connect("text_entered", this,"_seek_frame_changed");
	edit_anim->connect("pressed", this,"_animation_edit");
	blend_anim->connect("pressed", this,"_animation_blend");
	remove_anim->connect("pressed", this,"_animation_remove");
	animation->connect("item_selected", this,"_animation_selected",Vector<Variant>(),true);
	resource_edit_anim->connect("pressed", this,"_animation_resource_edit");
	file->connect("file_selected", this,"_dialog_action");
	 seek->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true);
	 scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true);
	 editor->get_animation_editor()->connect("timeline_changed",this,"_animation_key_editor_seek");
	 editor->get_animation_editor()->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed");

	 HBoxContainer *ahb = editor->get_animation_panel_hb();
	 nodename = memnew( Label );
	 ahb->add_child(nodename);
	 nodename->set_h_size_flags(SIZE_EXPAND_FILL);
	 nodename->set_opacity(0.5);
	 pin = memnew( TextureButton );
	 pin->set_toggle_mode(true);
	 ahb->add_child(pin);

	renaming=false;
	last_active=false;

	set_process_unhandled_key_input(true);
}
コード例 #26
0
AnimationTreeEditor::AnimationTreeEditor() {

	set_focus_mode(FOCUS_ALL);

	PopupMenu *p;
	List<PropertyInfo> defaults;

	add_menu = memnew( MenuButton );
	//add_menu->set_
	add_menu->set_pos( Point2( 0,0) );
	add_menu->set_size( Point2( 25,15) );
	add_child( add_menu );

	p=add_menu->get_popup();
	p->add_item("Animation Node",AnimationTreePlayer::NODE_ANIMATION);
	p->add_item("OneShot Node",AnimationTreePlayer::NODE_ONESHOT);
	p->add_item("Mix Node",AnimationTreePlayer::NODE_MIX);
	p->add_item("Blend2 Node",AnimationTreePlayer::NODE_BLEND2);
	p->add_item("Blend3 Node",AnimationTreePlayer::NODE_BLEND3);
	p->add_item("Blend4 Node",AnimationTreePlayer::NODE_BLEND4);
	p->add_item("TimeScale Node",AnimationTreePlayer::NODE_TIMESCALE);
	p->add_item("TimeSeek Node",AnimationTreePlayer::NODE_TIMESEEK);
	p->add_item("Transition Node",AnimationTreePlayer::NODE_TRANSITION);
	p->add_separator();
	p->add_item("Import Animations...", MENU_IMPORT_ANIMATIONS); // wtf
	p->add_separator();
	p->add_item("Clear",MENU_GRAPH_CLEAR);

	p->connect("item_pressed", this,"_add_menu_item");

	play_button = memnew(Button);
	play_button->set_pos(Point2(25,0));
	play_button->set_size(Point2(25,15));
	add_child(play_button);
	play_button->set_toggle_mode(true);
	play_button->connect("pressed", this,"_play_toggled");





	last_x=50;
	last_y=50;

	property_editor = memnew( CustomPropertyEditor );
	add_child(property_editor);
	property_editor->connect("variant_changed", this,"_edit_dialog_animation_changed");
	 property_editor->connect("resource_edit_request", this, "_edit_dialog_edit_animation");

	h_scroll = memnew( HScrollBar );
	v_scroll = memnew( VScrollBar );

	add_child(h_scroll);
	add_child(v_scroll);

	h_scroll->connect("value_changed", this,"_scroll_moved");
	v_scroll->connect("value_changed", this,"_scroll_moved");

	node_popup= memnew(PopupMenu );
	add_child(node_popup);
	node_popup->set_as_toplevel(true);

	master_anim_popup = memnew( PopupMenu );
	add_child(master_anim_popup);
	master_anim_popup->connect("item_pressed",this,"_master_anim_menu_item");


	node_popup->connect("item_pressed", this,"_node_menu_item");

	updating_edit=false;

	edit_dialog = memnew( PopupPanel );
//	edit_dialog->get_ok()->hide();
//	edit_dialog->get_cancel()->hide();
	add_child(edit_dialog);

	edit_option = memnew( OptionButton );
	edit_option->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	edit_option->set_margin(MARGIN_RIGHT, 10);
	edit_dialog->add_child(edit_option);
	edit_option->connect("item_selected", this,"_edit_dialog_changedf");
	edit_option->hide();


	for(int i=0;i<2;i++) {
		edit_scroll[i] = memnew ( HSlider );
		edit_scroll[i]->set_anchor( MARGIN_RIGHT, ANCHOR_END );
		edit_scroll[i]->set_margin(MARGIN_RIGHT, 10);
		edit_dialog->add_child(edit_scroll[i]);
		edit_scroll[i]->hide();
		edit_scroll[i]->connect("value_changed", this,"_edit_dialog_changedf");
	}
	for(int i=0;i<4;i++) {
		edit_line[i] = memnew ( LineEdit );
		edit_line[i]->set_anchor( MARGIN_RIGHT, ANCHOR_END );
		edit_line[i]->set_margin(MARGIN_RIGHT, 10);
		edit_dialog->add_child(edit_line[i]);
		edit_line[i]->hide();
		edit_line[i]->connect("text_changed", this,"_edit_dialog_changeds");
		edit_line[i]->connect("text_entered", this,"_edit_dialog_changede");
		edit_label[i] = memnew ( Label );
		edit_dialog->add_child(edit_label[i]);
		edit_label[i]->hide();
	}

	edit_button = memnew( Button );
	edit_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	edit_button->set_margin(MARGIN_RIGHT, 10);
	edit_dialog->add_child(edit_button);
	edit_button->hide();;
	edit_button->connect("pressed", this,"_edit_oneshot_start");

	edit_check = memnew( CheckButton );
	edit_check->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	edit_check->set_margin(MARGIN_RIGHT, 10);
	edit_dialog->add_child(edit_check);
	edit_check->hide();;
	edit_check->connect("pressed", this,"_edit_dialog_changed");

	file_dialog = memnew( EditorFileDialog );
	file_dialog->set_enable_multiple_selection(true);
	file_dialog->set_current_dir(Globals::get_singleton()->get_resource_path());
	add_child(file_dialog);
	 file_dialog->connect("file_selected", this, "_file_dialog_selected");

	filter_dialog = memnew( AcceptDialog );
	filter_dialog->set_title("Edit Node Filters");
	add_child(filter_dialog);

	filter = memnew( Tree );
	filter_dialog->add_child(filter);
	filter_dialog->set_child_rect(filter);
	filter->connect("item_edited",this,"_filter_edited");

	filter_button = memnew( Button );
	filter_button->set_anchor( MARGIN_RIGHT, ANCHOR_END );
	filter_button->set_margin(MARGIN_RIGHT, 10);
	edit_dialog->add_child(filter_button);
	filter_button->hide();;
	filter_button->set_text("Filters..");
	filter_button->connect("pressed", this,"_edit_filters");

}
コード例 #27
0
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");
}
コード例 #28
0
ファイル: graph_edit.cpp プロジェクト: UgisBrekis/godot
GraphEdit::GraphEdit() {
	set_focus_mode(FOCUS_ALL);

	awaiting_scroll_offset_update = false;
	top_layer = NULL;
	top_layer = memnew(GraphEditFilter(this));
	add_child(top_layer);
	top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
	top_layer->set_anchors_and_margins_preset(Control::PRESET_WIDE);
	top_layer->connect("draw", this, "_top_layer_draw");
	top_layer->set_mouse_filter(MOUSE_FILTER_PASS);
	top_layer->connect("gui_input", this, "_top_layer_input");

	connections_layer = memnew(Control);
	add_child(connections_layer);
	connections_layer->connect("draw", this, "_connections_layer_draw");
	connections_layer->set_name("CLAYER");
	connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offset
	connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE);

	h_scroll = memnew(HScrollBar);
	h_scroll->set_name("_h_scroll");
	top_layer->add_child(h_scroll);

	v_scroll = memnew(VScrollBar);
	v_scroll->set_name("_v_scroll");
	top_layer->add_child(v_scroll);
	updating = false;
	connecting = false;
	right_disconnects = false;

	box_selecting = false;
	dragging = false;

	//set large minmax so it can scroll even if not resized yet
	h_scroll->set_min(-10000);
	h_scroll->set_max(10000);

	v_scroll->set_min(-10000);
	v_scroll->set_max(10000);

	h_scroll->connect("value_changed", this, "_scroll_moved");
	v_scroll->connect("value_changed", this, "_scroll_moved");

	zoom = 1;

	zoom_hb = memnew(HBoxContainer);
	top_layer->add_child(zoom_hb);
	zoom_hb->set_position(Vector2(10, 10));

	zoom_minus = memnew(ToolButton);
	zoom_hb->add_child(zoom_minus);
	zoom_minus->set_tooltip(RTR("Zoom Out"));
	zoom_minus->connect("pressed", this, "_zoom_minus");
	zoom_minus->set_focus_mode(FOCUS_NONE);

	zoom_reset = memnew(ToolButton);
	zoom_hb->add_child(zoom_reset);
	zoom_reset->set_tooltip(RTR("Zoom Reset"));
	zoom_reset->connect("pressed", this, "_zoom_reset");
	zoom_reset->set_focus_mode(FOCUS_NONE);

	zoom_plus = memnew(ToolButton);
	zoom_hb->add_child(zoom_plus);
	zoom_plus->set_tooltip(RTR("Zoom In"));
	zoom_plus->connect("pressed", this, "_zoom_plus");
	zoom_plus->set_focus_mode(FOCUS_NONE);

	snap_button = memnew(ToolButton);
	snap_button->set_toggle_mode(true);
	snap_button->set_tooltip(RTR("Enable snap and show grid."));
	snap_button->connect("pressed", this, "_snap_toggled");
	snap_button->set_pressed(true);
	snap_button->set_focus_mode(FOCUS_NONE);
	zoom_hb->add_child(snap_button);

	snap_amount = memnew(SpinBox);
	snap_amount->set_min(5);
	snap_amount->set_max(100);
	snap_amount->set_step(1);
	snap_amount->set_value(20);
	snap_amount->connect("value_changed", this, "_snap_value_changed");
	zoom_hb->add_child(snap_amount);

	setting_scroll_ofs = false;
	just_disconnected = false;
	set_clip_contents(true);
}