Merge branch 'refactor-orbit-ui' of ssh://code.sebastiankujas.com:20002/sebastian/viseq into refactor-orbit-ui
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
CompileFlags:
|
||||||
|
Add: [-I/home/sebastian/code/viseq/include, -std=c++23]
|
||||||
|
|
||||||
@@ -1,23 +1,21 @@
|
|||||||
.PHONY: all clean
|
.PHONY: clean
|
||||||
|
|
||||||
CXX := g++
|
CXX := g++
|
||||||
CXXFLAGS = -std=c++23 -Wall -g -fno-omit-frame-pointer -gdwarf-4 -Og -Wnarrowing -DLIBREMIDI_ALSA=1 -DLIBREMIDI_HEADER_ONLY=1
|
CXXFLAGS := -std=c++23 -Wall -g -fno-omit-frame-pointer -gdwarf-4 -Og -Wnarrowing -DLIBREMIDI_ALSA=1 -DLIBREMIDI_HEADER_ONLY=1
|
||||||
CXXINC := -Iinclude -isysteminclude
|
CXXINC := -Iinclude -isysteminclude
|
||||||
|
|
||||||
LDLIBS := -lraylib -lasound -llibremidi -pthread
|
LDLIBS := -lraylib -lasound -llibremidi -pthread
|
||||||
LDFLAGS := -Llib -L/usr/lib -L/usr/local/lib
|
LDFLAGS := -Llib -L/usr/lib -L/usr/local/lib
|
||||||
|
|
||||||
SOURCES := $(wildcard src/*.cpp)
|
SRCS := $(wildcard src/*.cpp)
|
||||||
OBJECTS := $(SOURCES:src%.cpp=build%.o)
|
OBJECTS := $(patsubst src/%.cpp,build/%.o, $(SRCS))
|
||||||
|
|
||||||
all: viseq
|
|
||||||
|
|
||||||
viseq: $(OBJECTS)
|
viseq: $(OBJECTS)
|
||||||
@mkdir -p build
|
$(CXX) $(OBJECTS) -o $@ $(LDFLAGS) $(LDLIBS)
|
||||||
$(CXX) $(LDFLAGS) $(LDLIBS) -o viseq $^
|
|
||||||
|
|
||||||
build/%.o: src/%.cpp
|
$(OBJECTS): build/%.o : src/%.cpp
|
||||||
$(CXX) $(CXXFLAGS) $(CXXINC) -c $< -o $@
|
@mkdir -p build
|
||||||
|
$(CXX) -c $< -o $@ $(CXXFLAGS) $(CXXINC)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f build/*
|
rm -f build/*
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
#include "selectable.h
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
#include "canvas.h"
|
#include "canvas.h"
|
||||||
|
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "interaction-event.h"
|
//#include "interaction-event.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "draggable.h"
|
#include "draggable.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "clipboard.h"
|
||||||
|
|
||||||
|
namespace VISEQ::APP {
|
||||||
|
GRAPH::NODES::VEC_SPTR_Node Clipboard::pasteNodes(){
|
||||||
|
return clipboard.back();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Clipboard::copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes){
|
||||||
|
if(clipboard.size() == 20) clipboard.pop_back();
|
||||||
|
clipboard.emplace(clipboard.begin());
|
||||||
|
for(auto n : selected_nodes){
|
||||||
|
clipboard.front().push_back(n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-10
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace VISEQ::APP {
|
namespace VISEQ::APP {
|
||||||
class Clipboard {
|
class Clipboard {
|
||||||
@@ -9,17 +10,9 @@ namespace VISEQ::APP {
|
|||||||
|
|
||||||
std::vector<GRAPH::NODES::VEC_SPTR_Node> clipboard;
|
std::vector<GRAPH::NODES::VEC_SPTR_Node> clipboard;
|
||||||
|
|
||||||
GRAPH::NODES::VEC_SPTR_Node pasteNodes(){
|
GRAPH::NODES::VEC_SPTR_Node pasteNodes();
|
||||||
return clipboard.back();
|
|
||||||
}
|
|
||||||
|
|
||||||
void copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes){
|
void copyNodes(GRAPH::NODES::VEC_SPTR_Node selected_nodes);
|
||||||
if(clipboard.size() == 20) clipboard.pop_back();
|
|
||||||
clipboard.emplace(clipboard.begin());
|
|
||||||
for(auto n : selected_nodes){
|
|
||||||
clipboard.front().push_back(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
#include "connectable.h"
|
#include "connectable.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "graph-item.h"
|
#include "graph-item.h"
|
||||||
#include "interaction-event.h"
|
//#include "interaction-event.h"
|
||||||
#include "raymath.h"
|
#include "raymath.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#include "draggable.h"
|
||||||
|
|
||||||
|
namespace VISEQ::BASE {
|
||||||
|
bool Draggable::entered() {
|
||||||
|
return !is_hovering && hovering();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Draggable::exited() {
|
||||||
|
return is_hovering && !hovering();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Draggable::pickedUp() {
|
||||||
|
return held() && picked_up;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draggable::pickUp() {
|
||||||
|
picked_up = true;
|
||||||
|
drag_offset = position - SCREEN_MOUSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draggable::pickUp(Vec2Df selection_origin) {
|
||||||
|
picked_up = true;
|
||||||
|
drag_offset = position - selection_origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draggable::drag(Vec2Df new_position) {
|
||||||
|
position = new_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draggable::putDown() {
|
||||||
|
picked_up = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Draggable::select() {
|
||||||
|
return CheckCollisionPointRec(position, state->selection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Draggable::deselect() {
|
||||||
|
selected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-38
@@ -20,43 +20,14 @@ namespace VISEQ::BASE {
|
|||||||
|
|
||||||
bool picked_up = false;
|
bool picked_up = false;
|
||||||
|
|
||||||
virtual bool entered() override {
|
virtual bool entered() override;
|
||||||
return !is_hovering && hovering();
|
virtual bool exited() override;
|
||||||
}
|
virtual bool pickedUp();
|
||||||
|
virtual void pickUp() override;
|
||||||
virtual bool exited() override {
|
virtual void pickUp(Vec2Df selection_origin) override;
|
||||||
return is_hovering && !hovering();
|
virtual void drag(Vec2Df new_position) override;
|
||||||
}
|
virtual void putDown() override;
|
||||||
|
virtual bool select() override;
|
||||||
virtual bool pickedUp() {
|
virtual void deselect() override;
|
||||||
return held() && picked_up;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void pickUp() override {
|
|
||||||
picked_up = true;
|
|
||||||
drag_offset = position - SCREEN_MOUSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void pickUp(Vec2Df selection_origin) override {
|
|
||||||
picked_up = true;
|
|
||||||
drag_offset = position - selection_origin;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void drag(Vec2Df new_position) override {
|
|
||||||
position = new_position;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void putDown() override {
|
|
||||||
picked_up = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool select() override {
|
|
||||||
return CheckCollisionPointRec(position, state->selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void deselect() override {
|
|
||||||
selected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include "interactable.h"
|
||||||
|
|
||||||
|
namespace VISEQ::BASE {
|
||||||
|
|
||||||
|
bool Interactable::clicked() {
|
||||||
|
return hovering() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Interactable::held() {
|
||||||
|
return IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Interactable::released() {
|
||||||
|
return IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+3
-9
@@ -24,17 +24,11 @@ namespace VISEQ::BASE {
|
|||||||
virtual bool entered() {return false;};
|
virtual bool entered() {return false;};
|
||||||
virtual bool exited() {return false;};
|
virtual bool exited() {return false;};
|
||||||
|
|
||||||
virtual bool clicked() {
|
virtual bool clicked();
|
||||||
return hovering() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool held() {
|
virtual bool held();
|
||||||
return IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool released() {
|
virtual bool released();
|
||||||
return IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual GRAPH::GraphItemType getType() = 0;
|
virtual GRAPH::GraphItemType getType() = 0;
|
||||||
virtual void pickUp() = 0;
|
virtual void pickUp() = 0;
|
||||||
|
|||||||
@@ -17,5 +17,4 @@ namespace VISEQ::APP{
|
|||||||
return lhs.item == rhs.item;
|
return lhs.item == rhs.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static std::deque<APP::InteractionEvent> event_queue;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "clipboard.h"
|
#include "clipboard.h"
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "interaction-event.h"
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
@@ -134,12 +133,13 @@ namespace VISEQ::INTERACTION{
|
|||||||
bool connect_once = false;
|
bool connect_once = false;
|
||||||
|
|
||||||
state->mouse_z = canvas->z_index;
|
state->mouse_z = canvas->z_index;
|
||||||
|
std::cout << state->event_queue.size() << " ";
|
||||||
|
|
||||||
for(auto e : APP::event_queue){
|
for(auto e : state->event_queue){
|
||||||
if(!connect_once && e.action == APP::Interaction::CONNECT){
|
if(!connect_once && e.action == APP::Interaction::CONNECT){
|
||||||
APP::InteractionEvent partner;
|
APP::InteractionEvent partner;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for(auto ei : APP::event_queue){
|
for(auto ei : state->event_queue){
|
||||||
if(ei.action == APP::Interaction::HOVER && ei.item->getType() == GraphItemType::CONNECTOR) {
|
if(ei.action == APP::Interaction::HOVER && ei.item->getType() == GraphItemType::CONNECTOR) {
|
||||||
std::cout << "YEAH" << std::endl;
|
std::cout << "YEAH" << std::endl;
|
||||||
partner = ei;
|
partner = ei;
|
||||||
@@ -167,8 +167,12 @@ namespace VISEQ::INTERACTION{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(APP::event_queue.size() > 0 && !exit){
|
while(state->event_queue.size() > 0 && !exit){
|
||||||
auto e = APP::event_queue.front();
|
auto e = state->event_queue.front();
|
||||||
|
std::cout << e.action;
|
||||||
|
if(e.action == APP::Interaction::CLICK){
|
||||||
|
gm->addToSelection();
|
||||||
|
}
|
||||||
if(e.action == APP::Interaction::RIGHTCLICK){
|
if(e.action == APP::Interaction::RIGHTCLICK){
|
||||||
gm->addToSelection();
|
gm->addToSelection();
|
||||||
state->context_menu = !state->context_menu;
|
state->context_menu = !state->context_menu;
|
||||||
@@ -249,8 +253,8 @@ namespace VISEQ::INTERACTION{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
APP::event_queue.pop_front();
|
state->event_queue.pop_front();
|
||||||
}
|
}
|
||||||
APP::event_queue.clear();
|
state->event_queue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
VISEQ::APP::AppManager app;
|
VISEQ::APP::AppManager app;
|
||||||
|
|
||||||
std::shared_ptr<VISEQ::APP::State> state = VISEQ::APP::State::get();
|
std::shared_ptr<VISEQ::APP::State> state = VISEQ::APP::State::get();
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
#include "node-handle.h"
|
||||||
|
|
||||||
|
namespace VISEQ::GRAPH::NODES {
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::init(){
|
||||||
|
position = parentPosition.orbitAtAngle(orbit, 0) - parentPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
float NodeHandle<T>::distance(){
|
||||||
|
return (parentPosition + position).dist(parentPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::drag(Vec2Df mouse_pos) {
|
||||||
|
float range = (maxValue - minValue) + 1;
|
||||||
|
float stepping = 360.0f / range;
|
||||||
|
|
||||||
|
if(KEYS_DOWN.shift) stepping = stepping * steps;
|
||||||
|
|
||||||
|
float angle = Vector2Angle((SCREEN_MOUSE - parentPosition), Vector2(0,1)) * RAD2DEG - 180; // -180 because round(180 / 33.75) * 33.75 is not 0
|
||||||
|
|
||||||
|
if(KEYS_PRESSED.ctrl) angle_start = angle;
|
||||||
|
if(KEYS_DOWN.ctrl) angle = angle_start + (angle - angle_start) / 10;
|
||||||
|
|
||||||
|
float stepped_angle = (round(angle / stepping) * stepping + 180) * DEG2RAD; // see above. -180 + 180 to get 0 right round(0 / 33.75) * 33.75 is still 0
|
||||||
|
position = parentPosition.orbitAtAngle(orbit, stepped_angle) - parentPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::lock(){
|
||||||
|
visible = false;
|
||||||
|
locked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::unlock(){
|
||||||
|
visible = true;
|
||||||
|
locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NodeHandle<T>::hovering() {
|
||||||
|
return CheckCollisionPointCircle(SCREEN_MOUSE, position + parentPosition, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::update(Vec2Df pos) {
|
||||||
|
if(!locked && visible){
|
||||||
|
if(hovering()) state->pushEvent({getPtr(), APP::Interaction::HOVER});
|
||||||
|
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
||||||
|
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
||||||
|
}
|
||||||
|
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
||||||
|
|
||||||
|
parentPosition = pos;
|
||||||
|
if(!locked && visible) updateAssignedValue();
|
||||||
|
|
||||||
|
minP = parentPosition.orbitAlongVector((parentPosition + position), minDistance);
|
||||||
|
maxP = parentPosition.orbitAlongVector((parentPosition + position), maxDistance);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void NodeHandle<T>::draw() {
|
||||||
|
if(!locked && visible){
|
||||||
|
bool show = hovering() || picked_up;
|
||||||
|
Color dcol = ColorBrightness(col, -0.5f);
|
||||||
|
Color dyncol = show ? col : dcol;
|
||||||
|
Color dGrey = ColorBrightness(VS_COLOR_GREY, -0.2f);
|
||||||
|
Color dynGrey = show ? VS_COLOR_GREY : dGrey;
|
||||||
|
|
||||||
|
if(steps > 0){
|
||||||
|
for(int i = 0; i < steps; i++){
|
||||||
|
Vec2Df pos = parentPosition.orbitAtAngle(orbit, DEG2RAD * i * (360.0f/steps));
|
||||||
|
Vec2Df pos1 = parentPosition.orbitAtAngle(orbit - 3.0f, DEG2RAD * i * (360.0f/steps));
|
||||||
|
DrawLineV(pos, pos1, dynGrey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float r = (parentPosition + position).dist(parentPosition);
|
||||||
|
DrawRing(parentPosition, r - 5, r + 5, 0, 360, 90, ColorAlpha(dyncol, 0.1));
|
||||||
|
DrawRing(parentPosition, r - 5, r + 5, -90, angle_g - 90, 90, ColorAlpha(dyncol, 0.3));
|
||||||
|
DrawCircleV(position + parentPosition, radius, dyncol);
|
||||||
|
//VISEQ::HELPER::DrawSuperText(std::format("{}", assignedValueRef), position + parentPosition, position + parentPosition + Vec2Df(50,0), 1, 0, 8, dyncol);
|
||||||
|
|
||||||
|
/*if(show) {*/
|
||||||
|
/* std::string text = std::format("{}", assignedValueRef);*/
|
||||||
|
/* DrawCenteredText(text, parentPosition, 12, ColorBrightness(dyncol, 0.75f));*/
|
||||||
|
/*}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
bool NodeHandle<T>::select() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+9
-76
@@ -70,43 +70,12 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
bool locked = true;
|
bool locked = true;
|
||||||
bool visible = false;
|
bool visible = false;
|
||||||
|
|
||||||
void init(){
|
void init();
|
||||||
position = parentPosition.orbitAtAngle(orbit, 0) - parentPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void assignValue(T &value){
|
void assignValue(T &value){
|
||||||
assignedValueRef = value;
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float distance(){
|
|
||||||
return (parentPosition + position).dist(parentPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void drag(Vec2Df mouse_pos) override {
|
|
||||||
float range = (maxValue - minValue) + 1;
|
|
||||||
float stepping = 360.0f / range;
|
|
||||||
|
|
||||||
if(KEYS_DOWN.shift) stepping = stepping * steps;
|
|
||||||
|
|
||||||
float angle = Vector2Angle((SCREEN_MOUSE - parentPosition), Vector2(0,1)) * RAD2DEG - 180; // -180 because round(180 / 33.75) * 33.75 is not 0
|
|
||||||
|
|
||||||
if(KEYS_PRESSED.ctrl) angle_start = angle;
|
|
||||||
if(KEYS_DOWN.ctrl) angle = angle_start + (angle - angle_start) / 10;
|
|
||||||
|
|
||||||
float stepped_angle = (round(angle / stepping) * stepping + 180) * DEG2RAD; // see above. -180 + 180 to get 0 right round(0 / 33.75) * 33.75 is still 0
|
|
||||||
position = parentPosition.orbitAtAngle(orbit, stepped_angle) - parentPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void lock(){
|
|
||||||
visible = false;
|
|
||||||
locked = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unlock(){
|
|
||||||
visible = true;
|
|
||||||
locked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void assignValue(T &value, float min, float max, float minDistance, float maxDistance){
|
void assignValue(T &value, float min, float max, float minDistance, float maxDistance){
|
||||||
assignedValueRef = value;
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
@@ -125,57 +94,21 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
assignedValueRef = value;
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hovering() override {
|
float distance();
|
||||||
return CheckCollisionPointCircle(SCREEN_MOUSE, position + parentPosition, radius);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void update(Vec2Df pos) override {
|
virtual void drag(Vec2Df mouse_pos) override;
|
||||||
if(!locked && visible){
|
|
||||||
if(hovering()) state->pushEvent({getPtr(), APP::Interaction::HOVER});
|
|
||||||
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
|
||||||
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
|
||||||
}
|
|
||||||
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
|
||||||
|
|
||||||
parentPosition = pos;
|
void lock();
|
||||||
if(!locked && visible) updateAssignedValue();
|
|
||||||
|
|
||||||
minP = parentPosition.orbitAlongVector((parentPosition + position), minDistance);
|
void unlock();
|
||||||
maxP = parentPosition.orbitAlongVector((parentPosition + position), maxDistance);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void draw() override {
|
virtual bool hovering() override;
|
||||||
if(!locked && visible){
|
|
||||||
bool show = hovering() || picked_up;
|
|
||||||
Color dcol = ColorBrightness(col, -0.5f);
|
|
||||||
Color dyncol = show ? col : dcol;
|
|
||||||
Color dGrey = ColorBrightness(VS_COLOR_GREY, -0.2f);
|
|
||||||
Color dynGrey = show ? VS_COLOR_GREY : dGrey;
|
|
||||||
|
|
||||||
if(steps > 0){
|
virtual void update(Vec2Df pos) override;
|
||||||
for(int i = 0; i < steps; i++){
|
|
||||||
Vec2Df pos = parentPosition.orbitAtAngle(orbit, DEG2RAD * i * (360.0f/steps));
|
|
||||||
Vec2Df pos1 = parentPosition.orbitAtAngle(orbit - 3.0f, DEG2RAD * i * (360.0f/steps));
|
|
||||||
DrawLineV(pos, pos1, dynGrey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float r = (parentPosition + position).dist(parentPosition);
|
virtual void draw() override;
|
||||||
DrawRing(parentPosition, r - 5, r + 5, 0, 360, 90, ColorAlpha(dyncol, 0.1));
|
|
||||||
DrawRing(parentPosition, r - 5, r + 5, -90, angle_g - 90, 90, ColorAlpha(dyncol, 0.3));
|
|
||||||
DrawCircleV(position + parentPosition, radius, dyncol);
|
|
||||||
//VISEQ::HELPER::DrawSuperText(std::format("{}", assignedValueRef), position + parentPosition, position + parentPosition + Vec2Df(50,0), 1, 0, 8, dyncol);
|
|
||||||
|
|
||||||
/*if(show) {*/
|
virtual bool select() override;
|
||||||
/* std::string text = std::format("{}", assignedValueRef);*/
|
|
||||||
/* DrawCenteredText(text, parentPosition, 12, ColorBrightness(dyncol, 0.75f));*/
|
|
||||||
/*}*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool select() override {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(NodeHandle, position, name);
|
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(NodeHandle, position, name);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
#include "connector.h"
|
#include "connector.h"
|
||||||
#include "datatypes.h"
|
#include "datatypes.h"
|
||||||
#include "interaction-event.h"
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "vmath.h"
|
#include "vmath.h"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#include "selectable.h"
|
||||||
|
|
||||||
|
namespace VISEQ::BASE {
|
||||||
|
bool Selectable::clicked() {
|
||||||
|
return (selected || hovering()) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-3
@@ -16,9 +16,7 @@ namespace VISEQ::BASE {
|
|||||||
bool erase = false;
|
bool erase = false;
|
||||||
Vec2Df selection_offset;
|
Vec2Df selection_offset;
|
||||||
|
|
||||||
virtual bool clicked() override {
|
virtual bool clicked() override;
|
||||||
return (selected || hovering()) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool select() = 0;
|
virtual bool select() = 0;
|
||||||
virtual void deselect() = 0;
|
virtual void deselect() = 0;
|
||||||
|
|||||||
+3
-1
@@ -8,10 +8,12 @@
|
|||||||
namespace VISEQ::APP{
|
namespace VISEQ::APP{
|
||||||
|
|
||||||
void State::pushEvent(InteractionEvent e){
|
void State::pushEvent(InteractionEvent e){
|
||||||
|
std::cout << "push event" << std::endl;
|
||||||
event_queue.push_back(e);
|
event_queue.push_back(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
InteractionEvent pullEvent(){
|
InteractionEvent State::pullEvent(){
|
||||||
|
std::cout << "pull event" << std::endl;
|
||||||
if(!event_queue.empty()){
|
if(!event_queue.empty()){
|
||||||
InteractionEvent e = event_queue.front();
|
InteractionEvent e = event_queue.front();
|
||||||
event_queue.pop_front();
|
event_queue.pop_front();
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ namespace VISEQ::APP{
|
|||||||
|
|
||||||
inline static std::shared_ptr<State> instance;
|
inline static std::shared_ptr<State> instance;
|
||||||
static std::shared_ptr<State> get();
|
static std::shared_ptr<State> get();
|
||||||
|
|
||||||
|
std::deque<InteractionEvent> event_queue;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user