mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51: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
|
@ -1,9 +1,9 @@
|
|||
use gtk::prelude::*;
|
||||
use gtk::{Button, Label, Orientation};
|
||||
use gtk::{Button, Label};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::{CustomWidget, CustomWidgetContext, ExecEvent, WidgetConfig};
|
||||
use crate::config::ModuleOrientation;
|
||||
use crate::config::LayoutConfig;
|
||||
use crate::dynamic_value::dynamic_string;
|
||||
use crate::gtk_helpers::IronbarLabelExt;
|
||||
use crate::modules::PopupButton;
|
||||
|
@ -37,13 +37,9 @@ pub struct ButtonWidget {
|
|||
/// **Default**: `null`
|
||||
on_click: Option<String>,
|
||||
|
||||
/// Orientation of the button.
|
||||
///
|
||||
/// **Valid options**: `horizontal`, `vertical`, `h`, `v`
|
||||
/// <br />
|
||||
/// **Default**: `horizontal`
|
||||
#[serde(default)]
|
||||
orientation: ModuleOrientation,
|
||||
/// See [layout options](module-level-options#layout)
|
||||
#[serde(default, flatten)]
|
||||
layout: LayoutConfig,
|
||||
|
||||
/// Modules and widgets to add to this box.
|
||||
///
|
||||
|
@ -59,7 +55,7 @@ impl CustomWidget for ButtonWidget {
|
|||
context.popup_buttons.borrow_mut().push(button.clone());
|
||||
|
||||
if let Some(widgets) = self.widgets {
|
||||
let container = gtk::Box::new(Orientation::Horizontal, 0);
|
||||
let container = gtk::Box::new(self.layout.orientation(context.info), 0);
|
||||
|
||||
for widget in widgets {
|
||||
widget.widget.add_to(&container, &context, widget.common);
|
||||
|
@ -70,7 +66,9 @@ impl CustomWidget for ButtonWidget {
|
|||
let label = Label::new(None);
|
||||
label.set_use_markup(true);
|
||||
|
||||
label.set_angle(self.orientation.to_angle());
|
||||
if !context.is_popup {
|
||||
label.set_angle(self.layout.angle(context.info));
|
||||
}
|
||||
|
||||
button.add(&label);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue