Skip to content

Commit

Permalink
Merge pull request #62 from darmiel/feat/playlist
Browse files Browse the repository at this point in the history
feat: .sub playlist plugin
  • Loading branch information
xMasterX authored Sep 10, 2022
2 parents de4e7b9 + e0efb2b commit b0633af
Show file tree
Hide file tree
Showing 7 changed files with 875 additions and 0 deletions.
1 change: 1 addition & 0 deletions applications/meta/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@ App(
"multi_converter",
"flipfrid",
"subbrute",
"sub_playlist",
],
)
10 changes: 10 additions & 0 deletions applications/playlist/application.fam
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
App(
appid="sub_playlist",
name=".sub Playlist",
apptype=FlipperAppType.PLUGIN,
entry_point="playlist_app",
cdefines=["APP_PLAYLIST"],
requires=["storage", "gui", "dialogs", "subghz"],
stack_size=2 * 1024,
order=14,
)
81 changes: 81 additions & 0 deletions applications/playlist/canvas_helper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <gui/gui.h>

#define WIDTH 128
#define HEIGHT 64

void draw_centered_boxed_str(Canvas* canvas, int x, int y, int height, int pad, const char* text) {
// get width of text
int w = canvas_string_width(canvas, text);
canvas_draw_rframe(canvas, x, y, w + pad, height, 2);
canvas_draw_str_aligned(canvas, x + pad / 2, y + height / 2, AlignLeft, AlignCenter, text);
}

void draw_corner_aligned(Canvas* canvas, int width, int height, Align horizontal, Align vertical) {
canvas_set_color(canvas, ColorBlack);
switch(horizontal) {
case AlignLeft:
switch(vertical) {
case AlignTop:
canvas_draw_rbox(canvas, 0, 0, width, height, 3);
canvas_draw_box(canvas, 0, 0, width, 3);
canvas_draw_box(canvas, 0, 0, 3, height);
break;
case AlignCenter:
canvas_draw_rbox(canvas, 0, HEIGHT - height / 2, width, height, 3);
canvas_draw_box(canvas, 0, HEIGHT - height / 2, 3, height);
break;
case AlignBottom:
canvas_draw_rbox(canvas, 0, HEIGHT - height, width, height, 3);
canvas_draw_box(canvas, 0, HEIGHT - height, 3, height);
canvas_draw_box(canvas, 0, HEIGHT - 3, width, 3);
break;
default:
break;
}
break;
case AlignRight:
switch(vertical) {
case AlignTop:
canvas_draw_rbox(canvas, WIDTH - width, 0, width, height, 3);
canvas_draw_box(canvas, WIDTH - width, 0, width, 3); // bottom corner
canvas_draw_box(canvas, WIDTH - 3, 0, 3, height); // right corner
break;
case AlignCenter:
canvas_draw_rbox(canvas, WIDTH - width, HEIGHT / 2 - height / 2, width, height, 3);
canvas_draw_box(canvas, WIDTH - 3, HEIGHT / 2 - height / 2, 3, height); // right corner
break;
case AlignBottom:
canvas_draw_rbox(canvas, WIDTH - width, HEIGHT - height, width, height, 3);
canvas_draw_box(canvas, WIDTH - 3, HEIGHT - height, 3, height); // right corner
canvas_draw_box(canvas, WIDTH - width, HEIGHT - 3, width, 3); // bottom corner
break;
default:
break;
}
break;
case AlignCenter:
switch(vertical) {
case AlignTop:
canvas_draw_rbox(canvas, WIDTH / 2 - width / 2, 0, width, height, 3);
canvas_draw_box(canvas, WIDTH / 2 - width / 2, 0, width, 3); // bottom corner
canvas_draw_box(canvas, WIDTH / 2 - 3, 0, 3, height); // right corner
break;
case AlignCenter:
canvas_draw_rbox(
canvas, WIDTH / 2 - width / 2, HEIGHT / 2 - height / 2, width, height, 3);
canvas_draw_box(
canvas, WIDTH / 2 - 3, HEIGHT / 2 - height / 2, 3, height); // right corner
break;
case AlignBottom:
canvas_draw_rbox(canvas, WIDTH / 2 - width / 2, HEIGHT - height, width, height, 3);
canvas_draw_box(canvas, WIDTH / 2 - 3, HEIGHT - height, 3, height); // right corner
canvas_draw_box(canvas, WIDTH / 2 - width / 2, HEIGHT - 3, width, 3); // bottom corner
break;
default:
break;
}
break;
default:
break;
}
}
5 changes: 5 additions & 0 deletions applications/playlist/canvas_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <gui/gui.h>

void draw_centered_boxed_str(Canvas* canvas, int x, int y, int height, int pad, const char* text);

void draw_corner_aligned(Canvas* canvas, int width, int height, Align horizontal, Align vertical);
Loading

0 comments on commit b0633af

Please sign in to comment.