add theme titlebar height and app-owned strip dragging
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, ElementId, Entity, InteractiveElement as _,
|
||||
IntoElement, ParentElement as _, Pixels, RenderOnce, SharedString,
|
||||
StatefulInteractiveElement as _, Styled as _, Window, WindowControlArea, div, px,
|
||||
IntoElement, ParentElement as _, Pixels, RenderOnce, SharedString, Styled as _, Window, div,
|
||||
px,
|
||||
};
|
||||
use gpui_native_core::button::{Button, ButtonVariant};
|
||||
use gpui_native_core::common::{Sizable as _, h_flex, v_flex};
|
||||
@@ -14,7 +14,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};
|
||||
use crate::window_frame::frame;
|
||||
|
||||
/// The width a sidebar opens at.
|
||||
@@ -207,6 +207,8 @@ impl RenderOnce for Shell {
|
||||
&state,
|
||||
metrics.strip_height,
|
||||
metrics.dense_padding_x,
|
||||
window,
|
||||
cx,
|
||||
))
|
||||
.child(ResizeHandle::new((id.clone(), "left-resize")).on_resize({
|
||||
let state = state.clone();
|
||||
@@ -239,6 +241,8 @@ impl RenderOnce for Shell {
|
||||
&state,
|
||||
metrics.strip_height,
|
||||
metrics.dense_padding_x,
|
||||
window,
|
||||
cx,
|
||||
))
|
||||
});
|
||||
|
||||
@@ -248,6 +252,7 @@ impl RenderOnce for Shell {
|
||||
}
|
||||
|
||||
/// One sidebar: a header strip with the hide toggle over the app's content.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn sidebar_region(
|
||||
width: Pixels,
|
||||
content: AnyElement,
|
||||
@@ -255,6 +260,8 @@ fn sidebar_region(
|
||||
state: &Entity<LayoutState>,
|
||||
strip_height: Pixels,
|
||||
padding_x: Pixels,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> AnyElement {
|
||||
let strip = h_flex()
|
||||
.id(SharedString::from(format!("sidebar-strip-{}", side.name())))
|
||||
@@ -263,8 +270,7 @@ fn sidebar_region(
|
||||
.h(strip_height)
|
||||
.items_center()
|
||||
.justify_end()
|
||||
.window_control_area(WindowControlArea::Drag)
|
||||
.on_click(maximize_on_double_click())
|
||||
.map(|strip| titlebar_strip(strip, window, cx))
|
||||
.map(|strip| match side {
|
||||
Side::Left => strip.when(cfg!(target_os = "macos"), |strip| {
|
||||
strip.pl(px(TRAFFIC_LIGHT_PAD))
|
||||
|
||||
Reference in New Issue
Block a user