Created a basic UI system (UNTESTED)
This commit is contained in:
parent
e36d75c4fa
commit
b7873a34c6
3 changed files with 89 additions and 0 deletions
|
@ -1,10 +1,26 @@
|
|||
// Libraries
|
||||
#include <furi.h>
|
||||
#include "ui.h"
|
||||
|
||||
// Entry Point
|
||||
int32_t flippypass_app(void* p) {
|
||||
// Not using P Parameter
|
||||
UNUSED(p);
|
||||
|
||||
// Creating the UI struct
|
||||
uiManager* ui = ui_create();
|
||||
|
||||
// Timer
|
||||
int alive_timer = 0;
|
||||
|
||||
// Drawwing the UI
|
||||
while(ui->running) {
|
||||
// Updating canvas
|
||||
view_port_update(ui->canvas);
|
||||
|
||||
alive_timer += 1;
|
||||
if (alive_timer > 10000000) {ui->running = false; break;}
|
||||
}
|
||||
|
||||
// Exit App
|
||||
return 0;
|
||||
|
|
49
project/ui.c
Normal file
49
project/ui.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Header
|
||||
#include "ui.h"
|
||||
|
||||
// Functions
|
||||
uiManager* ui_create() {
|
||||
// Creating the UI Manager
|
||||
uiManager* result = malloc(sizeof(uiManager));
|
||||
|
||||
// Defining basic variables
|
||||
result->running = true;
|
||||
result->page = 0;
|
||||
|
||||
// Creating a canvas
|
||||
result->canvas = view_port_alloc();
|
||||
view_port_draw_callback_set(result->canvas, ui_draw, result);
|
||||
|
||||
// Returning the UI Manager
|
||||
return result;
|
||||
}
|
||||
|
||||
void ui_draw(Canvas* canvas, void* ctx) {
|
||||
// Context into Result
|
||||
uiManager* manager = (uiManager*)ctx;
|
||||
|
||||
// Switching page
|
||||
switch(manager->page){
|
||||
case 0:
|
||||
ui_p_mainmenu(canvas);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void ui_p_mainmenu(Canvas* canvas) {
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 11, "FlippyPass");
|
||||
|
||||
//canvas_draw_icon(canvas, 15, 16, &I_ButtonRight_4x7);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 22, 23, "View Passwords");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 22, 41, "Create Password");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 22, 51, "About");
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
canvas_draw_str(canvas, 22, 32, "View Archive");
|
||||
}
|
24
project/ui.h
Normal file
24
project/ui.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Define once
|
||||
#ifndef H_UI
|
||||
#define H_UI
|
||||
|
||||
// Libraries
|
||||
#include <furi.h>
|
||||
#include <gui/gui.h>
|
||||
|
||||
// Structures
|
||||
typedef struct {
|
||||
ViewPort* canvas;
|
||||
int page;
|
||||
|
||||
bool running;
|
||||
} uiManager;
|
||||
|
||||
// Constructors
|
||||
uiManager* ui_create();
|
||||
|
||||
// Functions
|
||||
void ui_draw(Canvas* canvas, void* ctx);
|
||||
void ui_p_mainmenu(Canvas* canvas);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue