title_bar: Make the left padding adjustable (#386)
This commit is contained in:
parent
c986a294e4
commit
b997eabcba
1 changed files with 8 additions and 11 deletions
|
|
@ -18,8 +18,14 @@ pub const TITLE_BAR_HEIGHT: Pixels = px(35.);
|
||||||
|
|
||||||
impl TitleBar {
|
impl TitleBar {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
// Leave more space for the macOS window controls.
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let pl = px(80.);
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let pl = px(12.);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
base: div().id("title-bar"),
|
base: div().id("title-bar").pl(pl),
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -184,11 +190,6 @@ impl ParentElement for TitleBar {
|
||||||
impl RenderOnce for TitleBar {
|
impl RenderOnce for TitleBar {
|
||||||
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
||||||
let is_linux = cfg!(target_os = "linux");
|
let is_linux = cfg!(target_os = "linux");
|
||||||
let macos_pl = if cfg!(target_os = "macos") {
|
|
||||||
Some(px(80.))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
const HEIGHT: Pixels = px(34.);
|
const HEIGHT: Pixels = px(34.);
|
||||||
|
|
||||||
|
|
@ -201,14 +202,10 @@ impl RenderOnce for TitleBar {
|
||||||
.items_center()
|
.items_center()
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.h(HEIGHT)
|
.h(HEIGHT)
|
||||||
.pl(px(12.))
|
|
||||||
.when(!cx.is_fullscreen(), |this| {
|
|
||||||
// Leave space for the macOS window controls.
|
|
||||||
this.when_some(macos_pl, |this, pl| this.pl(pl))
|
|
||||||
})
|
|
||||||
.border_b_1()
|
.border_b_1()
|
||||||
.border_color(cx.theme().title_bar_border)
|
.border_color(cx.theme().title_bar_border)
|
||||||
.bg(cx.theme().title_bar)
|
.bg(cx.theme().title_bar)
|
||||||
|
.when(cx.is_fullscreen(), |this| this.pl(px(12.)))
|
||||||
.on_double_click(|_, cx| cx.zoom_window())
|
.on_double_click(|_, cx| cx.zoom_window())
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue