migrate resizable onto gpui-base
This commit is contained in:
@@ -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| {
|
||||
|
||||
Reference in New Issue
Block a user