Refactor menuHandler to mainMenu
parent
bfbe63c88a
commit
0ad9c9915b
|
@ -50,7 +50,7 @@ list(APPEND PB_INCLUDE_DIRECTORIES "${TOOLCHAIN_PATH}/usr/arm-obreey-linux-gnuea
|
|||
|
||||
set(SOURCES ${CMAKE_SOURCE_DIR}/src/main.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/handler/eventHandler.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/handler/menuHandler.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/handler/mainMenu.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/util/nextcloud.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/util/item.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/ui/listView.cpp
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "inkview.h"
|
||||
#include "eventHandler.h"
|
||||
#include "menuHandler.h"
|
||||
#include "mainMenu.h"
|
||||
#include "listView.h"
|
||||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef EVENT_HANDLER
|
||||
#define EVENT_HANDLER
|
||||
|
||||
#include "menuHandler.h"
|
||||
#include "mainMenu.h"
|
||||
#include "nextcloud.h"
|
||||
#include "listView.h"
|
||||
#include "loginView.h"
|
||||
|
@ -40,7 +40,7 @@ private:
|
|||
static std::unique_ptr<EventHandler> _eventHandlerStatic;
|
||||
std::unique_ptr<ListView> _listView;
|
||||
std::unique_ptr<LoginView> _loginView;
|
||||
MenuHandler _menu = MenuHandler("Nextcloud");
|
||||
MainMenu _menu = MainMenu("Nextcloud");
|
||||
Nextcloud _nextcloud = Nextcloud();
|
||||
std::string _tempPath;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//------------------------------------------------------------------
|
||||
// menuHandler.cpp
|
||||
// mainMenu.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Date: 14.06.2020
|
||||
|
@ -7,13 +7,13 @@
|
|||
//-------------------------------------------------------------------
|
||||
|
||||
#include "inkview.h"
|
||||
#include "menuHandler.h"
|
||||
#include "mainMenu.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
MenuHandler::MenuHandler(const string &name)
|
||||
MainMenu::MainMenu(const string &name)
|
||||
{
|
||||
//Define panel size
|
||||
_panelMenuHeight = ScreenHeight() / 18;
|
||||
|
@ -23,7 +23,7 @@ MenuHandler::MenuHandler(const string &name)
|
|||
|
||||
_menuButtonRect = iRect(_mainMenuWidth * 2, _panelMenuBeginY, _mainMenuWidth, _panelMenuHeight, ALIGN_RIGHT);
|
||||
|
||||
_menuFont = OpenFont("LiberationMono-Bold", _panelMenuHeight / 2, 1);
|
||||
_menuFont = OpenFont("LiberationMono-Bold", _panelMenuHeight / 2, FONT_STD);
|
||||
|
||||
SetFont(_menuFont, BLACK);
|
||||
DrawTextRect(0, _panelMenuBeginY, ScreenWidth(), _panelMenuHeight, name.c_str(), ALIGN_CENTER);
|
||||
|
@ -32,17 +32,13 @@ MenuHandler::MenuHandler(const string &name)
|
|||
|
||||
_contentRect = iRect(0, _panelMenuHeight, ScreenWidth(), (ScreenHeight() - PanelHeight() - _panelMenuHeight), 0);
|
||||
|
||||
_loadingScreenRect = iRect(_contentRect.w / 2 - 125, _contentRect.h / 2 - 50, 250, 100, ALIGN_CENTER);
|
||||
_loadingFont = OpenFont("LiberationMono", _loadingScreenRect.h / 4, 1);
|
||||
|
||||
SetHardTimer("PANELUPDATE", panelHandlerStatic, 110000);
|
||||
DrawPanel(NULL, "", NULL, -1);
|
||||
}
|
||||
|
||||
MenuHandler::~MenuHandler()
|
||||
MainMenu::~MainMenu()
|
||||
{
|
||||
CloseFont(_menuFont);
|
||||
CloseFont(_loadingFont);
|
||||
free(_text);
|
||||
free(_menu);
|
||||
free(_makeStartfolder);
|
||||
|
@ -51,13 +47,13 @@ MenuHandler::~MenuHandler()
|
|||
free(_exit);
|
||||
}
|
||||
|
||||
void MenuHandler::panelHandlerStatic()
|
||||
void MainMenu::panelHandlerStatic()
|
||||
{
|
||||
DrawPanel(NULL, "", NULL, -1);
|
||||
SetHardTimer("PANELUPDATE", panelHandlerStatic, 110000);
|
||||
}
|
||||
|
||||
int MenuHandler::createMenu(bool loggedIn, bool workOffline, iv_menuhandler handler)
|
||||
int MainMenu::createMenu(bool loggedIn, bool workOffline, iv_menuhandler handler)
|
||||
{
|
||||
string text = "Work offline";
|
||||
if (workOffline)
|
||||
|
@ -80,17 +76,4 @@ int MenuHandler::createMenu(bool loggedIn, bool workOffline, iv_menuhandler hand
|
|||
OpenMenu(mainMenu, 0, _panelMenuBeginX, _panelMenuBeginY, handler);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void MenuHandler::drawLoadingScreen()
|
||||
{
|
||||
SetFont(_loadingFont, BLACK);
|
||||
DrawTextRect2(&_loadingScreenRect, "Loading...");
|
||||
PartialUpdate(_loadingScreenRect.x, _loadingScreenRect.y, _loadingScreenRect.w, _loadingScreenRect.h);
|
||||
}
|
||||
|
||||
void MenuHandler::clearLoadingScreen()
|
||||
{
|
||||
FillArea(_loadingScreenRect.x, _loadingScreenRect.y, _loadingScreenRect.w, _loadingScreenRect.h / 4, WHITE);
|
||||
PartialUpdate(_loadingScreenRect.x, _loadingScreenRect.y, _loadingScreenRect.w, _loadingScreenRect.h);
|
||||
}
|
||||
}
|
|
@ -1,17 +1,19 @@
|
|||
//------------------------------------------------------------------
|
||||
// eventHandler.h
|
||||
// mainMenu.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Date: 14.06.2020
|
||||
// Description: Handles the menubar and the menu
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#ifndef MENU_HANDLER
|
||||
#define MENU_HANDLER
|
||||
#ifndef MAIN_MENU
|
||||
#define MAIN_MENU
|
||||
|
||||
#include "inkview.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class MenuHandler
|
||||
class MainMenu
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -19,9 +21,9 @@ public:
|
|||
*
|
||||
* @param name name of the application
|
||||
*/
|
||||
MenuHandler(const std::string &name);
|
||||
MainMenu(const std::string &name);
|
||||
|
||||
~MenuHandler();
|
||||
~MainMenu();
|
||||
|
||||
irect *getContentRect() { return &_contentRect; };
|
||||
irect *getMenuButtonRect() { return &_menuButtonRect; };
|
||||
|
@ -35,26 +37,14 @@ public:
|
|||
*/
|
||||
int createMenu(bool loggedIn, bool workOffline, iv_menuhandler handler);
|
||||
|
||||
/**
|
||||
* Draws a loading screen at the top of the screen
|
||||
*/
|
||||
void drawLoadingScreen();
|
||||
|
||||
/**
|
||||
* Clears the area of the loading screen
|
||||
*/
|
||||
void clearLoadingScreen();
|
||||
|
||||
private:
|
||||
ifont *_menuFont;
|
||||
ifont *_loadingFont;
|
||||
|
||||
int _panelMenuBeginX;
|
||||
int _panelMenuBeginY;
|
||||
int _panelMenuHeight;
|
||||
int _mainMenuWidth;
|
||||
irect _menuButtonRect;
|
||||
irect _loadingScreenRect;
|
||||
|
||||
imenu _mainMenu;
|
||||
irect _contentRect;
|
Loading…
Reference in New Issue