void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z); ED_SHORTCUT("script_text_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y); ED_SHORTCUT("script_text_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X); ED_SHORTCUT("script_text_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C); ED_SHORTCUT("script_text_editor/paste", TTR("Paste"), KEY_MASK_CMD|KEY_V); ED_SHORTCUT("script_text_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A); ED_SHORTCUT("script_text_editor/move_up", TTR("Move Up"), KEY_MASK_ALT|KEY_UP); ED_SHORTCUT("script_text_editor/move_down", TTR("Move Down"), KEY_MASK_ALT|KEY_DOWN); ED_SHORTCUT("script_text_editor/indent_left", TTR("Indent Left"), KEY_MASK_ALT|KEY_LEFT); ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD|KEY_K); ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD|KEY_B); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL|KEY_SPACE); #else ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CMD|KEY_SPACE); #endif ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KEY_MASK_CTRL|KEY_MASK_ALT|KEY_T); ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KEY_MASK_CMD|KEY_I); ED_SHORTCUT("script_text_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9); ED_SHORTCUT("script_text_editor/remove_all_breakpoints", TTR("Remove All Breakpoints"), KEY_MASK_CTRL|KEY_MASK_SHIFT|KEY_F9); ED_SHORTCUT("script_text_editor/goto_next_breakpoint", TTR("Goto Next Breakpoint"), KEY_MASK_CTRL|KEY_PERIOD); ED_SHORTCUT("script_text_editor/goto_previous_breakpoint", TTR("Goto Previous Breakpoint"), KEY_MASK_CTRL|KEY_COMMA); ED_SHORTCUT("script_text_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F); ED_SHORTCUT("script_text_editor/find_next", TTR("Find Next"), KEY_F3); ED_SHORTCUT("script_text_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT|KEY_F3); ED_SHORTCUT("script_text_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R); ED_SHORTCUT("script_text_editor/goto_function", TTR("Goto Function.."), KEY_MASK_SHIFT|KEY_MASK_CMD|KEY_F); ED_SHORTCUT("script_text_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L); ED_SHORTCUT("script_text_editor/contextual_help", TTR("Contextual Help"), KEY_MASK_SHIFT|KEY_F1); ScriptEditor::register_create_script_editor_function(create_editor); }
void InspectorDock::update(Object *p_object) { EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); backward_button->set_disabled(editor_history->is_at_beginning()); forward_button->set_disabled(editor_history->is_at_end()); history_menu->set_disabled(true); if (editor_history->get_history_len() > 0) { history_menu->set_disabled(false); } editor_path->update_path(); current = p_object; if (!p_object) { object_menu->set_disabled(true); warning->hide(); search->set_editable(false); return; } bool is_resource = p_object->is_class("Resource"); bool is_node = p_object->is_class("Node"); object_menu->set_disabled(false); search->set_editable(true); PopupMenu *p = object_menu->get_popup(); p->clear(); p->add_shortcut(ED_SHORTCUT("property_editor/expand_all", TTR("Expand all properties")), EXPAND_ALL); p->add_shortcut(ED_SHORTCUT("property_editor/collapse_all", TTR("Collapse all properties")), COLLAPSE_ALL); p->add_separator(); if (is_resource) { p->add_item(TTR("Save"), RESOURCE_SAVE); p->add_item(TTR("Save As..."), RESOURCE_SAVE_AS); p->add_separator(); } p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Params")), OBJECT_COPY_PARAMS); p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Params")), OBJECT_PASTE_PARAMS); p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource", TTR("Paste Resource")), RESOURCE_PASTE); if (is_resource) { p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY); p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Built-In")), RESOURCE_UNREF); } if (is_resource || is_node) { p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES); p->add_separator(); p->add_icon_shortcut(get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); } List<MethodInfo> methods; p_object->get_method_list(&methods); if (!methods.empty()) { bool found = false; List<MethodInfo>::Element *I = methods.front(); int i = 0; while (I) { if (I->get().flags & METHOD_FLAG_EDITOR) { if (!found) { p->add_separator(); found = true; } p->add_item(I->get().name.capitalize(), OBJECT_METHOD_BASE + i); } i++; I = I->next(); } } }
CodeTextEditor::CodeTextEditor() { code_complete_func = NULL; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS); ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0); find_replace_bar = memnew(FindReplaceBar); add_child(find_replace_bar); find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL); find_replace_bar->hide(); text_editor = memnew(TextEdit); add_child(text_editor); text_editor->set_v_size_flags(SIZE_EXPAND_FILL); find_replace_bar->set_text_edit(text_editor); text_editor->set_show_line_numbers(true); text_editor->set_brace_matching(true); text_editor->set_auto_indent(true); MarginContainer *status_mc = memnew(MarginContainer); add_child(status_mc); status_mc->set("custom_constants/margin_left", 2); status_mc->set("custom_constants/margin_top", 5); status_mc->set("custom_constants/margin_right", 2); status_mc->set("custom_constants/margin_bottom", 1); HBoxContainer *status_bar = memnew(HBoxContainer); status_mc->add_child(status_bar); status_bar->set_h_size_flags(SIZE_EXPAND_FILL); status_bar->add_child(memnew(Label)); //to keep the height if the other labels are not visible idle = memnew(Timer); add_child(idle); idle->set_one_shot(true); idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2)); code_complete_timer = memnew(Timer); add_child(code_complete_timer); code_complete_timer->set_one_shot(true); enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay", true); code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay", .3f)); error = memnew(Label); status_bar->add_child(error); error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right error->set_valign(Label::VALIGN_CENTER); error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch Label *line_txt = memnew(Label); status_bar->add_child(line_txt); line_txt->set_align(Label::ALIGN_RIGHT); line_txt->set_valign(Label::VALIGN_CENTER); line_txt->set_v_size_flags(SIZE_FILL); line_txt->set_text(TTR("Line:")); line_nb = memnew(Label); status_bar->add_child(line_nb); line_nb->set_valign(Label::VALIGN_CENTER); line_nb->set_v_size_flags(SIZE_FILL); line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch line_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); Label *col_txt = memnew(Label); status_bar->add_child(col_txt); col_txt->set_align(Label::ALIGN_RIGHT); col_txt->set_valign(Label::VALIGN_CENTER); col_txt->set_v_size_flags(SIZE_FILL); col_txt->set_text(TTR("Col:")); col_nb = memnew(Label); status_bar->add_child(col_nb); col_nb->set_valign(Label::VALIGN_CENTER); col_nb->set_v_size_flags(SIZE_FILL); col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch col_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); text_editor->connect("gui_input", this, "_text_editor_gui_input"); text_editor->connect("cursor_changed", this, "_line_col_changed"); text_editor->connect("text_changed", this, "_text_changed"); text_editor->connect("request_completion", this, "_complete_request"); Vector<String> cs; cs.push_back("."); cs.push_back(","); cs.push_back("("); cs.push_back("="); cs.push_back("$"); text_editor->set_completion(true, cs); idle->connect("timeout", this, "_text_changed_idle_timeout"); code_complete_timer->connect("timeout", this, "_code_complete_timer_timeout"); font_resize_val = 0; font_resize_timer = memnew(Timer); add_child(font_resize_timer); font_resize_timer->set_one_shot(true); font_resize_timer->set_wait_time(0.07); font_resize_timer->connect("timeout", this, "_font_resize_timeout"); EditorSettings::get_singleton()->connect("settings_changed", this, "_on_settings_change"); }
ShaderEditor::ShaderEditor() { tab_container = memnew( TabContainer ); add_child(tab_container); tab_container->set_area_as_parent_rect(); tab_container->set_begin(Point2(0,0)); //tab_container->set_begin(Point2(0,0)); close = memnew( TextureButton ); close->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_END,20); close->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END,4); close->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN,2); add_child(close); edit_menu = memnew( MenuButton ); add_child(edit_menu); edit_menu->set_pos(Point2(5,-1)); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD|KEY_Z), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD|KEY_Y), EDIT_REDO); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD|KEY_X), EDIT_CUT); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD|KEY_C), EDIT_COPY); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/paste", TTR("Paste"), KEY_MASK_CMD|KEY_V), EDIT_PASTE); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/select_all", TTR("Select All"), KEY_MASK_CMD|KEY_A), EDIT_SELECT_ALL); edit_menu->get_popup()->connect("item_pressed", this,"_menu_option"); search_menu = memnew( MenuButton ); add_child(search_menu); search_menu->set_pos(Point2(38,-1)); search_menu->set_text(TTR("Search")); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD|KEY_F), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), SEARCH_FIND_NEXT); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT|KEY_F3), SEARCH_FIND_PREV); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD|KEY_R), SEARCH_REPLACE); search_menu->get_popup()->add_separator(); // search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K); search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD|KEY_L), SEARCH_GOTO_LINE); search_menu->get_popup()->connect("item_pressed", this,"_menu_option"); tab_container->connect("tab_changed", this,"_tab_changed"); erase_tab_confirm = memnew( ConfirmationDialog ); add_child(erase_tab_confirm); erase_tab_confirm->connect("confirmed", this,"_close_current_tab"); goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); vertex_editor = memnew( ShaderTextEditor ); tab_container->add_child(vertex_editor); vertex_editor->set_name(TTR("Vertex")); fragment_editor = memnew( ShaderTextEditor ); tab_container->add_child(fragment_editor); fragment_editor->set_name(TTR("Fragment")); light_editor = memnew( ShaderTextEditor ); tab_container->add_child(light_editor); light_editor->set_name(TTR("Lighting")); tab_container->set_current_tab(1); vertex_editor->connect("script_changed", this,"apply_shaders"); fragment_editor->connect("script_changed", this,"apply_shaders"); light_editor->connect("script_changed", this,"apply_shaders"); EditorSettings::get_singleton()->connect("settings_changed",this,"_editor_settings_changed"); _editor_settings_changed(); }
TextEditor::TextEditor() { code_editor = memnew(CodeTextEditor); add_child(code_editor); code_editor->add_constant_override("separation", 0); code_editor->connect("load_theme_settings", this, "_load_theme_settings"); code_editor->connect("validate_script", this, "_validate_script"); code_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); update_settings(); code_editor->get_text_edit()->set_context_menu_enabled(false); code_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input"); context_menu = memnew(PopupMenu); add_child(context_menu); context_menu->connect("id_pressed", this, "_edit_option"); edit_hb = memnew(HBoxContainer); search_menu = memnew(MenuButton); edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); search_menu->get_popup()->connect("id_pressed", this, "_edit_option"); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE); search_menu->get_popup()->add_separator(); search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE); goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); edit_menu->get_popup()->connect("id_pressed", this, "_edit_option"); edit_hb->add_child(edit_menu); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES); edit_menu->get_popup()->add_separator(); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS); edit_menu->get_popup()->add_separator(); PopupMenu *convert_case = memnew(PopupMenu); convert_case->set_name("convert_case"); edit_menu->get_popup()->add_child(convert_case); edit_menu->get_popup()->add_submenu_item(TTR("Convert Case"), "convert_case"); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_uppercase", TTR("Uppercase")), EDIT_TO_UPPERCASE); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/convert_to_lowercase", TTR("Lowercase")), EDIT_TO_LOWERCASE); convert_case->add_shortcut(ED_SHORTCUT("script_text_editor/capitalize", TTR("Capitalize")), EDIT_CAPITALIZE); convert_case->connect("id_pressed", this, "_edit_option"); highlighters["Standard"] = NULL; highlighter_menu = memnew(PopupMenu); highlighter_menu->set_name("highlighter_menu"); edit_menu->get_popup()->add_child(highlighter_menu); edit_menu->get_popup()->add_submenu_item(TTR("Syntax Highlighter"), "highlighter_menu"); highlighter_menu->add_radio_check_item(TTR("Standard")); highlighter_menu->connect("id_pressed", this, "_change_syntax_highlighter"); code_editor->get_text_edit()->set_drag_forwarding(this); }
CodeTextEditor::CodeTextEditor() { code_complete_func = NULL; ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL); ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS); ED_SHORTCUT("script_editor/reset_zoom", TTR("Reset Zoom"), KEY_MASK_CMD | KEY_0); find_replace_bar = memnew(FindReplaceBar); add_child(find_replace_bar); find_replace_bar->set_h_size_flags(SIZE_EXPAND_FILL); find_replace_bar->hide(); text_editor = memnew(TextEdit); add_child(text_editor); text_editor->set_v_size_flags(SIZE_EXPAND_FILL); find_replace_bar->set_text_edit(text_editor); text_editor->set_show_line_numbers(true); text_editor->set_brace_matching(true); text_editor->set_auto_indent(true); status_bar = memnew(HBoxContainer); add_child(status_bar); status_bar->set_h_size_flags(SIZE_EXPAND_FILL); idle = memnew(Timer); add_child(idle); idle->set_one_shot(true); idle->set_wait_time(EDITOR_DEF("text_editor/completion/idle_parse_delay", 2)); code_complete_timer = memnew(Timer); add_child(code_complete_timer); code_complete_timer->set_one_shot(true); enable_complete_timer = EDITOR_DEF("text_editor/completion/enable_code_completion_delay", true); code_complete_timer->set_wait_time(EDITOR_DEF("text_editor/completion/code_complete_delay", .3f)); error = memnew(Label); status_bar->add_child(error); error->set_autowrap(true); error->set_valign(Label::VALIGN_CENTER); error->add_color_override("font_color", EditorNode::get_singleton()->get_gui_base()->get_color("error_color", "Editor")); error->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch find_replace_bar->connect("error", error, "set_text"); status_bar->add_child(memnew(Label)); //to keep the height if the other labels are not visible warning_label = memnew(Label); status_bar->add_child(warning_label); warning_label->set_align(Label::ALIGN_RIGHT); warning_label->set_valign(Label::VALIGN_CENTER); warning_label->set_v_size_flags(SIZE_FILL); warning_label->set_default_cursor_shape(CURSOR_POINTING_HAND); warning_label->set_mouse_filter(MOUSE_FILTER_STOP); warning_label->set_text(TTR("Warnings:")); warning_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); warning_count_label = memnew(Label); status_bar->add_child(warning_count_label); warning_count_label->set_valign(Label::VALIGN_CENTER); warning_count_label->set_v_size_flags(SIZE_FILL); warning_count_label->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch warning_count_label->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch warning_count_label->set_custom_minimum_size(Size2(40, 1) * EDSCALE); warning_count_label->set_align(Label::ALIGN_RIGHT); warning_count_label->set_default_cursor_shape(CURSOR_POINTING_HAND); warning_count_label->set_mouse_filter(MOUSE_FILTER_STOP); warning_count_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); warning_count_label->set_text("0"); Label *zoom_txt = memnew(Label); status_bar->add_child(zoom_txt); zoom_txt->set_align(Label::ALIGN_RIGHT); zoom_txt->set_valign(Label::VALIGN_CENTER); zoom_txt->set_v_size_flags(SIZE_FILL); zoom_txt->set_text(TTR("Zoom:")); zoom_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); zoom_nb = memnew(Label); status_bar->add_child(zoom_nb); zoom_nb->set_valign(Label::VALIGN_CENTER); zoom_nb->set_v_size_flags(SIZE_FILL); zoom_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch zoom_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch zoom_nb->set_custom_minimum_size(Size2(60, 1) * EDSCALE); zoom_nb->set_align(Label::ALIGN_RIGHT); zoom_nb->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); Label *line_txt = memnew(Label); status_bar->add_child(line_txt); line_txt->set_align(Label::ALIGN_RIGHT); line_txt->set_valign(Label::VALIGN_CENTER); line_txt->set_v_size_flags(SIZE_FILL); line_txt->set_text(TTR("Line:")); line_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); line_nb = memnew(Label); status_bar->add_child(line_nb); line_nb->set_valign(Label::VALIGN_CENTER); line_nb->set_v_size_flags(SIZE_FILL); line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch line_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); line_nb->set_align(Label::ALIGN_RIGHT); line_nb->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); Label *col_txt = memnew(Label); status_bar->add_child(col_txt); col_txt->set_align(Label::ALIGN_RIGHT); col_txt->set_valign(Label::VALIGN_CENTER); col_txt->set_v_size_flags(SIZE_FILL); col_txt->set_text(TTR("Col:")); col_txt->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); col_nb = memnew(Label); status_bar->add_child(col_nb); col_nb->set_valign(Label::VALIGN_CENTER); col_nb->set_v_size_flags(SIZE_FILL); col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch col_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE); col_nb->set_align(Label::ALIGN_RIGHT); col_nb->set("custom_constants/margin_right", 0); col_nb->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); text_editor->connect("gui_input", this, "_text_editor_gui_input"); text_editor->connect("cursor_changed", this, "_line_col_changed"); text_editor->connect("text_changed", this, "_text_changed"); text_editor->connect("request_completion", this, "_complete_request"); Vector<String> cs; cs.push_back("."); cs.push_back(","); cs.push_back("("); cs.push_back("="); cs.push_back("$"); text_editor->set_completion(true, cs); idle->connect("timeout", this, "_text_changed_idle_timeout"); code_complete_timer->connect("timeout", this, "_code_complete_timer_timeout"); font_resize_val = 0; font_size = EditorSettings::get_singleton()->get("interface/editor/code_font_size"); zoom_nb->set_text(itos(100 * font_size / (14 * EDSCALE)) + "%"); font_resize_timer = memnew(Timer); add_child(font_resize_timer); font_resize_timer->set_one_shot(true); font_resize_timer->set_wait_time(0.07); font_resize_timer->connect("timeout", this, "_font_resize_timeout"); EditorSettings::get_singleton()->connect("settings_changed", this, "_on_settings_change"); }
EditorFileDialog::EditorFileDialog() { show_hidden_files=default_show_hidden_files; display_mode=default_display_mode; local_history_pos=0; disable_overwrite_warning=false; VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); set_child_rect(vbc); mode=MODE_SAVE_FILE; set_title(TTR("Save a File")); ED_SHORTCUT("file_dialog/go_back", TTR("Go Back"), KEY_MASK_ALT|KEY_LEFT); ED_SHORTCUT("file_dialog/go_forward", TTR("Go Forward"), KEY_MASK_ALT|KEY_RIGHT); ED_SHORTCUT("file_dialog/go_up", TTR("Go Up"), KEY_MASK_ALT|KEY_UP); ED_SHORTCUT("file_dialog/refresh", TTR("Refresh"), KEY_F5); ED_SHORTCUT("file_dialog/toggle_hidden_files", TTR("Toggle Hidden Files"), KEY_MASK_CMD|KEY_H); ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT|KEY_F); ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT|KEY_V); ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD|KEY_N); ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD|KEY_D); ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD|KEY_UP); ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD|KEY_DOWN); HBoxContainer *pathhb = memnew( HBoxContainer ); dir_prev = memnew( ToolButton ); dir_next = memnew( ToolButton ); dir_up = memnew( ToolButton ); pathhb->add_child(dir_prev); pathhb->add_child(dir_next); pathhb->add_child(dir_up); dir_prev->connect("pressed",this,"_go_back"); dir_next->connect("pressed",this,"_go_forward"); dir_up->connect("pressed",this,"_go_up"); dir = memnew(LineEdit); pathhb->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); refresh = memnew( ToolButton ); refresh->connect("pressed",this,"_update_file_list"); pathhb->add_child(refresh); favorite = memnew( ToolButton ); favorite->set_toggle_mode(true); favorite->connect("toggled",this,"_favorite_toggled"); pathhb->add_child(favorite); mode_thumbnails = memnew( ToolButton ); mode_thumbnails->connect("pressed",this,"set_display_mode",varray(DISPLAY_THUMBNAILS)); mode_thumbnails->set_toggle_mode(true); mode_thumbnails->set_pressed(display_mode==DISPLAY_THUMBNAILS); pathhb->add_child(mode_thumbnails); mode_list = memnew( ToolButton ); mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST)); mode_list->set_toggle_mode(true); mode_list->set_pressed(display_mode==DISPLAY_LIST); pathhb->add_child(mode_list); drives = memnew( OptionButton ); pathhb->add_child(drives); drives->connect("item_selected",this,"_select_drive"); makedir = memnew( Button ); makedir->set_text(TTR("Create Folder")); makedir->connect("pressed",this,"_make_dir"); pathhb->add_child(makedir); list_hb = memnew( HBoxContainer ); vbc->add_margin_child(TTR("Path:"),pathhb); vbc->add_child(list_hb); list_hb->set_v_size_flags(SIZE_EXPAND_FILL); VBoxContainer *fav_vb = memnew( VBoxContainer ); list_hb->add_child(fav_vb); HBoxContainer *fav_hb = memnew( HBoxContainer ); fav_vb->add_child(fav_hb); fav_hb->add_child(memnew(Label(TTR("Favorites:")))); fav_hb->add_spacer(); fav_up = memnew( ToolButton ); fav_hb->add_child(fav_up); fav_up->connect("pressed",this,"_favorite_move_up"); fav_down = memnew( ToolButton ); fav_hb->add_child(fav_down); fav_down->connect("pressed",this,"_favorite_move_down"); fav_rm = memnew( ToolButton ); fav_hb->add_child(fav_rm); fav_rm->hide(); // redundant MarginContainer *fav_mv = memnew( MarginContainer ); fav_vb->add_child(fav_mv); fav_mv->set_v_size_flags(SIZE_EXPAND_FILL); favorites = memnew( ItemList ); fav_mv->add_child(favorites); favorites->connect("item_selected",this,"_favorite_selected"); recent = memnew( ItemList ); fav_vb->add_margin_child(TTR("Recent:"),recent,true); recent->connect("item_selected",this,"_recent_selected"); VBoxContainer *item_vb = memnew( VBoxContainer ); list_hb->add_child(item_vb); item_vb->set_h_size_flags(SIZE_EXPAND_FILL); item_list = memnew( ItemList ); item_list->set_v_size_flags(SIZE_EXPAND_FILL); item_vb->add_margin_child(TTR("Directories & Files:"),item_list,true); HBoxContainer* filter_hb = memnew( HBoxContainer ); item_vb->add_child(filter_hb); VBoxContainer *filter_vb = memnew( VBoxContainer ); filter_hb->add_child(filter_vb); filter_vb->set_h_size_flags(SIZE_EXPAND_FILL); preview_vb = memnew( VBoxContainer ); filter_hb->add_child(preview_vb); CenterContainer *prev_cc = memnew( CenterContainer ); preview_vb->add_margin_child(TTR("Preview:"),prev_cc); preview = memnew( TextureFrame ); prev_cc->add_child(preview); preview_vb->hide(); file = memnew(LineEdit); //add_child(file); filter_vb->add_margin_child(TTR("File:"),file); filter = memnew( OptionButton ); //add_child(filter); filter_vb->add_margin_child(TTR("Filter:"),filter); filter->set_clip_text(true);//too many extensions overflow it dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES); access=ACCESS_RESOURCES; _update_drives(); connect("confirmed", this,"_action_pressed"); //cancel->connect("pressed", this,"_cancel_pressed"); item_list->connect("item_selected", this,"_item_selected",varray(),CONNECT_DEFERRED); item_list->connect("item_activated", this,"_item_db_selected",varray()); dir->connect("text_entered", this,"_dir_entered"); file->connect("text_entered", this,"_file_entered"); filter->connect("item_selected", this,"_filter_selected"); confirm_save = memnew( ConfirmationDialog ); confirm_save->set_as_toplevel(true); add_child(confirm_save); confirm_save->connect("confirmed", this,"_save_confirm_pressed"); makedialog = memnew( ConfirmationDialog ); makedialog->set_title(TTR("Create Folder")); VBoxContainer *makevb= memnew( VBoxContainer ); makedialog->add_child(makevb); makedialog->set_child_rect(makevb); makedirname = memnew( LineEdit ); makevb->add_margin_child(TTR("Name:"),makedirname); add_child(makedialog); makedialog->register_text_enter(makedirname); makedialog->connect("confirmed",this,"_make_dir_confirm"); mkdirerr = memnew( AcceptDialog ); mkdirerr->set_text(TTR("Could not create folder.")); add_child(mkdirerr); exterr = memnew( AcceptDialog ); exterr->set_text(TTR("Must use a valid extension.")); add_child(exterr); //update_file_list(); update_filters(); update_dir(); set_hide_on_ok(false); vbox=vbc; invalidated=true; if (register_func) register_func(this); preview_wheel_timeout=0; preview_wheel_index=0; preview_waiting=false; }
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); play_bw_from = memnew( ToolButton ); play_bw_from->set_tooltip(TTR("Play selected animation backwards from current pos. (A)")); hb->add_child(play_bw_from); play_bw = memnew( ToolButton ); play_bw->set_tooltip(TTR("Play selected animation backwards from end. (Shift+A)")); hb->add_child(play_bw); stop = memnew( ToolButton ); stop->set_toggle_mode(true); hb->add_child(stop); stop->set_tooltip(TTR("Stop animation playback. (S)")); play = memnew( ToolButton ); play->set_tooltip(TTR("Play selected animation from start. (Shift+D)")); hb->add_child(play); play_from = memnew( ToolButton ); play_from->set_tooltip(TTR("Play selected animation from current pos. (D)")); hb->add_child(play_from); //pause = memnew( Button ); //pause->set_toggle_mode(true); //hb->add_child(pause); frame = memnew( SpinBox ); hb->add_child(frame); frame->set_custom_minimum_size(Size2(60,0)); frame->set_stretch_ratio(2); frame->set_tooltip(TTR("Animation position (in seconds).")); hb->add_child( memnew( VSeparator)); scale = memnew( LineEdit ); hb->add_child(scale); scale->set_h_size_flags(SIZE_EXPAND_FILL); scale->set_stretch_ratio(1); scale->set_tooltip(TTR("Scale animation playback globally for the node.")); scale->hide(); add_anim = memnew( ToolButton ); ED_SHORTCUT("animation_player_editor/add_animation", TTR("Create new animation in player.")); add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/add_animation")); add_anim->set_tooltip(TTR("Create new animation in player.")); hb->add_child(add_anim); load_anim = memnew( ToolButton ); ED_SHORTCUT("animation_player_editor/load_from_disk", TTR("Load animation from disk.")); add_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/load_from_disk")); load_anim->set_tooltip(TTR("Load an animation from disk.")); hb->add_child(load_anim); save_anim = memnew(MenuButton); save_anim->set_tooltip(TTR("Save the current animation")); save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save", TTR("Save")), ANIM_SAVE); save_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/save_as", TTR("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); ED_SHORTCUT("animation_player_editor/duplicate_animation", TTR("Duplicate Animation")); duplicate_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/duplicate_animation")); duplicate_anim->set_tooltip(TTR("Duplicate Animation")); rename_anim = memnew( ToolButton ); hb->add_child(rename_anim); ED_SHORTCUT("animation_player_editor/rename_animation", TTR("Rename Animation")); rename_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/rename_animation")); rename_anim->set_tooltip(TTR("Rename Animation")); remove_anim = memnew( ToolButton ); hb->add_child(remove_anim); ED_SHORTCUT("animation_player_editor/remove_animation", TTR("Remove Animation")); remove_anim->set_shortcut(ED_GET_SHORTCUT("animation_player_editor/remove_animation")); remove_anim->set_tooltip(TTR("Remove Animation")); animation = memnew( OptionButton ); hb->add_child(animation); animation->set_h_size_flags(SIZE_EXPAND_FILL); animation->set_tooltip(TTR("Display list of animations in player.")); animation->set_clip_text(true); autoplay = memnew( ToolButton ); hb->add_child(autoplay); autoplay->set_tooltip(TTR("Autoplay on Load")); blend_anim = memnew( ToolButton ); hb->add_child(blend_anim); blend_anim->set_tooltip(TTR("Edit Target Blend Times")); tool_anim = memnew( MenuButton); //tool_anim->set_flat(false); tool_anim->set_tooltip(TTR("Animation Tools")); tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/copy_animation", TTR("Copy Animation")),TOOL_COPY_ANIM); tool_anim->get_popup()->add_shortcut(ED_SHORTCUT("animation_player_editor/paste_animation", TTR("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); nodename = memnew( Button ); hb->add_child(nodename); pin = memnew( ToolButton ); pin->set_toggle_mode(true); hb->add_child(pin); 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(TTR("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(TTR("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(TTR("Close")); //error_dialog->get_cancel()->set_text("Close"); error_dialog->set_text(TTR("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(TTR("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(TTR("Blend Times:"),blend_editor.tree,true); blend_editor.next = memnew( OptionButton ); blend_vb->add_margin_child(TTR("Next (Auto Queue):"),blend_editor.next); blend_editor.dialog->set_title(TTR("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"); 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"); frame->connect("value_changed", this, "_seek_value_changed",Vector<Variant>(),true); scale->connect("text_entered", this, "_scale_changed",Vector<Variant>(),true); renaming=false; last_active=false; set_process_unhandled_key_input(true); key_editor = memnew( AnimationKeyEditor); add_child(key_editor); add_constant_override("separation",get_constant("separation","VBoxContainer")); key_editor->set_v_size_flags(SIZE_EXPAND_FILL); key_editor->connect("timeline_changed",this,"_animation_key_editor_seek"); key_editor->connect("animation_len_changed",this,"_animation_key_editor_anim_len_changed"); key_editor->connect("animation_step_changed",this,"_animation_key_editor_anim_step_changed"); _update_player(); }