Restructure Pane to have a single Toolbar with multiple items

This commit is contained in:
Antonio Scandurra
2022-03-29 11:48:21 +02:00
parent d296bb21a8
commit 9df2dacd85
9 changed files with 318 additions and 264 deletions
+4 -2
View File
@@ -85,7 +85,10 @@ diagnostic_message = "$text.2"
lsp_message = "$text.2"
[workspace.toolbar]
background = "$surface.1"
border = { color = "$border.0", width = 1, left = false, right = false, bottom = true, top = false }
height = 44
item_spacing = 8
[panel]
padding = { top = 12, left = 12, bottom = 12, right = 12 }
@@ -353,8 +356,8 @@ tab_icon_spacing = 4
tab_summary_spacing = 10
[search]
max_editor_width = 400
match_background = "$state.highlighted_line"
background = "$surface.1"
results_status = { extends = "$text.0", size = 18 }
tab_icon_width = 14
tab_icon_spacing = 4
@@ -388,7 +391,6 @@ extends = "$text.1"
padding = 6
[search.editor]
max_width = 400
background = "$surface.0"
corner_radius = 6
padding = { left = 13, right = 13, top = 3, bottom = 3 }
+12
View File
@@ -21,6 +21,7 @@ pub use lsp;
use project::Project;
pub use project::{self, fs};
use project_panel::ProjectPanel;
use search::SearchBar;
use std::{path::PathBuf, sync::Arc};
pub use workspace;
use workspace::{AppState, Settings, Workspace, WorkspaceParams};
@@ -104,6 +105,17 @@ pub fn build_workspace(
app_state: &Arc<AppState>,
cx: &mut ViewContext<Workspace>,
) -> Workspace {
cx.subscribe(&cx.handle(), |_, _, event, cx| {
let workspace::Event::PaneAdded(pane) = event;
pane.update(cx, |pane, cx| {
pane.toolbar().update(cx, |toolbar, cx| {
let search_bar = cx.add_view(|cx| SearchBar::new(cx));
toolbar.add_right_item(search_bar, cx);
})
});
})
.detach();
let workspace_params = WorkspaceParams {
project,
client: app_state.client.clone(),