Fix multiple color changes of foreground or time midground

This commit is contained in:
2026-05-30 17:50:14 -04:00
parent 748ad13cd4
commit e133627af8
+30 -10
View File
@@ -36,6 +36,8 @@ static GBitmap *s_c_icon;
static GBitmap *s_h_icon;
static GBitmap *s_e_icon;
static GBitmap *s_f_icon;
static GColor s_applied_fg = GColorWhite;
static GColor s_applied_time_mg = GColorWhite;
// tracking statics
static int s_batt_level;
@@ -102,6 +104,31 @@ static void fuel_mg_update_proc(Layer *layer, GContext *ctx) {
temp_fuel_mg_update_proc_helper(layer, ctx, true);
}
static void apply_fg_color(GColor new_color) {
if (new_color.argb == s_applied_fg.argb) {
return;
}
for (int i = 0; i < 10; ++i) {
replace_gbitmap_color(s_applied_fg, new_color, s_font_bitmaps[i], NULL);
}
replace_gbitmap_color(s_applied_fg, new_color, s_c_icon, NULL);
replace_gbitmap_color(s_applied_fg, new_color, s_h_icon, NULL);
replace_gbitmap_color(s_applied_fg, new_color, s_e_icon, NULL);
replace_gbitmap_color(s_applied_fg, new_color, s_f_icon, NULL);
s_applied_fg = new_color;
}
static void apply_time_mg_color(GColor new_color) {
if (!s_time_mg_8 || new_color.argb == s_applied_time_mg.argb) {
return;
}
replace_gbitmap_color(s_applied_time_mg, new_color, s_time_mg_8, NULL);
s_applied_time_mg = new_color;
}
static void main_window_load() {
Layer *window_layer = window_get_root_layer(s_main_window);
@@ -116,7 +143,8 @@ static void main_window_load() {
if (settings.ShowTimeMG) {
s_time_mg_8 = gbitmap_create_with_resource(RESOURCE_ID_8);
replace_gbitmap_color(GColorWhite, settings.ColorMGTime, s_time_mg_8, NULL);
s_applied_time_mg = GColorWhite;
apply_time_mg_color(settings.ColorMGTime);
for (int i = 0; i < 4; ++i) {
s_time_mg_layers[i] = bitmap_layer_create(s_time_grects[i]);
bitmap_layer_set_bitmap(s_time_mg_layers[i], s_time_mg_8);
@@ -138,15 +166,7 @@ static void main_window_load() {
bitmap_layer_set_compositing_mode(s_e_layer, GCompOpSet);
bitmap_layer_set_compositing_mode(s_f_layer, GCompOpSet);
if (settings.ColorFG.argb != GColorWhite.argb) {
for (int i = 0; i < 10; ++i) {
replace_gbitmap_color(GColorWhite, settings.ColorFG, s_font_bitmaps[i], NULL);
}
replace_gbitmap_color(GColorWhite, settings.ColorFG, s_c_icon, NULL);
replace_gbitmap_color(GColorWhite, settings.ColorFG, s_h_icon, NULL);
replace_gbitmap_color(GColorWhite, settings.ColorFG, s_e_icon, NULL);
replace_gbitmap_color(GColorWhite, settings.ColorFG, s_f_icon, NULL);
}
apply_fg_color(settings.ColorFG);
for (int i = 0; i < 4; ++i) {
layer_add_child(window_layer, bitmap_layer_get_layer(s_time_fg_layers[i]));