suppression de l'ancienne lib GUI
This commit is contained in:
parent
4f1e1be9fb
commit
080266d48a
@ -1,56 +0,0 @@
|
|||||||
#include <algorithm>
|
|
||||||
#include <iostream>
|
|
||||||
#include "GUIScreen.h"
|
|
||||||
|
|
||||||
// Abstract AGuiScreen definition
|
|
||||||
|
|
||||||
gui::AGUIScreen::AGUIScreen() {
|
|
||||||
std::cout << "Hello form AGUIScreen" << "\n";
|
|
||||||
this->widgets = std::vector<AGUIWidget*>();
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIScreen::update() {
|
|
||||||
std::sort(widgets.begin(), widgets.end(), [](AGUIWidget* aWidget, AGUIWidget* bWidget) {
|
|
||||||
return aWidget->getLayer() < bWidget->getLayer();
|
|
||||||
});
|
|
||||||
for (auto *widget: widgets) {
|
|
||||||
widget->update();
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIScreen::addWidget(gui::AGUIWidget *widget) {
|
|
||||||
this->widgets.push_back(widget);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIScreen::removeWidget(gui::AGUIWidget *_widget) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIScreen::removeWidget(int _index) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIScreen::removeWidget(const char *_name) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<gui::AGUIWidget*> gui::AGUIScreen::getWidgets() const {
|
|
||||||
return this->widgets;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// DefaultGuiScreen definition
|
|
||||||
|
|
||||||
gui::DefaultGuiScreen::DefaultGuiScreen() {
|
|
||||||
std::cout << "Hello form DefaultGuiScreen" << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::DefaultGuiScreen::setup() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *gui::DefaultGuiScreen::getName() const {
|
|
||||||
return "DefaultGuiScreen";
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef T_IOT_901_CONVOYOR_GUICONTAINER_H
|
|
||||||
#define T_IOT_901_CONVOYOR_GUICONTAINER_H
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "GUIWidget.h"
|
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
|
|
||||||
class AGUIScreen {
|
|
||||||
public:
|
|
||||||
AGUIScreen();
|
|
||||||
~AGUIScreen() = default;
|
|
||||||
virtual const char* getName() const = 0;
|
|
||||||
virtual int setup() = 0;
|
|
||||||
int update();
|
|
||||||
int addWidget(AGUIWidget* widget);
|
|
||||||
int removeWidget(AGUIWidget* widget);
|
|
||||||
int removeWidget(int index);
|
|
||||||
int removeWidget(const char* name);
|
|
||||||
std::vector<AGUIWidget*> getWidgets() const;
|
|
||||||
protected:
|
|
||||||
std::vector<AGUIWidget*> widgets;
|
|
||||||
};
|
|
||||||
|
|
||||||
class DefaultGuiScreen : public AGUIScreen {
|
|
||||||
public:
|
|
||||||
DefaultGuiScreen();
|
|
||||||
~DefaultGuiScreen() = default;
|
|
||||||
const char* getName() const override;
|
|
||||||
int setup() override;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //T_IOT_901_CONVOYOR_GUICONTAINER_H
|
|
@ -1,33 +0,0 @@
|
|||||||
#include "GUIWidget.h"
|
|
||||||
|
|
||||||
gui::AGUIWidget::AGUIWidget(int x, int y, int width, int height, int layer) : layer(layer) {
|
|
||||||
this->position.x = x;
|
|
||||||
this->position.y = y;
|
|
||||||
this->size.width = width;
|
|
||||||
this->size.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
int gui::AGUIWidget::getLayer() const {
|
|
||||||
return this->layer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gui::AGUIWidget::setLayer(int newLayer) {
|
|
||||||
this->layer = newLayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiWidgetPosition gui::AGUIWidget::getPosition() const {
|
|
||||||
return this->position;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gui::AGUIWidget::setPosition(GuiWidgetPosition pos) {
|
|
||||||
this->position = pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiWidgetSize gui::AGUIWidget::getSize() const {
|
|
||||||
return this->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gui::AGUIWidget::setSize(GuiWidgetSize newSize) {
|
|
||||||
this->size = newSize;
|
|
||||||
}
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef T_IOT_901_CONVOYOR_GUIWIDGET_H
|
|
||||||
#define T_IOT_901_CONVOYOR_GUIWIDGET_H
|
|
||||||
|
|
||||||
struct GuiWidgetPosition {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GuiWidgetSize {
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
class AGUIWidget {
|
|
||||||
public:
|
|
||||||
AGUIWidget(int x, int y, int width, int height, int layer = 0);
|
|
||||||
~AGUIWidget() = default;
|
|
||||||
virtual const char* getName() const = 0;
|
|
||||||
virtual void setup() = 0;
|
|
||||||
virtual void update() = 0;
|
|
||||||
int getLayer() const;
|
|
||||||
void setLayer(int layer);
|
|
||||||
GuiWidgetPosition getPosition() const;
|
|
||||||
void setPosition(GuiWidgetPosition position);
|
|
||||||
GuiWidgetSize getSize() const;
|
|
||||||
void setSize(GuiWidgetSize size);
|
|
||||||
private:
|
|
||||||
GuiWidgetPosition position{};
|
|
||||||
GuiWidgetSize size{};
|
|
||||||
int layer;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //T_IOT_901_CONVOYOR_GUIWIDGET_H
|
|
@ -1,82 +0,0 @@
|
|||||||
#include "WarehouseGUI.h"
|
|
||||||
#include "M5Stack.h"
|
|
||||||
|
|
||||||
using namespace gui;
|
|
||||||
|
|
||||||
WarehouseGUI::WarehouseGUI() {
|
|
||||||
this->screens = std::vector<AGUIScreen*>();
|
|
||||||
}
|
|
||||||
|
|
||||||
WarehouseGUI::~WarehouseGUI() = default;
|
|
||||||
|
|
||||||
int WarehouseGUI::addScreens(gui::AGUIScreen *screen) {
|
|
||||||
this->screens.push_back(screen);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::removeScreens(gui::AGUIScreen *screen) {
|
|
||||||
for (int i = 0; i < this->screens.size(); ++i) {
|
|
||||||
if (this->screens[i] == screen) {
|
|
||||||
this->screens.erase(this->screens.begin() + i);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::removeScreens(int index) {
|
|
||||||
if (index < 0 || index >= this->screens.size()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
this->screens.erase(this->screens.begin() + index);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::removeScreens(const char *name) {
|
|
||||||
for (int i = 0; i < this->screens.size(); ++i) {
|
|
||||||
if (this->screens[i]->getName() == name) {
|
|
||||||
this->screens.erase(this->screens.begin() + i);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::update() {
|
|
||||||
return this->current_screen->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::setup() {
|
|
||||||
if (this->current_screen == nullptr) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return this->current_screen->setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::changeCurrentScreen(const char *name) {
|
|
||||||
for (auto *screen : this->screens) {
|
|
||||||
if (screen->getName() == name) {
|
|
||||||
this->current_screen = screen;
|
|
||||||
this->current_screen->setup();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int WarehouseGUI::changeCurrentScreen(int index) {
|
|
||||||
if (index < 0 || index >= this->screens.size()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
this->current_screen = this->screens[index];
|
|
||||||
this->current_screen->setup();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<AGUIScreen *> gui::WarehouseGUI::getAllScreens() {
|
|
||||||
return this->screens;
|
|
||||||
}
|
|
||||||
|
|
||||||
AGUIScreen *gui::WarehouseGUI::getCurrentScreen() {
|
|
||||||
return this->current_screen;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef T_IOT_901_CONVOYOR_WAREHOUSEGUI_H
|
|
||||||
#define T_IOT_901_CONVOYOR_WAREHOUSEGUI_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "GUIScreen.h"
|
|
||||||
|
|
||||||
namespace gui {
|
|
||||||
class WarehouseGUI {
|
|
||||||
public:
|
|
||||||
WarehouseGUI();
|
|
||||||
~WarehouseGUI();
|
|
||||||
int addScreens(AGUIScreen* screen);
|
|
||||||
int removeScreens(AGUIScreen* screen);
|
|
||||||
int removeScreens(int index);
|
|
||||||
int removeScreens(const char *name);
|
|
||||||
int changeCurrentScreen(const char* name);
|
|
||||||
int changeCurrentScreen(int index);
|
|
||||||
std::vector<AGUIScreen*> getAllScreens();
|
|
||||||
AGUIScreen* getCurrentScreen();
|
|
||||||
int setup();
|
|
||||||
int update();
|
|
||||||
private:
|
|
||||||
std::vector<AGUIScreen*> screens;
|
|
||||||
AGUIScreen *current_screen{nullptr};
|
|
||||||
};
|
|
||||||
} // namespace gui
|
|
||||||
|
|
||||||
#endif //T_IOT_901_CONVOYOR_WAREHOUSEGUI_H
|
|
Loading…
x
Reference in New Issue
Block a user