Allow showing both left and right side panels

This commit is contained in:
Haoyu Qiu 2022-01-08 19:53:04 +08:00
parent 37b9aba458
commit 37a38ece59
7 changed files with 138 additions and 42 deletions

View file

@ -411,14 +411,10 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
SpatialEditor::get_singleton()->add_control_to_left_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
SpatialEditor::get_singleton()->add_control_to_right_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control);
@ -429,14 +425,10 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
CanvasItemEditor::get_singleton()->add_control_to_left_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
CanvasItemEditor::get_singleton()->add_control_to_right_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
@ -471,10 +463,11 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
SpatialEditor::get_singleton()->remove_control_from_left_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control);
SpatialEditor::get_singleton()->remove_control_from_right_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control);
@ -484,10 +477,11 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT:
case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
CanvasItemEditor::get_singleton()->remove_control_from_left_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control);
CanvasItemEditor::get_singleton()->remove_control_from_right_panel(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_BOTTOM: {
CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);

View file

@ -5683,8 +5683,46 @@ void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) {
hbc_context_menu->remove_child(p_control);
}
HSplitContainer *CanvasItemEditor::get_palette_split() {
return palette_split;
void CanvasItemEditor::add_control_to_left_panel(Control *p_control) {
left_panel_split->add_child(p_control);
left_panel_split->move_child(p_control, 0);
}
void CanvasItemEditor::add_control_to_right_panel(Control *p_control) {
right_panel_split->add_child(p_control);
right_panel_split->move_child(p_control, 1);
}
void CanvasItemEditor::remove_control_from_left_panel(Control *p_control) {
left_panel_split->remove_child(p_control);
}
void CanvasItemEditor::remove_control_from_right_panel(Control *p_control) {
right_panel_split->remove_child(p_control);
}
void CanvasItemEditor::move_control_to_left_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
if (p_control->get_parent() == left_panel_split) {
return;
}
ERR_FAIL_COND(p_control->get_parent() != right_panel_split);
right_panel_split->remove_child(p_control);
add_control_to_left_panel(p_control);
}
void CanvasItemEditor::move_control_to_right_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
if (p_control->get_parent() == right_panel_split) {
return;
}
ERR_FAIL_COND(p_control->get_parent() != left_panel_split);
left_panel_split->remove_child(p_control);
add_control_to_right_panel(p_control);
}
VSplitContainer *CanvasItemEditor::get_bottom_split() {
@ -5777,12 +5815,16 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
add_child(bottom_split);
bottom_split->set_v_size_flags(SIZE_EXPAND_FILL);
palette_split = memnew(HSplitContainer);
bottom_split->add_child(palette_split);
palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
left_panel_split = memnew(HSplitContainer);
bottom_split->add_child(left_panel_split);
left_panel_split->set_v_size_flags(SIZE_EXPAND_FILL);
right_panel_split = memnew(HSplitContainer);
left_panel_split->add_child(right_panel_split);
right_panel_split->set_v_size_flags(SIZE_EXPAND_FILL);
viewport_scrollable = memnew(Control);
palette_split->add_child(viewport_scrollable);
right_panel_split->add_child(viewport_scrollable);
viewport_scrollable->set_mouse_filter(MOUSE_FILTER_PASS);
viewport_scrollable->set_clip_contents(true);
viewport_scrollable->set_v_size_flags(SIZE_EXPAND_FILL);

View file

@ -555,7 +555,8 @@ private:
void _update_override_camera_button(bool p_game_running);
HSplitContainer *palette_split;
HSplitContainer *left_panel_split;
HSplitContainer *right_panel_split;
VSplitContainer *bottom_split;
bool bone_list_dirty;
@ -629,7 +630,15 @@ public:
void add_control_to_info_overlay(Control *p_control);
void remove_control_from_info_overlay(Control *p_control);
HSplitContainer *get_palette_split();
void add_control_to_left_panel(Control *p_control);
void remove_control_from_left_panel(Control *p_control);
void add_control_to_right_panel(Control *p_control);
void remove_control_from_right_panel(Control *p_control);
void move_control_to_left_panel(Control *p_control);
void move_control_to_right_panel(Control *p_control);
VSplitContainer *get_bottom_split();
Control *get_viewport_control() { return viewport; }

View file

@ -6292,8 +6292,46 @@ VSplitContainer *SpatialEditor::get_shader_split() {
return shader_split;
}
HSplitContainer *SpatialEditor::get_palette_split() {
return palette_split;
void SpatialEditor::add_control_to_left_panel(Control *p_control) {
left_panel_split->add_child(p_control);
left_panel_split->move_child(p_control, 0);
}
void SpatialEditor::add_control_to_right_panel(Control *p_control) {
right_panel_split->add_child(p_control);
right_panel_split->move_child(p_control, 1);
}
void SpatialEditor::remove_control_from_left_panel(Control *p_control) {
left_panel_split->remove_child(p_control);
}
void SpatialEditor::remove_control_from_right_panel(Control *p_control) {
right_panel_split->remove_child(p_control);
}
void SpatialEditor::move_control_to_left_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
if (p_control->get_parent() == left_panel_split) {
return;
}
ERR_FAIL_COND(p_control->get_parent() != right_panel_split);
right_panel_split->remove_child(p_control);
add_control_to_left_panel(p_control);
}
void SpatialEditor::move_control_to_right_panel(Control *p_control) {
ERR_FAIL_NULL(p_control);
if (p_control->get_parent() == right_panel_split) {
return;
}
ERR_FAIL_COND(p_control->get_parent() != left_panel_split);
left_panel_split->remove_child(p_control);
add_control_to_right_panel(p_control);
}
void SpatialEditor::_request_gizmo(Object *p_obj) {
@ -6691,13 +6729,17 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
/* REST OF MENU */
palette_split = memnew(HSplitContainer);
palette_split->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(palette_split);
left_panel_split = memnew(HSplitContainer);
left_panel_split->set_v_size_flags(SIZE_EXPAND_FILL);
vbc->add_child(left_panel_split);
right_panel_split = memnew(HSplitContainer);
right_panel_split->set_v_size_flags(SIZE_EXPAND_FILL);
left_panel_split->add_child(right_panel_split);
shader_split = memnew(VSplitContainer);
shader_split->set_h_size_flags(SIZE_EXPAND_FILL);
palette_split->add_child(shader_split);
right_panel_split->add_child(shader_split);
viewport_base = memnew(SpatialEditorViewportContainer);
shader_split->add_child(viewport_base);
viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);

View file

@ -584,7 +584,8 @@ private:
SpatialEditorViewportContainer *viewport_base;
SpatialEditorViewport *viewports[VIEWPORTS_COUNT];
VSplitContainer *shader_split;
HSplitContainer *palette_split;
HSplitContainer *left_panel_split;
HSplitContainer *right_panel_split;
/////
@ -801,8 +802,16 @@ public:
void add_control_to_menu_panel(Control *p_control);
void remove_control_from_menu_panel(Control *p_control);
void add_control_to_left_panel(Control *p_control);
void remove_control_from_left_panel(Control *p_control);
void add_control_to_right_panel(Control *p_control);
void remove_control_from_right_panel(Control *p_control);
void move_control_to_left_panel(Control *p_control);
void move_control_to_right_panel(Control *p_control);
VSplitContainer *get_shader_split();
HSplitContainer *get_palette_split();
Spatial *get_selected() { return selected; }

View file

@ -2132,10 +2132,10 @@ void TileMapEditorPlugin::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
case 0: { // Left.
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 0);
CanvasItemEditor::get_singleton()->move_control_to_left_panel(tile_map_editor);
} break;
case 1: { // Right.
CanvasItemEditor::get_singleton()->get_palette_split()->move_child(tile_map_editor, 1);
CanvasItemEditor::get_singleton()->move_control_to_right_panel(tile_map_editor);
} break;
}
}
@ -2182,10 +2182,10 @@ TileMapEditorPlugin::TileMapEditorPlugin(EditorNode *p_node) {
tile_map_editor = memnew(TileMapEditor(p_node));
switch ((int)EditorSettings::get_singleton()->get("editors/tile_map/editor_side")) {
case 0: { // Left.
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_LEFT, tile_map_editor);
CanvasItemEditor::get_singleton()->add_control_to_left_panel(tile_map_editor);
} break;
case 1: { // Right.
add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, tile_map_editor);
CanvasItemEditor::get_singleton()->add_control_to_right_panel(tile_map_editor);
} break;
}
tile_map_editor->hide();

View file

@ -1511,10 +1511,10 @@ void GridMapEditorPlugin::_notification(int p_what) {
if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
case 0: { // Left.
SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 0);
SpatialEditor::get_singleton()->move_control_to_left_panel(grid_map_editor);
} break;
case 1: { // Right.
SpatialEditor::get_singleton()->get_palette_split()->move_child(grid_map_editor, 1);
SpatialEditor::get_singleton()->move_control_to_right_panel(grid_map_editor);
} break;
}
}
@ -1550,10 +1550,10 @@ GridMapEditorPlugin::GridMapEditorPlugin(EditorNode *p_node) {
grid_map_editor = memnew(GridMapEditor(editor));
switch ((int)EditorSettings::get_singleton()->get("editors/grid_map/editor_side")) {
case 0: { // Left.
add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, grid_map_editor);
SpatialEditor::get_singleton()->add_control_to_left_panel(grid_map_editor);
} break;
case 1: { // Right.
add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, grid_map_editor);
SpatialEditor::get_singleton()->add_control_to_right_panel(grid_map_editor);
} break;
}
grid_map_editor->hide();