Add icon_tooltip for panel buttons rather than using persistent name (#3849)
Fixes missing spaces in these tooltips Release Notes: - N/A
This commit is contained in:
@@ -1281,6 +1281,10 @@ impl Panel for AssistantPanel {
|
||||
Some(Icon::Ai)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Assistant Panel")
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
|
||||
@@ -611,6 +611,10 @@ impl Panel for ChatPanel {
|
||||
Some(ui::Icon::MessageBubbles)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Chat Panel")
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
|
||||
@@ -2362,6 +2362,10 @@ impl Panel for CollabPanel {
|
||||
.then(|| ui::Icon::Collab)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Collab Panel")
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
|
||||
@@ -661,6 +661,10 @@ impl Panel for NotificationPanel {
|
||||
.then(|| Icon::Bell)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Notification Panel")
|
||||
}
|
||||
|
||||
fn icon_label(&self, cx: &WindowContext) -> Option<String> {
|
||||
let count = self.notification_store.read(cx).unread_notification_count();
|
||||
if count == 0 {
|
||||
|
||||
@@ -1612,6 +1612,10 @@ impl Panel for ProjectPanel {
|
||||
Some(ui::Icon::FileTree)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Project Panel")
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
|
||||
@@ -419,6 +419,10 @@ impl Panel for TerminalPanel {
|
||||
Some(Icon::Terminal)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
Some("Terminal Panel")
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn gpui::Action> {
|
||||
Box::new(ToggleFocus)
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ pub trait Panel: FocusableView + EventEmitter<PanelEvent> {
|
||||
fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>);
|
||||
fn size(&self, cx: &WindowContext) -> Pixels;
|
||||
fn set_size(&mut self, size: Option<Pixels>, cx: &mut ViewContext<Self>);
|
||||
// todo!("We should have a icon tooltip method, rather than using persistant_name")
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon>;
|
||||
fn icon_tooltip(&self, cx: &WindowContext) -> Option<&'static str>;
|
||||
fn toggle_action(&self) -> Box<dyn Action>;
|
||||
fn icon_label(&self, _: &WindowContext) -> Option<String> {
|
||||
None
|
||||
@@ -54,6 +54,7 @@ pub trait PanelHandle: Send + Sync {
|
||||
fn size(&self, cx: &WindowContext) -> Pixels;
|
||||
fn set_size(&self, size: Option<Pixels>, cx: &mut WindowContext);
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon>;
|
||||
fn icon_tooltip(&self, cx: &WindowContext) -> Option<&'static str>;
|
||||
fn toggle_action(&self, cx: &WindowContext) -> Box<dyn Action>;
|
||||
fn icon_label(&self, cx: &WindowContext) -> Option<String>;
|
||||
fn focus_handle(&self, cx: &AppContext) -> FocusHandle;
|
||||
@@ -108,6 +109,10 @@ where
|
||||
self.read(cx).icon(cx)
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, cx: &WindowContext) -> Option<&'static str> {
|
||||
self.read(cx).icon_tooltip(cx)
|
||||
}
|
||||
|
||||
fn toggle_action(&self, cx: &WindowContext) -> Box<dyn Action> {
|
||||
self.read(cx).toggle_action()
|
||||
}
|
||||
@@ -612,6 +617,7 @@ impl Render for PanelButtons {
|
||||
.enumerate()
|
||||
.filter_map(|(i, entry)| {
|
||||
let icon = entry.panel.icon(cx)?;
|
||||
let icon_tooltip = entry.panel.icon_tooltip(cx)?;
|
||||
let name = entry.panel.persistent_name();
|
||||
let panel = entry.panel.clone();
|
||||
|
||||
@@ -627,7 +633,7 @@ impl Render for PanelButtons {
|
||||
} else {
|
||||
let action = entry.panel.toggle_action(cx);
|
||||
|
||||
(action, name.into())
|
||||
(action, icon_tooltip.into())
|
||||
};
|
||||
|
||||
Some(
|
||||
@@ -748,6 +754,10 @@ pub mod test {
|
||||
None
|
||||
}
|
||||
|
||||
fn icon_tooltip(&self, _cx: &WindowContext) -> Option<&'static str> {
|
||||
None
|
||||
}
|
||||
|
||||
fn toggle_action(&self) -> Box<dyn Action> {
|
||||
ToggleTestPanel.boxed_clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user