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
This commit is contained in:
Alexander Mohr 2025-06-04 21:33:08 +02:00
parent db2ae90268
commit 4b33e3e44e
5 changed files with 27 additions and 12 deletions

View file

@ -3,3 +3,4 @@ allow_images=true
term="kitty -e" term="kitty -e"
insensitive=true insensitive=true
key_detection_type="Code" key_detection_type="Code"
lines_size_factor=1.9

View file

@ -4,3 +4,4 @@ term="kitty -e"
insensitive=true insensitive=true
key_detection_type="Code" key_detection_type="Code"
blurred_background=false blurred_background=false
lines_size_factor=1.9

View file

@ -13,6 +13,7 @@
* { * {
font-family: var(--font); font-family: var(--font);
box-sizing: border-box; box-sizing: border-box;
outline: none;
} }
#background { #background {
@ -79,8 +80,6 @@
background-color: rgba(32, 32, 32, 0); background-color: rgba(32, 32, 32, 0);
padding: 1rem; padding: 1rem;
margin: 1rem; margin: 1rem;
border-radius: 0.5rem;
border-bottom: 5px solid rgba(32, 32, 32, 0.1);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
@ -96,7 +95,7 @@
#entry:selected { #entry:selected {
color: #fff; color: #fff;
background-color: var(--entry-selected); 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-left-radius: 0;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
} }
@ -120,4 +119,5 @@
#row:hover { #row:hover {
background-color: transparent; background-color: transparent;
outline: inherit; outline: inherit;
border-width: 0;
} }

View file

@ -307,6 +307,10 @@ pub struct Config {
#[clap(long = "line-additional-space")] #[clap(long = "line-additional-space")]
lines_additional_space: Option<i32>, lines_additional_space: Option<i32>,
/// factor to multiple the line height with.
#[clap(long = "lines-size-factor")]
lines_size_factor: Option<f64>,
#[clap(short = 'w', long = "columns")] #[clap(short = 'w', long = "columns")]
columns: Option<u32>, columns: Option<u32>,
@ -333,6 +337,10 @@ pub struct Config {
#[clap(long = "content-halign")] #[clap(long = "content-halign")]
content_halign: Option<Align>, content_halign: Option<Align>,
/// center content on vertical axis
#[clap(long = "content-vcenter")]
content_vcenter: Option<bool>,
/// Vertical alignment /// Vertical alignment
#[clap(long = "valign")] #[clap(long = "valign")]
valign: Option<Align>, valign: Option<Align>,
@ -490,6 +498,11 @@ impl Config {
self.content_halign.unwrap_or(Align::Fill) self.content_halign.unwrap_or(Align::Fill)
} }
#[must_use]
pub fn content_vcenter(&self) -> bool {
self.content_vcenter.unwrap_or(false)
}
#[must_use] #[must_use]
pub fn valign(&self) -> Align { pub fn valign(&self) -> Align {
self.valign.unwrap_or(Align::Center) self.valign.unwrap_or(Align::Center)
@ -642,6 +655,11 @@ impl Config {
self.lines_additional_space.unwrap_or(0) 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] #[must_use]
pub fn version(&self) -> bool { pub fn version(&self) -> bool {
self.version self.version

View file

@ -777,7 +777,7 @@ fn build_main_box<T: Clone + 'static>(config: &Config, ui_elements: &Rc<UiElemen
ui_elements.main_box.set_widget_name("inner-box"); ui_elements.main_box.set_widget_name("inner-box");
ui_elements.main_box.set_css_classes(&["inner-box"]); ui_elements.main_box.set_css_classes(&["inner-box"]);
ui_elements.main_box.set_hexpand(true); ui_elements.main_box.set_hexpand(true);
ui_elements.main_box.set_vexpand(false); ui_elements.main_box.set_vexpand(config.content_vcenter());
ui_elements ui_elements
.main_box .main_box
@ -1258,15 +1258,10 @@ fn calculate_row_height<T: Clone + 'static>(
.find_map(|(fb, _)| { .find_map(|(fb, _)| {
let (_, _, _, baseline) = fb.measure(Orientation::Vertical, MEAS_SIZE); let (_, _, _, baseline) = fb.measure(Orientation::Vertical, MEAS_SIZE);
if baseline > 0 { if baseline > 0 {
let factor = if lines > 1 { let factor = config.lines_size_factor();
1.4 // todo find a better way to do this
// most likely it will not work with all styles
} else {
1.0
};
if config.allow_images() && baseline < i32::from(config.image_size()) { 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 { } else {
Some((f64::from(baseline) * factor) as i32) Some((f64::from(baseline) * factor) as i32)
} }
@ -1283,7 +1278,7 @@ fn calculate_row_height<T: Clone + 'static>(
}; };
log::debug!( 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 height_box