From fefda66337996f61c461d041f8df81ad21ebf1c8 Mon Sep 17 00:00:00 2001 From: Robert Borzecki Date: Mon, 5 Aug 2019 06:28:45 +0200 Subject: [PATCH] Added stub class for text widget. --- module-apps/CMakeLists.txt | 1 + .../application-call/ApplicationCall.cpp | 25 ++-- .../application-call/ApplicationCall.hpp | 2 +- .../application-call/windows/CallWindow.cpp | 42 ++---- .../application-call/windows/CallWindow.hpp | 5 + .../ApplicationDesktop.cpp | 2 +- .../ApplicationDesktop.hpp | 5 +- .../windows/MenuWindow.cpp | 4 +- .../application-notes/ApplicationNotes.cpp | 80 +++++++++++ .../application-notes/ApplicationNotes.hpp | 47 +++++++ module-apps/application-notes/CMakeLists.txt | 23 +++ .../windows/NotesMainWindow.cpp | 131 ++++++++++++++++++ .../windows/NotesMainWindow.hpp | 40 ++++++ .../ApplicationSettings.cpp | 4 +- .../ApplicationSettings.hpp | 10 +- module-gui/gui/widgets/BoxLayout.cpp | 10 -- module-gui/gui/widgets/CMakeLists.txt | 2 + module-gui/gui/widgets/Text.cpp | 25 ++++ module-gui/gui/widgets/Text.hpp | 56 ++++++++ .../service-appmgr/ApplicationManager.cpp | 35 +++-- source/main.cpp | 18 +-- 21 files changed, 482 insertions(+), 85 deletions(-) create mode 100644 module-apps/application-notes/ApplicationNotes.cpp create mode 100644 module-apps/application-notes/ApplicationNotes.hpp create mode 100644 module-apps/application-notes/CMakeLists.txt create mode 100644 module-apps/application-notes/windows/NotesMainWindow.cpp create mode 100644 module-apps/application-notes/windows/NotesMainWindow.hpp create mode 100644 module-gui/gui/widgets/Text.cpp create mode 100644 module-gui/gui/widgets/Text.hpp diff --git a/module-apps/CMakeLists.txt b/module-apps/CMakeLists.txt index baa5fc0ad..a7eacc2fe 100644 --- a/module-apps/CMakeLists.txt +++ b/module-apps/CMakeLists.txt @@ -39,6 +39,7 @@ add_subdirectory( application-viewer ) add_subdirectory( application-desktop ) add_subdirectory( application-settings ) add_subdirectory( application-call ) +add_subdirectory( application-notes ) include_directories( ../module-sys ) include_directories( ../module-utils ) diff --git a/module-apps/application-call/ApplicationCall.cpp b/module-apps/application-call/ApplicationCall.cpp index e36721103..bc42ef320 100644 --- a/module-apps/application-call/ApplicationCall.cpp +++ b/module-apps/application-call/ApplicationCall.cpp @@ -49,34 +49,41 @@ sys::Message_t ApplicationCall::DataReceivedHandler(sys::DataMessage* msgl) { if( msgl->messageType == static_cast(MessageType::CellularNotification) ) { CellularNotificationMessage *msg = reinterpret_cast(msgl); + gui::CallWindow* callWindow = reinterpret_cast( windows.find( "CallWindow")->second); + if (msg->type == CellularNotificationMessage::Type::CallAborted) { - LOG_INFO("CallAborted"); + LOG_INFO("---------------------------------CallAborted"); + callWindow->setState( gui::CallWindow::State::CALL_ENDED ); + refreshWindow( gui::RefreshModes::GUI_REFRESH_FAST ); } else if( msg->type == CellularNotificationMessage::Type::CallBusy) { - LOG_INFO("CallBusy"); + LOG_INFO("---------------------------------CallBusy"); + callWindow->setState( gui::CallWindow::State::CALL_ENDED ); + refreshWindow( gui::RefreshModes::GUI_REFRESH_FAST ); } else if( msg->type == CellularNotificationMessage::Type::CallActive ) { - LOG_INFO("CallActive"); + LOG_INFO("---------------------------------CallActive"); + callWindow->setState( gui::CallWindow::State::CALL_IN_PROGRESS ); + refreshWindow( gui::RefreshModes::GUI_REFRESH_FAST ); } else if( msg->type == CellularNotificationMessage::Type::IncomingCall ) { - LOG_INFO("IncomingCall 1 %s", msg->data.c_str()); + LOG_INFO("---------------------------------IncomingCall"); std::unique_ptr data = std::make_unique(msg->data); - LOG_INFO("IncomingCall 2"); //send to itself message to switch (run) call application if( state == State::ACTIVE_FORGROUND ) { - LOG_INFO("FORGROUND"); + switchWindow( "CallWindow",0,nullptr ); } else { - LOG_INFO("BACKGROUND"); + callWindow->setState( gui::CallWindow::State::INCOMMING_CALL ); sapm::ApplicationManager::messageSwitchApplication( this, "ApplicationCall", "CallWindow", std::move(data) ); // ApplicationManager::messageSwitchApplication( this, "ApplicationCall", "CallWindow", std::move(data) ); } } else if( msg->type == CellularNotificationMessage::Type::NewIncomingSMS ) { - LOG_INFO("NewIncomingSMS"); + LOG_INFO("---------------------------------NewIncomingSMS"); } else if( msg->type == CellularNotificationMessage::Type::SignalStrengthUpdate ) { - LOG_INFO("SignalStrengthUpdate"); + LOG_INFO("---------------------------------SignalStrengthUpdate"); } handled = true; } diff --git a/module-apps/application-call/ApplicationCall.hpp b/module-apps/application-call/ApplicationCall.hpp index c46a12935..81db35224 100644 --- a/module-apps/application-call/ApplicationCall.hpp +++ b/module-apps/application-call/ApplicationCall.hpp @@ -49,7 +49,7 @@ public: return sysmgr->CreateService(std::make_shared(name),sysmgr); }; bool runBackground(sys::SystemManager* sysmgr) { - return sysmgr->CreateService(std::make_shared(name), sysmgr); + return sysmgr->CreateService(std::make_shared(name, true), sysmgr); }; }; diff --git a/module-apps/application-call/windows/CallWindow.cpp b/module-apps/application-call/windows/CallWindow.cpp index c67d0b62b..ec2585de5 100644 --- a/module-apps/application-call/windows/CallWindow.cpp +++ b/module-apps/application-call/windows/CallWindow.cpp @@ -65,6 +65,11 @@ void CallWindow::destroyInterface() { CallWindow::~CallWindow() { } +void CallWindow::setState( State state ) { + this->state = state; + setVisibleState(); +} + void CallWindow::setVisibleState() { //show state of the window switch( state ) { @@ -131,15 +136,6 @@ bool CallWindow::handleLeftButton() { if( state == State::INCOMMING_CALL ) { auto ret = CellularServiceAPI::AnswerIncomingCall(application); LOG_INFO("AnswerIncomingCall: %s",(ret?"OK":"FAIL")); - if( ret ) { - state = State::CALL_IN_PROGRESS; - setVisibleState(); - } - else { - //TODO show some info - } - - return true; } else if( state == State::OUTGOING_CALL ) { @@ -176,34 +172,22 @@ bool CallWindow::handleRightButton() { auto ret = CellularServiceAPI::HangupCall(application); LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); - state = State::CALL_ENDED; - //start 3 sek timer - - //show enc call screen - - //return to previous application - sapm::ApplicationManager::messageSwitchPreviousApplication( application ); - return true; } else if( state == State::OUTGOING_CALL ) { - + auto ret = CellularServiceAPI::HangupCall(application); + LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); } else if( state == State::CALL_ENDED ) { - + //return to previous application + sapm::ApplicationManager::messageSwitchPreviousApplication( application ); + return true; } else if( state == State::CALL_IN_PROGRESS ) { auto ret = CellularServiceAPI::HangupCall(application); LOG_INFO("HangupCall: %s",(ret?"OK":"FAIL")); - state = State::CALL_ENDED; - //start 3 sek timer - - //show enc call screen - - //return to previous application - sapm::ApplicationManager::messageSwitchPreviousApplication( application ); - return true; + return true; } return false; } @@ -233,8 +217,8 @@ bool CallWindow::onInput( const InputEvent& inputEvent ) { } } - if( handled ) - application->refreshWindow( RefreshModes::GUI_REFRESH_FAST); +// if( handled ) +// application->refreshWindow( RefreshModes::GUI_REFRESH_FAST); return false; } diff --git a/module-apps/application-call/windows/CallWindow.hpp b/module-apps/application-call/windows/CallWindow.hpp index 95d110fa1..b60eaca0d 100644 --- a/module-apps/application-call/windows/CallWindow.hpp +++ b/module-apps/application-call/windows/CallWindow.hpp @@ -40,6 +40,11 @@ public: CallWindow( app::Application* app, std::string windowName = "CallWindow" ); virtual ~CallWindow(); + /** + * Used by application to update window's state + */ + void setState( State state ); + //virtual methods bool onInput( const InputEvent& inputEvent ) override; void onBeforeShow( ShowMode mode, uint32_t command, SwitchData* data ) override; diff --git a/module-apps/application-desktop/ApplicationDesktop.cpp b/module-apps/application-desktop/ApplicationDesktop.cpp index cc3057caa..273a1beda 100644 --- a/module-apps/application-desktop/ApplicationDesktop.cpp +++ b/module-apps/application-desktop/ApplicationDesktop.cpp @@ -22,7 +22,7 @@ namespace app { ApplicationDesktop::ApplicationDesktop(std::string name) : - Application( name, 4096 ) { + Application( name ) { } ApplicationDesktop::~ApplicationDesktop() { diff --git a/module-apps/application-desktop/ApplicationDesktop.hpp b/module-apps/application-desktop/ApplicationDesktop.hpp index 1fb30f6cb..9b093fa15 100644 --- a/module-apps/application-desktop/ApplicationDesktop.hpp +++ b/module-apps/application-desktop/ApplicationDesktop.hpp @@ -25,7 +25,7 @@ protected: uint32_t unreadMessages = 0; uint32_t missedCalls = 0; public: - ApplicationDesktop( std::string name="ApplicationDesktop"); + ApplicationDesktop( std::string name="ApplicationDesktop" ); virtual ~ApplicationDesktop(); sys::Message_t DataReceivedHandler(sys::DataMessage* msgl) override; sys::ReturnCodes InitHandler() override; @@ -54,6 +54,9 @@ public: bool run(sys::SystemManager* sysmgr) override { return sysmgr->CreateService(std::make_shared(name),sysmgr); }; + bool runBackground(sys::SystemManager* sysmgr) override { + return sysmgr->CreateService(std::make_shared(name),sysmgr); +}; }; diff --git a/module-apps/application-desktop/windows/MenuWindow.cpp b/module-apps/application-desktop/windows/MenuWindow.cpp index dded4855e..f896b6cfe 100644 --- a/module-apps/application-desktop/windows/MenuWindow.cpp +++ b/module-apps/application-desktop/windows/MenuWindow.cpp @@ -150,7 +150,9 @@ void MenuWindow::buildInterface() { //PAGE 2 std::vector page2Definitions { - TileDescription{"menu_tools_notes", "app_desktop_tools_notes",[=] (gui::Item& item){ return true; }}, + TileDescription{"menu_tools_notes", "app_desktop_tools_notes",[=] (gui::Item& item){ + sapm::ApplicationManager::messageSwitchApplication( application, "ApplicationNotes", "MainWindow", nullptr ); + return true; }}, TileDescription{"menu_tools_calculator","app_desktop_tools_calculator",[=] (gui::Item& item){ return true; }}, TileDescription{"menu_tools_recorder", "app_desktop_tools_recorder",[=] (gui::Item& item){ return true; }}, }; diff --git a/module-apps/application-notes/ApplicationNotes.cpp b/module-apps/application-notes/ApplicationNotes.cpp new file mode 100644 index 000000000..9ebc01673 --- /dev/null +++ b/module-apps/application-notes/ApplicationNotes.cpp @@ -0,0 +1,80 @@ +/* + * @file ApplicationNotes.cpp + * @author Robert Borzecki (robert.borzecki@mudita.com) + * @date 30 lip 2019 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ +#include "MessageType.hpp" +#include "windows/NotesMainWindow.hpp" + +#include "ApplicationNotes.hpp" + +namespace app { + +ApplicationNotes::ApplicationNotes(std::string name, bool startBackgound) : + Application( name, startBackgound, 2048 ) { +} + +ApplicationNotes::~ApplicationNotes() { +} + +// Invoked upon receiving data message +sys::Message_t ApplicationNotes::DataReceivedHandler(sys::DataMessage* msgl) { + + auto retMsg = Application::DataReceivedHandler(msgl); + //if message was handled by application's template there is no need to process further. + if( (reinterpret_cast( retMsg.get() )->retCode == + sys::ReturnCodes::Success ) ){ + return retMsg; + } + + //this variable defines whether message was processed. + bool handled = true; + + if( handled ) + return std::make_shared(); + else + return std::make_shared(sys::ReturnCodes::Unresolved); +} + +// Invoked during initialization +sys::ReturnCodes ApplicationNotes::InitHandler() { + + auto ret = Application::InitHandler(); + if( ret != sys::ReturnCodes::Success ) + return ret; + + createUserInterface(); + + setActiveWindow("MainWindow"); + + return ret; +} + +sys::ReturnCodes ApplicationNotes::DeinitHandler() { + return sys::ReturnCodes::Success; +} + +sys::ReturnCodes ApplicationNotes::WakeUpHandler() { + return sys::ReturnCodes::Success; +} + + +sys::ReturnCodes ApplicationNotes::SleepHandler() { + return sys::ReturnCodes::Success; +} + +void ApplicationNotes::createUserInterface() { + + gui::AppWindow* window = nullptr; + + window = new gui::NotesMainWindow(this); + windows.insert(std::pair(window->getName(), window)); +} + +void ApplicationNotes::destroyUserInterface() { +} + +} /* namespace app */ diff --git a/module-apps/application-notes/ApplicationNotes.hpp b/module-apps/application-notes/ApplicationNotes.hpp new file mode 100644 index 000000000..be9284195 --- /dev/null +++ b/module-apps/application-notes/ApplicationNotes.hpp @@ -0,0 +1,47 @@ +/* + * @file ApplicationNotes.hpp + * @author Robert Borzecki (robert.borzecki@mudita.com) + * @date 30 lip 2019 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ +#ifndef MODULE_APPS_APPLICATION_NOTES_APPLICATIONNOTES_HPP_ +#define MODULE_APPS_APPLICATION_NOTES_APPLICATIONNOTES_HPP_ + +#include "Application.hpp" + +namespace app { + +class ApplicationNotes: public Application { +public: + ApplicationNotes( std::string name="ApplicationNotes", bool startBackgound = false); + virtual ~ApplicationNotes(); + sys::Message_t DataReceivedHandler(sys::DataMessage* msgl) override; + sys::ReturnCodes InitHandler() override; + sys::ReturnCodes DeinitHandler() override; + sys::ReturnCodes WakeUpHandler() override; + sys::ReturnCodes SleepHandler() override; + + void createUserInterface() ; + void destroyUserInterface(); +}; + +class ApplicationNotesLauncher : public ApplicationLauncher { +public: + ApplicationNotesLauncher() : ApplicationLauncher("ApplicationNotes", true) { + }; + bool run(sys::SystemManager* sysmgr) override { + return sysmgr->CreateService(std::make_shared(name),sysmgr); + }; + bool runBackground(sys::SystemManager* sysmgr) { + return sysmgr->CreateService(std::make_shared(name, true), sysmgr); + }; +}; + +} /* namespace app */ + + + + +#endif /* MODULE_APPS_APPLICATION_NOTES_APPLICATIONNOTES_HPP_ */ diff --git a/module-apps/application-notes/CMakeLists.txt b/module-apps/application-notes/CMakeLists.txt new file mode 100644 index 000000000..ecd84e563 --- /dev/null +++ b/module-apps/application-notes/CMakeLists.txt @@ -0,0 +1,23 @@ + +include_directories( ${CMAKE_PROJECT_NAME} + + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}" +) + +include_directories( ${PROJECT_NAME} + + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}" +) + +target_sources( ${PROJECT_NAME} + + PRIVATE + "${CMAKE_CURRENT_LIST_DIR}/ApplicationNotes.cpp" + "${CMAKE_CURRENT_LIST_DIR}/windows/NotesMainWindow.cpp" + PUBLIC + "${CMAKE_CURRENT_LIST_DIR}/ApplicationNotes.hpp" + "${CMAKE_CURRENT_LIST_DIR}/windows/NotesMainWindow.hpp" +) + diff --git a/module-apps/application-notes/windows/NotesMainWindow.cpp b/module-apps/application-notes/windows/NotesMainWindow.cpp new file mode 100644 index 000000000..7ba31ff24 --- /dev/null +++ b/module-apps/application-notes/windows/NotesMainWindow.cpp @@ -0,0 +1,131 @@ +/* + * @file NotesMainWindow.cpp + * @author Robert Borzecki (robert.borzecki@mudita.com) + * @date 31 lip 2019 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ +#include +#include + +#include "service-appmgr/ApplicationManager.hpp" + +#include "../ApplicationNotes.hpp" + + +#include "i18/i18.hpp" + +#include "Label.hpp" +#include "Margins.hpp" +#include "NotesMainWindow.hpp" + +namespace gui { + +NotesMainWindow::NotesMainWindow( app::Application* app ) : AppWindow(app,"MainWindow"){ + setSize( 480, 600 ); + + buildInterface(); +} + +void NotesMainWindow::rebuild() { + destroyInterface(); + buildInterface(); +} +void NotesMainWindow::buildInterface() { + AppWindow::buildInterface(); +// bottomBar->setActive( BottomBar::Side::CENTER, true ); +// bottomBar->setActive( BottomBar::Side::RIGHT, true ); +// bottomBar->setText( BottomBar::Side::CENTER, utils::localize.get("common_open")); +// bottomBar->setText( BottomBar::Side::RIGHT, utils::localize.get("common_back")); +// +// topBar->setActive(TopBar::Elements::SIGNAL, true ); +// topBar->setActive(TopBar::Elements::BATTERY, true ); +// +// title = new gui::Label(this, 0, 50, 480, 50 ); +// title->setFilled( false ); +// title->setBorderColor( gui::ColorNoColor ); +// title->setFont("gt_pressura_bold_24"); +// title->setText(utils::localize.get("app_settings_title_main")); +// title->setAlignement( gui::Alignment(gui::Alignment::ALIGN_HORIZONTAL_CENTER, gui::Alignment::ALIGN_VERTICAL_CENTER)); +// +// //add option connectivity option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_connectivity"), [=] (gui::Item& item){ return true; }) ); +// +// //add option date and time option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_date_and_time"), [=](gui::Item&){ return true;}) ); +// +// //add option display option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_display"), [=](gui::Item&){ return true;} )); +// +// //add option phone mode option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_phone_modes"), [=](gui::Item&){ return true;} )); +// +// //add option security option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_security"), [=](gui::Item&){ return true;} )); +// +// //add option language option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_language"), [=](gui::Item&){ +// LOG_INFO("switching to language page" ); +// application->switchWindow("Languages", 0, nullptr ); +// return true;} )); +// +// //add option security option +// options.push_back( addOptionLabel( utils::localize.get("app_settings_about"), [=](gui::Item&){ return true;} )); +// +// //set position and navigation for labels +// uint32_t posY = 100; +// uint32_t size = options.size(); +// for( uint32_t i=0; isetPosition(17,posY); +// posY += 60; +// options[i]->setNavigationItem( NavigationDirection::DOWN, options[(i+1)%size]); +// options[i]->setNavigationItem( NavigationDirection::UP, options[(size+i-1)%size]); +// } +} +void NotesMainWindow::destroyInterface() { + AppWindow::destroyInterface(); +// delete title; +// for( uint32_t i=0; ifocusItem = nullptr; +// LOG_INFO("options size: %d", options.size()); + children.clear(); +} + +NotesMainWindow::~NotesMainWindow() { + destroyInterface(); +} + +void NotesMainWindow::onBeforeShow( ShowMode mode, uint32_t command, SwitchData* data ) { +// setFocusItem( options[0] ); +} + +bool NotesMainWindow::onInput( const InputEvent& inputEvent ) { + //check if any of the lower inheritance onInput methods catch the event + bool ret = AppWindow::onInput( inputEvent ); + if( ret ) { + //refresh window only when key is other than enter + if( inputEvent.keyCode != KeyCode::KEY_ENTER ) + application->render( RefreshModes::GUI_REFRESH_FAST ); + return true; + } + + //process only if key is released + if(( inputEvent.state != InputEvent::State::keyReleasedShort ) && + (( inputEvent.state != InputEvent::State::keyReleasedLong ))) + return false; + + if( inputEvent.keyCode == KeyCode::KEY_ENTER ) { + LOG_INFO("Enter pressed"); + } + else if( inputEvent.keyCode == KeyCode::KEY_RF ) { + sapm::ApplicationManager::messageSwitchPreviousApplication(application); + return true; + } + + return false; +} + +} /* namespace gui */ diff --git a/module-apps/application-notes/windows/NotesMainWindow.hpp b/module-apps/application-notes/windows/NotesMainWindow.hpp new file mode 100644 index 000000000..2c18268fa --- /dev/null +++ b/module-apps/application-notes/windows/NotesMainWindow.hpp @@ -0,0 +1,40 @@ +/* + * @file NotesMainWindow.hpp + * @author Robert Borzecki (robert.borzecki@mudita.com) + * @date 31 lip 2019 + * @brief + * @copyright Copyright (C) 2019 mudita.com + * @details + */ +#ifndef MODULE_APPS_APPLICATION_NOTES_WINDOWS_NOTESMAINWINDOW_HPP_ +#define MODULE_APPS_APPLICATION_NOTES_WINDOWS_NOTESMAINWINDOW_HPP_ + +#include +#include + +#include "AppWindow.hpp" +#include "gui/widgets/Label.hpp" +#include "gui/widgets/Image.hpp" +#include "gui/widgets/Window.hpp" +#include "gui/widgets/BottomBar.hpp" +#include "gui/widgets/TopBar.hpp" + +namespace gui { + +class NotesMainWindow: public AppWindow { +public: + NotesMainWindow( app::Application* app ); + virtual ~NotesMainWindow(); + + //virtual methods + bool onInput( const InputEvent& inputEvent ) override; + void onBeforeShow( ShowMode mode, uint32_t command, SwitchData* data ) override; + + void rebuild() override; + void buildInterface() override; + void destroyInterface() override; +}; + +} /* namespace gui */ + +#endif /* MODULE_APPS_APPLICATION_NOTES_WINDOWS_NOTESMAINWINDOW_HPP_ */ diff --git a/module-apps/application-settings/ApplicationSettings.cpp b/module-apps/application-settings/ApplicationSettings.cpp index 7865a8545..4b680a7a7 100644 --- a/module-apps/application-settings/ApplicationSettings.cpp +++ b/module-apps/application-settings/ApplicationSettings.cpp @@ -16,8 +16,8 @@ namespace app { -ApplicationSettings::ApplicationSettings(std::string name) : - Application( name, 2048 ) { +ApplicationSettings::ApplicationSettings(std::string name, bool startBackgound) : + Application( name, startBackgound, 2048 ) { } ApplicationSettings::~ApplicationSettings() { diff --git a/module-apps/application-settings/ApplicationSettings.hpp b/module-apps/application-settings/ApplicationSettings.hpp index 98ad5b07e..129d43f46 100644 --- a/module-apps/application-settings/ApplicationSettings.hpp +++ b/module-apps/application-settings/ApplicationSettings.hpp @@ -18,7 +18,7 @@ namespace app { */ class ApplicationSettings: public app::Application { public: - ApplicationSettings( std::string name="ApplicationSettings"); + ApplicationSettings( std::string name="ApplicationSettings", bool startBackgound = false); virtual ~ApplicationSettings(); sys::Message_t DataReceivedHandler(sys::DataMessage* msgl) override; sys::ReturnCodes InitHandler() override; @@ -32,9 +32,13 @@ public: class ApplicationSettingsLauncher : public ApplicationLauncher { public: - ApplicationSettingsLauncher() : ApplicationLauncher("ApplicationSettings", true) {}; + ApplicationSettingsLauncher() : ApplicationLauncher("ApplicationSettings", true) { + }; bool run(sys::SystemManager* sysmgr) override { - return sysmgr->CreateService(std::make_shared(name),sysmgr, 1000); + return sysmgr->CreateService(std::make_shared(name),sysmgr); + }; + bool runBackground(sys::SystemManager* sysmgr) { + return sysmgr->CreateService(std::make_shared(name, true), sysmgr); }; }; diff --git a/module-gui/gui/widgets/BoxLayout.cpp b/module-gui/gui/widgets/BoxLayout.cpp index 7663d26ec..e25de2cb9 100644 --- a/module-gui/gui/widgets/BoxLayout.cpp +++ b/module-gui/gui/widgets/BoxLayout.cpp @@ -136,11 +136,6 @@ void HBox::resizeItems() { break; } -// for( Item* item : children ) -// std::cout<<"x: "<< item->widgetArea.x<<" y: "<< item->widgetArea.y<< -// " w: "<< item->widgetArea.w<<" h: "<< item->widgetArea.h<widgetArea.x<<" y: "<< item->widgetArea.y<< -// " w: "<< item->widgetArea.w<<" h: "<< item->widgetArea.h< + +#include "utf8/UTF8.hpp" + +#include "BoxLayout.hpp" +#include "Rect.hpp" + +namespace gui { + +/* + * @brief Widget that holds multiple lines of text. This widget can expand vertically if needed to hold lines of text. + */ +class Text: public Rect{ +public: + enum class LineEndType { + EOT, //end of source text + BREAK, //line had enter defined as a /r + CONTINUE, //line was broken due to not enough space to hold all characters + CONTINUE_SPACE //line was broken on the space character because next word doesn't fit current line. + }; + +protected: + VBox labelsBox; + + class TextLine { + public: + UTF8 text; + LineEndType endType; + + TextLine( const UTF8 ); + }; +public: + Text(); + Text( Item* parent, const uint32_t& x, const uint32_t& y, const uint32_t& w, const uint32_t& h, const UTF8& text = "", bool expandVertically = false); + virtual ~Text(); + + //virtual methods + std::list buildDrawList() override; + void setPosition( const short& x, const short& y ) override; + void setSize( const short& w, const short& h ) override; +}; + +} /* namespace gui */ + +#endif /* MODULE_GUI_GUI_WIDGETS_TEXT_HPP_ */ diff --git a/module-services/service-appmgr/ApplicationManager.cpp b/module-services/service-appmgr/ApplicationManager.cpp index 672c4c161..6de803f61 100644 --- a/module-services/service-appmgr/ApplicationManager.cpp +++ b/module-services/service-appmgr/ApplicationManager.cpp @@ -135,16 +135,16 @@ sys::ReturnCodes ApplicationManager::InitHandler() { //search for application with specified name and run it -#if 0 //change to 0 if you want to run only viewer application for kickstarter +#if 1 //change to 0 if you want to run only viewer application for kickstarter std::string runDesktopName = "ApplicationDesktop"; std::string runCallAppName = "ApplicationCall"; -// auto it = applications.find(runCallAppName); -// if( it!= applications.end()){ -// it->second->lanucher->runBackground(reinterpret_cast(this)); -// } + auto it = applications.find(runCallAppName); + if( it!= applications.end()){ + it->second->lanucher->runBackground(reinterpret_cast(this)); + } - auto it = applications.find(runDesktopName); + it = applications.find(runDesktopName); if( it!= applications.end()){ messageSwitchApplication( this, it->second->lanucher->getName(), "", nullptr ); } @@ -310,10 +310,13 @@ bool ApplicationManager::handleSwitchPrevApplication( APMSwitchPrevApp* msg ) { } bool ApplicationManager::handleRegisterApplication( APMRegister* msg ) { - //check if this is register message from recently launched application - if( msg->getSenderName() == launchApplicationName ) { - auto it = applications.find(launchApplicationName); + if( msg->getSenderName() == launchApplicationName ) { + + //check if this is register message from recently launched application + auto it = applications.find(msg->getSenderName()); + if( it == applications.end()) + return false; //application starts in background if( msg->getStartBackground()) { it->second->state = app::Application::State::ACTIVE_BACKGROUND; @@ -326,6 +329,10 @@ bool ApplicationManager::handleRegisterApplication( APMRegister* msg ) { app::Application::messageSwitchApplication( this, launchApplicationName, it->second->switchWindow, std::move(it->second->switchData) ); } } + else { + auto it = applications.find(msg->getSenderName()); + it->second->state = app::Application::State::ACTIVE_BACKGROUND; + } return true; } @@ -435,40 +442,30 @@ bool ApplicationManager::messageConfirmSwitch( sys::Service* sender) { auto msg = std::make_shared(sender->GetName() ); sys::Bus::SendUnicast(msg, "ApplicationManager", sender); return true; -// auto ret = sys::Bus::SendUnicast(msg, "ApplicationManager", sender, 500 ); -// return (ret.first == sys::ReturnCodes::Success )?true:false; } bool ApplicationManager::messageConfirmClose( sys::Service* sender) { auto msg = std::make_shared(sender->GetName() ); sys::Bus::SendUnicast(msg, "ApplicationManager", sender); return true; -// auto ret = sys::Bus::SendUnicast(msg, "ApplicationManager", sender, 500 ); -// return (ret.first == sys::ReturnCodes::Success )?true:false; } bool ApplicationManager::messageSwitchPreviousApplication( sys::Service* sender ) { auto msg = std::make_shared(sender->GetName() ); sys::Bus::SendUnicast(msg, "ApplicationManager", sender); return true; -// auto ret = sys::Bus::SendUnicast(msg, "ApplicationManager", sender, 500); -// return (ret.first == sys::ReturnCodes::Success )?true:false; } bool ApplicationManager::messageRegisterApplication( sys::Service* sender, const bool& status, const bool& startBackground ) { auto msg = std::make_shared(sender->GetName(), status, startBackground ); sys::Bus::SendUnicast(msg, "ApplicationManager", sender); return true; -// auto ret = sys::Bus::SendUnicast(msg, "ApplicationManager", sender, 500 ); -// return (ret.first == sys::ReturnCodes::Success )?true:false; } bool ApplicationManager::messageChangeLanguage( sys::Service* sender, utils::Lang language ) { auto msg = std::make_shared( sender->GetName(), language ); sys::Bus::SendUnicast(msg, "ApplicationManager", sender); return true; -// auto ret = sys::Bus::SendUnicast(msg, "ApplicationManager", sender, 500 ); -// return (ret.first == sys::ReturnCodes::Success )?true:false; } } /* namespace sapm */ diff --git a/source/main.cpp b/source/main.cpp index cd5d9dc34..9b454ec14 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -13,6 +13,7 @@ #include "application-viewer/ApplicationViewer.hpp" #include "application-desktop/ApplicationDesktop.hpp" #include "application-settings/ApplicationSettings.hpp" +#include "application-notes/ApplicationNotes.hpp" //module-services #include "service-gui/ServiceGUI.hpp" @@ -96,27 +97,26 @@ int SystemStart(sys::SystemManager* sysmgr) ret |= sysmgr->CreateService(std::make_shared("EventManager"),sysmgr); ret |= sysmgr->CreateService(std::make_shared(),sysmgr); // ret |= sysmgr->CreateService(std::make_shared("Blinky"),sysmgr); -// ret |= sysmgr->CreateService(std::make_shared(),sysmgr); + ret |= sysmgr->CreateService(std::make_shared(),sysmgr); //vector with launchers to applications std::vector< std::unique_ptr > applications; //launcher for viewer - std::unique_ptr viewerLauncher = std::unique_ptr(new app::ApplicationViewerLauncher()); - applications.push_back( std::move(viewerLauncher) ); + applications.push_back(std::unique_ptr(new app::ApplicationViewerLauncher())); //launcher for desktop application - std::unique_ptr desktopLauncher = std::unique_ptr(new app::ApplicationDesktopLauncher()); - applications.push_back( std::move(desktopLauncher) ); + applications.push_back(std::unique_ptr(new app::ApplicationDesktopLauncher())); //launcher for call application - std::unique_ptr callLauncher = std::unique_ptr(new app::ApplicationCallLauncher()); - applications.push_back( std::move(callLauncher) ); + applications.push_back(std::unique_ptr(new app::ApplicationCallLauncher())); //launcher for settings application - std::unique_ptr settingsLauncher = std::unique_ptr(new app::ApplicationSettingsLauncher()); - applications.push_back( std::move(settingsLauncher) ); + applications.push_back(std::unique_ptr(new app::ApplicationSettingsLauncher())); + + //launcher for notes application + applications.push_back(std::unique_ptr(new app::ApplicationNotesLauncher())); //start application manager ret |= sysmgr->CreateService(std::make_shared("ApplicationManager",sysmgr,applications),sysmgr );