add theme titlebar height and app-owned strip dragging
This commit is contained in:
+22
-12
@@ -7,9 +7,9 @@ use std::rc::Rc;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, AnyView, App, AppContext as _, Axis, Context, ElementId, Entity,
|
||||
InteractiveElement as _, IntoElement, ParentElement as _, Render, RenderOnce, Role,
|
||||
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window,
|
||||
WindowControlArea, canvas, div, px, relative, size,
|
||||
InteractiveElement as _, IntoElement, ParentElement as _, Pixels, Render, RenderOnce, Role,
|
||||
SharedString, StatefulInteractiveElement as _, StyleRefinement, Styled as _, Window, canvas,
|
||||
div, px, relative, size,
|
||||
};
|
||||
use gpui_native_core::common::{h_flex, v_flex};
|
||||
use gpui_native_core::context_menu::ContextMenu;
|
||||
@@ -19,7 +19,7 @@ use gpui_native_icons::IconRole;
|
||||
use gpui_native_theme::{ActiveTheme as _, Size};
|
||||
|
||||
use crate::resize_handle::ResizeHandle;
|
||||
use crate::window_controls::{TRAFFIC_LIGHT_PAD, WindowControls, maximize_on_double_click};
|
||||
use crate::window_controls::{TRAFFIC_LIGHT_PAD, WindowControls, titlebar_strip};
|
||||
|
||||
/// The narrowest either side of a split can get, as a fraction of the split.
|
||||
const MIN_SPLIT_RATIO: f32 = 0.1;
|
||||
@@ -789,6 +789,7 @@ impl RenderOnce for Dock {
|
||||
let titlebar = Titlebar {
|
||||
window_controls: self.window_controls,
|
||||
traffic_light_pad: self.traffic_light_pad,
|
||||
height: cx.theme().titlebar_height,
|
||||
};
|
||||
let root = render_node(&self.id, &self.state, &tree, &titlebar, window, cx);
|
||||
|
||||
@@ -811,6 +812,7 @@ impl RenderOnce for Dock {
|
||||
struct Titlebar {
|
||||
window_controls: bool,
|
||||
traffic_light_pad: bool,
|
||||
height: Pixels,
|
||||
}
|
||||
|
||||
/// The right sidebar content of the dock's active panel.
|
||||
@@ -997,7 +999,7 @@ fn render_pane(
|
||||
let pane = pane.clone();
|
||||
let titlebar = *titlebar;
|
||||
let padding_x = metrics.dense_padding_x;
|
||||
move |_, _| {
|
||||
move |window, cx| {
|
||||
let selected = pane
|
||||
.active
|
||||
.as_ref()
|
||||
@@ -1074,20 +1076,28 @@ fn render_pane(
|
||||
})
|
||||
.flex_none()
|
||||
.w_full()
|
||||
.h(titlebar.height)
|
||||
.items_center()
|
||||
.window_control_area(WindowControlArea::Drag)
|
||||
.on_click(maximize_on_double_click())
|
||||
.when(titlebar.traffic_light_pad, |bar| {
|
||||
bar.pl(px(TRAFFIC_LIGHT_PAD))
|
||||
})
|
||||
.pr(padding_x)
|
||||
.child(tabs)
|
||||
.when(titlebar.window_controls, |bar| {
|
||||
bar.child(div().flex_1())
|
||||
.child(WindowControls::new(SharedString::from(format!(
|
||||
"{dock_id}-pane-{}-controls",
|
||||
pane.key
|
||||
))))
|
||||
bar.child(titlebar_strip(
|
||||
div()
|
||||
.id(SharedString::from(format!(
|
||||
"{dock_id}-pane-{}-strip",
|
||||
pane.key
|
||||
)))
|
||||
.flex_1(),
|
||||
window,
|
||||
cx,
|
||||
))
|
||||
.child(WindowControls::new(SharedString::from(format!(
|
||||
"{dock_id}-pane-{}-controls",
|
||||
pane.key
|
||||
))))
|
||||
})
|
||||
.into_any_element()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user