mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 11:01:54 +00:00
Rename DockItem to Panel
This commit is contained in:
parent
03f8c1206a
commit
1ddbda5095
9 changed files with 25 additions and 24 deletions
|
@ -65,7 +65,7 @@ impl View for CopilotButton {
|
|||
.workspace
|
||||
.status_bar
|
||||
.panel_buttons
|
||||
.item
|
||||
.button
|
||||
.style_for(state, active);
|
||||
|
||||
Flex::row()
|
||||
|
|
|
@ -41,7 +41,7 @@ impl View for DeployFeedbackButton {
|
|||
.workspace
|
||||
.status_bar
|
||||
.panel_buttons
|
||||
.item
|
||||
.button
|
||||
.style_for(state, active);
|
||||
|
||||
Svg::new("icons/feedback_16.svg")
|
||||
|
|
|
@ -1327,7 +1327,7 @@ impl Entity for ProjectPanel {
|
|||
type Event = Event;
|
||||
}
|
||||
|
||||
impl workspace::dock::DockItem for ProjectPanel {
|
||||
impl workspace::dock::Panel for ProjectPanel {
|
||||
fn should_show_badge(&self, _: &AppContext) -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ impl View for TerminalButton {
|
|||
.workspace
|
||||
.status_bar
|
||||
.panel_buttons
|
||||
.item
|
||||
.button
|
||||
.style_for(state, active);
|
||||
|
||||
Flex::row()
|
||||
|
|
|
@ -344,7 +344,7 @@ pub struct StatusBar {
|
|||
pub struct StatusBarPanelButtons {
|
||||
pub group_left: ContainerStyle,
|
||||
pub group_right: ContainerStyle,
|
||||
pub item: Interactive<DockItem>,
|
||||
pub button: Interactive<PanelButton>,
|
||||
pub badge: ContainerStyle,
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ pub struct Dock {
|
|||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Default)]
|
||||
pub struct DockItem {
|
||||
pub struct PanelButton {
|
||||
#[serde(flatten)]
|
||||
pub container: ContainerStyle,
|
||||
pub icon_color: Color,
|
||||
|
|
|
@ -7,7 +7,7 @@ use serde::Deserialize;
|
|||
use settings::Settings;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub trait DockItem: View {
|
||||
pub trait Panel: View {
|
||||
fn should_activate_item_on_event(&self, _: &Self::Event, _: &AppContext) -> bool {
|
||||
false
|
||||
}
|
||||
|
@ -19,16 +19,17 @@ pub trait DockItem: View {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait DockItemHandle {
|
||||
pub trait PanelHandle {
|
||||
|
||||
fn id(&self) -> usize;
|
||||
fn should_show_badge(&self, cx: &WindowContext) -> bool;
|
||||
fn is_focused(&self, cx: &WindowContext) -> bool;
|
||||
fn as_any(&self) -> &AnyViewHandle;
|
||||
}
|
||||
|
||||
impl<T> DockItemHandle for ViewHandle<T>
|
||||
impl<T> PanelHandle for ViewHandle<T>
|
||||
where
|
||||
T: DockItem,
|
||||
T: Panel,
|
||||
{
|
||||
fn id(&self) -> usize {
|
||||
self.id()
|
||||
|
@ -47,8 +48,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl From<&dyn DockItemHandle> for AnyViewHandle {
|
||||
fn from(val: &dyn DockItemHandle) -> Self {
|
||||
impl From<&dyn PanelHandle> for AnyViewHandle {
|
||||
fn from(val: &dyn PanelHandle) -> Self {
|
||||
val.as_any().clone()
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +79,7 @@ impl DockPosition {
|
|||
struct Item {
|
||||
icon_path: &'static str,
|
||||
tooltip: String,
|
||||
view: Rc<dyn DockItemHandle>,
|
||||
view: Rc<dyn PanelHandle>,
|
||||
_subscriptions: [Subscription; 2],
|
||||
}
|
||||
|
||||
|
@ -88,12 +89,12 @@ pub struct PanelButtons {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq)]
|
||||
pub struct ToggleDockItem {
|
||||
pub struct TogglePanel {
|
||||
pub dock_position: DockPosition,
|
||||
pub item_index: usize,
|
||||
}
|
||||
|
||||
impl_actions!(workspace, [ToggleDockItem]);
|
||||
impl_actions!(workspace, [TogglePanel]);
|
||||
|
||||
impl Dock {
|
||||
pub fn new(position: DockPosition) -> Self {
|
||||
|
@ -126,7 +127,7 @@ impl Dock {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn add_item<T: DockItem>(
|
||||
pub fn add_item<T: Panel>(
|
||||
&mut self,
|
||||
icon_path: &'static str,
|
||||
tooltip: String,
|
||||
|
@ -171,7 +172,7 @@ impl Dock {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn active_item(&self) -> Option<&Rc<dyn DockItemHandle>> {
|
||||
pub fn active_item(&self) -> Option<&Rc<dyn PanelHandle>> {
|
||||
if self.is_open {
|
||||
self.items.get(self.active_item_ix).map(|item| &item.view)
|
||||
} else {
|
||||
|
@ -235,7 +236,7 @@ impl View for PanelButtons {
|
|||
let tooltip_style = theme.tooltip.clone();
|
||||
let theme = &theme.workspace.status_bar.panel_buttons;
|
||||
let dock = self.dock.read(cx);
|
||||
let item_style = theme.item.clone();
|
||||
let item_style = theme.button.clone();
|
||||
let badge_style = theme.badge;
|
||||
let active_ix = dock.active_item_ix;
|
||||
let is_open = dock.is_open;
|
||||
|
@ -255,7 +256,7 @@ impl View for PanelButtons {
|
|||
Flex::row()
|
||||
.with_children(items.into_iter().enumerate().map(
|
||||
|(ix, (icon_path, tooltip, item_view))| {
|
||||
let action = ToggleDockItem {
|
||||
let action = TogglePanel {
|
||||
dock_position,
|
||||
item_index: ix,
|
||||
};
|
||||
|
|
|
@ -766,7 +766,7 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
|||
#[cfg(test)]
|
||||
pub(crate) mod test {
|
||||
use super::{Item, ItemEvent};
|
||||
use crate::{dock::DockItem, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
|
||||
use crate::{dock::Panel, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId};
|
||||
use gpui::{
|
||||
elements::Empty, AnyElement, AppContext, Element, Entity, ModelHandle, Task, View,
|
||||
ViewContext, ViewHandle, WeakViewHandle,
|
||||
|
@ -1060,5 +1060,5 @@ pub(crate) mod test {
|
|||
}
|
||||
}
|
||||
|
||||
impl DockItem for TestItem {}
|
||||
impl Panel for TestItem {}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
|
|||
use serde::Deserialize;
|
||||
use settings::{Autosave, Settings};
|
||||
use shared_screen::SharedScreen;
|
||||
use dock::{Dock, PanelButtons, DockPosition, ToggleDockItem};
|
||||
use dock::{Dock, PanelButtons, DockPosition, TogglePanel};
|
||||
use status_bar::StatusBar;
|
||||
pub use status_bar::StatusItemView;
|
||||
use theme::{Theme, ThemeRegistry};
|
||||
|
@ -1322,7 +1322,7 @@ impl Workspace {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn toggle_panel(&mut self, action: &ToggleDockItem, cx: &mut ViewContext<Self>) {
|
||||
pub fn toggle_panel(&mut self, action: &TogglePanel, cx: &mut ViewContext<Self>) {
|
||||
let dock = match action.dock_position {
|
||||
DockPosition::Left => &mut self.left_dock,
|
||||
DockPosition::Right => &mut self.right_dock,
|
||||
|
|
|
@ -96,7 +96,7 @@ export default function statusBar(colorScheme: ColorScheme) {
|
|||
panelButtons: {
|
||||
groupLeft: {},
|
||||
groupRight: {},
|
||||
item: {
|
||||
button: {
|
||||
...statusContainer,
|
||||
iconSize: 16,
|
||||
iconColor: foreground(layer, "variant"),
|
||||
|
|
Loading…
Reference in a new issue