WIP
co-authored-by: conrad <conrad@zed.dev> co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
6985b70859
commit
2c4d83c9af
96 changed files with 1926 additions and 1955 deletions
|
@ -8,9 +8,7 @@ use schemars::JsonSchema;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use theme2::ActiveTheme;
|
||||
use ui::{
|
||||
h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Label, ListEntry, Tooltip,
|
||||
};
|
||||
use ui::{h_stack, menu_handle, ContextMenu, IconButton, InteractionState, Tooltip};
|
||||
|
||||
pub enum PanelEvent {
|
||||
ChangePosition,
|
||||
|
@ -476,8 +474,8 @@ impl Dock {
|
|||
}
|
||||
}
|
||||
|
||||
impl Render<Self> for Dock {
|
||||
type Element = Div<Self>;
|
||||
impl Render for Dock {
|
||||
type Element = Div;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
if let Some(entry) = self.visible_entry() {
|
||||
|
@ -662,8 +660,8 @@ impl PanelButtons {
|
|||
// }
|
||||
|
||||
// here be kittens
|
||||
impl Render<Self> for PanelButtons {
|
||||
type Element = Div<Self>;
|
||||
impl Render for PanelButtons {
|
||||
type Element = Div;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
// todo!()
|
||||
|
@ -688,45 +686,50 @@ impl Render<Self> for PanelButtons {
|
|||
let name = entry.panel.persistent_name();
|
||||
let panel = entry.panel.clone();
|
||||
|
||||
let mut button: IconButton<Self> = if i == active_index && is_open {
|
||||
let mut button: IconButton = if i == active_index && is_open {
|
||||
let action = dock.toggle_action();
|
||||
let tooltip: SharedString =
|
||||
format!("Close {} dock", dock.position.to_label()).into();
|
||||
IconButton::new(name, icon)
|
||||
.state(InteractionState::Active)
|
||||
.action(action.boxed_clone())
|
||||
.tooltip(move |_, cx| Tooltip::for_action(tooltip.clone(), &*action, cx))
|
||||
.tooltip(move |cx| Tooltip::for_action(tooltip.clone(), &*action, cx))
|
||||
} else {
|
||||
let action = entry.panel.toggle_action(cx);
|
||||
|
||||
IconButton::new(name, icon)
|
||||
.action(action.boxed_clone())
|
||||
.tooltip(move |_, cx| Tooltip::for_action(name, &*action, cx))
|
||||
.tooltip(move |cx| Tooltip::for_action(name, &*action, cx))
|
||||
};
|
||||
|
||||
Some(
|
||||
menu_handle(name)
|
||||
.menu(move |_, cx| {
|
||||
.menu(move |cx| {
|
||||
const POSITIONS: [DockPosition; 3] = [
|
||||
DockPosition::Left,
|
||||
DockPosition::Right,
|
||||
DockPosition::Bottom,
|
||||
];
|
||||
|
||||
//CX: Pane
|
||||
ContextMenu::build(cx, |mut menu, cx| {
|
||||
// CX: Menu
|
||||
for position in POSITIONS {
|
||||
if position != dock_position
|
||||
&& panel.position_is_valid(position, cx)
|
||||
{
|
||||
let panel = panel.clone();
|
||||
menu = menu.entry(
|
||||
ListEntry::new(Label::new(format!(
|
||||
"Dock {}",
|
||||
position.to_label()
|
||||
))),
|
||||
move |_, cx| {
|
||||
panel.set_position(position, cx);
|
||||
},
|
||||
)
|
||||
// let panel = panel.clone();
|
||||
todo!()
|
||||
// menu = menu.entry(
|
||||
// ListEntry::new(Label::new(format!(
|
||||
// "Dock {}",
|
||||
// position.to_label()
|
||||
// ))),
|
||||
// cx.listener(move |_, cx| {
|
||||
// //What should CX be? CX: Pane
|
||||
// panel.set_position(position, cx);
|
||||
// }),
|
||||
//)
|
||||
}
|
||||
}
|
||||
menu
|
||||
|
@ -780,8 +783,8 @@ pub mod test {
|
|||
}
|
||||
}
|
||||
|
||||
impl Render<Self> for TestPanel {
|
||||
type Element = Div<Self>;
|
||||
impl Render for TestPanel {
|
||||
type Element = Div;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue