fix(bar): use truncated labels for titles

This commit introduces a new wrapper, CustomUi, which is used to
implement custom methods on top of eframe::egui::Ui.

The default ui::add_sized method always has the text in a label
centered, which is not desirable for a status bar where the layout
should be ltr.

A new function CustomUi::add_sized_left_to_right has been added to
ensure that labels can be truncated with a custom width (which requires
allocate_ui_with_layout), while also retaining the ability for the text
to be aligned to the left rather than the center of the allocated
layout.
This commit is contained in:
LGUG2Z
2024-09-21 10:20:26 -07:00
parent 1080159e68
commit 3720ce42d0
7 changed files with 114 additions and 26 deletions
+3
View File
@@ -8,6 +8,7 @@ mod memory;
mod network;
mod storage;
mod time;
mod ui;
mod widget;
use crate::bar::Komobar;
@@ -24,11 +25,13 @@ use schemars::gen::SchemaSettings;
use std::io::BufReader;
use std::io::Read;
use std::path::PathBuf;
use std::sync::atomic::AtomicI32;
use std::sync::Arc;
use std::time::Duration;
use tracing_subscriber::EnvFilter;
pub static WIDGET_SPACING: f32 = 10.0;
pub static MAX_LABEL_WIDTH: AtomicI32 = AtomicI32::new(400);
#[derive(Parser)]
#[clap(author, about, version)]