diff --git a/app/src/app.rs b/app/src/app.rs index 5bca633..28d8cf2 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -5,7 +5,7 @@ use std::sync::mpsc::{Receiver, TryRecvError, channel}; use std::time::Duration; use rune::tok::type_; -use rune::{Cx, El, Key, KeyEvent, Tx, col, el, row, text}; +use rune::{ChromeInsets, Cx, El, Key, KeyEvent, Tx, col, el, row, text}; use crate::export::{self, Clip}; use crate::history::{self, QueueCategory, Summary, Timeline}; @@ -17,6 +17,9 @@ use crate::screens; use crate::settings::{AudioSource, AudioSourceType, Settings}; use crate::ui::{self, Paint, body, heading}; +/// The band the app draws its own title bar in, which the window's controls sit over. +pub const TITLEBAR_HEIGHT: f32 = 48.0; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Screen { Settings, @@ -1224,7 +1227,7 @@ fn back_label(screen: Screen) -> &'static str { } } -fn titlebar(p: Paint, app: &App) -> El { +fn titlebar(p: Paint, app: &App, insets: ChromeInsets) -> El { // Leaving a screen is on the left, where a window's back arrow lives; the app's own // actions stay on the right. let mut leading = row().key("leading").gap(8.0).center_y(); @@ -1284,9 +1287,12 @@ fn titlebar(p: Paint, app: &App) -> El { } row() .key("titlebar") - .h(48.0) + .h(TITLEBAR_HEIGHT) .w_full() - .px(16.0) + // What the window's controls take: the traffic lights on macOS, the caption buttons on + // Windows, which are drawn over this band. + .pl(16.0 + insets.leading) + .pr(16.0 + insets.trailing) .gap(8.0) .center_y() .justify_between() @@ -1330,6 +1336,9 @@ fn notice(p: Paint, notice: &Notice) -> El { pub fn view(app: &App, cx: &mut Cx) -> El { let p = Paint::new(app.dark, cx.env().scale); + // The window's own controls sit over the title bar and take its ink: the caption buttons + // on Windows, the traffic lights on macOS. + cx.caption_color(p.t.text); // Menus and dialogs cover the whole window, title bar and status bar included: the // history row menus, the add-application form and the delete confirmation. let mut overlays = Vec::new(); @@ -1350,7 +1359,7 @@ pub fn view(app: &App, cx: &mut Cx) -> El { .w_full() .h_full() .fill(p.t.bg) - .child(titlebar(p, app)) + .child(titlebar(p, app, cx.chrome_insets())) .child(main) .child(statusbar(p, app)); let content = match app.screen { diff --git a/app/src/main.rs b/app/src/main.rs index 16c2778..5cb484a 100644 --- a/app/src/main.rs +++ b/app/src/main.rs @@ -163,9 +163,15 @@ fn main() { setup: Some(app::setup), poll: Some(app::poll), on_key: Some(app::on_key), + // Narrower than this, the title bar's own buttons would run under the window's + // caption buttons. + min_size: Some((640.0, 480.0)), ..AppSpec::new("League Recorder", (1200.0, 800.0), app::App::new, app::view) }) .args(args) + // The app draws the title bar itself, so the window keeps no native caption: Rune draws the + // caption buttons over the bar's right edge and keeps Windows' resize edges and snap. + .titlebar(rune::Titlebar::new(app::TITLEBAR_HEIGHT)) .keep_running() .on_close(app::window_closed) .on_quit(app::window_closed)