1use crate::{status_bar::StatusItemView, Axis, Workspace};
2use gpui::{
3 div, px, Action, AnyView, AppContext, Component, Div, Entity, EntityId, EventEmitter,
4 FocusHandle, ParentComponent, Render, Styled, Subscription, View, ViewContext, WeakView,
5 WindowContext,
6};
7use schemars::JsonSchema;
8use serde::{Deserialize, Serialize};
9use std::sync::Arc;
10use ui::{h_stack, IconButton, InteractionState, Tooltip};
11
12pub enum PanelEvent {
13 ChangePosition,
14 ZoomIn,
15 ZoomOut,
16 Activate,
17 Close,
18 Focus,
19}
20
21pub trait Panel: Render + EventEmitter<PanelEvent> {
22 fn persistent_name(&self) -> &'static str;
23 fn position(&self, cx: &WindowContext) -> DockPosition;
24 fn position_is_valid(&self, position: DockPosition) -> bool;
25 fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>);
26 fn size(&self, cx: &WindowContext) -> f32;
27 fn set_size(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>);
28 fn icon(&self, cx: &WindowContext) -> Option<ui::Icon>;
29 fn toggle_action(&self) -> Box<dyn Action>;
30 fn icon_label(&self, _: &WindowContext) -> Option<String> {
31 None
32 }
33 fn is_zoomed(&self, _cx: &WindowContext) -> bool {
34 false
35 }
36 fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
37 fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
38 fn has_focus(&self, cx: &WindowContext) -> bool;
39 fn focus_handle(&self, cx: &WindowContext) -> FocusHandle;
40}
41
42pub trait PanelHandle: Send + Sync {
43 fn id(&self) -> EntityId;
44 fn persistent_name(&self, cx: &WindowContext) -> &'static str;
45 fn position(&self, cx: &WindowContext) -> DockPosition;
46 fn position_is_valid(&self, position: DockPosition, cx: &WindowContext) -> bool;
47 fn set_position(&self, position: DockPosition, cx: &mut WindowContext);
48 fn is_zoomed(&self, cx: &WindowContext) -> bool;
49 fn set_zoomed(&self, zoomed: bool, cx: &mut WindowContext);
50 fn set_active(&self, active: bool, cx: &mut WindowContext);
51 fn size(&self, cx: &WindowContext) -> f32;
52 fn set_size(&self, size: Option<f32>, cx: &mut WindowContext);
53 fn icon(&self, cx: &WindowContext) -> Option<ui::Icon>;
54 fn toggle_action(&self, cx: &WindowContext) -> Box<dyn Action>;
55 fn icon_label(&self, cx: &WindowContext) -> Option<String>;
56 fn has_focus(&self, cx: &WindowContext) -> bool;
57 fn focus_handle(&self, cx: &WindowContext) -> FocusHandle;
58 fn to_any(&self) -> AnyView;
59}
60
61impl<T> PanelHandle for View<T>
62where
63 T: Panel,
64{
65 fn id(&self) -> EntityId {
66 self.entity_id()
67 }
68
69 fn persistent_name(&self, cx: &WindowContext) -> &'static str {
70 self.read(cx).persistent_name()
71 }
72
73 fn position(&self, cx: &WindowContext) -> DockPosition {
74 self.read(cx).position(cx)
75 }
76
77 fn position_is_valid(&self, position: DockPosition, cx: &WindowContext) -> bool {
78 self.read(cx).position_is_valid(position)
79 }
80
81 fn set_position(&self, position: DockPosition, cx: &mut WindowContext) {
82 self.update(cx, |this, cx| this.set_position(position, cx))
83 }
84
85 fn is_zoomed(&self, cx: &WindowContext) -> bool {
86 self.read(cx).is_zoomed(cx)
87 }
88
89 fn set_zoomed(&self, zoomed: bool, cx: &mut WindowContext) {
90 self.update(cx, |this, cx| this.set_zoomed(zoomed, cx))
91 }
92
93 fn set_active(&self, active: bool, cx: &mut WindowContext) {
94 self.update(cx, |this, cx| this.set_active(active, cx))
95 }
96
97 fn size(&self, cx: &WindowContext) -> f32 {
98 self.read(cx).size(cx)
99 }
100
101 fn set_size(&self, size: Option<f32>, cx: &mut WindowContext) {
102 self.update(cx, |this, cx| this.set_size(size, cx))
103 }
104
105 fn icon(&self, cx: &WindowContext) -> Option<ui::Icon> {
106 self.read(cx).icon(cx)
107 }
108
109 fn toggle_action(&self, cx: &WindowContext) -> Box<dyn Action> {
110 self.read(cx).toggle_action()
111 }
112
113 fn icon_label(&self, cx: &WindowContext) -> Option<String> {
114 self.read(cx).icon_label(cx)
115 }
116
117 fn has_focus(&self, cx: &WindowContext) -> bool {
118 self.read(cx).has_focus(cx)
119 }
120
121 fn to_any(&self) -> AnyView {
122 self.clone().into()
123 }
124
125 fn focus_handle(&self, cx: &WindowContext) -> FocusHandle {
126 self.read(cx).focus_handle(cx).clone()
127 }
128}
129
130impl From<&dyn PanelHandle> for AnyView {
131 fn from(val: &dyn PanelHandle) -> Self {
132 val.to_any()
133 }
134}
135
136pub struct Dock {
137 position: DockPosition,
138 panel_entries: Vec<PanelEntry>,
139 is_open: bool,
140 active_panel_index: usize,
141}
142
143#[derive(Clone, Copy, Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
144#[serde(rename_all = "lowercase")]
145pub enum DockPosition {
146 Left,
147 Bottom,
148 Right,
149}
150
151impl DockPosition {
152 fn to_label(&self) -> &'static str {
153 match self {
154 Self::Left => "left",
155 Self::Bottom => "bottom",
156 Self::Right => "right",
157 }
158 }
159
160 // todo!()
161 // fn to_resize_handle_side(self) -> HandleSide {
162 // match self {
163 // Self::Left => HandleSide::Right,
164 // Self::Bottom => HandleSide::Top,
165 // Self::Right => HandleSide::Left,
166 // }
167 // }
168
169 pub fn axis(&self) -> Axis {
170 match self {
171 Self::Left | Self::Right => Axis::Horizontal,
172 Self::Bottom => Axis::Vertical,
173 }
174 }
175}
176
177struct PanelEntry {
178 panel: Arc<dyn PanelHandle>,
179 // todo!()
180 // context_menu: View<ContextMenu>,
181 _subscriptions: [Subscription; 2],
182}
183
184pub struct PanelButtons {
185 dock: View<Dock>,
186 workspace: WeakView<Workspace>,
187}
188
189impl Dock {
190 pub fn new(position: DockPosition) -> Self {
191 Self {
192 position,
193 panel_entries: Default::default(),
194 active_panel_index: 0,
195 is_open: false,
196 }
197 }
198
199 pub fn position(&self) -> DockPosition {
200 self.position
201 }
202
203 pub fn is_open(&self) -> bool {
204 self.is_open
205 }
206
207 // pub fn has_focus(&self, cx: &WindowContext) -> bool {
208 // self.visible_panel()
209 // .map_or(false, |panel| panel.has_focus(cx))
210 // }
211
212 // pub fn panel<T: Panel>(&self) -> Option<View<T>> {
213 // self.panel_entries
214 // .iter()
215 // .find_map(|entry| entry.panel.as_any().clone().downcast())
216 // }
217
218 pub fn panel_index_for_type<T: Panel>(&self) -> Option<usize> {
219 self.panel_entries
220 .iter()
221 .position(|entry| entry.panel.to_any().downcast::<T>().is_ok())
222 }
223
224 pub fn panel_index_for_ui_name(&self, _ui_name: &str, _cx: &AppContext) -> Option<usize> {
225 todo!()
226 // self.panel_entries.iter().position(|entry| {
227 // let panel = entry.panel.as_any();
228 // cx.view_ui_name(panel.window(), panel.id()) == Some(ui_name)
229 // })
230 }
231
232 pub fn active_panel_index(&self) -> usize {
233 self.active_panel_index
234 }
235
236 pub(crate) fn set_open(&mut self, open: bool, cx: &mut ViewContext<Self>) {
237 if open != self.is_open {
238 self.is_open = open;
239 if let Some(active_panel) = self.panel_entries.get(self.active_panel_index) {
240 active_panel.panel.set_active(open, cx);
241 }
242
243 cx.notify();
244 }
245 }
246
247 // todo!()
248 // pub fn set_panel_zoomed(&mut self, panel: &AnyView, zoomed: bool, cx: &mut ViewContext<Self>) {
249 // for entry in &mut self.panel_entries {
250 // if entry.panel.as_any() == panel {
251 // if zoomed != entry.panel.is_zoomed(cx) {
252 // entry.panel.set_zoomed(zoomed, cx);
253 // }
254 // } else if entry.panel.is_zoomed(cx) {
255 // entry.panel.set_zoomed(false, cx);
256 // }
257 // }
258
259 // cx.notify();
260 // }
261
262 pub fn zoom_out(&mut self, cx: &mut ViewContext<Self>) {
263 for entry in &mut self.panel_entries {
264 if entry.panel.is_zoomed(cx) {
265 entry.panel.set_zoomed(false, cx);
266 }
267 }
268 }
269
270 pub(crate) fn add_panel<T: Panel>(&mut self, panel: View<T>, cx: &mut ViewContext<Self>) {
271 let subscriptions = [
272 cx.observe(&panel, |_, _, cx| cx.notify()),
273 cx.subscribe(&panel, |this, panel, event, cx| {
274 match event {
275 PanelEvent::ChangePosition => {
276 //todo!()
277 // see: Workspace::add_panel_with_extra_event_handler
278 }
279 PanelEvent::ZoomIn => {
280 //todo!()
281 // see: Workspace::add_panel_with_extra_event_handler
282 }
283 PanelEvent::ZoomOut => {
284 // todo!()
285 // // see: Workspace::add_panel_with_extra_event_handler
286 }
287 PanelEvent::Activate => {
288 if let Some(ix) = this
289 .panel_entries
290 .iter()
291 .position(|entry| entry.panel.id() == panel.id())
292 {
293 this.set_open(true, cx);
294 this.activate_panel(ix, cx);
295 //` todo!()
296 // cx.focus(&panel);
297 }
298 }
299 PanelEvent::Close => {
300 if this.visible_panel().map_or(false, |p| p.id() == panel.id()) {
301 this.set_open(false, cx);
302 }
303 }
304 PanelEvent::Focus => todo!(),
305 }
306 }),
307 ];
308
309 // todo!()
310 // let dock_view_id = cx.view_id();
311 self.panel_entries.push(PanelEntry {
312 panel: Arc::new(panel),
313 // todo!()
314 // context_menu: cx.add_view(|cx| {
315 // let mut menu = ContextMenu::new(dock_view_id, cx);
316 // menu.set_position_mode(OverlayPositionMode::Local);
317 // menu
318 // }),
319 _subscriptions: subscriptions,
320 });
321 cx.notify()
322 }
323
324 pub fn remove_panel<T: Panel>(&mut self, panel: &View<T>, cx: &mut ViewContext<Self>) {
325 if let Some(panel_ix) = self
326 .panel_entries
327 .iter()
328 .position(|entry| entry.panel.id() == panel.id())
329 {
330 if panel_ix == self.active_panel_index {
331 self.active_panel_index = 0;
332 self.set_open(false, cx);
333 } else if panel_ix < self.active_panel_index {
334 self.active_panel_index -= 1;
335 }
336 self.panel_entries.remove(panel_ix);
337 cx.notify();
338 }
339 }
340
341 pub fn panels_len(&self) -> usize {
342 self.panel_entries.len()
343 }
344
345 pub fn activate_panel(&mut self, panel_ix: usize, cx: &mut ViewContext<Self>) {
346 if panel_ix != self.active_panel_index {
347 if let Some(active_panel) = self.panel_entries.get(self.active_panel_index) {
348 active_panel.panel.set_active(false, cx);
349 }
350
351 self.active_panel_index = panel_ix;
352 if let Some(active_panel) = self.panel_entries.get(self.active_panel_index) {
353 active_panel.panel.set_active(true, cx);
354 }
355
356 cx.notify();
357 }
358 }
359
360 pub fn visible_panel(&self) -> Option<&Arc<dyn PanelHandle>> {
361 let entry = self.visible_entry()?;
362 Some(&entry.panel)
363 }
364
365 pub fn active_panel(&self) -> Option<&Arc<dyn PanelHandle>> {
366 Some(&self.panel_entries.get(self.active_panel_index)?.panel)
367 }
368
369 fn visible_entry(&self) -> Option<&PanelEntry> {
370 if self.is_open {
371 self.panel_entries.get(self.active_panel_index)
372 } else {
373 None
374 }
375 }
376
377 pub fn zoomed_panel(&self, cx: &WindowContext) -> Option<Arc<dyn PanelHandle>> {
378 let entry = self.visible_entry()?;
379 if entry.panel.is_zoomed(cx) {
380 Some(entry.panel.clone())
381 } else {
382 None
383 }
384 }
385
386 pub fn panel_size(&self, panel: &dyn PanelHandle, cx: &WindowContext) -> Option<f32> {
387 self.panel_entries
388 .iter()
389 .find(|entry| entry.panel.id() == panel.id())
390 .map(|entry| entry.panel.size(cx))
391 }
392
393 pub fn active_panel_size(&self, cx: &WindowContext) -> Option<f32> {
394 if self.is_open {
395 self.panel_entries
396 .get(self.active_panel_index)
397 .map(|entry| entry.panel.size(cx))
398 } else {
399 None
400 }
401 }
402
403 pub fn resize_active_panel(&mut self, size: Option<f32>, cx: &mut ViewContext<Self>) {
404 if let Some(entry) = self.panel_entries.get_mut(self.active_panel_index) {
405 entry.panel.set_size(size, cx);
406 cx.notify();
407 }
408 }
409
410 // pub fn render_placeholder(&self, cx: &WindowContext) -> AnyElement<Workspace> {
411 // todo!()
412 // if let Some(active_entry) = self.visible_entry() {
413 // Empty::new()
414 // .into_any()
415 // .contained()
416 // .with_style(self.style(cx))
417 // .resizable::<WorkspaceBounds>(
418 // self.position.to_resize_handle_side(),
419 // active_entry.panel.size(cx),
420 // |_, _, _| {},
421 // )
422 // .into_any()
423 // } else {
424 // Empty::new().into_any()
425 // }
426 // }
427}
428
429impl Render for Dock {
430 type Element = Div<Self>;
431
432 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
433 if let Some(entry) = self.visible_entry() {
434 let size = entry.panel.size(cx);
435
436 div()
437 .map(|this| match self.position().axis() {
438 Axis::Horizontal => this.w(px(size)).h_full(),
439 Axis::Vertical => this.h(px(size)).w_full(),
440 })
441 .child(entry.panel.to_any())
442 } else {
443 div()
444 }
445 }
446}
447
448// todo!()
449// impl View for Dock {
450// fn ui_name() -> &'static str {
451// "Dock"
452// }
453
454// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
455// if let Some(active_entry) = self.visible_entry() {
456// let style = self.style(cx);
457// ChildView::new(active_entry.panel.as_any(), cx)
458// .contained()
459// .with_style(style)
460// .resizable::<WorkspaceBounds>(
461// self.position.to_resize_handle_side(),
462// active_entry.panel.size(cx),
463// |dock: &mut Self, size, cx| dock.resize_active_panel(size, cx),
464// )
465// .into_any()
466// } else {
467// Empty::new().into_any()
468// }
469// }
470
471// fn focus_in(&mut self, _: AnyViewHandle, cx: &mut ViewContext<Self>) {
472// if cx.is_self_focused() {
473// if let Some(active_entry) = self.visible_entry() {
474// cx.focus(active_entry.panel.as_any());
475// } else {
476// cx.focus_parent();
477// }
478// }
479// }
480// }
481
482impl PanelButtons {
483 pub fn new(
484 dock: View<Dock>,
485 workspace: WeakView<Workspace>,
486 cx: &mut ViewContext<Self>,
487 ) -> Self {
488 cx.observe(&dock, |_, _, cx| cx.notify()).detach();
489 Self { dock, workspace }
490 }
491}
492
493// impl Render for PanelButtons {
494// type Element = ();
495
496// fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
497// todo!("")
498// }
499
500// fn ui_name() -> &'static str {
501// "PanelButtons"
502// }
503
504// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
505// let theme = &settings::get::<ThemeSettings>(cx).theme;
506// let tooltip_style = theme.tooltip.clone();
507// let theme = &theme.workspace.status_bar.panel_buttons;
508// let button_style = theme.button.clone();
509// let dock = self.dock.read(cx);
510// let active_ix = dock.active_panel_index;
511// let is_open = dock.is_open;
512// let dock_position = dock.position;
513// let group_style = match dock_position {
514// DockPosition::Left => theme.group_left,
515// DockPosition::Bottom => theme.group_bottom,
516// DockPosition::Right => theme.group_right,
517// };
518// let menu_corner = match dock_position {
519// DockPosition::Left => AnchorCorner::BottomLeft,
520// DockPosition::Bottom | DockPosition::Right => AnchorCorner::BottomRight,
521// };
522
523// let panels = dock
524// .panel_entries
525// .iter()
526// .map(|item| (item.panel.clone(), item.context_menu.clone()))
527// .collect::<Vec<_>>();
528// Flex::row()
529// .with_children(panels.into_iter().enumerate().filter_map(
530// |(panel_ix, (view, context_menu))| {
531// let icon_path = view.icon_path(cx)?;
532// let is_active = is_open && panel_ix == active_ix;
533// let (tooltip, tooltip_action) = if is_active {
534// (
535// format!("Close {} dock", dock_position.to_label()),
536// Some(match dock_position {
537// DockPosition::Left => crate::ToggleLeftDock.boxed_clone(),
538// DockPosition::Bottom => crate::ToggleBottomDock.boxed_clone(),
539// DockPosition::Right => crate::ToggleRightDock.boxed_clone(),
540// }),
541// )
542// } else {
543// view.icon_tooltip(cx)
544// };
545// Some(
546// Stack::new()
547// .with_child(
548// MouseEventHandler::new::<Self, _>(panel_ix, cx, |state, cx| {
549// let style = button_style.in_state(is_active);
550
551// let style = style.style_for(state);
552// Flex::row()
553// .with_child(
554// Svg::new(icon_path)
555// .with_color(style.icon_color)
556// .constrained()
557// .with_width(style.icon_size)
558// .aligned(),
559// )
560// .with_children(if let Some(label) = view.icon_label(cx) {
561// Some(
562// Label::new(label, style.label.text.clone())
563// .contained()
564// .with_style(style.label.container)
565// .aligned(),
566// )
567// } else {
568// None
569// })
570// .constrained()
571// .with_height(style.icon_size)
572// .contained()
573// .with_style(style.container)
574// })
575// .with_cursor_style(CursorStyle::PointingHand)
576// .on_click(MouseButton::Left, {
577// let tooltip_action =
578// tooltip_action.as_ref().map(|action| action.boxed_clone());
579// move |_, this, cx| {
580// if let Some(tooltip_action) = &tooltip_action {
581// let window = cx.window();
582// let view_id = this.workspace.id();
583// let tooltip_action = tooltip_action.boxed_clone();
584// cx.spawn(|_, mut cx| async move {
585// window.dispatch_action(
586// view_id,
587// &*tooltip_action,
588// &mut cx,
589// );
590// })
591// .detach();
592// }
593// }
594// })
595// .on_click(MouseButton::Right, {
596// let view = view.clone();
597// let menu = context_menu.clone();
598// move |_, _, cx| {
599// const POSITIONS: [DockPosition; 3] = [
600// DockPosition::Left,
601// DockPosition::Right,
602// DockPosition::Bottom,
603// ];
604
605// menu.update(cx, |menu, cx| {
606// let items = POSITIONS
607// .into_iter()
608// .filter(|position| {
609// *position != dock_position
610// && view.position_is_valid(*position, cx)
611// })
612// .map(|position| {
613// let view = view.clone();
614// ContextMenuItem::handler(
615// format!("Dock {}", position.to_label()),
616// move |cx| view.set_position(position, cx),
617// )
618// })
619// .collect();
620// menu.show(Default::default(), menu_corner, items, cx);
621// })
622// }
623// })
624// .with_tooltip::<Self>(
625// panel_ix,
626// tooltip,
627// tooltip_action,
628// tooltip_style.clone(),
629// cx,
630// ),
631// )
632// .with_child(ChildView::new(&context_menu, cx)),
633// )
634// },
635// ))
636// .contained()
637// .with_style(group_style)
638// .into_any()
639// }
640// }
641
642impl Render for PanelButtons {
643 type Element = Div<Self>;
644
645 fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
646 // todo!()
647 let dock = self.dock.read(cx);
648 let active_index = dock.active_panel_index;
649 let is_open = dock.is_open;
650
651 let buttons = dock
652 .panel_entries
653 .iter()
654 .enumerate()
655 .filter_map(|(i, panel)| {
656 let icon = panel.panel.icon(cx)?;
657 let name = panel.panel.persistent_name(cx);
658 let action = panel.panel.toggle_action(cx);
659 let action2 = action.boxed_clone();
660
661 let mut button = IconButton::new(panel.panel.persistent_name(cx), icon)
662 .when(i == active_index, |el| el.state(InteractionState::Active))
663 .on_click(move |this, cx| cx.dispatch_action(action.boxed_clone()))
664 .tooltip(move |_, cx| Tooltip::for_action(name, &*action2, cx));
665
666 Some(button)
667 });
668
669 h_stack().children(buttons)
670 }
671}
672
673impl StatusItemView for PanelButtons {
674 fn set_active_pane_item(
675 &mut self,
676 _active_pane_item: Option<&dyn crate::ItemHandle>,
677 _cx: &mut ViewContext<Self>,
678 ) {
679 // Nothing to do, panel buttons don't depend on the active center item
680 }
681}
682
683#[cfg(any(test, feature = "test-support"))]
684pub mod test {
685 use super::*;
686 use gpui::{actions, div, Div, ViewContext, WindowContext};
687
688 pub struct TestPanel {
689 pub position: DockPosition,
690 pub zoomed: bool,
691 pub active: bool,
692 pub has_focus: bool,
693 pub size: f32,
694 }
695 actions!(ToggleTestPanel);
696
697 impl EventEmitter<PanelEvent> for TestPanel {}
698
699 impl TestPanel {
700 pub fn new(position: DockPosition) -> Self {
701 Self {
702 position,
703 zoomed: false,
704 active: false,
705 has_focus: false,
706 size: 300.,
707 }
708 }
709 }
710
711 impl Render for TestPanel {
712 type Element = Div<Self>;
713
714 fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
715 div()
716 }
717 }
718
719 impl Panel for TestPanel {
720 fn persistent_name(&self) -> &'static str {
721 "TestPanel"
722 }
723
724 fn position(&self, _: &gpui::WindowContext) -> super::DockPosition {
725 self.position
726 }
727
728 fn position_is_valid(&self, _: super::DockPosition) -> bool {
729 true
730 }
731
732 fn set_position(&mut self, position: DockPosition, cx: &mut ViewContext<Self>) {
733 self.position = position;
734 cx.emit(PanelEvent::ChangePosition);
735 }
736
737 fn size(&self, _: &WindowContext) -> f32 {
738 self.size
739 }
740
741 fn set_size(&mut self, size: Option<f32>, _: &mut ViewContext<Self>) {
742 self.size = size.unwrap_or(300.);
743 }
744
745 fn icon(&self, _: &WindowContext) -> Option<ui::Icon> {
746 None
747 }
748
749 fn toggle_action(&self) -> Box<dyn Action> {
750 ToggleTestPanel.boxed_clone()
751 }
752
753 fn is_zoomed(&self, _: &WindowContext) -> bool {
754 self.zoomed
755 }
756
757 fn set_zoomed(&mut self, zoomed: bool, _cx: &mut ViewContext<Self>) {
758 self.zoomed = zoomed;
759 }
760
761 fn set_active(&mut self, active: bool, _cx: &mut ViewContext<Self>) {
762 self.active = active;
763 }
764
765 fn has_focus(&self, _cx: &WindowContext) -> bool {
766 self.has_focus
767 }
768
769 fn focus_handle(&self, cx: &WindowContext) -> FocusHandle {
770 unimplemented!()
771 }
772 }
773}