Remove reference to pane from a toolbar.
Co-authored-by: Kyle <kyle@zed.dev>
This commit is contained in:
parent
7d83d15bf3
commit
8831e03eba
6 changed files with 5 additions and 76 deletions
|
@ -238,7 +238,7 @@
|
||||||
"context": "ProjectSearchBar",
|
"context": "ProjectSearchBar",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"escape": "project_search::ToggleFocus",
|
"escape": "project_search::ToggleFocus",
|
||||||
"alt-tab": "project_search::CycleMode",
|
"alt-tab": "project_search::CycleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl AssistantPanel {
|
||||||
});
|
});
|
||||||
|
|
||||||
let toolbar = cx.add_view(|cx| {
|
let toolbar = cx.add_view(|cx| {
|
||||||
let mut toolbar = Toolbar::new(None);
|
let mut toolbar = Toolbar::new();
|
||||||
toolbar.set_can_navigate(false, cx);
|
toolbar.set_can_navigate(false, cx);
|
||||||
toolbar.add_item(cx.add_view(|cx| BufferSearchBar::new(cx)), cx);
|
toolbar.add_item(cx.add_view(|cx| BufferSearchBar::new(cx)), cx);
|
||||||
toolbar
|
toolbar
|
||||||
|
|
|
@ -308,7 +308,7 @@ impl Pane {
|
||||||
pane: handle.clone(),
|
pane: handle.clone(),
|
||||||
next_timestamp,
|
next_timestamp,
|
||||||
}))),
|
}))),
|
||||||
toolbar: cx.add_view(|_| Toolbar::new(Some(handle))),
|
toolbar: cx.add_view(|_| Toolbar::new()),
|
||||||
tab_bar_context_menu: TabBarContextMenu {
|
tab_bar_context_menu: TabBarContextMenu {
|
||||||
kind: TabBarContextMenuKind::New,
|
kind: TabBarContextMenuKind::New,
|
||||||
handle: context_menu,
|
handle: context_menu,
|
||||||
|
|
|
@ -54,7 +54,6 @@ pub struct Toolbar {
|
||||||
active_item: Option<Box<dyn ItemHandle>>,
|
active_item: Option<Box<dyn ItemHandle>>,
|
||||||
hidden: bool,
|
hidden: bool,
|
||||||
can_navigate: bool,
|
can_navigate: bool,
|
||||||
pane: Option<WeakViewHandle<Pane>>,
|
|
||||||
items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,
|
items: Vec<(Box<dyn ToolbarItemViewHandle>, ToolbarItemLocation)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,63 +143,10 @@ impl View for Toolbar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
fn nav_button<A: Action, F: 'static + Fn(&mut Toolbar, &mut ViewContext<Toolbar>)>(
|
|
||||||
svg_path: &'static str,
|
|
||||||
style: theme::Interactive<theme::IconButton>,
|
|
||||||
nav_button_height: f32,
|
|
||||||
tooltip_style: TooltipStyle,
|
|
||||||
enabled: bool,
|
|
||||||
spacing: f32,
|
|
||||||
on_click: F,
|
|
||||||
tooltip_action: A,
|
|
||||||
action_name: &str,
|
|
||||||
cx: &mut ViewContext<Toolbar>,
|
|
||||||
) -> AnyElement<Toolbar> {
|
|
||||||
MouseEventHandler::<A, _>::new(0, cx, |state, _| {
|
|
||||||
let style = if enabled {
|
|
||||||
style.style_for(state)
|
|
||||||
} else {
|
|
||||||
style.disabled_style()
|
|
||||||
};
|
|
||||||
Svg::new(svg_path)
|
|
||||||
.with_color(style.color)
|
|
||||||
.constrained()
|
|
||||||
.with_width(style.icon_width)
|
|
||||||
.aligned()
|
|
||||||
.contained()
|
|
||||||
.with_style(style.container)
|
|
||||||
.constrained()
|
|
||||||
.with_width(style.button_width)
|
|
||||||
.with_height(nav_button_height)
|
|
||||||
.aligned()
|
|
||||||
.top()
|
|
||||||
})
|
|
||||||
.with_cursor_style(if enabled {
|
|
||||||
CursorStyle::PointingHand
|
|
||||||
} else {
|
|
||||||
CursorStyle::default()
|
|
||||||
})
|
|
||||||
.on_click(MouseButton::Left, move |_, toolbar, cx| {
|
|
||||||
on_click(toolbar, cx)
|
|
||||||
})
|
|
||||||
.with_tooltip::<A>(
|
|
||||||
0,
|
|
||||||
action_name.to_string(),
|
|
||||||
Some(Box::new(tooltip_action)),
|
|
||||||
tooltip_style,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
.contained()
|
|
||||||
.with_margin_right(spacing)
|
|
||||||
.into_any_named("nav button")
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Toolbar {
|
impl Toolbar {
|
||||||
pub fn new(pane: Option<WeakViewHandle<Pane>>) -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
active_item: None,
|
active_item: None,
|
||||||
pane,
|
|
||||||
items: Default::default(),
|
items: Default::default(),
|
||||||
hidden: false,
|
hidden: false,
|
||||||
can_navigate: true,
|
can_navigate: true,
|
||||||
|
|
|
@ -100,7 +100,7 @@ export default function tab_bar(): any {
|
||||||
color: foreground(theme.highest, "on", "disabled"),
|
color: foreground(theme.highest, "on", "disabled"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
})
|
||||||
const dragged_tab = {
|
const dragged_tab = {
|
||||||
...active_pane_active_tab,
|
...active_pane_active_tab,
|
||||||
background: with_opacity(tab.background, 0.9),
|
background: with_opacity(tab.background, 0.9),
|
||||||
|
|
|
@ -132,23 +132,6 @@ export default function workspace(): any {
|
||||||
background: background(theme.highest),
|
background: background(theme.highest),
|
||||||
border: border(theme.highest, { bottom: true }),
|
border: border(theme.highest, { bottom: true }),
|
||||||
item_spacing: 8,
|
item_spacing: 8,
|
||||||
nav_button: interactive({
|
|
||||||
base: {
|
|
||||||
color: foreground(theme.highest, "on"),
|
|
||||||
icon_width: 12,
|
|
||||||
button_width: 24,
|
|
||||||
corner_radius: 6,
|
|
||||||
},
|
|
||||||
state: {
|
|
||||||
hovered: {
|
|
||||||
color: foreground(theme.highest, "on", "hovered"),
|
|
||||||
background: background(theme.highest, "on", "hovered"),
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
color: foreground(theme.highest, "on", "disabled"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
padding: { left: 8, right: 8, top: 4, bottom: 4 },
|
padding: { left: 8, right: 8, top: 4, bottom: 4 },
|
||||||
},
|
},
|
||||||
breadcrumb_height: 24,
|
breadcrumb_height: 24,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue