layout: add panel trait

This commit is contained in:
2026-11-15 12:50:57 +07:00
parent d2ac4c446d
commit f6ba9c0d47
4 changed files with 233 additions and 134 deletions
+11 -9
View File
@@ -4,11 +4,11 @@
//! half-width islands with a drag divider that resizes them.
use gpui::{
AnyView, AppContext as _, Context, InteractiveElement as _, IntoElement, Modifiers,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _, Render,
SharedString, Styled as _, TestAppContext, VisualTestContext, Window, div, point, px, size,
AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, Modifiers, MouseButton,
MouseDownEvent, MouseMoveEvent, MouseUpEvent, ParentElement as _, Render, SharedString,
Styled as _, TestAppContext, VisualTestContext, Window, div, point, px, size,
};
use gpui_native_layout::panel::Panel;
use gpui_native_layout::panel::{Panel, PanelRow};
use gpui_native_theme::Theme;
const WINDOW_WIDTH: f32 = 1024.0;
@@ -36,15 +36,17 @@ impl Render for TagView {
}
}
impl Panel for TagView {}
struct PanelHarness {
split: bool,
main: AnyView,
split_view: AnyView,
main: Entity<TagView>,
split_view: Entity<TagView>,
}
impl Render for PanelHarness {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
let panel = Panel::new("panel-harness").main(self.main.clone());
let panel = PanelRow::new("panel-harness").main(self.main.clone());
let panel = if self.split {
panel.split(self.split_view.clone())
} else {
@@ -65,8 +67,8 @@ fn panel_window(cx: &mut TestAppContext, split: bool) -> VisualTestContext {
let window = cx.open_window(size(px(WINDOW_WIDTH), px(WINDOW_HEIGHT)), |_, _| {
PanelHarness {
split,
main: main.into(),
split_view: split_view.into(),
main,
split_view,
}
});
let cx = VisualTestContext::from_window(window.into(), cx);