mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 23:01:04 +02:00
feat: fully implement orientation/justify options
Adds `orientation` and `justify` options to all modules and custom widgets where it makes sense to do so. Any modules without support document this. Widgets fully document the options inline where present for now. Resolves #296
This commit is contained in:
parent
0855039bce
commit
c20feb77b7
29 changed files with 317 additions and 161 deletions
|
@ -77,7 +77,7 @@ impl BarPosition {
|
|||
|
||||
/// Gets the angle that label text should be displayed at
|
||||
/// based on this position.
|
||||
pub const fn get_angle(self) -> f64 {
|
||||
pub const fn angle(self) -> f64 {
|
||||
match self {
|
||||
Self::Top | Self::Bottom => 0.0,
|
||||
Self::Left => 90.0,
|
||||
|
|
37
src/config/layout.rs
Normal file
37
src/config/layout.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
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(ModuleOrientation::into)
|
||||
.unwrap_or(info.bar_position.orientation())
|
||||
}
|
||||
|
||||
pub fn angle(&self, info: &ModuleInfo) -> f64 {
|
||||
self.orientation
|
||||
.map(ModuleOrientation::to_angle)
|
||||
.unwrap_or(info.bar_position.angle())
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
mod common;
|
||||
mod r#impl;
|
||||
mod layout;
|
||||
mod truncate;
|
||||
|
||||
#[cfg(feature = "cairo")]
|
||||
|
@ -46,6 +47,7 @@ use std::collections::HashMap;
|
|||
use schemars::JsonSchema;
|
||||
|
||||
pub use self::common::{CommonConfig, ModuleJustification, ModuleOrientation, TransitionType};
|
||||
pub use self::layout::LayoutConfig;
|
||||
pub use self::truncate::{EllipsizeMode, TruncateMode};
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue