Skip to content

Commit c150bd4

Browse files
committed
fw: black notification banner with inverted icon on bw
Signed-off-by: Joshua Jun <[email protected]>
1 parent 3ef37df commit c150bd4

File tree

11 files changed

+565
-571
lines changed

11 files changed

+565
-571
lines changed

src/fw/applib/applib_malloc.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
"_comment": "Generously padded because it's not feature complete yet (only 3.x)"
230230
}, {
231231
"name": "KinoLayer",
232-
"size_3x_padding": 40,
232+
"size_3x_padding": 36,
233233
"size_3x": 164,
234234
"dependencies": ["Layer", "KinoPlayer"],
235235
"_comment": "Generously padded because it's not feature complete yet (only 3.x)"
@@ -241,7 +241,7 @@
241241
"_comment": "Generously padded because it's not feature complete yet (only 3.x)"
242242
}, {
243243
"name": "ExpandableDialog",
244-
"size_3x_padding": 48,
244+
"size_3x_padding": 44,
245245
"size_3x": 1280,
246246
"dependencies": ["Dialog", "TextLayer", "ScrollLayer", "ActionBarLayer", "Layer"],
247247
"_comment": "Generously padded because it's not feature complete yet (only 3.x)"
@@ -253,7 +253,7 @@
253253
"_comment": "Generously padded because it's not feature complete yet (only 3.x)"
254254
}, {
255255
"name": "VoiceWindow",
256-
"size_3x_padding": 40,
256+
"size_3x_padding": 36,
257257
"size_3x": 2368,
258258
"dependencies": ["TranscriptionDialog", "Layer", "Layer", "StatusBarLayer", "TextLayer",
259259
"KinoLayer", "Window", "EventServiceInfo"],

src/fw/applib/ui/kino/kino_layer.c

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,37 @@
1616

1717
#include "kino_layer.h"
1818

19+
#include <stdint.h> // For uintptr_t
20+
1921
#include "applib/applib_malloc.auto.h"
2022
#include "applib/graphics/graphics.h"
2123

24+
static GColor prv_invert_bw_color(GColor color) {
25+
if (gcolor_equal(color, GColorBlack)) {
26+
return GColorWhite;
27+
} else if (gcolor_equal(color, GColorWhite)) {
28+
return GColorBlack;
29+
}
30+
return color;
31+
}
32+
33+
static void prv_invert_pdc_colors(GDrawCommandProcessor *processor, GDrawCommand *processed_command,
34+
size_t processed_command_max_size, const GDrawCommandList *list,
35+
const GDrawCommand *command) {
36+
gdraw_command_set_stroke_color(
37+
processed_command,
38+
prv_invert_bw_color(gdraw_command_get_stroke_color((GDrawCommand *)command)));
39+
gdraw_command_set_fill_color(
40+
processed_command,
41+
prv_invert_bw_color(gdraw_command_get_fill_color((GDrawCommand *)command)));
42+
}
43+
44+
GDrawCommandProcessor prv_gdraw_inv_processor = {
45+
.command = prv_invert_pdc_colors,
46+
};
47+
48+
KinoReelProcessor PRV_INVERT_COLORS_PROCESSOR = {.draw_command_processor = &prv_gdraw_inv_processor};
49+
2250
static void prv_update_proc(Layer *layer, GContext *ctx) {
2351
KinoLayer *kino_layer = (KinoLayer *)layer;
2452

@@ -35,7 +63,9 @@ static void prv_update_proc(Layer *layer, GContext *ctx) {
3563
}
3664

3765
const GRect reel_bounds = kino_layer_get_reel_bounds(kino_layer);
38-
kino_player_draw(&kino_layer->player, ctx, reel_bounds.origin);
66+
67+
KinoReelProcessor processor = kino_layer->invert_colors ? PRV_INVERT_COLORS_PROCESSOR : (KinoReelProcessor){};
68+
kino_player_draw_processed(&kino_layer->player, ctx, reel_bounds.origin, &processor);
3969
}
4070

4171
//////////////////////
@@ -66,10 +96,12 @@ void kino_layer_init(KinoLayer *kino_layer, const GRect *frame) {
6696
// init kino layer
6797
kino_layer->background_color = GColorClear;
6898
// init kino player
69-
kino_player_set_callbacks(&kino_layer->player, (KinoPlayerCallbacks){
70-
.frame_did_change = prv_player_frame_did_change,
71-
.did_stop = prv_player_did_stop,
72-
}, kino_layer);
99+
kino_player_set_callbacks(&kino_layer->player,
100+
(KinoPlayerCallbacks){
101+
.frame_did_change = prv_player_frame_did_change,
102+
.did_stop = prv_player_did_stop,
103+
},
104+
kino_layer);
73105
}
74106

75107
void kino_layer_deinit(KinoLayer *kino_layer) {
@@ -107,22 +139,26 @@ void kino_layer_set_reel(KinoLayer *kino_layer, KinoReel *reel, bool take_owners
107139
kino_player_set_reel(&kino_layer->player, reel, take_ownership);
108140
}
109141

142+
void kino_layer_set_invert_colors(KinoLayer *kino_layer, bool invert) {
143+
// Store the invert flag in the LSB of the context pointer
144+
kino_layer->invert_colors = invert;
145+
}
146+
110147
void kino_layer_set_reel_with_resource(KinoLayer *kino_layer, uint32_t resource_id) {
111148
kino_player_set_reel_with_resource(&kino_layer->player, resource_id);
112149
}
113150

114151
void kino_layer_set_reel_with_resource_system(KinoLayer *kino_layer, ResAppNum app_num,
115-
uint32_t resource_id) {
152+
uint32_t resource_id, bool invert) {
153+
kino_layer_set_invert_colors(kino_layer, invert);
116154
kino_player_set_reel_with_resource_system(&kino_layer->player, app_num, resource_id);
117155
}
118156

119157
KinoReel *kino_layer_get_reel(KinoLayer *kino_layer) {
120158
return kino_player_get_reel(&kino_layer->player);
121159
}
122160

123-
KinoPlayer *kino_layer_get_player(KinoLayer *kino_layer) {
124-
return &kino_layer->player;
125-
}
161+
KinoPlayer *kino_layer_get_player(KinoLayer *kino_layer) { return &kino_layer->player; }
126162

127163
void kino_layer_set_alignment(KinoLayer *kino_layer, GAlign alignment) {
128164
kino_layer->alignment = alignment;
@@ -134,9 +170,7 @@ void kino_layer_set_background_color(KinoLayer *kino_layer, GColor color) {
134170
layer_mark_dirty(&kino_layer->layer);
135171
}
136172

137-
void kino_layer_play(KinoLayer *kino_layer) {
138-
kino_player_play(&kino_layer->player);
139-
}
173+
void kino_layer_play(KinoLayer *kino_layer) { kino_player_play(&kino_layer->player); }
140174

141175
void kino_layer_play_section(KinoLayer *kino_layer, uint32_t from_position, uint32_t to_position) {
142176
kino_player_play_section(&kino_layer->player, from_position, to_position);
@@ -146,27 +180,21 @@ ImmutableAnimation *kino_layer_create_play_animation(KinoLayer *kino_layer) {
146180
return kino_player_create_play_animation(&kino_layer->player);
147181
}
148182

149-
ImmutableAnimation *kino_layer_create_play_section_animation(
150-
KinoLayer *kino_layer, uint32_t from_position, uint32_t to_position) {
151-
return kino_player_create_play_section_animation(&kino_layer->player, from_position,
152-
to_position);
183+
ImmutableAnimation *kino_layer_create_play_section_animation(KinoLayer *kino_layer,
184+
uint32_t from_position,
185+
uint32_t to_position) {
186+
return kino_player_create_play_section_animation(&kino_layer->player, from_position, to_position);
153187
}
154188

155-
void kino_layer_pause(KinoLayer *kino_layer) {
156-
kino_player_pause(&kino_layer->player);
157-
}
189+
void kino_layer_pause(KinoLayer *kino_layer) { kino_player_pause(&kino_layer->player); }
158190

159-
void kino_layer_rewind(KinoLayer *kino_layer) {
160-
kino_player_rewind(&kino_layer->player);
161-
}
191+
void kino_layer_rewind(KinoLayer *kino_layer) { kino_player_rewind(&kino_layer->player); }
162192

163193
GColor kino_layer_get_background_color(KinoLayer *kino_layer) {
164194
return kino_layer->background_color;
165195
}
166196

167-
GAlign kino_layer_get_alignment(KinoLayer *kino_layer) {
168-
return kino_layer->alignment;
169-
}
197+
GAlign kino_layer_get_alignment(KinoLayer *kino_layer) { return kino_layer->alignment; }
170198

171199
GRect kino_layer_get_reel_bounds(KinoLayer *kino_layer) {
172200
KinoPlayer *player = kino_layer_get_player(kino_layer);

src/fw/applib/ui/kino/kino_layer.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616

1717
#pragma once
1818

19-
#include "kino_reel.h"
20-
#include "kino_player.h"
21-
2219
#include "applib/ui/layer.h"
20+
#include "kino_player.h"
21+
#include "kino_reel.h"
2322

2423
struct KinoLayer;
2524
typedef struct KinoLayer KinoLayer;
@@ -37,6 +36,7 @@ struct KinoLayer {
3736
GAlign alignment;
3837
KinoLayerCallbacks callbacks;
3938
void *context;
39+
bool invert_colors;
4040
};
4141

4242
void kino_layer_init(KinoLayer *kino_layer, const GRect *frame);
@@ -50,11 +50,12 @@ void kino_layer_destroy(KinoLayer *kino_layer);
5050
Layer *kino_layer_get_layer(KinoLayer *kino_layer);
5151

5252
void kino_layer_set_reel(KinoLayer *kino_layer, KinoReel *reel, bool take_ownership);
53+
void kino_layer_set_invert_colors(KinoLayer *kino_layer, bool invert);
5354

5455
//! @internal
5556
void kino_layer_set_reel_with_resource(KinoLayer *kino_layer, uint32_t resource_id);
5657
void kino_layer_set_reel_with_resource_system(KinoLayer *kino_layer, ResAppNum app_num,
57-
uint32_t resource_id);
58+
uint32_t resource_id, bool invert);
5859

5960
KinoReel *kino_layer_get_reel(KinoLayer *kino_layer);
6061

@@ -74,8 +75,9 @@ void kino_layer_play_section(KinoLayer *kino_layer, uint32_t from_position, uint
7475

7576
ImmutableAnimation *kino_layer_create_play_animation(KinoLayer *kino_layer);
7677

77-
ImmutableAnimation *kino_layer_create_play_section_animation(
78-
KinoLayer *kino_layer, uint32_t from_position, uint32_t to_position);
78+
ImmutableAnimation *kino_layer_create_play_section_animation(KinoLayer *kino_layer,
79+
uint32_t from_position,
80+
uint32_t to_position);
7981

8082
void kino_layer_pause(KinoLayer *kino_layer);
8183

src/fw/applib/ui/kino/kino_player.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ T_STATIC void prv_play_animation_update(Animation *animation, const AnimationPro
5050
bool is_reel_infinite = (kino_reel_duration == PLAY_DURATION_INFINITE);
5151
bool is_animation_reversed = animation_get_reverse(animation);
5252
bool is_animation_infinite =
53-
(animation_get_duration(animation, false, false) == PLAY_DURATION_INFINITE);
53+
(animation_get_duration(animation, false, false) == PLAY_DURATION_INFINITE);
5454

5555
if (!is_animation_infinite && !is_reel_infinite) {
5656
// If neither animation nor reel is infinite
@@ -81,11 +81,11 @@ static void prv_play_anim_stopped(Animation *anim, bool finished, void *context)
8181
}
8282

8383
static const AnimationImplementation s_play_animation_impl = {
84-
.update = prv_play_animation_update,
84+
.update = prv_play_animation_update,
8585
};
8686

8787
static const AnimationHandlers s_play_anim_handlers = {
88-
.stopped = prv_play_anim_stopped,
88+
.stopped = prv_play_anim_stopped,
8989
};
9090

9191
//////////////////////////////////
@@ -129,9 +129,7 @@ void kino_player_set_reel_with_resource_system(KinoPlayer *player, ResAppNum app
129129
kino_player_set_reel(player, new_reel, true);
130130
}
131131

132-
KinoReel *kino_player_get_reel(KinoPlayer *player) {
133-
return player->reel;
134-
}
132+
KinoReel *kino_player_get_reel(KinoPlayer *player) { return player->reel; }
135133

136134
static void prv_create_play_animation(KinoPlayer *player, uint32_t from_value, uint32_t to_value) {
137135
// stop any ongoing animation
@@ -180,8 +178,9 @@ ImmutableAnimation *kino_player_create_play_animation(KinoPlayer *player) {
180178
return NULL;
181179
}
182180

183-
ImmutableAnimation *kino_player_create_play_section_animation(
184-
KinoPlayer *player, uint32_t from_elapsed_ms, uint32_t to_elapsed_ms) {
181+
ImmutableAnimation *kino_player_create_play_section_animation(KinoPlayer *player,
182+
uint32_t from_elapsed_ms,
183+
uint32_t to_elapsed_ms) {
185184
if (player && player->reel) {
186185
prv_create_play_animation(player, from_elapsed_ms, to_elapsed_ms);
187186
return (ImmutableAnimation *)player->animation;
@@ -207,12 +206,17 @@ void kino_player_rewind(KinoPlayer *player) {
207206
}
208207

209208
void kino_player_draw(KinoPlayer *player, GContext *ctx, GPoint offset) {
209+
kino_player_draw_processed(player, ctx, offset, NULL);
210+
}
211+
212+
void kino_player_draw_processed(KinoPlayer *player, GContext *ctx, GPoint offset,
213+
KinoReelProcessor *processor) {
210214
if (player && player->reel) {
211-
kino_reel_draw(player->reel, ctx, offset);
215+
kino_reel_draw_processed(player->reel, ctx, offset, processor);
212216
}
213217
}
214218

215219
void kino_player_deinit(KinoPlayer *player) {
216-
player->callbacks = (KinoPlayerCallbacks) { 0 };
220+
player->callbacks = (KinoPlayerCallbacks){0};
217221
kino_player_set_reel(player, NULL, false);
218222
}

src/fw/applib/ui/kino/kino_player.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616

1717
#pragma once
1818

19-
#include "kino_reel.h"
20-
2119
#include "applib/ui/animation.h"
20+
#include "kino_reel.h"
2221

2322
struct KinoPlayer;
2423
typedef struct KinoPlayer KinoPlayer;
@@ -67,8 +66,9 @@ void kino_player_play_section(KinoPlayer *player, uint32_t from_elapsed_ms, uint
6766
//! @return a pointer to a ImmutableAnimation object that plays the KinoPlayer when scheduled
6867
ImmutableAnimation *kino_player_create_play_animation(KinoPlayer *player);
6968

70-
ImmutableAnimation *kino_player_create_play_section_animation(
71-
KinoPlayer *player, uint32_t from_elapsed_ms, uint32_t to_elapsed_ms);
69+
ImmutableAnimation *kino_player_create_play_section_animation(KinoPlayer *player,
70+
uint32_t from_elapsed_ms,
71+
uint32_t to_elapsed_ms);
7272

7373
void kino_player_pause(KinoPlayer *player);
7474

@@ -77,3 +77,6 @@ void kino_player_rewind(KinoPlayer *player);
7777
void kino_player_deinit(KinoPlayer *player);
7878

7979
void kino_player_draw(KinoPlayer *player, GContext *ctx, GPoint offset);
80+
81+
void kino_player_draw_processed(KinoPlayer *player, GContext *ctx, GPoint offset,
82+
KinoReelProcessor *processor);

0 commit comments

Comments
 (0)