Super simple events added. Seems to be a good way for handling interaction. Modified a few base classes.
This commit is contained in:
+9
-2
@@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "interaction-event.h"
|
||||
#include "raylib.h"
|
||||
#include "vmath.h"
|
||||
#include <memory>
|
||||
#include <queue>
|
||||
|
||||
#define STATE state->istate
|
||||
#define SETTINGS state->settings
|
||||
@@ -30,7 +32,7 @@ namespace VISEQ::APP{
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(AppSettings, width, height, grid, bpm, fps, speed, gui_selected_midi_out)
|
||||
|
||||
enum InteractionState {HOVER_CANVAS, HOVER_NODE, HOVER_CONNECTOR, ADD_NODES_MENU, DRAG_NODE, CONNECT_NODE, DRAW_SELECTION, SCALE_SELECTION, DELETE_SELECTED_NODES, COPY_SELECTED_NODES, PASTE_SELECTED_NODES};
|
||||
|
||||
|
||||
inline std::vector<std::string> state_string = {"HOVER_CANVAS"," HOVER_NODE"," HOVER_CONNECTOR"," ADD_NODES_MENU"," DRAG_NODE"," CONNECT_NODE"," DRAW_SELECTION"," SCALE_SELECTION"," DELETE_SELECTED_NODES"," COPY_SELECTED_NODES"," PASTE_SELECTED_NODES"};
|
||||
|
||||
struct MouseState{
|
||||
@@ -59,7 +61,7 @@ namespace VISEQ::APP{
|
||||
|
||||
InteractionState istate = HOVER_CANVAS;
|
||||
InteractionState old_istate = HOVER_CANVAS;
|
||||
|
||||
|
||||
int node_mode = 0;
|
||||
|
||||
bool hovering = false;
|
||||
@@ -77,8 +79,13 @@ namespace VISEQ::APP{
|
||||
Vec2Df mouse_delta;
|
||||
|
||||
Vec2Df hover_position;
|
||||
|
||||
void pushEvent(InteractionEvent e){
|
||||
event_queue.push(e);
|
||||
}
|
||||
|
||||
void update(Camera2D camera){
|
||||
|
||||
if(istate != old_istate) std::cout << state_string[istate] << std::endl;
|
||||
|
||||
mouse_delta = {GetMouseDelta().x, GetMouseDelta().y};
|
||||
|
||||
Reference in New Issue
Block a user