1mod application_menu;
2mod collab;
3mod onboarding_banner;
4mod platforms;
5mod window_controls;
6
7#[cfg(feature = "stories")]
8mod stories;
9
10use crate::application_menu::ApplicationMenu;
11
12#[cfg(not(target_os = "macos"))]
13use crate::application_menu::{
14 ActivateDirection, ActivateMenuLeft, ActivateMenuRight, OpenApplicationMenu,
15};
16
17use crate::platforms::{platform_linux, platform_mac, platform_windows};
18use auto_update::AutoUpdateStatus;
19use call::ActiveCall;
20use client::{Client, UserStore};
21use feature_flags::{FeatureFlagAppExt, NewBillingFeatureFlag};
22use gpui::{
23 Action, AnyElement, App, Context, Corner, Decorations, Element, Entity, InteractiveElement,
24 Interactivity, IntoElement, MouseButton, ParentElement, Render, Stateful,
25 StatefulInteractiveElement, Styled, Subscription, WeakEntity, Window, actions, div, px,
26};
27use onboarding_banner::OnboardingBanner;
28use project::Project;
29use rpc::proto;
30use settings::Settings as _;
31use smallvec::SmallVec;
32use std::sync::Arc;
33use theme::ActiveTheme;
34use ui::{
35 Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon, IconName, IconSize,
36 IconWithIndicator, Indicator, PopoverMenu, Tooltip, h_flex, prelude::*,
37};
38use util::ResultExt;
39use workspace::{Workspace, notifications::NotifyResultExt};
40use zed_actions::{OpenBrowser, OpenRecent, OpenRemote};
41
42pub use onboarding_banner::restore_banner;
43
44#[cfg(feature = "stories")]
45pub use stories::*;
46
47const MAX_PROJECT_NAME_LENGTH: usize = 40;
48const MAX_BRANCH_NAME_LENGTH: usize = 40;
49const MAX_SHORT_SHA_LENGTH: usize = 8;
50
51const BOOK_ONBOARDING: &str = "https://dub.sh/zed-c-onboarding";
52
53actions!(collab, [ToggleUserMenu, ToggleProjectMenu, SwitchBranch]);
54
55pub fn init(cx: &mut App) {
56 cx.observe_new(|workspace: &mut Workspace, window, cx| {
57 let Some(window) = window else {
58 return;
59 };
60 let item = cx.new(|cx| TitleBar::new("title-bar", workspace, window, cx));
61 workspace.set_titlebar_item(item.into(), window, cx);
62
63 #[cfg(not(target_os = "macos"))]
64 workspace.register_action(|workspace, action: &OpenApplicationMenu, window, cx| {
65 if let Some(titlebar) = workspace
66 .titlebar_item()
67 .and_then(|item| item.downcast::<TitleBar>().ok())
68 {
69 titlebar.update(cx, |titlebar, cx| {
70 if let Some(ref menu) = titlebar.application_menu {
71 menu.update(cx, |menu, cx| menu.open_menu(action, window, cx));
72 }
73 });
74 }
75 });
76
77 #[cfg(not(target_os = "macos"))]
78 workspace.register_action(|workspace, _: &ActivateMenuRight, window, cx| {
79 if let Some(titlebar) = workspace
80 .titlebar_item()
81 .and_then(|item| item.downcast::<TitleBar>().ok())
82 {
83 titlebar.update(cx, |titlebar, cx| {
84 if let Some(ref menu) = titlebar.application_menu {
85 menu.update(cx, |menu, cx| {
86 menu.navigate_menus_in_direction(ActivateDirection::Right, window, cx)
87 });
88 }
89 });
90 }
91 });
92
93 #[cfg(not(target_os = "macos"))]
94 workspace.register_action(|workspace, _: &ActivateMenuLeft, window, cx| {
95 if let Some(titlebar) = workspace
96 .titlebar_item()
97 .and_then(|item| item.downcast::<TitleBar>().ok())
98 {
99 titlebar.update(cx, |titlebar, cx| {
100 if let Some(ref menu) = titlebar.application_menu {
101 menu.update(cx, |menu, cx| {
102 menu.navigate_menus_in_direction(ActivateDirection::Left, window, cx)
103 });
104 }
105 });
106 }
107 });
108 })
109 .detach();
110}
111
112pub struct TitleBar {
113 platform_style: PlatformStyle,
114 content: Stateful<Div>,
115 children: SmallVec<[AnyElement; 2]>,
116 project: Entity<Project>,
117 user_store: Entity<UserStore>,
118 client: Arc<Client>,
119 workspace: WeakEntity<Workspace>,
120 should_move: bool,
121 application_menu: Option<Entity<ApplicationMenu>>,
122 _subscriptions: Vec<Subscription>,
123 banner: Entity<OnboardingBanner>,
124}
125
126impl Render for TitleBar {
127 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
128 let close_action = Box::new(workspace::CloseWindow);
129 let height = Self::height(window);
130 let supported_controls = window.window_controls();
131 let decorations = window.window_decorations();
132 let titlebar_color = if cfg!(any(target_os = "linux", target_os = "freebsd")) {
133 if window.is_window_active() && !self.should_move {
134 cx.theme().colors().title_bar_background
135 } else {
136 cx.theme().colors().title_bar_inactive_background
137 }
138 } else {
139 cx.theme().colors().title_bar_background
140 };
141
142 h_flex()
143 .id("titlebar")
144 .w_full()
145 .h(height)
146 .map(|this| {
147 if window.is_fullscreen() {
148 this.pl_2()
149 } else if self.platform_style == PlatformStyle::Mac {
150 this.pl(px(platform_mac::TRAFFIC_LIGHT_PADDING))
151 } else {
152 this.pl_2()
153 }
154 })
155 .map(|el| match decorations {
156 Decorations::Server => el,
157 Decorations::Client { tiling, .. } => el
158 .when(!(tiling.top || tiling.right), |el| {
159 el.rounded_tr(theme::CLIENT_SIDE_DECORATION_ROUNDING)
160 })
161 .when(!(tiling.top || tiling.left), |el| {
162 el.rounded_tl(theme::CLIENT_SIDE_DECORATION_ROUNDING)
163 })
164 // this border is to avoid a transparent gap in the rounded corners
165 .mt(px(-1.))
166 .border(px(1.))
167 .border_color(titlebar_color),
168 })
169 .bg(titlebar_color)
170 .content_stretch()
171 .child(
172 div()
173 .id("titlebar-content")
174 .flex()
175 .flex_row()
176 .items_center()
177 .justify_between()
178 .w_full()
179 // Note: On Windows the title bar behavior is handled by the platform implementation.
180 .when(self.platform_style != PlatformStyle::Windows, |this| {
181 this.on_click(|event, window, _| {
182 if event.up.click_count == 2 {
183 window.zoom_window();
184 }
185 })
186 })
187 .child(
188 h_flex()
189 .gap_1()
190 .map(|title_bar| {
191 let mut render_project_items = true;
192 title_bar
193 .when_some(self.application_menu.clone(), |title_bar, menu| {
194 render_project_items = !menu.read(cx).all_menus_shown();
195 title_bar.child(menu)
196 })
197 .when(render_project_items, |title_bar| {
198 title_bar
199 .children(self.render_project_host(cx))
200 .child(self.render_project_name(cx))
201 .children(self.render_project_branch(cx))
202 })
203 })
204 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()),
205 )
206 .child(self.render_collaborator_list(window, cx))
207 .child(self.banner.clone())
208 .child(
209 h_flex()
210 .gap_1()
211 .pr_1()
212 .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
213 .children(self.render_call_controls(window, cx))
214 .map(|el| {
215 let status = self.client.status();
216 let status = &*status.borrow();
217 if matches!(status, client::Status::Connected { .. }) {
218 el.child(self.render_user_menu_button(cx))
219 } else {
220 el.children(self.render_connection_status(status, cx))
221 .child(self.render_sign_in_button(cx))
222 .child(self.render_user_menu_button(cx))
223 }
224 }),
225 ),
226 )
227 .when(!window.is_fullscreen(), |title_bar| {
228 match self.platform_style {
229 PlatformStyle::Mac => title_bar,
230 PlatformStyle::Linux => {
231 if matches!(decorations, Decorations::Client { .. }) {
232 title_bar
233 .child(platform_linux::LinuxWindowControls::new(close_action))
234 .when(supported_controls.window_menu, |titlebar| {
235 titlebar.on_mouse_down(
236 gpui::MouseButton::Right,
237 move |ev, window, _| window.show_window_menu(ev.position),
238 )
239 })
240 .on_mouse_move(cx.listener(move |this, _ev, window, _| {
241 if this.should_move {
242 this.should_move = false;
243 window.start_window_move();
244 }
245 }))
246 .on_mouse_down_out(cx.listener(move |this, _ev, _window, _cx| {
247 this.should_move = false;
248 }))
249 .on_mouse_up(
250 gpui::MouseButton::Left,
251 cx.listener(move |this, _ev, _window, _cx| {
252 this.should_move = false;
253 }),
254 )
255 .on_mouse_down(
256 gpui::MouseButton::Left,
257 cx.listener(move |this, _ev, _window, _cx| {
258 this.should_move = true;
259 }),
260 )
261 } else {
262 title_bar
263 }
264 }
265 PlatformStyle::Windows => {
266 title_bar.child(platform_windows::WindowsWindowControls::new(height))
267 }
268 }
269 })
270 }
271}
272
273impl TitleBar {
274 pub fn new(
275 id: impl Into<ElementId>,
276 workspace: &Workspace,
277 window: &mut Window,
278 cx: &mut Context<Self>,
279 ) -> Self {
280 let project = workspace.project().clone();
281 let user_store = workspace.app_state().user_store.clone();
282 let client = workspace.app_state().client.clone();
283 let active_call = ActiveCall::global(cx);
284
285 let platform_style = PlatformStyle::platform();
286 let application_menu = match platform_style {
287 PlatformStyle::Mac => {
288 if option_env!("ZED_USE_CROSS_PLATFORM_MENU").is_some() {
289 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
290 } else {
291 None
292 }
293 }
294 PlatformStyle::Linux | PlatformStyle::Windows => {
295 Some(cx.new(|cx| ApplicationMenu::new(window, cx)))
296 }
297 };
298
299 let mut subscriptions = Vec::new();
300 subscriptions.push(
301 cx.observe(&workspace.weak_handle().upgrade().unwrap(), |_, _, cx| {
302 cx.notify()
303 }),
304 );
305 subscriptions.push(cx.subscribe(&project, |_, _, _: &project::Event, cx| cx.notify()));
306 subscriptions.push(cx.observe(&active_call, |this, _, cx| this.active_call_changed(cx)));
307 subscriptions.push(cx.observe_window_activation(window, Self::window_activation_changed));
308 subscriptions.push(cx.observe(&user_store, |_, _, cx| cx.notify()));
309
310 let banner = cx.new(|cx| {
311 OnboardingBanner::new(
312 "Git Onboarding",
313 IconName::GitBranchSmall,
314 "Git Support",
315 None,
316 zed_actions::OpenGitIntegrationOnboarding.boxed_clone(),
317 cx,
318 )
319 });
320
321 Self {
322 platform_style,
323 content: div().id(id.into()),
324 children: SmallVec::new(),
325 application_menu,
326 workspace: workspace.weak_handle(),
327 should_move: false,
328 project,
329 user_store,
330 client,
331 _subscriptions: subscriptions,
332 banner,
333 }
334 }
335
336 #[cfg(not(target_os = "windows"))]
337 pub fn height(window: &mut Window) -> Pixels {
338 (1.75 * window.rem_size()).max(px(34.))
339 }
340
341 #[cfg(target_os = "windows")]
342 pub fn height(_window: &mut Window) -> Pixels {
343 // todo(windows) instead of hard coded size report the actual size to the Windows platform API
344 px(32.)
345 }
346
347 /// Sets the platform style.
348 pub fn platform_style(mut self, style: PlatformStyle) -> Self {
349 self.platform_style = style;
350 self
351 }
352
353 fn render_ssh_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
354 let options = self.project.read(cx).ssh_connection_options(cx)?;
355 let host: SharedString = options.connection_string().into();
356
357 let nickname = options
358 .nickname
359 .clone()
360 .map(|nick| nick.into())
361 .unwrap_or_else(|| host.clone());
362
363 let (indicator_color, meta) = match self.project.read(cx).ssh_connection_state(cx)? {
364 remote::ConnectionState::Connecting => (Color::Info, format!("Connecting to: {host}")),
365 remote::ConnectionState::Connected => (Color::Success, format!("Connected to: {host}")),
366 remote::ConnectionState::HeartbeatMissed => (
367 Color::Warning,
368 format!("Connection attempt to {host} missed. Retrying..."),
369 ),
370 remote::ConnectionState::Reconnecting => (
371 Color::Warning,
372 format!("Lost connection to {host}. Reconnecting..."),
373 ),
374 remote::ConnectionState::Disconnected => {
375 (Color::Error, format!("Disconnected from {host}"))
376 }
377 };
378
379 let icon_color = match self.project.read(cx).ssh_connection_state(cx)? {
380 remote::ConnectionState::Connecting => Color::Info,
381 remote::ConnectionState::Connected => Color::Default,
382 remote::ConnectionState::HeartbeatMissed => Color::Warning,
383 remote::ConnectionState::Reconnecting => Color::Warning,
384 remote::ConnectionState::Disconnected => Color::Error,
385 };
386
387 let meta = SharedString::from(meta);
388
389 Some(
390 ButtonLike::new("ssh-server-icon")
391 .child(
392 h_flex()
393 .gap_2()
394 .max_w_32()
395 .child(
396 IconWithIndicator::new(
397 Icon::new(IconName::Server)
398 .size(IconSize::XSmall)
399 .color(icon_color),
400 Some(Indicator::dot().color(indicator_color)),
401 )
402 .indicator_border_color(Some(cx.theme().colors().title_bar_background))
403 .into_any_element(),
404 )
405 .child(
406 Label::new(nickname.clone())
407 .size(LabelSize::Small)
408 .truncate(),
409 ),
410 )
411 .tooltip(move |window, cx| {
412 Tooltip::with_meta(
413 "Remote Project",
414 Some(&OpenRemote),
415 meta.clone(),
416 window,
417 cx,
418 )
419 })
420 .on_click(|_, window, cx| {
421 window.dispatch_action(OpenRemote.boxed_clone(), cx);
422 })
423 .into_any_element(),
424 )
425 }
426
427 pub fn render_project_host(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
428 if self.project.read(cx).is_via_ssh() {
429 return self.render_ssh_project_host(cx);
430 }
431
432 if self.project.read(cx).is_disconnected(cx) {
433 return Some(
434 Button::new("disconnected", "Disconnected")
435 .disabled(true)
436 .color(Color::Disabled)
437 .style(ButtonStyle::Subtle)
438 .label_size(LabelSize::Small)
439 .into_any_element(),
440 );
441 }
442
443 let host = self.project.read(cx).host()?;
444 let host_user = self.user_store.read(cx).get_cached_user(host.user_id)?;
445 let participant_index = self
446 .user_store
447 .read(cx)
448 .participant_indices()
449 .get(&host_user.id)?;
450 Some(
451 Button::new("project_owner_trigger", host_user.github_login.clone())
452 .color(Color::Player(participant_index.0))
453 .style(ButtonStyle::Subtle)
454 .label_size(LabelSize::Small)
455 .tooltip(Tooltip::text(format!(
456 "{} is sharing this project. Click to follow.",
457 host_user.github_login.clone()
458 )))
459 .on_click({
460 let host_peer_id = host.peer_id;
461 cx.listener(move |this, _, window, cx| {
462 this.workspace
463 .update(cx, |workspace, cx| {
464 workspace.follow(host_peer_id, window, cx);
465 })
466 .log_err();
467 })
468 })
469 .into_any_element(),
470 )
471 }
472
473 pub fn render_project_name(&self, cx: &mut Context<Self>) -> impl IntoElement {
474 let name = {
475 let mut names = self.project.read(cx).visible_worktrees(cx).map(|worktree| {
476 let worktree = worktree.read(cx);
477 worktree.root_name()
478 });
479
480 names.next()
481 };
482 let is_project_selected = name.is_some();
483 let name = if let Some(name) = name {
484 util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH)
485 } else {
486 "Open recent project".to_string()
487 };
488
489 Button::new("project_name_trigger", name)
490 .when(!is_project_selected, |b| b.color(Color::Muted))
491 .style(ButtonStyle::Subtle)
492 .label_size(LabelSize::Small)
493 .tooltip(move |window, cx| {
494 Tooltip::for_action(
495 "Recent Projects",
496 &zed_actions::OpenRecent {
497 create_new_window: false,
498 },
499 window,
500 cx,
501 )
502 })
503 .on_click(cx.listener(move |_, _, window, cx| {
504 window.dispatch_action(
505 OpenRecent {
506 create_new_window: false,
507 }
508 .boxed_clone(),
509 cx,
510 );
511 }))
512 }
513
514 pub fn render_project_branch(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
515 let repository = self.project.read(cx).active_repository(cx)?;
516 let workspace = self.workspace.upgrade()?;
517 let branch_name = {
518 let repo = repository.read(cx);
519 repo.branch
520 .as_ref()
521 .map(|branch| branch.name())
522 .map(|name| util::truncate_and_trailoff(&name, MAX_BRANCH_NAME_LENGTH))
523 .or_else(|| {
524 repo.head_commit.as_ref().map(|commit| {
525 commit
526 .sha
527 .chars()
528 .take(MAX_SHORT_SHA_LENGTH)
529 .collect::<String>()
530 })
531 })
532 }?;
533
534 Some(
535 Button::new("project_branch_trigger", branch_name)
536 .color(Color::Muted)
537 .style(ButtonStyle::Subtle)
538 .label_size(LabelSize::Small)
539 .tooltip(move |window, cx| {
540 Tooltip::with_meta(
541 "Recent Branches",
542 Some(&zed_actions::git::Branch),
543 "Local branches only",
544 window,
545 cx,
546 )
547 })
548 .on_click(move |_, window, cx| {
549 let _ = workspace.update(cx, |_this, cx| {
550 window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx);
551 });
552 }),
553 )
554 }
555
556 fn window_activation_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
557 if window.is_window_active() {
558 ActiveCall::global(cx)
559 .update(cx, |call, cx| call.set_location(Some(&self.project), cx))
560 .detach_and_log_err(cx);
561 } else if cx.active_window().is_none() {
562 ActiveCall::global(cx)
563 .update(cx, |call, cx| call.set_location(None, cx))
564 .detach_and_log_err(cx);
565 }
566 self.workspace
567 .update(cx, |workspace, cx| {
568 workspace.update_active_view_for_followers(window, cx);
569 })
570 .ok();
571 }
572
573 fn active_call_changed(&mut self, cx: &mut Context<Self>) {
574 cx.notify();
575 }
576
577 fn share_project(&mut self, cx: &mut Context<Self>) {
578 let active_call = ActiveCall::global(cx);
579 let project = self.project.clone();
580 active_call
581 .update(cx, |call, cx| call.share_project(project, cx))
582 .detach_and_log_err(cx);
583 }
584
585 fn unshare_project(&mut self, _: &mut Window, cx: &mut Context<Self>) {
586 let active_call = ActiveCall::global(cx);
587 let project = self.project.clone();
588 active_call
589 .update(cx, |call, cx| call.unshare_project(project, cx))
590 .log_err();
591 }
592
593 fn render_connection_status(
594 &self,
595 status: &client::Status,
596 cx: &mut Context<Self>,
597 ) -> Option<AnyElement> {
598 match status {
599 client::Status::ConnectionError
600 | client::Status::ConnectionLost
601 | client::Status::Reauthenticating { .. }
602 | client::Status::Reconnecting { .. }
603 | client::Status::ReconnectionError { .. } => Some(
604 div()
605 .id("disconnected")
606 .child(Icon::new(IconName::Disconnected).size(IconSize::Small))
607 .tooltip(Tooltip::text("Disconnected"))
608 .into_any_element(),
609 ),
610 client::Status::UpgradeRequired => {
611 let auto_updater = auto_update::AutoUpdater::get(cx);
612 let label = match auto_updater.map(|auto_update| auto_update.read(cx).status()) {
613 Some(AutoUpdateStatus::Updated { .. }) => "Please restart Zed to Collaborate",
614 Some(AutoUpdateStatus::Installing)
615 | Some(AutoUpdateStatus::Downloading)
616 | Some(AutoUpdateStatus::Checking) => "Updating...",
617 Some(AutoUpdateStatus::Idle) | Some(AutoUpdateStatus::Errored) | None => {
618 "Please update Zed to Collaborate"
619 }
620 };
621
622 Some(
623 Button::new("connection-status", label)
624 .label_size(LabelSize::Small)
625 .on_click(|_, window, cx| {
626 if let Some(auto_updater) = auto_update::AutoUpdater::get(cx) {
627 if auto_updater.read(cx).status().is_updated() {
628 workspace::reload(&Default::default(), cx);
629 return;
630 }
631 }
632 auto_update::check(&Default::default(), window, cx);
633 })
634 .into_any_element(),
635 )
636 }
637 _ => None,
638 }
639 }
640
641 pub fn render_sign_in_button(&mut self, _: &mut Context<Self>) -> Button {
642 let client = self.client.clone();
643 Button::new("sign_in", "Sign in")
644 .label_size(LabelSize::Small)
645 .on_click(move |_, window, cx| {
646 let client = client.clone();
647 window
648 .spawn(cx, async move |cx| {
649 client
650 .authenticate_and_connect(true, &cx)
651 .await
652 .notify_async_err(cx);
653 })
654 .detach();
655 })
656 }
657
658 pub fn render_user_menu_button(&mut self, cx: &mut Context<Self>) -> impl Element {
659 let user_store = self.user_store.read(cx);
660 if let Some(user) = user_store.current_user() {
661 let plan = user_store.current_plan();
662 PopoverMenu::new("user-menu")
663 .anchor(Corner::TopRight)
664 .menu(move |window, cx| {
665 ContextMenu::build(window, cx, |menu, _, cx| {
666 menu.when(cx.has_flag::<NewBillingFeatureFlag>(), |menu| {
667 menu.action(
668 format!(
669 "Current Plan: {}",
670 match plan {
671 None => "",
672 Some(proto::Plan::Free) => "Free",
673 Some(proto::Plan::ZedPro) => "Pro",
674 Some(proto::Plan::ZedProTrial) => "Pro (Trial)",
675 }
676 ),
677 zed_actions::OpenAccountSettings.boxed_clone(),
678 )
679 .separator()
680 })
681 .action("Settings", zed_actions::OpenSettings.boxed_clone())
682 .action("Key Bindings", Box::new(zed_actions::OpenKeymap))
683 .action(
684 "Themes…",
685 zed_actions::theme_selector::Toggle::default().boxed_clone(),
686 )
687 .action(
688 "Icon Themes…",
689 zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
690 )
691 .action(
692 "Extensions",
693 zed_actions::Extensions::default().boxed_clone(),
694 )
695 .separator()
696 .link(
697 "Book Onboarding",
698 OpenBrowser {
699 url: BOOK_ONBOARDING.to_string(),
700 }
701 .boxed_clone(),
702 )
703 .action("Sign Out", client::SignOut.boxed_clone())
704 })
705 .into()
706 })
707 .trigger_with_tooltip(
708 ButtonLike::new("user-menu")
709 .child(
710 h_flex()
711 .gap_0p5()
712 .children(
713 workspace::WorkspaceSettings::get_global(cx)
714 .show_user_picture
715 .then(|| Avatar::new(user.avatar_uri.clone())),
716 )
717 .child(
718 Icon::new(IconName::ChevronDown)
719 .size(IconSize::Small)
720 .color(Color::Muted),
721 ),
722 )
723 .style(ButtonStyle::Subtle),
724 Tooltip::text("Toggle User Menu"),
725 )
726 .anchor(gpui::Corner::TopRight)
727 } else {
728 PopoverMenu::new("user-menu")
729 .anchor(Corner::TopRight)
730 .menu(|window, cx| {
731 ContextMenu::build(window, cx, |menu, _, _| {
732 menu.action("Settings", zed_actions::OpenSettings.boxed_clone())
733 .action("Key Bindings", Box::new(zed_actions::OpenKeymap))
734 .action(
735 "Themes…",
736 zed_actions::theme_selector::Toggle::default().boxed_clone(),
737 )
738 .action(
739 "Icon Themes…",
740 zed_actions::icon_theme_selector::Toggle::default().boxed_clone(),
741 )
742 .action(
743 "Extensions",
744 zed_actions::Extensions::default().boxed_clone(),
745 )
746 .separator()
747 .link(
748 "Book Onboarding",
749 OpenBrowser {
750 url: BOOK_ONBOARDING.to_string(),
751 }
752 .boxed_clone(),
753 )
754 })
755 .into()
756 })
757 .trigger_with_tooltip(
758 IconButton::new("user-menu", IconName::ChevronDown).icon_size(IconSize::Small),
759 Tooltip::text("Toggle User Menu"),
760 )
761 }
762 }
763}
764
765impl InteractiveElement for TitleBar {
766 fn interactivity(&mut self) -> &mut Interactivity {
767 self.content.interactivity()
768 }
769}
770
771impl StatefulInteractiveElement for TitleBar {}
772
773impl ParentElement for TitleBar {
774 fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
775 self.children.extend(elements)
776 }
777}