Skip to content

Commit b0633af

Browse files
authored
Merge pull request #62 from darmiel/feat/playlist
feat: .sub playlist plugin
2 parents de4e7b9 + e0efb2b commit b0633af

File tree

7 files changed

+875
-0
lines changed

7 files changed

+875
-0
lines changed

applications/meta/application.fam

+1
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ App(
7979
"multi_converter",
8080
"flipfrid",
8181
"subbrute",
82+
"sub_playlist",
8283
],
8384
)

applications/playlist/application.fam

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
App(
2+
appid="sub_playlist",
3+
name=".sub Playlist",
4+
apptype=FlipperAppType.PLUGIN,
5+
entry_point="playlist_app",
6+
cdefines=["APP_PLAYLIST"],
7+
requires=["storage", "gui", "dialogs", "subghz"],
8+
stack_size=2 * 1024,
9+
order=14,
10+
)

applications/playlist/canvas_helper.c

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include <gui/gui.h>
2+
3+
#define WIDTH 128
4+
#define HEIGHT 64
5+
6+
void draw_centered_boxed_str(Canvas* canvas, int x, int y, int height, int pad, const char* text) {
7+
// get width of text
8+
int w = canvas_string_width(canvas, text);
9+
canvas_draw_rframe(canvas, x, y, w + pad, height, 2);
10+
canvas_draw_str_aligned(canvas, x + pad / 2, y + height / 2, AlignLeft, AlignCenter, text);
11+
}
12+
13+
void draw_corner_aligned(Canvas* canvas, int width, int height, Align horizontal, Align vertical) {
14+
canvas_set_color(canvas, ColorBlack);
15+
switch(horizontal) {
16+
case AlignLeft:
17+
switch(vertical) {
18+
case AlignTop:
19+
canvas_draw_rbox(canvas, 0, 0, width, height, 3);
20+
canvas_draw_box(canvas, 0, 0, width, 3);
21+
canvas_draw_box(canvas, 0, 0, 3, height);
22+
break;
23+
case AlignCenter:
24+
canvas_draw_rbox(canvas, 0, HEIGHT - height / 2, width, height, 3);
25+
canvas_draw_box(canvas, 0, HEIGHT - height / 2, 3, height);
26+
break;
27+
case AlignBottom:
28+
canvas_draw_rbox(canvas, 0, HEIGHT - height, width, height, 3);
29+
canvas_draw_box(canvas, 0, HEIGHT - height, 3, height);
30+
canvas_draw_box(canvas, 0, HEIGHT - 3, width, 3);
31+
break;
32+
default:
33+
break;
34+
}
35+
break;
36+
case AlignRight:
37+
switch(vertical) {
38+
case AlignTop:
39+
canvas_draw_rbox(canvas, WIDTH - width, 0, width, height, 3);
40+
canvas_draw_box(canvas, WIDTH - width, 0, width, 3); // bottom corner
41+
canvas_draw_box(canvas, WIDTH - 3, 0, 3, height); // right corner
42+
break;
43+
case AlignCenter:
44+
canvas_draw_rbox(canvas, WIDTH - width, HEIGHT / 2 - height / 2, width, height, 3);
45+
canvas_draw_box(canvas, WIDTH - 3, HEIGHT / 2 - height / 2, 3, height); // right corner
46+
break;
47+
case AlignBottom:
48+
canvas_draw_rbox(canvas, WIDTH - width, HEIGHT - height, width, height, 3);
49+
canvas_draw_box(canvas, WIDTH - 3, HEIGHT - height, 3, height); // right corner
50+
canvas_draw_box(canvas, WIDTH - width, HEIGHT - 3, width, 3); // bottom corner
51+
break;
52+
default:
53+
break;
54+
}
55+
break;
56+
case AlignCenter:
57+
switch(vertical) {
58+
case AlignTop:
59+
canvas_draw_rbox(canvas, WIDTH / 2 - width / 2, 0, width, height, 3);
60+
canvas_draw_box(canvas, WIDTH / 2 - width / 2, 0, width, 3); // bottom corner
61+
canvas_draw_box(canvas, WIDTH / 2 - 3, 0, 3, height); // right corner
62+
break;
63+
case AlignCenter:
64+
canvas_draw_rbox(
65+
canvas, WIDTH / 2 - width / 2, HEIGHT / 2 - height / 2, width, height, 3);
66+
canvas_draw_box(
67+
canvas, WIDTH / 2 - 3, HEIGHT / 2 - height / 2, 3, height); // right corner
68+
break;
69+
case AlignBottom:
70+
canvas_draw_rbox(canvas, WIDTH / 2 - width / 2, HEIGHT - height, width, height, 3);
71+
canvas_draw_box(canvas, WIDTH / 2 - 3, HEIGHT - height, 3, height); // right corner
72+
canvas_draw_box(canvas, WIDTH / 2 - width / 2, HEIGHT - 3, width, 3); // bottom corner
73+
break;
74+
default:
75+
break;
76+
}
77+
break;
78+
default:
79+
break;
80+
}
81+
}

applications/playlist/canvas_helper.h

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <gui/gui.h>
2+
3+
void draw_centered_boxed_str(Canvas* canvas, int x, int y, int height, int pad, const char* text);
4+
5+
void draw_corner_aligned(Canvas* canvas, int width, int height, Align horizontal, Align vertical);

0 commit comments

Comments
 (0)