feat: fix wired padding for some notifications, add rudimentary button bar

This commit is contained in:
oddlama 2023-10-12 21:15:46 +02:00
parent d8138efbec
commit 34d96f6895
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A

View file

@ -111,8 +111,12 @@
}
];
mkBody = name: ident: yOffset: summaryRightPadding: extra:
map (x: extra // x) [
mkBody = name: ident: yOffset: summaryRightPadding: extra: let
maxWFull = 580 - 12;
maxWImg = maxWFull - 128 - 12;
in
map (x: extra // x) (
[
{
name = "${name}_${ident}_hint";
parent = "${name}_root";
@ -137,10 +141,10 @@
font = "${fonts.sansSerif.name} Bold ${toString (globalScale * 16)}";
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 (summaryRightPadding + 16) 0 8;
dimensions = mkDimensionsWH (580 - summaryRightPadding) (580 - summaryRightPadding) 0 30;
dimensions_image_hint = mkDimensionsWH 440 440 0 30;
dimensions_image_both = mkDimensionsWH 440 440 0 30;
padding = mkPaddingLrBt 16 16 0 8;
dimensions = mkDimensionsWH (maxWFull - summaryRightPadding) (maxWFull - summaryRightPadding) 0 30;
dimensions_image_hint = mkDimensionsWH (maxWImg - summaryRightPadding) (maxWImg - summaryRightPadding) 0 30;
dimensions_image_both = mkDimensionsWH (maxWImg - summaryRightPadding) (maxWImg - summaryRightPadding) 0 30;
});
}
{
@ -160,15 +164,88 @@
ellipsize = mkLiteral "End";
color = colors.base06;
padding = mkPaddingLrBt 16 16 12 0;
dimensions = mkDimensionsWH 580 580 0 88;
dimensions_image_hint = mkDimensionsWH 440 440 0 88;
dimensions_image_both = mkDimensionsWH 440 440 0 88;
dimensions = mkDimensionsWH maxWFull maxWFull 0 88;
dimensions_image_hint = mkDimensionsWH maxWImg maxWImg 0 88;
dimensions_image_both = mkDimensionsWH maxWImg maxWImg 0 88;
});
}
]
# We unfortunately cannot move these out of mkBody, because the depend
# on the specific name for the parent, which cannot be changed dynamically.
# So each call to mkBody creates these progress bars which only differ in
# their parent :/
++ (mkProgress name "${ident}_hint" 0 {
render_criteria = [
(And (extra.render_criteria
++ [
(mkLiteral "Progress")
(mkLiteral "HintImage")
]))
];
})
++ (mkProgress name "${ident}_body" 0 {
render_criteria = [
(And (extra.render_criteria
++ [
(mkLiteral "Progress")
(mkLiteral "Body")
(Not (mkLiteral "HintImage"))
]))
];
})
++ (mkProgress name "${ident}_summary" 9 {
render_criteria = [
(And (extra.render_criteria
++ [
(mkLiteral "Progress")
(mkLiteral "Summary")
(Not (Or [
(mkLiteral "Body")
(mkLiteral "HintImage")
]))
]))
];
})
# Each mkProgress includes a button bar. But if no progress is included in a notification,
# those won't be rendered, so we have to define bars for non-progress notifications.
# (And yes, we need 3 because we cannot have duplicate names or dynamic parents)
++ (mkButtonBar name "${ident}_hint" {
render_criteria = [
(And (extra.render_criteria
++ [
(Not (mkLiteral "Progress"))
(mkLiteral "HintImage")
]))
];
})
++ (mkButtonBar name "${ident}_body" {
render_criteria = [
(And (extra.render_criteria
++ [
(Not (mkLiteral "Progress"))
(mkLiteral "Body")
(Not (mkLiteral "HintImage"))
]))
];
})
++ (mkButtonBar name "${ident}_summary" {
render_criteria = [
(And (extra.render_criteria
++ [
(Not (mkLiteral "Progress"))
(mkLiteral "Summary")
(Not (Or [
(mkLiteral "Body")
(mkLiteral "HintImage")
]))
]))
];
})
);
mkProgress = name: parent: yOffset: extra:
map (x: extra // x) [
map (x: extra // x) (
[
{
name = "${name}_progress_${parent}_text";
parent = "${name}_${parent}";
@ -190,7 +267,7 @@
hook = mkHook "BL" "TL";
offset = mkVec2 0 0;
params = struct "ProgressBlock" (unnamedStruct {
width = globalScale * 520;
width = globalScale * 510;
height = globalScale * 12;
border_width = 0.0;
border_rounding = globalScale * 6;
@ -201,6 +278,45 @@
padding = mkPaddingLrBt 68 16 12 (yOffset + 8);
});
}
]
++ (mkButtonBar name "progress_${parent}_text" extra)
);
mkButtonBar = name: parent: extra:
map (x: extra // x) [
{
name = "${name}_action_0_for_${parent}";
parent = "${name}_${parent}";
hook = mkHook "BL" "TL";
offset = mkVec2 0 0;
render_criteria = [
(And (extra.render_criteria
++ [
(Or [
(struct "ActionOther" 0)
#(struct "ActionOther" 1)
#(struct "ActionOther" 2)
#(struct "ActionOther" 3)
])
]))
];
params = struct "ButtonBlock" (unnamedStruct {
text = "%a";
font = "${fonts.monospace.name} Bold ${toString (globalScale * 14)}";
ellipsize = mkLiteral "End";
action = struct "OtherAction" 0;
text_color = colors.base06;
text_color_hovered = colors.base06;
background_color = colors.base01;
background_color_hovered = colors.base02;
border_color = colors.base04;
border_color_hovered = colors.base0F;
border_rounding = globalScale * 0;
border_width = globalScale * 2;
padding = mkPaddingLrBt 12 16 12 0;
dimensions = mkDimensionsWH 144 48 24 24;
});
}
];
in
format.generate "wired.ron" (unnamedStruct {
@ -217,6 +333,7 @@
# https://github.com/Toqozz/wired-notify/wiki/Shortcuts
shortcuts = ShortcutsConfig {
notification_interact = 1; # left click
notification_pause = 1;
notification_close = 2; # right click
notification_action1 = 3; # middle click
};
@ -240,7 +357,7 @@
offset = mkVec2 0 0;
params = struct "TextBlock" (unnamedStruct {
color = colors.base05;
dimensions = mkDimensionsWH 0 (-1) 28 28;
dimensions = mkDimensionsWH 100 100 28 28;
ellipsize = mkLiteral "End";
font = "${fonts.monospace.name} Bold ${toString (globalScale * 14)}";
padding = mkPaddingLrBt 0 16 4 12;
@ -253,54 +370,13 @@
render_criteria = [criterionHasTopBar];
})
# if no top bar present: A body with no offset and a summary padding to the right (to not overlay the time)
(mkBody "general" "notop" 0 24 {
(mkBody "general" "notop" 0 (16 + 100) {
render_criteria = [(Not criterionHasTopBar)];
})
# if top bar present: A body with matching y offset and no summary padding to the right
(mkBody "general" "withtop" 36 0 {
render_criteria = [criterionHasTopBar];
})
# We unfortunately need to duplicate each layout that has the body, summary or hint as
# a parent, since each name must be unique and we cannot select the correct parent dynamically.
(lib.flip map ["notop" "withtop"] (parent: let
parentCriterion =
if parent == "withtop"
then criterionHasTopBar
else (Not criterionHasTopBar);
in [
(mkProgress "general" "${parent}_hint" 0 {
render_criteria = [
(And [
parentCriterion
(mkLiteral "Progress")
(mkLiteral "HintImage")
])
];
})
(mkProgress "general" "${parent}_body" 0 {
render_criteria = [
(And [
parentCriterion
(mkLiteral "Progress")
(mkLiteral "Body")
(Not (mkLiteral "HintImage"))
])
];
})
(mkProgress "general" "${parent}_summary" 9 {
render_criteria = [
(And [
parentCriterion
(mkLiteral "Progress")
(mkLiteral "Summary")
(Not (Or [
(mkLiteral "Body")
(mkLiteral "HintImage")
]))
])
];
})
]))
]);
});
};