migrate resizable onto gpui-base

This commit is contained in:
2026-09-17 16:58:35 +07:00
parent 84e8ad29bc
commit a7baa03c64
5 changed files with 49 additions and 926 deletions
+14 -2
View File
@@ -7,12 +7,13 @@ use gpui::{
MouseUpEvent, ParentElement as _, Pixels, Point, Render, Style, StyleRefinement, Styled as _,
WeakEntity, Window, div, px,
};
use gpui_base::Side;
use super::{DockArea, DockItem};
use crate::StyledExt;
use crate::dock::panel::PanelView;
use crate::dock::tab_panel::TabPanel;
use crate::resizable::{PANEL_MIN_SIZE, resize_handle};
use crate::resizable::{PANEL_MIN_SIZE, resize_handle, resize_handle_appearance};
#[derive(Clone)]
struct ResizePanel;
@@ -51,6 +52,16 @@ impl DockPlacement {
pub fn is_right(&self) -> bool {
matches!(self, Self::Right)
}
/// Base positions the handle against the window edge for the left dock only,
/// so every other placement is the same to it as the right one.
fn side(&self) -> Side {
if self.is_left() {
Side::Left
} else {
Side::Right
}
}
}
/// The Dock is a fixed container that places at left, bottom, right of the Windows.
@@ -242,7 +253,8 @@ impl Dock {
let view = cx.entity().clone();
resize_handle("resize-handle", axis)
.placement(self.placement)
.placement(self.placement.side())
.with_appearance(resize_handle_appearance())
.on_drag(ResizePanel {}, move |info, _, _, cx| {
cx.stop_propagation();
view.update(cx, |view, _cx| {