mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-09-18 12:46:58 +02:00
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
use crate::config::{ModuleJustification, ModuleOrientation};
|
|
use crate::modules::ModuleInfo;
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Clone, Debug, Deserialize, Default)]
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
pub struct LayoutConfig {
|
|
/// The orientation to display the widget contents.
|
|
/// Setting to vertical will rotate text 90 degrees.
|
|
///
|
|
/// **Valid options**: `horizontal`, `vertical`
|
|
/// <br>
|
|
/// **Default**: `horizontal`
|
|
orientation: Option<ModuleOrientation>,
|
|
|
|
/// The justification (alignment) of the widget text shown on the bar.
|
|
///
|
|
/// **Valid options**: `left`, `right`, `center`, `fill`
|
|
/// <br>
|
|
/// **Default**: `left`
|
|
#[serde(default)]
|
|
pub justify: ModuleJustification,
|
|
}
|
|
|
|
impl LayoutConfig {
|
|
pub fn orientation(&self, info: &ModuleInfo) -> gtk::Orientation {
|
|
self.orientation
|
|
.map_or(info.bar_position.orientation(), ModuleOrientation::into)
|
|
}
|
|
|
|
pub fn angle(&self, info: &ModuleInfo) -> f64 {
|
|
self.orientation
|
|
.map_or(info.bar_position.angle(), ModuleOrientation::to_angle)
|
|
}
|
|
}
|