signal_slot.hpp
BASH
2021.03.06 17:54
#include <iostream>
#include <string>
#include <queue>
#include <functional>
#include <vector>
#include <type_traits>
 
struct KeyPressedEvent
{
  KeyPressedEvent() : keyCode_{-1} {}
  KeyPressedEvent(int keyCode) : keyCode_{keyCode} {}
  int keyCode() {return keyCode_;}
 
  private:
    int keyCode_;
};
 
struct KeyReleasedEvent
{
  KeyReleasedEvent() : keyCode_{-1} {}
  KeyReleasedEvent(int keyCode) : keyCode_{keyCode} {}
  int keyCode() {return keyCode_;}
 
  private:
    int keyCode_;
};
 
struct KeyRepeatedEvent
{
  KeyRepeatedEvent() : keyCode_{-1} {}
  KeyRepeatedEvent(int keyCode) : keyCode_{keyCode} {}
  int keyCode() {return keyCode_;}
 
  private:
    int keyCode_;
};
 
struct Window
{
  float x_ = 0;
  float y_ = 0;
 
  void setSize(float x, float y)
  {
    x_ = x;
    y_ = y;
  }
 
  template <typename T>
  void keyEventHandler(T keyEvent)