New listener system for different components

This commit is contained in:
Harrison Deng 2018-05-06 14:49:57 -05:00
parent ccb95d43a5
commit 310b3edfcc
3 changed files with 19 additions and 1 deletions

View File

@ -19,6 +19,11 @@ void UI::render() {
if (*lastKey == 100) {
debug = !debug;
if (debug == true) {
for (unsigned i = 0; i < UIListeners.size(); i++) {
UIListeners[i]->componentSetup();
}
}
}
if (debug) {

View File

@ -8,6 +8,7 @@
#ifndef UI_H_
#define UI_H_
#include <opencv2/opencv.hpp>
#include "UIListener.hpp"
class UI {
bool debug = false, showSlider = false;
@ -15,8 +16,8 @@ class UI {
int *lastKey;
unsigned state = 0;
std::vector<cv::Mat> frames = {cv::Mat()};
std::vector<void(*)()> debugAddonStarter;
public:
std::vector<UIListener *> UIListeners;
UI(int *lastKey);
void render();
void nextDebugFrame();

12
src/UIListener.hpp Executable file
View File

@ -0,0 +1,12 @@
#ifndef UILISTENER_HPP_
#define UILISTENER_HPP_
class UIListener {
public:
virtual void componentSetup() = 0;
virtual ~UIListener();
};
#endif /* UILISTENER_HPP_ */