mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
feat: justify property for clock and custom label
This commit is contained in:
parent
5136637752
commit
708118d266
6 changed files with 52 additions and 9 deletions
|
@ -8,7 +8,7 @@ use serde::Deserialize;
|
|||
use tokio::sync::{broadcast, mpsc};
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::config::{CommonConfig, ModuleOrientation};
|
||||
use crate::config::{CommonConfig, ModuleJustification, ModuleOrientation};
|
||||
use crate::gtk_helpers::IronbarGtkExt;
|
||||
use crate::modules::{
|
||||
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, PopupButton, WidgetContext,
|
||||
|
@ -61,6 +61,14 @@ pub struct ClockModule {
|
|||
/// See [common options](module-level-options#common-options).
|
||||
#[serde(flatten)]
|
||||
pub common: Option<CommonConfig>,
|
||||
|
||||
/// The justification (alignment) of the date/time shown on the bar.
|
||||
///
|
||||
/// **Valid options**: `left`, `right`, `center`, `fill`
|
||||
/// <br>
|
||||
/// **Default**: `left`
|
||||
#[serde(default)]
|
||||
justify: ModuleJustification
|
||||
}
|
||||
|
||||
impl Default for ClockModule {
|
||||
|
@ -71,6 +79,7 @@ impl Default for ClockModule {
|
|||
locale: default_locale(),
|
||||
orientation: ModuleOrientation::Horizontal,
|
||||
common: Some(CommonConfig::default()),
|
||||
justify: ModuleJustification::Left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +138,7 @@ impl Module<Button> for ClockModule {
|
|||
let label = Label::builder()
|
||||
.angle(self.orientation.to_angle())
|
||||
.use_markup(true)
|
||||
.justify(self.justify.into())
|
||||
.build();
|
||||
button.add(&label);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue