Allow changing displayed fields in DriverView

This commit is contained in:
2023-03-20 23:31:28 +01:00
parent c8ee51a78f
commit 0d7cc03e02
28 changed files with 603 additions and 68 deletions

View File

@ -17,12 +17,9 @@ public:
virtual void changeToStartScreen()
{
gotoMissionSelectScreenNoTransition();
gotoDriverViewScreenNoTransition();
}
// MissionSelect
void gotoMissionSelectScreenNoTransition();
// AMI
void gotoAMIScreenNoTransition();
@ -34,9 +31,6 @@ protected:
FrontendHeap& frontendHeap;
Model& model;
// MissionSelect
void gotoMissionSelectScreenNoTransitionImpl();
// AMI
void gotoAMIScreenNoTransitionImpl();

View File

@ -81,7 +81,7 @@ public:
virtual void gotoStartScreen(FrontendApplication& app)
{
app.gotoMissionSelectScreenNoTransition();
app.gotoDriverViewScreenNoTransition();
}
protected:
FrontendHeapBase(touchgfx::AbstractPartition& presenters, touchgfx::AbstractPartition& views, touchgfx::AbstractPartition& transitions, FrontendApplication& app)

View File

@ -0,0 +1,42 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef DRIVERVIEWFIELDSELECTIONBASE_HPP
#define DRIVERVIEWFIELDSELECTIONBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/widgets/canvas/Line.hpp>
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
class DriverViewFieldSelectionBase : public touchgfx::Container
{
public:
DriverViewFieldSelectionBase();
virtual ~DriverViewFieldSelectionBase();
virtual void initialize();
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box bg;
touchgfx::TextArea name;
touchgfx::Line line1;
touchgfx::PainterRGB565 line1Painter;
touchgfx::Line line2;
touchgfx::PainterRGB565 line2Painter;
touchgfx::Line line2_1;
touchgfx::PainterRGB565 line2_1Painter;
private:
};
#endif // DRIVERVIEWFIELDSELECTIONBASE_HPP

View File

@ -15,6 +15,8 @@
#include <touchgfx/containers/progress_indicators/LineProgress.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <gui/containers/DriverViewField.hpp>
#include <touchgfx/containers/scrollers/ScrollWheel.hpp>
#include <gui/containers/DriverViewFieldSelection.hpp>
class DriverViewViewBase : public touchgfx::View<DriverViewPresenter>
{
@ -23,6 +25,36 @@ public:
virtual ~DriverViewViewBase();
virtual void setupScreen();
virtual void fieldTypeSelectionUpdateItem(DriverViewFieldSelection& item, int16_t itemIndex)
{
// Override and implement this function in DriverView
}
virtual void handleKeyEvent(uint8_t key);
/*
* Virtual Action Handlers
*/
virtual void selectPrevField()
{
// Override and implement this function in DriverView
}
virtual void selectNextField()
{
// Override and implement this function in DriverView
}
virtual void selectPrevFieldType()
{
// Override and implement this function in DriverView
}
virtual void selectNextFieldType()
{
// Override and implement this function in DriverView
}
virtual void confirmFieldType()
{
// Override and implement this function in DriverView
}
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
@ -51,6 +83,8 @@ protected:
DriverViewField field1;
DriverViewField field2;
DriverViewField field3;
touchgfx::ScrollWheel fieldTypeSelection;
touchgfx::DrawableListItems<DriverViewFieldSelection, 11> fieldTypeSelectionListItems;
private:
@ -60,6 +94,16 @@ private:
static const uint32_t CANVAS_BUFFER_SIZE = 7200;
uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
/*
* Callback Declarations
*/
touchgfx::Callback<DriverViewViewBase, touchgfx::DrawableListItemsInterface*, int16_t, int16_t> updateItemCallback;
/*
* Callback Handler Declarations
*/
void updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex);
};
#endif // DRIVERVIEWVIEWBASE_HPP

View File

@ -33,19 +33,6 @@ FrontendApplicationBase::FrontendApplicationBase(Model& m, FrontendHeap& heap)
* Screen Transition Declarations
*/
// MissionSelect
void FrontendApplicationBase::gotoMissionSelectScreenNoTransition()
{
transitionCallback = touchgfx::Callback<FrontendApplicationBase>(this, &FrontendApplication::gotoMissionSelectScreenNoTransitionImpl);
pendingScreenTransitionCallback = &transitionCallback;
}
void FrontendApplicationBase::gotoMissionSelectScreenNoTransitionImpl()
{
touchgfx::makeTransition<MissionSelectView, MissionSelectPresenter, touchgfx::NoTransition, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
}
// AMI
void FrontendApplicationBase::gotoAMIScreenNoTransition()

View File

@ -0,0 +1,58 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/containers/DriverViewFieldSelectionBase.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
DriverViewFieldSelectionBase::DriverViewFieldSelectionBase()
{
setWidth(160);
setHeight(26);
bg.setPosition(0, 0, 160, 25);
bg.setColor(touchgfx::Color::getColorFromRGB(34, 34, 34));
add(bg);
name.setPosition(0, 0, 160, 25);
name.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
name.setLinespacing(0);
name.setTypedText(touchgfx::TypedText(T___SINGLEUSE_PNKR));
add(name);
line1.setPosition(0, 25, 160, 1);
line1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line1.setPainter(line1Painter);
line1.setStart(0, 0);
line1.setEnd(160, 0);
line1.setLineWidth(10);
line1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line1);
line2.setPosition(0, 0, 1, 26);
line2Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line2.setPainter(line2Painter);
line2.setStart(0, 0);
line2.setEnd(0, 26);
line2.setLineWidth(10);
line2.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line2);
line2_1.setPosition(159, 0, 1, 26);
line2_1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line2_1.setPainter(line2_1Painter);
line2_1.setStart(0, 0);
line2_1.setEnd(0, 26);
line2_1.setLineWidth(10);
line2_1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line2_1);
}
DriverViewFieldSelectionBase::~DriverViewFieldSelectionBase()
{
}
void DriverViewFieldSelectionBase::initialize()
{
}

View File

@ -7,7 +7,8 @@
#include <images/BitmapDatabase.hpp>
#include <texts/TextKeysAndLanguages.hpp>
DriverViewViewBase::DriverViewViewBase()
DriverViewViewBase::DriverViewViewBase() :
updateItemCallback(this, &DriverViewViewBase::updateItemCallbackHandler)
{
touchgfx::CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);
@ -101,6 +102,20 @@ DriverViewViewBase::DriverViewViewBase()
field3.setXY(320, 0);
add(field3);
fieldTypeSelection.setPosition(0, 80, 160, 240);
fieldTypeSelection.setHorizontal(false);
fieldTypeSelection.setCircular(true);
fieldTypeSelection.setEasingEquation(touchgfx::EasingEquations::backEaseOut);
fieldTypeSelection.setSwipeAcceleration(10);
fieldTypeSelection.setDragAcceleration(10);
fieldTypeSelection.setNumberOfItems(1);
fieldTypeSelection.setSelectedItemOffset(94);
fieldTypeSelection.setDrawableSize(26, 0);
fieldTypeSelection.setDrawables(fieldTypeSelectionListItems, updateItemCallback);
fieldTypeSelection.animateToItem(0, 0);
fieldTypeSelection.setVisible(false);
add(fieldTypeSelection);
}
DriverViewViewBase::~DriverViewViewBase()
@ -117,4 +132,67 @@ void DriverViewViewBase::setupScreen()
field1.initialize();
field2.initialize();
field3.initialize();
fieldTypeSelection.initialize();
for (int i = 0; i < fieldTypeSelectionListItems.getNumberOfDrawables(); i++)
{
fieldTypeSelectionListItems[i].initialize();
}
}
void DriverViewViewBase::handleKeyEvent(uint8_t key)
{
if(22 == key)
{
//SelectPreviousField
//When hardware button 22 clicked call virtual function
//Call selectPrevField
selectPrevField();
}
if(21 == key)
{
//SelectNextField
//When hardware button 21 clicked call virtual function
//Call selectNextField
selectNextField();
}
if(24 == key)
{
//SelectPreviousFieldType
//When hardware button 24 clicked call virtual function
//Call selectPrevFieldType
selectPrevFieldType();
}
if(23 == key)
{
//SelectNextFieldType
//When hardware button 23 clicked call virtual function
//Call selectNextFieldType
selectNextFieldType();
}
if(6 == key)
{
//ConfirmFieldType
//When hardware button 6 clicked call virtual function
//Call confirmFieldType
confirmFieldType();
}
}
void DriverViewViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
{
if (items == &fieldTypeSelectionListItems)
{
touchgfx::Drawable* d = items->getDrawable(containerIndex);
DriverViewFieldSelection* cc = (DriverViewFieldSelection*)d;
fieldTypeSelectionUpdateItem(*cc, itemIndex);
}
}