diff --git a/Cargo.lock b/Cargo.lock index 2bd0bfa..de99e27 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -807,9 +807,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.11" +version = "1.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" +checksum = "755717a7de9ec452bf7f3f1a3099085deabd7f2962b861dae91ecd7a365903d2" dependencies = [ "jobserver", "libc", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "collections" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "indexmap", "rustc-hash 2.1.0", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "derive_refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "proc-macro2", "quote", @@ -2059,7 +2059,7 @@ dependencies = [ [[package]] name = "gpui" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "as-raw-xcb-connection", @@ -2146,7 +2146,7 @@ dependencies = [ [[package]] name = "gpui_macros" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "proc-macro2", "quote", @@ -2156,7 +2156,7 @@ dependencies = [ [[package]] name = "gpui_tokio" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "gpui", "tokio", @@ -2361,7 +2361,7 @@ dependencies = [ [[package]] name = "http_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "bytes", @@ -2851,7 +2851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -3012,7 +3012,7 @@ dependencies = [ [[package]] name = "media" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "bindgen", @@ -3191,7 +3191,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" [[package]] name = "nostr" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "aes", "base64", @@ -3219,7 +3219,7 @@ dependencies = [ [[package]] name = "nostr-connect" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "async-utility", "nostr", @@ -3231,7 +3231,7 @@ dependencies = [ [[package]] name = "nostr-database" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "flatbuffers", "nostr", @@ -3241,7 +3241,7 @@ dependencies = [ [[package]] name = "nostr-lmdb" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "async-utility", "heed", @@ -3252,7 +3252,7 @@ dependencies = [ [[package]] name = "nostr-relay-pool" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "async-utility", "async-wsocket", @@ -3268,7 +3268,7 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.39.0" -source = "git+https://github.com/rust-nostr/nostr#dda112c89422cda6740fdae404e09a227a0f79ce" +source = "git+https://github.com/rust-nostr/nostr#e57c6e3733de2799294bd70bf325aaf08a60e4d8" dependencies = [ "async-utility", "nostr", @@ -4276,7 +4276,7 @@ dependencies = [ [[package]] name = "refineable" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "derive_refineable", ] @@ -4405,7 +4405,7 @@ dependencies = [ [[package]] name = "reqwest_client" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "bytes", @@ -4755,7 +4755,7 @@ checksum = "c2fdfc24bc566f839a2da4c4295b82db7d25a24253867d5c64355abb5799bdbe" [[package]] name = "semantic_version" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "serde", @@ -5080,7 +5080,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "sum_tree" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "arrayvec", "log", @@ -5902,7 +5902,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "util" version = "0.1.0" -source = "git+https://github.com/zed-industries/zed#28b80455f97dbe21d5d9845b85928feca652c518" +source = "git+https://github.com/zed-industries/zed#0963401a8d0e7afed461090cb57be8047e1f79c5" dependencies = [ "anyhow", "async-fs", @@ -5927,11 +5927,11 @@ dependencies = [ [[package]] name = "uuid" -version = "1.12.1" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +checksum = "ced87ca4be083373936a67f8de945faa23b6b42384bd5b64434850802c6dccd0" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.3.1", "serde", "sha1_smol", ] @@ -6287,7 +6287,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/crates/ui/src/dock_area/dock.rs b/crates/ui/src/dock_area/dock.rs index aa41e11..5ffff81 100644 --- a/crates/ui/src/dock_area/dock.rs +++ b/crates/ui/src/dock_area/dock.rs @@ -6,9 +6,10 @@ use crate::{ AxisExt as _, StyledExt, }; use gpui::{ - div, prelude::FluentBuilder as _, px, App, AppContext, Axis, Context, Element, Entity, + div, prelude::FluentBuilder as _, px, AnyView, App, AppContext, Axis, Context, Element, Entity, InteractiveElement as _, IntoElement, MouseMoveEvent, MouseUpEvent, ParentElement as _, Pixels, - Point, Render, StatefulInteractiveElement, Style, Styled as _, WeakEntity, Window, + Point, Render, StatefulInteractiveElement, Style, StyleRefinement, Styled as _, WeakEntity, + Window, }; use serde::{Deserialize, Serialize}; use std::sync::Arc; @@ -355,6 +356,8 @@ impl Render for Dock { return div(); } + let cache_style = StyleRefinement::default().v_flex().size_full(); + div() .relative() .overflow_hidden() @@ -369,8 +372,10 @@ impl Render for Dock { }) .map(|this| match &self.panel { DockItem::Split { view, .. } => this.child(view.clone()), - DockItem::Tabs { view, .. } => this.child(view.clone()), - DockItem::Panel { view, .. } => this.child(view.clone().view()), + DockItem::Tabs { view, .. } => { + this.child(AnyView::from(view.clone()).cached(cache_style)) + } + DockItem::Panel { view, .. } => this.child(view.clone().view().cached(cache_style)), }) .child(self.render_resize_handle(window, cx)) .child(DockElement { diff --git a/crates/ui/src/dock_area/panel.rs b/crates/ui/src/dock_area/panel.rs index 473a0d0..5b83de6 100644 --- a/crates/ui/src/dock_area/panel.rs +++ b/crates/ui/src/dock_area/panel.rs @@ -51,6 +51,27 @@ pub trait Panel: EventEmitter + Render + Focusable { true } + /// Return false to hide panel, true to show panel, default is `true`. + /// + /// This method called in Panel render, we should make sure it is fast. + fn visible(&self, _cx: &App) -> bool { + true + } + + /// Set active state of the panel. + /// + /// This method will be called when the panel is active or inactive. + /// + /// The last_active_panel and current_active_panel will be touched when the panel is active. + fn set_active(&self, _active: bool, _cx: &mut App) {} + + /// Set zoomed state of the panel. + /// + /// This method will be called when the panel is zoomed or unzoomed. + /// + /// Only current Panel will touch this method. + fn set_zoomed(&self, _zoomed: bool, _cx: &mut App) {} + /// The addition popup menu of the panel, default is `None`. fn popup_menu(&self, this: PopupMenu, _cx: &App) -> PopupMenu { this @@ -68,6 +89,9 @@ pub trait PanelView: 'static + Send + Sync { fn title(&self, cx: &App) -> AnyElement; fn closable(&self, cx: &App) -> bool; fn zoomable(&self, cx: &App) -> bool; + fn visible(&self, cx: &App) -> bool; + fn set_active(&self, active: bool, cx: &mut App); + fn set_zoomed(&self, zoomed: bool, cx: &mut App); fn popup_menu(&self, menu: PopupMenu, cx: &App) -> PopupMenu; fn toolbar_buttons(&self, window: &Window, cx: &App) -> Vec