Merge branch 'main' into guest-promotion
This commit is contained in:
commit
276bfa0fab
121 changed files with 1649 additions and 904 deletions
|
@ -28,7 +28,7 @@ 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>);
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon>;
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName>;
|
||||
fn icon_tooltip(&self, cx: &WindowContext) -> Option<&'static str>;
|
||||
fn toggle_action(&self) -> Box<dyn Action>;
|
||||
fn icon_label(&self, _: &WindowContext) -> Option<String> {
|
||||
|
@ -52,7 +52,7 @@ pub trait PanelHandle: Send + Sync {
|
|||
fn set_active(&self, active: bool, cx: &mut WindowContext);
|
||||
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(&self, cx: &WindowContext) -> Option<ui::IconName>;
|
||||
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>;
|
||||
|
@ -104,7 +104,7 @@ where
|
|||
self.update(cx, |this, cx| this.set_size(size, cx))
|
||||
}
|
||||
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName> {
|
||||
self.read(cx).icon(cx)
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,6 @@ impl Dock {
|
|||
})
|
||||
.ok();
|
||||
}
|
||||
// todo!() we do not use this event in the production code (even in zed1), remove it
|
||||
PanelEvent::Activate => {
|
||||
if let Some(ix) = this
|
||||
.panel_entries
|
||||
|
@ -775,7 +774,7 @@ pub mod test {
|
|||
self.size = size.unwrap_or(px(300.));
|
||||
}
|
||||
|
||||
fn icon(&self, _: &WindowContext) -> Option<ui::Icon> {
|
||||
fn icon(&self, _: &WindowContext) -> Option<ui::IconName> {
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -101,6 +101,10 @@ impl ModalLayer {
|
|||
let active_modal = self.active_modal.as_ref()?;
|
||||
active_modal.modal.view().downcast::<V>().ok()
|
||||
}
|
||||
|
||||
pub fn has_active_modal(&self) -> bool {
|
||||
self.active_modal.is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for ModalLayer {
|
||||
|
|
|
@ -175,7 +175,7 @@ pub mod simple_message_notification {
|
|||
};
|
||||
use std::sync::Arc;
|
||||
use ui::prelude::*;
|
||||
use ui::{h_stack, v_stack, Button, Icon, IconElement, Label, StyledExt};
|
||||
use ui::{h_stack, v_stack, Button, Icon, IconName, Label, StyledExt};
|
||||
|
||||
pub struct MessageNotification {
|
||||
message: SharedString,
|
||||
|
@ -230,7 +230,7 @@ pub mod simple_message_notification {
|
|||
.child(
|
||||
div()
|
||||
.id("cancel")
|
||||
.child(IconElement::new(Icon::Close))
|
||||
.child(Icon::new(IconName::Close))
|
||||
.cursor_pointer()
|
||||
.on_click(cx.listener(|this, _, cx| this.dismiss(cx))),
|
||||
),
|
||||
|
@ -247,105 +247,6 @@ pub mod simple_message_notification {
|
|||
}))
|
||||
}
|
||||
}
|
||||
// todo!()
|
||||
// impl View for MessageNotification {
|
||||
// fn ui_name() -> &'static str {
|
||||
// "MessageNotification"
|
||||
// }
|
||||
|
||||
// fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> gpui::AnyElement<Self> {
|
||||
// let theme = theme::current(cx).clone();
|
||||
// let theme = &theme.simple_message_notification;
|
||||
|
||||
// enum MessageNotificationTag {}
|
||||
|
||||
// let click_message = self.click_message.clone();
|
||||
// let message = match &self.message {
|
||||
// NotificationMessage::Text(text) => {
|
||||
// Text::new(text.to_owned(), theme.message.text.clone()).into_any()
|
||||
// }
|
||||
// NotificationMessage::Element(e) => e(theme.message.text.clone(), cx),
|
||||
// };
|
||||
// let on_click = self.on_click.clone();
|
||||
// let has_click_action = on_click.is_some();
|
||||
|
||||
// Flex::column()
|
||||
// .with_child(
|
||||
// Flex::row()
|
||||
// .with_child(
|
||||
// message
|
||||
// .contained()
|
||||
// .with_style(theme.message.container)
|
||||
// .aligned()
|
||||
// .top()
|
||||
// .left()
|
||||
// .flex(1., true),
|
||||
// )
|
||||
// .with_child(
|
||||
// MouseEventHandler::new::<Cancel, _>(0, cx, |state, _| {
|
||||
// let style = theme.dismiss_button.style_for(state);
|
||||
// Svg::new("icons/x.svg")
|
||||
// .with_color(style.color)
|
||||
// .constrained()
|
||||
// .with_width(style.icon_width)
|
||||
// .aligned()
|
||||
// .contained()
|
||||
// .with_style(style.container)
|
||||
// .constrained()
|
||||
// .with_width(style.button_width)
|
||||
// .with_height(style.button_width)
|
||||
// })
|
||||
// .with_padding(Padding::uniform(5.))
|
||||
// .on_click(MouseButton::Left, move |_, this, cx| {
|
||||
// this.dismiss(&Default::default(), cx);
|
||||
// })
|
||||
// .with_cursor_style(CursorStyle::PointingHand)
|
||||
// .aligned()
|
||||
// .constrained()
|
||||
// .with_height(cx.font_cache().line_height(theme.message.text.font_size))
|
||||
// .aligned()
|
||||
// .top()
|
||||
// .flex_float(),
|
||||
// ),
|
||||
// )
|
||||
// .with_children({
|
||||
// click_message
|
||||
// .map(|click_message| {
|
||||
// MouseEventHandler::new::<MessageNotificationTag, _>(
|
||||
// 0,
|
||||
// cx,
|
||||
// |state, _| {
|
||||
// let style = theme.action_message.style_for(state);
|
||||
|
||||
// Flex::row()
|
||||
// .with_child(
|
||||
// Text::new(click_message, style.text.clone())
|
||||
// .contained()
|
||||
// .with_style(style.container),
|
||||
// )
|
||||
// .contained()
|
||||
// },
|
||||
// )
|
||||
// .on_click(MouseButton::Left, move |_, this, cx| {
|
||||
// if let Some(on_click) = on_click.as_ref() {
|
||||
// on_click(cx);
|
||||
// this.dismiss(&Default::default(), cx);
|
||||
// }
|
||||
// })
|
||||
// // Since we're not using a proper overlay, we have to capture these extra events
|
||||
// .on_down(MouseButton::Left, |_, _, _| {})
|
||||
// .on_up(MouseButton::Left, |_, _, _| {})
|
||||
// .with_cursor_style(if has_click_action {
|
||||
// CursorStyle::PointingHand
|
||||
// } else {
|
||||
// CursorStyle::Arrow
|
||||
// })
|
||||
// })
|
||||
// .into_iter()
|
||||
// })
|
||||
// .into_any()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
pub trait NotifyResultExt {
|
||||
|
|
|
@ -31,8 +31,8 @@ use std::{
|
|||
use theme::ThemeSettings;
|
||||
|
||||
use ui::{
|
||||
prelude::*, right_click_menu, ButtonSize, Color, Icon, IconButton, IconSize, Indicator, Label,
|
||||
Tab, TabBar, TabPosition, Tooltip,
|
||||
prelude::*, right_click_menu, ButtonSize, Color, IconButton, IconName, IconSize, Indicator,
|
||||
Label, Tab, TabBar, TabPosition, Tooltip,
|
||||
};
|
||||
use ui::{v_stack, ContextMenu};
|
||||
use util::{maybe, truncate_and_remove_front, ResultExt};
|
||||
|
@ -384,7 +384,7 @@ impl Pane {
|
|||
h_stack()
|
||||
.gap_2()
|
||||
.child(
|
||||
IconButton::new("plus", Icon::Plus)
|
||||
IconButton::new("plus", IconName::Plus)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(Color::Muted)
|
||||
.on_click(cx.listener(|pane, _, cx| {
|
||||
|
@ -406,7 +406,7 @@ impl Pane {
|
|||
el.child(Self::render_menu_overlay(new_item_menu))
|
||||
})
|
||||
.child(
|
||||
IconButton::new("split", Icon::Split)
|
||||
IconButton::new("split", IconName::Split)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(Color::Muted)
|
||||
.on_click(cx.listener(|pane, _, cx| {
|
||||
|
@ -427,11 +427,11 @@ impl Pane {
|
|||
)
|
||||
.child({
|
||||
let zoomed = pane.is_zoomed();
|
||||
IconButton::new("toggle_zoom", Icon::Maximize)
|
||||
IconButton::new("toggle_zoom", IconName::Maximize)
|
||||
.icon_size(IconSize::Small)
|
||||
.icon_color(Color::Muted)
|
||||
.selected(zoomed)
|
||||
.selected_icon(Icon::Minimize)
|
||||
.selected_icon(IconName::Minimize)
|
||||
.on_click(cx.listener(|pane, _, cx| {
|
||||
pane.toggle_zoom(&crate::ToggleZoom, cx);
|
||||
}))
|
||||
|
@ -1570,7 +1570,7 @@ impl Pane {
|
|||
})
|
||||
.start_slot::<Indicator>(indicator)
|
||||
.end_slot(
|
||||
IconButton::new("close tab", Icon::Close)
|
||||
IconButton::new("close tab", IconName::Close)
|
||||
.icon_color(Color::Muted)
|
||||
.size(ButtonSize::None)
|
||||
.icon_size(IconSize::XSmall)
|
||||
|
@ -1676,7 +1676,7 @@ impl Pane {
|
|||
h_stack()
|
||||
.gap_2()
|
||||
.child(
|
||||
IconButton::new("navigate_backward", Icon::ArrowLeft)
|
||||
IconButton::new("navigate_backward", IconName::ArrowLeft)
|
||||
.icon_size(IconSize::Small)
|
||||
.on_click({
|
||||
let view = cx.view().clone();
|
||||
|
@ -1686,7 +1686,7 @@ impl Pane {
|
|||
.tooltip(|cx| Tooltip::for_action("Go Back", &GoBack, cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("navigate_forward", Icon::ArrowRight)
|
||||
IconButton::new("navigate_forward", IconName::ArrowRight)
|
||||
.icon_size(IconSize::Small)
|
||||
.on_click({
|
||||
let view = cx.view().clone();
|
||||
|
|
|
@ -12,7 +12,7 @@ use serde::Deserialize;
|
|||
use std::sync::Arc;
|
||||
use ui::{prelude::*, Button};
|
||||
|
||||
const HANDLE_HITBOX_SIZE: f32 = 10.0; //todo!(change this back to 4)
|
||||
const HANDLE_HITBOX_SIZE: f32 = 4.0;
|
||||
const HORIZONTAL_MIN_SIZE: f32 = 80.;
|
||||
const VERTICAL_MIN_SIZE: f32 = 100.;
|
||||
|
||||
|
@ -579,12 +579,15 @@ mod element {
|
|||
Size, Style, WeakView, WindowContext,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use settings::Settings;
|
||||
use smallvec::SmallVec;
|
||||
use ui::prelude::*;
|
||||
use util::ResultExt;
|
||||
|
||||
use crate::Workspace;
|
||||
|
||||
use crate::WorkspaceSettings;
|
||||
|
||||
use super::{HANDLE_HITBOX_SIZE, HORIZONTAL_MIN_SIZE, VERTICAL_MIN_SIZE};
|
||||
|
||||
const DIVIDER_SIZE: f32 = 1.0;
|
||||
|
@ -704,7 +707,6 @@ mod element {
|
|||
proposed_current_pixel_change -= current_pixel_change;
|
||||
}
|
||||
|
||||
// todo!(schedule serialize)
|
||||
workspace
|
||||
.update(cx, |this, cx| this.schedule_serialize(cx))
|
||||
.log_err();
|
||||
|
@ -834,20 +836,39 @@ mod element {
|
|||
debug_assert!(flexes.len() == len);
|
||||
debug_assert!(flex_values_in_bounds(flexes.as_slice()));
|
||||
|
||||
let magnification_value = WorkspaceSettings::get(None, cx).active_pane_magnification;
|
||||
let active_pane_magnification = if magnification_value == 1. {
|
||||
None
|
||||
} else {
|
||||
Some(magnification_value)
|
||||
};
|
||||
|
||||
let total_flex = if let Some(flex) = active_pane_magnification {
|
||||
self.children.len() as f32 - 1. + flex
|
||||
} else {
|
||||
len as f32
|
||||
};
|
||||
|
||||
let mut origin = bounds.origin;
|
||||
let space_per_flex = bounds.size.along(self.axis) / len as f32;
|
||||
let space_per_flex = bounds.size.along(self.axis) / total_flex;
|
||||
|
||||
let mut bounding_boxes = self.bounding_boxes.lock();
|
||||
bounding_boxes.clear();
|
||||
|
||||
for (ix, child) in self.children.iter_mut().enumerate() {
|
||||
//todo!(active_pane_magnification)
|
||||
// If using active pane magnification, need to switch to using
|
||||
// 1 for all non-active panes, and then the magnification for the
|
||||
// active pane.
|
||||
let child_flex = active_pane_magnification
|
||||
.map(|magnification| {
|
||||
if self.active_pane_ix == Some(ix) {
|
||||
magnification
|
||||
} else {
|
||||
1.
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| flexes[ix]);
|
||||
|
||||
let child_size = bounds
|
||||
.size
|
||||
.apply_along(self.axis, |_| space_per_flex * flexes[ix]);
|
||||
.apply_along(self.axis, |_| space_per_flex * child_flex);
|
||||
|
||||
let child_bounds = Bounds {
|
||||
origin,
|
||||
|
@ -857,20 +878,23 @@ mod element {
|
|||
cx.with_z_index(0, |cx| {
|
||||
child.draw(origin, child_size.into(), cx);
|
||||
});
|
||||
cx.with_z_index(1, |cx| {
|
||||
if ix < len - 1 {
|
||||
Self::push_handle(
|
||||
self.flexes.clone(),
|
||||
state.clone(),
|
||||
self.axis,
|
||||
ix,
|
||||
child_bounds,
|
||||
bounds,
|
||||
self.workspace.clone(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if active_pane_magnification.is_none() {
|
||||
cx.with_z_index(1, |cx| {
|
||||
if ix < len - 1 {
|
||||
Self::push_handle(
|
||||
self.flexes.clone(),
|
||||
state.clone(),
|
||||
self.axis,
|
||||
ix,
|
||||
child_bounds,
|
||||
bounds,
|
||||
self.workspace.clone(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
origin = origin.apply_along(self.axis, |val| val + child_size.along(self.axis));
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use gpui::{
|
|||
WindowContext,
|
||||
};
|
||||
use std::sync::{Arc, Weak};
|
||||
use ui::{h_stack, prelude::*, Icon, IconElement, Label};
|
||||
use ui::{h_stack, prelude::*, Icon, IconName, Label};
|
||||
|
||||
pub enum Event {
|
||||
Close,
|
||||
|
@ -100,7 +100,7 @@ impl Item for SharedScreen {
|
|||
) -> gpui::AnyElement {
|
||||
h_stack()
|
||||
.gap_1()
|
||||
.child(IconElement::new(Icon::Screen))
|
||||
.child(Icon::new(IconName::Screen))
|
||||
.child(
|
||||
Label::new(format!("{}'s screen", self.user.github_login)).color(if selected {
|
||||
Color::Default
|
||||
|
|
|
@ -133,82 +133,6 @@ impl Render for Toolbar {
|
|||
}
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// impl View for Toolbar {
|
||||
// fn ui_name() -> &'static str {
|
||||
// "Toolbar"
|
||||
// }
|
||||
|
||||
// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
|
||||
// let theme = &theme::current(cx).workspace.toolbar;
|
||||
|
||||
// let mut primary_left_items = Vec::new();
|
||||
// let mut primary_right_items = Vec::new();
|
||||
// let mut secondary_item = None;
|
||||
// let spacing = theme.item_spacing;
|
||||
// let mut primary_items_row_count = 1;
|
||||
|
||||
// for (item, position) in &self.items {
|
||||
// match *position {
|
||||
// ToolbarItemLocation::Hidden => {}
|
||||
|
||||
// ToolbarItemLocation::PrimaryLeft { flex } => {
|
||||
// primary_items_row_count = primary_items_row_count.max(item.row_count(cx));
|
||||
// let left_item = ChildView::new(item.as_any(), cx).aligned();
|
||||
// if let Some((flex, expanded)) = flex {
|
||||
// primary_left_items.push(left_item.flex(flex, expanded).into_any());
|
||||
// } else {
|
||||
// primary_left_items.push(left_item.into_any());
|
||||
// }
|
||||
// }
|
||||
|
||||
// ToolbarItemLocation::PrimaryRight { flex } => {
|
||||
// primary_items_row_count = primary_items_row_count.max(item.row_count(cx));
|
||||
// let right_item = ChildView::new(item.as_any(), cx).aligned().flex_float();
|
||||
// if let Some((flex, expanded)) = flex {
|
||||
// primary_right_items.push(right_item.flex(flex, expanded).into_any());
|
||||
// } else {
|
||||
// primary_right_items.push(right_item.into_any());
|
||||
// }
|
||||
// }
|
||||
|
||||
// ToolbarItemLocation::Secondary => {
|
||||
// secondary_item = Some(
|
||||
// ChildView::new(item.as_any(), cx)
|
||||
// .constrained()
|
||||
// .with_height(theme.height * item.row_count(cx) as f32)
|
||||
// .into_any(),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// let container_style = theme.container;
|
||||
// let height = theme.height * primary_items_row_count as f32;
|
||||
|
||||
// let mut primary_items = Flex::row().with_spacing(spacing);
|
||||
// primary_items.extend(primary_left_items);
|
||||
// primary_items.extend(primary_right_items);
|
||||
|
||||
// let mut toolbar = Flex::column();
|
||||
// if !primary_items.is_empty() {
|
||||
// toolbar.add_child(primary_items.constrained().with_height(height));
|
||||
// }
|
||||
// if let Some(secondary_item) = secondary_item {
|
||||
// toolbar.add_child(secondary_item);
|
||||
// }
|
||||
|
||||
// if toolbar.is_empty() {
|
||||
// toolbar.into_any_named("toolbar")
|
||||
// } else {
|
||||
// toolbar
|
||||
// .contained()
|
||||
// .with_style(container_style)
|
||||
// .into_any_named("toolbar")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
impl Toolbar {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
@ -312,10 +236,3 @@ impl<T: ToolbarItemView> ToolbarItemViewHandle for View<T> {
|
|||
self.read(cx).row_count(cx)
|
||||
}
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// impl From<&dyn ToolbarItemViewHandle> for AnyViewHandle {
|
||||
// fn from(val: &dyn ToolbarItemViewHandle) -> Self {
|
||||
// val.as_any().clone()
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -943,10 +943,8 @@ impl Workspace {
|
|||
cx: &mut ViewContext<Workspace>,
|
||||
) -> Task<Result<()>> {
|
||||
let to_load = if let Some(pane) = pane.upgrade() {
|
||||
// todo!("focus")
|
||||
// cx.focus(&pane);
|
||||
|
||||
pane.update(cx, |pane, cx| {
|
||||
pane.focus(cx);
|
||||
loop {
|
||||
// Retrieve the weak item handle from the history.
|
||||
let entry = pane.nav_history_mut().pop(mode, cx)?;
|
||||
|
@ -1631,8 +1629,7 @@ impl Workspace {
|
|||
});
|
||||
}
|
||||
|
||||
// todo!("focus")
|
||||
// cx.focus_self();
|
||||
cx.focus_self();
|
||||
cx.notify();
|
||||
self.serialize_workspace(cx);
|
||||
}
|
||||
|
@ -1713,6 +1710,7 @@ impl Workspace {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// #[cfg(any(test, feature = "test-support"))]
|
||||
// pub fn zoomed_view(&self, cx: &AppContext) -> Option<AnyViewHandle> {
|
||||
// self.zoomed.and_then(|view| view.upgrade(cx))
|
||||
|
@ -2992,7 +2990,6 @@ impl Workspace {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn schedule_serialize(&mut self, cx: &mut ViewContext<Self>) {
|
||||
self._schedule_serialize = Some(cx.spawn(|this, mut cx| async move {
|
||||
cx.background_executor()
|
||||
|
@ -3386,6 +3383,10 @@ impl Workspace {
|
|||
div
|
||||
}
|
||||
|
||||
pub fn has_active_modal(&self, cx: &WindowContext<'_>) -> bool {
|
||||
self.modal_layer.read(cx).has_active_modal()
|
||||
}
|
||||
|
||||
pub fn active_modal<V: ManagedView + 'static>(
|
||||
&mut self,
|
||||
cx: &ViewContext<Self>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue