flipperzero-firmware/applications/gui/elements.c
あく 665f6d7d9c
Assets, Icons, UI toolkit. Part 1. (#202)
* Assets: import from gdrive
* Assets: fully working build pipeline and registry
* NFC: menu icon
* Gui: layers. Irukagotchi: base app to handle input on idle screen. Makefile: reboot after flash in dfu mode.
* ValueMutex: with lambda
* Assets: proper animation frames sorting
* ValueMutex: proper furi_open usage
* Assets,GUI: split icon into icon data and icon state.
* Format source code
* Docker: add python3 and imagemagic
* Irukagotchi: cleanup
* GUI: event lock moved to gui.
* Rfid: proper gui layer
* GUI: elements. Menu: frame and scroll
* GUI, Menu: format code.
* Menu: dual font main menu
* Menu: format sources
* GUI: 0 total scrollbar
* CI: enable lfs
* Menu: pixel perfect main menu

Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
Co-authored-by: aanper <mail@s3f.ru>
2020-10-26 20:00:17 +03:00

31 lines
1.2 KiB
C

#include "elements.h"
void elements_scrollbar(CanvasApi* canvas, uint8_t pos, uint8_t total) {
uint8_t width = canvas->width(canvas);
uint8_t height = canvas->height(canvas);
// prevent overflows
canvas->set_color(canvas, ColorWhite);
canvas->draw_box(canvas, width - 3, 0, 3, height);
// dot line
canvas->set_color(canvas, ColorBlack);
for(uint8_t i = 0; i < height; i += 2) {
canvas->draw_dot(canvas, width - 2, i);
}
// Position block
if(total) {
uint8_t block_h = ((float)height) / total;
canvas->draw_box(canvas, width - 3, block_h * pos, 3, block_h);
}
}
void elements_frame(CanvasApi* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) {
canvas->draw_line(canvas, x + 2, y, x + width - 2, y);
canvas->draw_line(canvas, x + 1, y + height - 1, x + width, y + height - 1);
canvas->draw_line(canvas, x + 2, y + height, x + width - 1, y + height);
canvas->draw_line(canvas, x, y + 2, x, y + height - 2);
canvas->draw_line(canvas, x + width - 1, y + 1, x + width - 1, y + height - 2);
canvas->draw_line(canvas, x + width, y + 2, x + width, y + height - 2);
canvas->draw_dot(canvas, x + 1, y + 1);
}