wip: refactor
This commit is contained in:
@@ -244,7 +244,8 @@ impl Dock {
|
||||
.right(px(1.))
|
||||
.h_full()
|
||||
.w(HANDLE_SIZE)
|
||||
.py_10()
|
||||
.pt_12()
|
||||
.pb_4()
|
||||
})
|
||||
.when(self.placement.is_right(), |this| {
|
||||
this.cursor_col_resize()
|
||||
@@ -252,7 +253,8 @@ impl Dock {
|
||||
.left(px(1.))
|
||||
.h_full()
|
||||
.w(HANDLE_SIZE)
|
||||
.py_10()
|
||||
.pt_12()
|
||||
.pb_4()
|
||||
})
|
||||
.when(self.placement.is_bottom(), |this| {
|
||||
this.cursor_row_resize()
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::dock_area::{
|
||||
tab_panel::TabPanel,
|
||||
};
|
||||
use gpui::{
|
||||
actions, canvas, div, prelude::FluentBuilder, AnyElement, AnyView, App, AppContext, Axis,
|
||||
actions, canvas, div, prelude::FluentBuilder, px, AnyElement, AnyView, App, AppContext, Axis,
|
||||
Bounds, Context, Edges, Entity, EntityId, EventEmitter, InteractiveElement as _, IntoElement,
|
||||
ParentElement as _, Pixels, Render, SharedString, Styled, Subscription, WeakEntity, Window,
|
||||
};
|
||||
@@ -543,7 +543,7 @@ impl DockArea {
|
||||
} else {
|
||||
self.set_left_dock(
|
||||
DockItem::tabs(vec![panel], None, &weak_self, window, cx),
|
||||
None,
|
||||
Some(px(320.)),
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
@@ -569,7 +569,7 @@ impl DockArea {
|
||||
} else {
|
||||
self.set_right_dock(
|
||||
DockItem::tabs(vec![panel], None, &weak_self, window, cx),
|
||||
None,
|
||||
Some(px(320.)),
|
||||
true,
|
||||
window,
|
||||
cx,
|
||||
|
||||
@@ -42,7 +42,7 @@ pub trait Panel: EventEmitter<PanelEvent> + Render + Focusable {
|
||||
}
|
||||
|
||||
/// Whether the panel can be closed, default is `true`.
|
||||
fn closeable(&self, _cx: &App) -> bool {
|
||||
fn closable(&self, _cx: &App) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ pub trait PanelView: 'static + Send + Sync {
|
||||
fn panel_id(&self, cx: &App) -> SharedString;
|
||||
fn panel_facepile(&self, cx: &App) -> Option<Vec<String>>;
|
||||
fn title(&self, cx: &App) -> AnyElement;
|
||||
fn closeable(&self, cx: &App) -> bool;
|
||||
fn closable(&self, cx: &App) -> bool;
|
||||
fn zoomable(&self, cx: &App) -> bool;
|
||||
fn popup_menu(&self, menu: PopupMenu, cx: &App) -> PopupMenu;
|
||||
fn toolbar_buttons(&self, window: &Window, cx: &App) -> Vec<Button>;
|
||||
@@ -87,8 +87,8 @@ impl<T: Panel> PanelView for Entity<T> {
|
||||
self.read(cx).title(cx)
|
||||
}
|
||||
|
||||
fn closeable(&self, cx: &App) -> bool {
|
||||
self.read(cx).closeable(cx)
|
||||
fn closable(&self, cx: &App) -> bool {
|
||||
self.read(cx).closable(cx)
|
||||
}
|
||||
|
||||
fn zoomable(&self, cx: &App) -> bool {
|
||||
|
||||
@@ -89,14 +89,14 @@ impl Panel for TabPanel {
|
||||
.unwrap_or("Empty Tab".into_any_element())
|
||||
}
|
||||
|
||||
fn closeable(&self, cx: &App) -> bool {
|
||||
fn closable(&self, cx: &App) -> bool {
|
||||
if !self.closeable {
|
||||
return false;
|
||||
}
|
||||
|
||||
self.active_panel()
|
||||
.map(|panel| panel.closeable(cx))
|
||||
.unwrap_or(false)
|
||||
.map(|panel| panel.closable(cx))
|
||||
.unwrap_or(true)
|
||||
}
|
||||
|
||||
fn zoomable(&self, cx: &App) -> bool {
|
||||
@@ -409,6 +409,7 @@ impl TabPanel {
|
||||
}
|
||||
|
||||
let dock_area = self.dock_area.upgrade()?.read(cx);
|
||||
|
||||
if !dock_area.is_dock_collapsible(placement, cx) {
|
||||
return None;
|
||||
}
|
||||
@@ -651,6 +652,7 @@ impl TabPanel {
|
||||
.h_full()
|
||||
.flex_grow()
|
||||
.min_w_16()
|
||||
.rounded(px(cx.theme().radius))
|
||||
.when(state.droppable, |this| {
|
||||
this.drag_over::<DragPanel>(|this, _, _, cx| {
|
||||
this.bg(cx.theme().base.step(cx, ColorScaleStep::TWO))
|
||||
@@ -1013,7 +1015,7 @@ impl Render for TabPanel {
|
||||
let focus_handle = self.focus_handle(cx);
|
||||
|
||||
let mut state = TabState {
|
||||
closeable: self.closeable(cx),
|
||||
closeable: self.closable(cx),
|
||||
draggable: self.draggable(cx),
|
||||
droppable: self.droppable(cx),
|
||||
zoomable: self.zoomable(cx),
|
||||
|
||||
Reference in New Issue
Block a user