mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
Merge pull request #1307 from zed-industries/nav-button-tweak
Add tooltips to pane nav buttons and make them trigger on click
This commit is contained in:
commit
304ea2d574
1 changed files with 18 additions and 1 deletions
|
@ -112,6 +112,7 @@ impl View for Toolbar {
|
||||||
let container_style = theme.container;
|
let container_style = theme.container;
|
||||||
let height = theme.height;
|
let height = theme.height;
|
||||||
let button_style = theme.nav_button;
|
let button_style = theme.nav_button;
|
||||||
|
let tooltip_style = cx.global::<Settings>().theme.tooltip.clone();
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_child(
|
.with_child(
|
||||||
|
@ -119,21 +120,27 @@ impl View for Toolbar {
|
||||||
.with_child(nav_button(
|
.with_child(nav_button(
|
||||||
"icons/arrow-left.svg",
|
"icons/arrow-left.svg",
|
||||||
button_style,
|
button_style,
|
||||||
|
tooltip_style.clone(),
|
||||||
enable_go_backward,
|
enable_go_backward,
|
||||||
spacing,
|
spacing,
|
||||||
super::GoBack {
|
super::GoBack {
|
||||||
pane: Some(pane.clone()),
|
pane: Some(pane.clone()),
|
||||||
},
|
},
|
||||||
|
super::GoBack { pane: None },
|
||||||
|
"Go Back",
|
||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
.with_child(nav_button(
|
.with_child(nav_button(
|
||||||
"icons/arrow-right.svg",
|
"icons/arrow-right.svg",
|
||||||
button_style,
|
button_style,
|
||||||
|
tooltip_style.clone(),
|
||||||
enable_go_forward,
|
enable_go_forward,
|
||||||
spacing,
|
spacing,
|
||||||
super::GoForward {
|
super::GoForward {
|
||||||
pane: Some(pane.clone()),
|
pane: Some(pane.clone()),
|
||||||
},
|
},
|
||||||
|
super::GoForward { pane: None },
|
||||||
|
"Go Forward",
|
||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
.with_children(primary_left_items)
|
.with_children(primary_left_items)
|
||||||
|
@ -152,9 +159,12 @@ impl View for Toolbar {
|
||||||
fn nav_button<A: Action + Clone>(
|
fn nav_button<A: Action + Clone>(
|
||||||
svg_path: &'static str,
|
svg_path: &'static str,
|
||||||
style: theme::Interactive<theme::IconButton>,
|
style: theme::Interactive<theme::IconButton>,
|
||||||
|
tooltip_style: TooltipStyle,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
spacing: f32,
|
spacing: f32,
|
||||||
action: A,
|
action: A,
|
||||||
|
tooltip_action: A,
|
||||||
|
action_name: &str,
|
||||||
cx: &mut RenderContext<Toolbar>,
|
cx: &mut RenderContext<Toolbar>,
|
||||||
) -> ElementBox {
|
) -> ElementBox {
|
||||||
MouseEventHandler::new::<A, _, _>(0, cx, |state, _| {
|
MouseEventHandler::new::<A, _, _>(0, cx, |state, _| {
|
||||||
|
@ -181,7 +191,14 @@ fn nav_button<A: Action + Clone>(
|
||||||
} else {
|
} else {
|
||||||
CursorStyle::default()
|
CursorStyle::default()
|
||||||
})
|
})
|
||||||
.on_mouse_down(move |_, cx| cx.dispatch_action(action.clone()))
|
.on_click(move |_, _, cx| cx.dispatch_action(action.clone()))
|
||||||
|
.with_tooltip::<A, _>(
|
||||||
|
0,
|
||||||
|
action_name.to_string(),
|
||||||
|
Some(Box::new(tooltip_action)),
|
||||||
|
tooltip_style,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
.contained()
|
.contained()
|
||||||
.with_margin_right(spacing)
|
.with_margin_right(spacing)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
|
Loading…
Reference in a new issue