Skip to content

Commit

Permalink
Merge branch 'bvr-yr-markup'
Browse files Browse the repository at this point in the history
  • Loading branch information
AMNatty committed Mar 5, 2024
2 parents 619730e + b05d7fa commit b275884
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct WButton {
action: String,
text: String,
keybind: String,
#[serde(default = "default_justify")]
justify: String,
#[serde(default = "default_width")]
width: f32,
#[serde(default = "default_height")]
Expand All @@ -30,6 +32,10 @@ struct WButton {
circular: bool,
}

fn default_justify() -> String {
String::from("center")
}

fn default_width() -> f32 {
0.5
}
Expand Down Expand Up @@ -188,6 +194,7 @@ fn app_main(config: &Arc<AppConfig>, app: &Application) {
Protocol::LayerShell => {
window.init_layer_shell();
window.set_layer(gtk_layer_shell::Layer::Overlay);
window.set_namespace("wleave");
window.set_exclusive_zone(-1);
window.set_keyboard_interactivity(true);

Expand Down Expand Up @@ -229,6 +236,14 @@ fn app_main(config: &Arc<AppConfig>, app: &Application) {
bttn.text.to_owned()
};

let justify = match bttn.justify.as_str() {
"center" => gtk::Justification::Center,
"fill" => gtk::Justification::Fill,
"left" => gtk::Justification::Left,
"right" => gtk::Justification::Right,
_ => gtk::Justification::Center
};

let button = gtk::Button::builder()
.label(&label)
.name(&bttn.label)
Expand All @@ -240,6 +255,8 @@ fn app_main(config: &Arc<AppConfig>, app: &Application) {
if let Some(label) = label.downcast_ref::<Label>() {
label.set_xalign(bttn.width);
label.set_yalign(bttn.height);
label.set_use_markup(true);
label.set_justify(justify);
}
}

Expand Down

0 comments on commit b275884

Please sign in to comment.