working again
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
#include "selectable.h
|
|
||||||
@@ -133,7 +133,6 @@ 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 : state->event_queue){
|
for(auto e : state->event_queue){
|
||||||
if(!connect_once && e.action == APP::Interaction::CONNECT){
|
if(!connect_once && e.action == APP::Interaction::CONNECT){
|
||||||
@@ -169,7 +168,6 @@ namespace VISEQ::INTERACTION{
|
|||||||
|
|
||||||
while(state->event_queue.size() > 0 && !exit){
|
while(state->event_queue.size() > 0 && !exit){
|
||||||
auto e = state->event_queue.front();
|
auto e = state->event_queue.front();
|
||||||
std::cout << e.action;
|
|
||||||
if(e.action == APP::Interaction::CLICK){
|
if(e.action == APP::Interaction::CLICK){
|
||||||
gm->addToSelection();
|
gm->addToSelection();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -287,7 +287,7 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
|
|
||||||
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
if(mode >= 0 && mode < 6){
|
if(selected && mode >= 0 && mode < 6){
|
||||||
for(auto mh : midiHandles[(Handles)mode]){
|
for(auto mh : midiHandles[(Handles)mode]){
|
||||||
mh->unlock();
|
mh->unlock();
|
||||||
mh->draw();
|
mh->draw();
|
||||||
|
|||||||
@@ -1,98 +0,0 @@
|
|||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+77
-10
@@ -70,13 +70,44 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assignValue(T &value, float min, float max, float minDistance, float maxDistance){
|
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){
|
||||||
assignedValueRef = value;
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,21 +125,57 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
assignedValueRef = value;
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float distance();
|
virtual bool hovering() override {
|
||||||
|
return CheckCollisionPointCircle(SCREEN_MOUSE, position + parentPosition, radius);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void drag(Vec2Df mouse_pos) override;
|
virtual void update(Vec2Df 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});
|
||||||
|
|
||||||
void lock();
|
parentPosition = pos;
|
||||||
|
if(!locked && visible) updateAssignedValue();
|
||||||
|
|
||||||
void unlock();
|
minP = parentPosition.orbitAlongVector((parentPosition + position), minDistance);
|
||||||
|
maxP = parentPosition.orbitAlongVector((parentPosition + position), maxDistance);
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool hovering() override;
|
virtual void draw() 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;
|
||||||
|
|
||||||
virtual void update(Vec2Df pos) override;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
virtual void draw() override;
|
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);
|
||||||
|
|
||||||
virtual bool select() override;
|
/*if(show) {*/
|
||||||
|
/* 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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,12 +8,10 @@
|
|||||||
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 State::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();
|
||||||
|
|||||||
Reference in New Issue
Block a user