diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 41ed3e87..bf0019e0 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -444,7 +444,6 @@ t_property_color } /** hwb ( 0-360 , 0-100 %, 0 - 100 %) */ | T_COL_HWB T_PARENT_LEFT T_INT T_COMMA t_property_color_value T_PERCENT T_COMMA t_property_color_value T_PERCENT T_PARENT_RIGHT { - $$.alpha = 1.0; if ( ! check_in_range($3,0,360, &(@$)) ) { YYABORT; } if ( ! check_in_range($5,0,100, &(@$)) ) { YYABORT; } if ( ! check_in_range($8,0,100, &(@$)) ) { YYABORT; } @@ -452,6 +451,7 @@ t_property_color double w = $5/100.0; double b = $8/100.0; $$ = hsl_to_rgb ( h, 1.0, 0.5); + $$.alpha = 1.0; $$.red *= ( 1. - w - b ); $$.red += w; $$.green *= ( 1. - w - b ); diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index e7ba6711..9e57b175 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -610,6 +610,28 @@ START_TEST ( test_properties_color_hsl ) ck_assert_double_eq_tol ( p->value.color.blue , 0 , 0.004); } END_TEST +START_TEST ( test_properties_color_hwb ) +{ + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string ( "* { test1: hwb(190,65%,0%); test2: hwb(265, 31%, 29%); }"); + ThemeWidget *twid = rofi_theme_find_widget ( wid.name, wid.state, FALSE ); + + Property *p = rofi_theme_find_property ( twid, P_COLOR, "test2", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 0x7a/255.0 , 0.004); + ck_assert_double_eq_tol ( p->value.color.green , 0x4f/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 0xb5/255.0 , 0.004); + p = rofi_theme_find_property ( twid, P_COLOR, "test1", FALSE ); + ck_assert_ptr_nonnull ( p ); + ck_assert_double_eq ( p->value.color.alpha , 1.0 ); + ck_assert_double_eq_tol ( p->value.color.red , 166/255.0, 0.004); + ck_assert_double_eq_tol ( p->value.color.green ,240/255.0, 0.004 ); + ck_assert_double_eq_tol ( p->value.color.blue , 255/255.0 , 0.004); +} +END_TEST START_TEST ( test_properties_color_cmyk ) { widget wid; @@ -841,6 +863,7 @@ static Suite * theme_parser_suite (void) tcase_add_test ( tc_prop_color, test_properties_color_rgba_percent); tcase_add_test ( tc_prop_color, test_properties_color_argb); tcase_add_test ( tc_prop_color, test_properties_color_hsl); + tcase_add_test ( tc_prop_color, test_properties_color_hwb); tcase_add_test ( tc_prop_color, test_properties_color_cmyk); suite_add_tcase(s, tc_prop_color ); }