[gnome-software: 1/3] gs-feature-tile: Refactor code to modify inappropriate colours
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 1/3] gs-feature-tile: Refactor code to modify inappropriate colours
- Date: Mon, 13 Dec 2021 13:23:33 +0000 (UTC)
commit cf53adb01a9afa682d2c2651b9ec5b099e6ee6ee
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Dec 10 12:13:05 2021 +0000
gs-feature-tile: Refactor code to modify inappropriate colours
The new code is equivalent, but keeps the modified values together in a
`GsHSBC` rather than in separate variables. This makes it a bit easier
to pass around in code, which will be used in subsequent commits.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1440
src/gs-feature-tile.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 7816e903c..f0b19c2a6 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -331,28 +331,28 @@ gs_feature_tile_refresh (GsAppTile *self)
* saturation to the valid range. */
if (colors != NULL && colors->len > 0) {
const GsHSBC *chosen_hsbc = &g_array_index (colors, GsHSBC, 0);
+ GsHSBC chosen_hsbc_modified;
GdkRGBA chosen_rgba;
- gfloat modified_saturation, modified_brightness;
- modified_saturation = CLAMP (chosen_hsbc->saturation, min_valid_saturation,
max_valid_saturation);
+ chosen_hsbc_modified = *chosen_hsbc;
- if (chosen_hsbc->contrast < -min_abs_contrast ||
- chosen_hsbc->contrast > min_abs_contrast)
- modified_brightness = chosen_hsbc->brightness;
- else
- modified_brightness = weber_contrast_find_brightness (&fg_hsbc,
min_abs_contrast);
+ chosen_hsbc_modified.saturation = CLAMP (chosen_hsbc->saturation,
min_valid_saturation, max_valid_saturation);
- gtk_hsv_to_rgb (chosen_hsbc->hue,
- modified_saturation,
- modified_brightness,
+ if (chosen_hsbc->contrast >= -min_abs_contrast &&
+ chosen_hsbc->contrast <= min_abs_contrast)
+ chosen_hsbc_modified.brightness = weber_contrast_find_brightness
(&fg_hsbc, min_abs_contrast);
+
+ gtk_hsv_to_rgb (chosen_hsbc_modified.hue,
+ chosen_hsbc_modified.saturation,
+ chosen_hsbc_modified.brightness,
&chosen_rgba.red, &chosen_rgba.green, &chosen_rgba.blue);
g_debug ("Chosen background colour for %s (saturation %s, brightness %s):
RGB: (%f, %f, %f), HSB: (%f, %f, %f)",
gs_app_get_id (app),
- (modified_saturation == chosen_hsbc->saturation) ? "not modified" :
"modified",
- (modified_brightness == chosen_hsbc->brightness) ? "not modified" :
"modified",
+ (chosen_hsbc_modified.saturation == chosen_hsbc->saturation) ? "not
modified" : "modified",
+ (chosen_hsbc_modified.brightness == chosen_hsbc->brightness) ? "not
modified" : "modified",
chosen_rgba.red, chosen_rgba.green, chosen_rgba.blue,
- chosen_hsbc->hue, modified_saturation, modified_brightness);
+ chosen_hsbc_modified.hue, chosen_hsbc_modified.saturation,
chosen_hsbc_modified.brightness);
css = g_strdup_printf ("background-color: rgb(%.0f,%.0f,%.0f);",
chosen_rgba.red * 255.f,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]