mirror of
https://github.com/godotengine/godot.git
synced 2026-02-07 11:21:49 +00:00
Convert the bottom VCS dock to a EditorDock and tie it with the Commit dock
Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
@@ -126,6 +126,11 @@
|
||||
Emitted when the dock is closed with the Close button in the context popup, before it's removed from its parent. See [member closable].
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="opened">
|
||||
<description>
|
||||
Emitted when the dock is opened via the Editor > Editor Docks menu, before it's made visible.
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
||||
<constants>
|
||||
<constant name="DOCK_LAYOUT_VERTICAL" value="1" enum="DockLayout" is_bitfield="true">
|
||||
|
||||
@@ -114,6 +114,7 @@ void EditorDock::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_available_layouts"), &EditorDock::get_available_layouts);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "available_layouts", PROPERTY_HINT_FLAGS, "Vertical:1,Horizontal:2,Floating:4"), "set_available_layouts", "get_available_layouts");
|
||||
|
||||
ADD_SIGNAL(MethodInfo("opened"));
|
||||
ADD_SIGNAL(MethodInfo("closed"));
|
||||
ADD_SIGNAL(MethodInfo("_tab_style_changed"));
|
||||
|
||||
|
||||
@@ -333,6 +333,7 @@ void EditorDockManager::_move_dock(EditorDock *p_dock, Control *p_target, int p_
|
||||
}
|
||||
|
||||
if (!p_target) {
|
||||
p_dock->is_open = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -656,6 +657,7 @@ void EditorDockManager::focus_dock(EditorDock *p_dock) {
|
||||
}
|
||||
|
||||
if (!p_dock->is_open) {
|
||||
p_dock->emit_signal("opened");
|
||||
open_dock(p_dock, false);
|
||||
}
|
||||
|
||||
|
||||
1
editor/icons/VCSCommit.svg
Normal file
1
editor/icons/VCSCommit.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="none" stroke="#e0e0e0" stroke-width="1.5" d="m 8.25,10.49996 c 1.380712,0 2.5,-1.1193927 2.5,-2.5002338 h 3.5 v 0 m -3.5,0 C 10.75,5.7721009 8.057154,4.6569057 6.4823232,6.2318837 4.9074925,7.8068618 6.0225834,10.49996 8.25,10.49996 M 1.75,7.9997262 h 3.5 v 0 m -3.5,0"/></svg>
|
||||
|
After Width: | Height: | Size: 353 B |
@@ -78,6 +78,20 @@ void VersionControlEditorPlugin::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void VersionControlEditorPlugin::_update_theme() {
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("success_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("error_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_color(SceneStringName(font_color), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusSuccess"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusError"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
|
||||
select_public_path_button->set_button_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder"));
|
||||
select_private_path_button->set_button_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder"));
|
||||
refresh_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));
|
||||
@@ -88,6 +102,10 @@ void VersionControlEditorPlugin::_update_theme() {
|
||||
pull_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveDown"), EditorStringName(EditorIcons)));
|
||||
push_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveUp"), EditorStringName(EditorIcons)));
|
||||
extra_options->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons)));
|
||||
|
||||
if (EditorVCSInterface::get_singleton()) {
|
||||
_refresh_stage_area();
|
||||
}
|
||||
}
|
||||
|
||||
void VersionControlEditorPlugin::_populate_available_vcs_names() {
|
||||
@@ -290,7 +308,9 @@ void VersionControlEditorPlugin::_commit() {
|
||||
|
||||
EditorVCSInterface::get_singleton()->commit(msg);
|
||||
|
||||
EditorNode::get_bottom_panel()->make_item_visible(version_control_dock, false);
|
||||
if (version_control_dock->get_current_layout() == EditorDock::DOCK_LAYOUT_HORIZONTAL) {
|
||||
version_control_dock->hide();
|
||||
}
|
||||
|
||||
commit_message->release_focus();
|
||||
commit_button->release_focus();
|
||||
@@ -502,7 +522,7 @@ void VersionControlEditorPlugin::_move_all(Object *p_tree) {
|
||||
void VersionControlEditorPlugin::_load_diff(Object *p_tree) {
|
||||
CHECK_PLUGIN_INITIALIZED();
|
||||
|
||||
EditorNode::get_bottom_panel()->make_item_visible(version_control_dock, true, true);
|
||||
version_control_dock->make_visible();
|
||||
|
||||
Tree *tree = Object::cast_to<Tree>(p_tree);
|
||||
if (tree == staged_files) {
|
||||
@@ -923,8 +943,7 @@ void VersionControlEditorPlugin::fetch_available_vcs_plugin_names() {
|
||||
|
||||
void VersionControlEditorPlugin::register_editor() {
|
||||
EditorDockManager::get_singleton()->add_dock(version_commit_dock);
|
||||
|
||||
EditorNode::get_bottom_panel()->add_item(TTRC("Version Control"), version_control_dock, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_version_control_bottom_panel", TTRC("Toggle Version Control Bottom Panel")));
|
||||
EditorDockManager::get_singleton()->add_dock(version_control_dock);
|
||||
|
||||
_set_vcs_ui_state(true);
|
||||
}
|
||||
@@ -943,7 +962,7 @@ void VersionControlEditorPlugin::shut_down() {
|
||||
EditorVCSInterface::set_singleton(nullptr);
|
||||
|
||||
EditorDockManager::get_singleton()->remove_dock(version_commit_dock);
|
||||
EditorNode::get_bottom_panel()->remove_item(version_control_dock);
|
||||
EditorDockManager::get_singleton()->remove_dock(version_control_dock);
|
||||
|
||||
_set_vcs_ui_state(false);
|
||||
}
|
||||
@@ -1160,7 +1179,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
version_commit_dock->set_visible(false);
|
||||
version_commit_dock->set_name(TTRC("Commit"));
|
||||
version_commit_dock->set_layout_key("VersionCommit");
|
||||
version_commit_dock->set_icon_name("VcsBranches");
|
||||
version_commit_dock->set_icon_name("VCSCommit");
|
||||
version_commit_dock->set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("docks/open_version_control", TTRC("Open Version Control Dock")));
|
||||
version_commit_dock->set_default_slot(EditorDock::DOCK_SLOT_RIGHT_UL);
|
||||
|
||||
@@ -1212,16 +1231,20 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
stage_all_button->set_tooltip_text(TTR("Stage all changes"));
|
||||
unstage_title->add_child(stage_all_button);
|
||||
|
||||
MarginContainer *mc = memnew(MarginContainer);
|
||||
mc->set_v_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
mc->set_theme_type_variation("NoBorderHorizontal");
|
||||
unstage_area->add_child(mc);
|
||||
|
||||
unstaged_files = memnew(Tree);
|
||||
unstaged_files->set_h_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
unstaged_files->set_v_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
unstaged_files->set_select_mode(Tree::SELECT_ROW);
|
||||
unstaged_files->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(unstaged_files));
|
||||
unstaged_files->connect(SNAME("item_activated"), callable_mp(this, &VersionControlEditorPlugin::_item_activated).bind(unstaged_files));
|
||||
unstaged_files->connect(SNAME("button_clicked"), callable_mp(this, &VersionControlEditorPlugin::_cell_button_pressed));
|
||||
unstaged_files->create_item();
|
||||
unstaged_files->set_hide_root(true);
|
||||
unstage_area->add_child(unstaged_files);
|
||||
unstaged_files->set_scroll_hint_mode(Tree::SCROLL_HINT_MODE_BOTH);
|
||||
mc->add_child(unstaged_files);
|
||||
|
||||
VBoxContainer *stage_area = memnew(VBoxContainer);
|
||||
stage_area->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
@@ -1242,23 +1265,25 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
unstage_all_button->set_tooltip_text(TTR("Unstage all changes"));
|
||||
stage_title->add_child(unstage_all_button);
|
||||
|
||||
mc = memnew(MarginContainer);
|
||||
mc->set_v_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
mc->set_theme_type_variation("NoBorderHorizontal");
|
||||
stage_area->add_child(mc);
|
||||
|
||||
staged_files = memnew(Tree);
|
||||
staged_files->set_h_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
staged_files->set_v_size_flags(Tree::SIZE_EXPAND_FILL);
|
||||
staged_files->set_select_mode(Tree::SELECT_ROW);
|
||||
staged_files->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(staged_files));
|
||||
staged_files->connect(SNAME("button_clicked"), callable_mp(this, &VersionControlEditorPlugin::_cell_button_pressed));
|
||||
staged_files->connect(SNAME("item_activated"), callable_mp(this, &VersionControlEditorPlugin::_item_activated).bind(staged_files));
|
||||
staged_files->create_item();
|
||||
staged_files->set_hide_root(true);
|
||||
stage_area->add_child(staged_files);
|
||||
staged_files->set_scroll_hint_mode(Tree::SCROLL_HINT_MODE_BOTH);
|
||||
mc->add_child(staged_files);
|
||||
|
||||
// Editor crashes if bind is null
|
||||
unstage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(staged_files));
|
||||
stage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(unstaged_files));
|
||||
|
||||
dock_vb->add_child(memnew(HSeparator));
|
||||
|
||||
VBoxContainer *commit_area = memnew(VBoxContainer);
|
||||
dock_vb->add_child(commit_area);
|
||||
|
||||
@@ -1307,21 +1332,22 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
commit_list_size_button->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_set_commit_list_size));
|
||||
commit_list_hbc->add_child(commit_list_size_button);
|
||||
|
||||
mc = memnew(MarginContainer);
|
||||
mc->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);
|
||||
mc->set_theme_type_variation("NoBorderHorizontal");
|
||||
dock_vb->add_child(mc);
|
||||
|
||||
commit_list = memnew(Tree);
|
||||
commit_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
commit_list->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);
|
||||
commit_list->set_custom_minimum_size(Size2(200, 160));
|
||||
commit_list->create_item();
|
||||
commit_list->set_hide_root(true);
|
||||
commit_list->set_select_mode(Tree::SELECT_ROW);
|
||||
commit_list->set_columns(2); // Commit msg, author
|
||||
commit_list->set_columns(2); // Commit message and author.
|
||||
commit_list->set_column_custom_minimum_width(0, 40);
|
||||
commit_list->set_column_custom_minimum_width(1, 20);
|
||||
commit_list->set_theme_type_variation("TreeSecondary");
|
||||
commit_list->set_scroll_hint_mode(Tree::SCROLL_HINT_MODE_BOTH);
|
||||
commit_list->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(commit_list));
|
||||
dock_vb->add_child(commit_list);
|
||||
|
||||
dock_vb->add_child(memnew(HSeparator));
|
||||
mc->add_child(commit_list);
|
||||
|
||||
HFlowContainer *menu_bar = memnew(HFlowContainer);
|
||||
menu_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
@@ -1483,29 +1509,25 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = TTR("Typechange");
|
||||
change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = TTR("Unmerged");
|
||||
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("success_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("error_color"), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_color(SceneStringName(font_color), EditorStringName(Editor));
|
||||
change_type_to_color[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));
|
||||
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusSuccess"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusError"), EditorStringName(EditorIcons));
|
||||
change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));
|
||||
|
||||
version_control_dock = memnew(VBoxContainer);
|
||||
version_control_dock->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
version_control_dock = memnew(EditorDock);
|
||||
version_control_dock->set_name(TTRC("Version Control"));
|
||||
version_control_dock->set_icon_name("VcsBranches");
|
||||
version_control_dock->set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_version_control_bottom_panel", TTRC("Toggle Version Control Dock")));
|
||||
version_control_dock->set_default_slot(EditorDock::DOCK_SLOT_BOTTOM);
|
||||
version_control_dock->set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
|
||||
version_control_dock->set_global(false);
|
||||
version_control_dock->set_transient(true);
|
||||
version_control_dock->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
|
||||
version_control_dock->hide();
|
||||
version_commit_dock->connect("opened", callable_mp(EditorDockManager::get_singleton(), &EditorDockManager::open_dock).bind(version_control_dock, false));
|
||||
version_commit_dock->connect("closed", callable_mp(EditorDockManager::get_singleton(), &EditorDockManager::close_dock).bind(version_control_dock));
|
||||
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
version_control_dock->add_child(vbc);
|
||||
|
||||
HBoxContainer *diff_heading = memnew(HBoxContainer);
|
||||
diff_heading->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
diff_heading->set_tooltip_text(TTR("View file diffs before committing them to the latest version"));
|
||||
version_control_dock->add_child(diff_heading);
|
||||
vbc->add_child(diff_heading);
|
||||
|
||||
diff_title = memnew(Label);
|
||||
diff_title->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
|
||||
@@ -1529,7 +1551,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() {
|
||||
diff->set_use_bbcode(true);
|
||||
diff->set_selection_enabled(true);
|
||||
diff->set_context_menu_enabled(true);
|
||||
version_control_dock->add_child(diff);
|
||||
vbc->add_child(diff);
|
||||
|
||||
_update_set_up_warning("");
|
||||
EditorNode::get_singleton()->get_gui_base()->connect(SceneStringName(theme_changed), callable_mp(this, &VersionControlEditorPlugin::_update_theme));
|
||||
|
||||
@@ -131,7 +131,7 @@ private:
|
||||
TextEdit *commit_message = nullptr;
|
||||
Button *commit_button = nullptr;
|
||||
|
||||
VBoxContainer *version_control_dock = nullptr;
|
||||
EditorDock *version_control_dock = nullptr;
|
||||
Label *diff_title = nullptr;
|
||||
RichTextLabel *diff = nullptr;
|
||||
OptionButton *diff_view_type_select = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user