mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-15 09:17:11 +00:00
[FL-2500] Change shadows direction and refactor status bar drawing code (#1200)
* GUI: cleanup status bar drawing code and change shadows positions * Archive: drop shadows where they should be
This commit is contained in:
parent
5171a6ad14
commit
51efe8b805
3 changed files with 104 additions and 78 deletions
|
@ -161,21 +161,21 @@ static void archive_render_status_bar(Canvas* canvas, ArchiveBrowserViewModel* m
|
|||
canvas_draw_box(canvas, 107, 0, 20, 13);
|
||||
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_frame(canvas, 1, 0, 50, 12);
|
||||
canvas_draw_line(canvas, 0, 1, 0, 11);
|
||||
canvas_draw_line(canvas, 1, 12, 49, 12);
|
||||
canvas_draw_str_aligned(canvas, 26, 9, AlignCenter, AlignBottom, tab_name);
|
||||
canvas_draw_rframe(canvas, 0, 0, 51, 13, 1); // frame
|
||||
canvas_draw_line(canvas, 49, 1, 49, 11); // shadow right
|
||||
canvas_draw_line(canvas, 1, 11, 49, 11); // shadow bottom
|
||||
canvas_draw_str_aligned(canvas, 25, 9, AlignCenter, AlignBottom, tab_name);
|
||||
|
||||
canvas_draw_frame(canvas, 108, 0, 20, 12);
|
||||
canvas_draw_line(canvas, 107, 1, 107, 11);
|
||||
canvas_draw_line(canvas, 108, 12, 126, 12);
|
||||
canvas_draw_rframe(canvas, 107, 0, 21, 13, 1);
|
||||
canvas_draw_line(canvas, 126, 1, 126, 11);
|
||||
canvas_draw_line(canvas, 108, 11, 126, 11);
|
||||
|
||||
if(model->move_fav) {
|
||||
canvas_draw_icon(canvas, 111, 4, &I_ButtonUp_7x4);
|
||||
canvas_draw_icon(canvas, 118, 4, &I_ButtonDown_7x4);
|
||||
canvas_draw_icon(canvas, 110, 4, &I_ButtonUp_7x4);
|
||||
canvas_draw_icon(canvas, 117, 4, &I_ButtonDown_7x4);
|
||||
} else {
|
||||
canvas_draw_icon(canvas, 112, 2, &I_ButtonLeft_4x7);
|
||||
canvas_draw_icon(canvas, 120, 2, &I_ButtonRight_4x7);
|
||||
canvas_draw_icon(canvas, 111, 2, &I_ButtonLeft_4x7);
|
||||
canvas_draw_icon(canvas, 119, 2, &I_ButtonRight_4x7);
|
||||
}
|
||||
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
|
@ -347,7 +347,7 @@ ArchiveBrowserView* browser_alloc() {
|
|||
browser->view = view_alloc();
|
||||
view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(ArchiveBrowserViewModel));
|
||||
view_set_context(browser->view, browser);
|
||||
view_set_draw_callback(browser->view, (ViewDrawCallback)archive_view_render);
|
||||
view_set_draw_callback(browser->view, archive_view_render);
|
||||
view_set_input_callback(browser->view, archive_view_input);
|
||||
|
||||
string_init(browser->path);
|
||||
|
|
|
@ -47,10 +47,9 @@ bool gui_redraw_fs(Gui* gui) {
|
|||
|
||||
static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
||||
ViewPortArray_it_t it;
|
||||
uint8_t x;
|
||||
uint8_t x_used = 0;
|
||||
uint8_t left_used = 0;
|
||||
uint8_t right_used = 0;
|
||||
uint8_t width;
|
||||
ViewPort* view_port;
|
||||
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
||||
canvas_frame_set(
|
||||
gui->canvas, GUI_STATUS_BAR_X, GUI_STATUS_BAR_Y, GUI_DISPLAY_WIDTH, GUI_STATUS_BAR_HEIGHT);
|
||||
|
@ -69,100 +68,126 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
|||
canvas_set_bitmap_mode(gui->canvas, 0);
|
||||
|
||||
// Right side
|
||||
x = GUI_DISPLAY_WIDTH;
|
||||
uint8_t x = GUI_DISPLAY_WIDTH - 1;
|
||||
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
||||
while(!ViewPortArray_end_p(it) && x_used < GUI_STATUS_BAR_WIDTH) {
|
||||
// Render view_port;
|
||||
view_port = *ViewPortArray_ref(it);
|
||||
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
||||
ViewPort* view_port = *ViewPortArray_ref(it);
|
||||
if(view_port_is_enabled(view_port)) {
|
||||
width = view_port_get_width(view_port);
|
||||
if(!width) width = 8;
|
||||
x_used += width;
|
||||
// Recalculate next position
|
||||
right_used += (width + 2);
|
||||
x -= (width + 2);
|
||||
// Prepare work area background
|
||||
canvas_frame_set(
|
||||
gui->canvas, x - 3, GUI_STATUS_BAR_Y, width + 5, GUI_STATUS_BAR_HEIGHT);
|
||||
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(gui->canvas, 2, 1, width + 2, 10);
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
|
||||
canvas_draw_rframe(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||
canvas_draw_line(gui->canvas, 1, 1, 1, canvas_height(gui->canvas) - 2);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
2,
|
||||
canvas_height(gui->canvas) - 2,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
|
||||
x - 1,
|
||||
GUI_STATUS_BAR_Y + 1,
|
||||
width + 2,
|
||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
// ViewPort draw
|
||||
canvas_frame_set(
|
||||
gui->canvas, x, GUI_STATUS_BAR_Y + 1, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
|
||||
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
view_port_draw(view_port, gui->canvas);
|
||||
}
|
||||
ViewPortArray_next(it);
|
||||
}
|
||||
// Draw frame around icons on the right
|
||||
if(right_used) {
|
||||
canvas_frame_set(
|
||||
gui->canvas,
|
||||
GUI_DISPLAY_WIDTH - 3 - right_used,
|
||||
GUI_STATUS_BAR_Y,
|
||||
right_used + 3,
|
||||
GUI_STATUS_BAR_HEIGHT);
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
canvas_draw_rframe(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
1,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
1,
|
||||
canvas_height(gui->canvas) - 2,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
}
|
||||
|
||||
// Left side
|
||||
x = 0;
|
||||
x = 2;
|
||||
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarLeft]);
|
||||
while(!ViewPortArray_end_p(it) && x_used < GUI_STATUS_BAR_WIDTH) {
|
||||
// Render view_port;
|
||||
view_port = *ViewPortArray_ref(it);
|
||||
while(!ViewPortArray_end_p(it) && (right_used + left_used) < GUI_STATUS_BAR_WIDTH) {
|
||||
ViewPort* view_port = *ViewPortArray_ref(it);
|
||||
if(view_port_is_enabled(view_port)) {
|
||||
width = view_port_get_width(view_port);
|
||||
if(!width) width = 8;
|
||||
x_used += width;
|
||||
|
||||
// Prepare work area background
|
||||
canvas_frame_set(
|
||||
gui->canvas, 0, GUI_STATUS_BAR_Y, x + width + 5, GUI_STATUS_BAR_HEIGHT);
|
||||
canvas_draw_rframe(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||
canvas_draw_line(gui->canvas, 1, 1, 1, canvas_height(gui->canvas) - 2);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
2,
|
||||
canvas_height(gui->canvas) - 2,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
|
||||
canvas_frame_set(gui->canvas, x, GUI_STATUS_BAR_Y, width + 5, GUI_STATUS_BAR_HEIGHT);
|
||||
|
||||
x - 1,
|
||||
GUI_STATUS_BAR_Y + 1,
|
||||
width + 2,
|
||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(gui->canvas, 2, 1, width + 2, 10);
|
||||
canvas_draw_box(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
|
||||
// ViewPort draw
|
||||
canvas_frame_set(
|
||||
gui->canvas, x + 3, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
view_port_draw(view_port, gui->canvas);
|
||||
|
||||
// Recalculate next position
|
||||
left_used += (width + 2);
|
||||
x += (width + 2);
|
||||
}
|
||||
ViewPortArray_next(it);
|
||||
}
|
||||
|
||||
// Extra notification
|
||||
if(need_attention) {
|
||||
width = icon_get_width(&I_Attention_5x8);
|
||||
canvas_frame_set(gui->canvas, 0, GUI_STATUS_BAR_Y, x + width + 5, GUI_STATUS_BAR_HEIGHT);
|
||||
// Prepare work area background
|
||||
canvas_frame_set(
|
||||
gui->canvas,
|
||||
x - 1,
|
||||
GUI_STATUS_BAR_Y + 1,
|
||||
width + 2,
|
||||
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
// Draw Icon
|
||||
canvas_frame_set(
|
||||
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
canvas_draw_icon(gui->canvas, 0, 0, &I_Attention_5x8);
|
||||
// Recalculate next position
|
||||
left_used += (width + 2);
|
||||
x += (width + 2);
|
||||
}
|
||||
// Draw frame around icons on the left
|
||||
if(left_used) {
|
||||
canvas_frame_set(gui->canvas, 0, 0, left_used + 3, GUI_STATUS_BAR_HEIGHT);
|
||||
canvas_draw_rframe(
|
||||
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
||||
canvas_draw_line(gui->canvas, 1, 1, 1, canvas_height(gui->canvas) - 2);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
2,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
1,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
canvas_draw_line(
|
||||
gui->canvas,
|
||||
1,
|
||||
canvas_height(gui->canvas) - 2,
|
||||
canvas_width(gui->canvas) - 2,
|
||||
canvas_height(gui->canvas) - 2);
|
||||
|
||||
canvas_frame_set(gui->canvas, x, GUI_STATUS_BAR_Y, width + 5, GUI_STATUS_BAR_HEIGHT);
|
||||
|
||||
canvas_set_color(gui->canvas, ColorWhite);
|
||||
canvas_draw_box(gui->canvas, 2, 1, width + 2, 10);
|
||||
canvas_set_color(gui->canvas, ColorBlack);
|
||||
|
||||
canvas_frame_set(
|
||||
gui->canvas, x + 3, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
||||
canvas_draw_icon(gui->canvas, 0, 0, &I_Attention_5x8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,20 +11,21 @@
|
|||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
furi_assert(context);
|
||||
Power* power = context;
|
||||
canvas_draw_icon(canvas, 0, 1, &I_Battery_26x8);
|
||||
canvas_draw_icon(canvas, 0, 0, &I_Battery_26x8);
|
||||
|
||||
if(power->info.gauge_is_ok) {
|
||||
canvas_draw_box(canvas, 2, 3, (power->info.charge + 4) / 5, 4);
|
||||
canvas_draw_box(canvas, 2, 2, (power->info.charge + 4) / 5, 4);
|
||||
if(power->state == PowerStateCharging) {
|
||||
canvas_set_bitmap_mode(canvas, 1);
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_icon(canvas, 8, 0, &I_Charging_lightning_mask_9x10);
|
||||
// TODO: replace -1 magic for uint8_t with re-framing
|
||||
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_mask_9x10);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_draw_icon(canvas, 8, 0, &I_Charging_lightning_9x10);
|
||||
canvas_draw_icon(canvas, 8, -1, &I_Charging_lightning_9x10);
|
||||
canvas_set_bitmap_mode(canvas, 0);
|
||||
}
|
||||
} else {
|
||||
canvas_draw_box(canvas, 8, 4, 8, 2);
|
||||
canvas_draw_box(canvas, 8, 3, 8, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue