From: n3rdopolis Date: Mon, 20 Mar 2023 02:40:52 +0000 (-0400) Subject: ply-label: Add ply_label_set_hex_color () based off of ply_pixel_buffer_fill_with_hex... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2df6d4a0f292367620f6085aae8db2796554a9bd;p=thirdparty%2Fplymouth.git ply-label: Add ply_label_set_hex_color () based off of ply_pixel_buffer_fill_with_hex_color for configuration of label text colors --- diff --git a/src/libply-splash-graphics/ply-label.c b/src/libply-splash-graphics/ply-label.c index 581dbff5..16256861 100644 --- a/src/libply-splash-graphics/ply-label.c +++ b/src/libply-splash-graphics/ply-label.c @@ -286,6 +286,30 @@ ply_label_set_font (ply_label_t *label, fontdesc); } +void +ply_label_set_hex_color (ply_label_t *label, + uint32_t hex_color) +{ + double red; + double green; + double blue; + double alpha; + + red = ((double) (hex_color & 0xff000000) / 0xff000000); + green = ((double) (hex_color & 0x00ff0000) / 0x00ff0000); + blue = ((double) (hex_color & 0x0000ff00) / 0x0000ff00); + alpha = ((double) (hex_color & 0x000000ff) / 0x000000ff); + + if (label->plugin_interface == NULL) + return; + + label->plugin_interface->set_color_for_control (label->control, + red, + green, + blue, + alpha); +} + void ply_label_set_color (ply_label_t *label, float red, diff --git a/src/libply-splash-graphics/ply-label.h b/src/libply-splash-graphics/ply-label.h index 55debd84..f936f72a 100644 --- a/src/libply-splash-graphics/ply-label.h +++ b/src/libply-splash-graphics/ply-label.h @@ -66,6 +66,8 @@ void ply_label_set_width (ply_label_t *label, long width); void ply_label_set_font (ply_label_t *label, const char *fontdesc); +void ply_label_set_hex_color (ply_label_t *label, + uint32_t hex_color); void ply_label_set_color (ply_label_t *label, float red, float green,