From 4b33e3e44eee056d918d2bd8991ebafca3c77697 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 4 Jun 2025 21:33:08 +0200 Subject: [PATCH] improve theming * add option to center center vertically, this makes it possible to show full screen dialogs which centered elements. i.e. for an exit dialog * improve dynamic line and update themes --- styles/AmberNight/config.toml | 1 + styles/IndigoEdge/config.toml | 1 + styles/launcher/style.css | 6 +++--- worf/src/lib/config.rs | 18 ++++++++++++++++++ worf/src/lib/gui.rs | 13 ++++--------- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/styles/AmberNight/config.toml b/styles/AmberNight/config.toml index caafaf7..3382260 100644 --- a/styles/AmberNight/config.toml +++ b/styles/AmberNight/config.toml @@ -3,3 +3,4 @@ allow_images=true term="kitty -e" insensitive=true key_detection_type="Code" +lines_size_factor=1.9 diff --git a/styles/IndigoEdge/config.toml b/styles/IndigoEdge/config.toml index 789f742..4a3624d 100644 --- a/styles/IndigoEdge/config.toml +++ b/styles/IndigoEdge/config.toml @@ -4,3 +4,4 @@ term="kitty -e" insensitive=true key_detection_type="Code" blurred_background=false +lines_size_factor=1.9 diff --git a/styles/launcher/style.css b/styles/launcher/style.css index 8e8d367..4d07857 100644 --- a/styles/launcher/style.css +++ b/styles/launcher/style.css @@ -13,6 +13,7 @@ * { font-family: var(--font); box-sizing: border-box; + outline: none; } #background { @@ -79,8 +80,6 @@ background-color: rgba(32, 32, 32, 0); padding: 1rem; margin: 1rem; - border-radius: 0.5rem; - border-bottom: 5px solid rgba(32, 32, 32, 0.1); display: flex; flex-direction: column; align-items: center; @@ -96,7 +95,7 @@ #entry:selected { color: #fff; background-color: var(--entry-selected); - border-bottom: 5px solid var(--search-border); + border-bottom: 3px solid var(--search-border); border-bottom-left-radius: 0; border-bottom-right-radius: 0; } @@ -120,4 +119,5 @@ #row:hover { background-color: transparent; outline: inherit; + border-width: 0; } diff --git a/worf/src/lib/config.rs b/worf/src/lib/config.rs index 4493896..1b3a87b 100644 --- a/worf/src/lib/config.rs +++ b/worf/src/lib/config.rs @@ -307,6 +307,10 @@ pub struct Config { #[clap(long = "line-additional-space")] lines_additional_space: Option, + /// factor to multiple the line height with. + #[clap(long = "lines-size-factor")] + lines_size_factor: Option, + #[clap(short = 'w', long = "columns")] columns: Option, @@ -333,6 +337,10 @@ pub struct Config { #[clap(long = "content-halign")] content_halign: Option, + /// center content on vertical axis + #[clap(long = "content-vcenter")] + content_vcenter: Option, + /// Vertical alignment #[clap(long = "valign")] valign: Option, @@ -490,6 +498,11 @@ impl Config { self.content_halign.unwrap_or(Align::Fill) } + #[must_use] + pub fn content_vcenter(&self) -> bool { + self.content_vcenter.unwrap_or(false) + } + #[must_use] pub fn valign(&self) -> Align { self.valign.unwrap_or(Align::Center) @@ -642,6 +655,11 @@ impl Config { self.lines_additional_space.unwrap_or(0) } + #[must_use] + pub fn lines_size_factor(&self) -> f64 { + self.lines_size_factor.unwrap_or(1.4) + } + #[must_use] pub fn version(&self) -> bool { self.version diff --git a/worf/src/lib/gui.rs b/worf/src/lib/gui.rs index f90a7ac..677302b 100644 --- a/worf/src/lib/gui.rs +++ b/worf/src/lib/gui.rs @@ -777,7 +777,7 @@ fn build_main_box(config: &Config, ui_elements: &Rc( .find_map(|(fb, _)| { let (_, _, _, baseline) = fb.measure(Orientation::Vertical, MEAS_SIZE); if baseline > 0 { - let factor = if lines > 1 { - 1.4 // todo find a better way to do this - // most likely it will not work with all styles - } else { - 1.0 - }; + let factor = config.lines_size_factor(); if config.allow_images() && baseline < i32::from(config.image_size()) { - Some(i32::from(config.image_size())) + Some((f64::from(i32::from(config.image_size())) * factor) as i32) } else { Some((f64::from(baseline) * factor) as i32) } @@ -1283,7 +1278,7 @@ fn calculate_row_height( }; log::debug!( - "heights: scroll {scroll_height}, window {window_height}, keys {height_box}, height {height:?}" + "heights: scroll {scroll_height}, window {window_height}, keys {height_box}, height {height:?}, lines {lines:?}" ); height_box