Mercurial > molko
diff examples/example-message.c @ 157:fb306ed990f8
ui: make message more flexible, closes #2501
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 16 Oct 2020 14:32:22 +0200 |
parents | c3a40062acc2 |
children | e8d2740703df |
line wrap: on
line diff
--- a/examples/example-message.c Fri Oct 16 13:54:31 2020 +0200 +++ b/examples/example-message.c Fri Oct 16 14:32:22 2020 +0200 @@ -38,7 +38,7 @@ #define H (720) #define MW (W * 0.75) -#define MH (H * 0.125) +#define MH (H * 0.130) #define MX ((W / 2) - (MW / 2)) #define MY (100) @@ -218,7 +218,7 @@ smallbottom(void) { const unsigned int w = window.w / 4; - const unsigned int h = 50; + const unsigned int h = MH; const int x = (window.w / 2) - (w / 2); const int y = (window.h - h - 10); @@ -238,6 +238,38 @@ } static void +toosmallh(void) +{ + struct message msg = { + .x = MX, + .y = MY, + .w = MW, + .h = 50, + .text = { + "This one is too small in height and will emit a warning.", + }, + }; + + run(&msg); +} + +static void +toosmallw(void) +{ + struct message msg = { + .x = MX, + .y = MY, + .w = 160, + .h = MH, + .text = { + "This one is too small in width." + }, + }; + + run(&msg); +} + +static void custom(void) { struct theme theme; @@ -261,6 +293,23 @@ run(&msg); } +static void +large(void) +{ + struct message msg = { + .x = MX, + .y = MY, + .w = 500, + .h = 500, + .text = { + "And this one is terribly large.", + "But lines are still padded at top." + }, + }; + + run(&msg); +} + int main(int argc, char **argv) { @@ -275,6 +324,9 @@ automatic(); question(); smallbottom(); + toosmallh(); + toosmallw(); custom(); + large(); quit(); }