Drag selection working again - not much progress
This commit is contained in:
+2
-3
@@ -33,8 +33,7 @@ namespace VISEQ::APP::CANVAS {
|
||||
EndMode2D();
|
||||
}
|
||||
|
||||
void select_rect(){
|
||||
|
||||
void selectNodes(){
|
||||
if(state->mouse_left.clicked){
|
||||
state->selection = (Rectangle){0,0,0,0};
|
||||
select_start = state->screen_mouse;
|
||||
@@ -55,7 +54,7 @@ namespace VISEQ::APP::CANVAS {
|
||||
virtual void update() override {
|
||||
camera_delta = state->mouse_delta * (-1.0f/camera.zoom);
|
||||
if(hovering()) drag();
|
||||
if(state->istate == InteractionState::HOVER_CANVAS || state->istate == InteractionState::DRAW_SELECTION) select_rect();
|
||||
if(state->istate == InteractionState::HOVER_CANVAS || state->istate == InteractionState::DRAW_SELECTION) selectNodes();
|
||||
|
||||
float wheel = GetMouseWheelMove();
|
||||
if(wheel != 0){
|
||||
|
||||
+15
-11
@@ -19,7 +19,7 @@ namespace VISEQ::BASE {
|
||||
bool picked_up = false;
|
||||
|
||||
virtual bool pickedUp() {
|
||||
if(clicked() && held() && state->istate == APP::InteractionState::HOVER_NODE) {
|
||||
if(clicked() && held() && (state->istate == APP::InteractionState::HOVER_NODE || state->istate == APP::InteractionState::DRAG_NODE)) {
|
||||
picked_up = true;
|
||||
drag_offset = position - state->screen_mouse;
|
||||
}
|
||||
@@ -40,16 +40,20 @@ namespace VISEQ::BASE {
|
||||
|
||||
virtual void select() override {
|
||||
selected = (state->keys_down.shift && selected) || CheckCollisionPointRec(position, state->selection);
|
||||
/**/
|
||||
/*//std::cout << "select" << std::endl;*/
|
||||
/*if(CheckCollisionPointRec(position, state->selection)) {*/
|
||||
/* in_selection_rect = true;*/
|
||||
/*} else {*/
|
||||
/* in_selection_rect = false;*/
|
||||
/*}*/
|
||||
/*if(released() && in_selection_rect) selected = true;*/
|
||||
/*if(released() && !in_selection_rect) selected = false;*/
|
||||
}
|
||||
|
||||
|
||||
virtual void update() override {
|
||||
if((held() && !picked_up) || (clicked() && !state->keys_down.shift)) select();
|
||||
if(entered()) state->istate = APP::InteractionState::HOVER_NODE;
|
||||
if(exited()) state->istate = APP::InteractionState::HOVER_CANVAS;
|
||||
if(pickedUp()){
|
||||
drag();
|
||||
state->istate = APP::InteractionState::DRAG_NODE;
|
||||
}
|
||||
if(released() && picked_up){
|
||||
putDown();
|
||||
state->istate = APP::InteractionState::HOVER_CANVAS;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ namespace VISEQ::GRAPH {
|
||||
EDGES::VEC_SPTR_Edge remove_edges;
|
||||
EDGES::VEC_SPTR_Edge split_edges;
|
||||
|
||||
VEC_SPTR_Node selected_nodes;
|
||||
//VEC_SPTR_Node selected_nodes;
|
||||
|
||||
std::map<NODES::SPTR_Node, int> counter;
|
||||
|
||||
|
||||
+7
-15
@@ -87,7 +87,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
void interact(){
|
||||
float wheel = GetMouseWheelMove();
|
||||
|
||||
if(IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
|
||||
if(state->keys_down.ctrl && !state->keys_down.alt){
|
||||
switch(GraphItem::state->node_mode){
|
||||
case 0:{
|
||||
midi_note += wheel;
|
||||
@@ -108,14 +108,14 @@ namespace VISEQ::GRAPH::NODES {
|
||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
||||
|
||||
} else if(IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_ALT)) {
|
||||
} else if(state->keys_down.shift && !state->keys_down.alt) {
|
||||
midi_velocity += wheel;
|
||||
if(midi_velocity < 0 ) midi_velocity = 127;
|
||||
if(midi_velocity > 127 ) midi_velocity = 0;
|
||||
} else if(IsKeyDown(KEY_LEFT_ALT)) {
|
||||
} else if(state->keys_down.alt) {
|
||||
switch(GraphItem::state->node_mode){
|
||||
case 0:{
|
||||
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
|
||||
float incr = (float)wheel * (state->keys_down.shift ? 100.0f : state->keys_down.ctrl ? 1000.0f : 10.0f);
|
||||
midi_gate += incr;
|
||||
if(midi_gate < 0 ) midi_gate = 0;
|
||||
break;}
|
||||
@@ -125,7 +125,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
if(midi_cc_value > 127 ) midi_cc_value = 127;
|
||||
break;}
|
||||
case 2:{
|
||||
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
|
||||
float incr = (float)wheel * (state->keys_down.shift ? 100.0f : state->keys_down.ctrl ? 1000.0f : 10.0f);
|
||||
midi_pitch_bend += incr;
|
||||
if(midi_pitch_bend < 0 ) midi_pitch_bend = 0;
|
||||
if(midi_pitch_bend > 16383 ) midi_pitch_bend = 16383;
|
||||
@@ -167,7 +167,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
break;}
|
||||
}
|
||||
if(!picked_up && !selected && !in_selection_rect && !hovering()) DrawCircle(position.x, position.y, radius, gate_color);
|
||||
//if(selected || picked_up || in_selection_rect || hovering()) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
||||
if(picked_up || in_selection_rect || hovering()) DrawCircle(position.x, position.y, radius, (Color){108, 153, 187, 255});
|
||||
if(selected) DrawCircle(position.x, position.y, radius, (Color){255, 153, 187, 255});
|
||||
|
||||
if(distributionMode == Distribution::RANDOM) DrawCircle(position.x, position.y, radius/2.0f, VS_COLOR_PINK);
|
||||
@@ -175,7 +175,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
||||
|
||||
if(IsKeyDown(KEY_LEFT_ALT)){
|
||||
if(state->keys_down.alt){
|
||||
float value = 0;
|
||||
int offset_gate = 0;
|
||||
switch(mode){
|
||||
@@ -212,14 +212,6 @@ namespace VISEQ::GRAPH::NODES {
|
||||
}
|
||||
}
|
||||
|
||||
/*Vec2Df connector = position - ((position - mouse)).norm() * (radius + RADIUS);*/
|
||||
/*float opacity = 150.0f - Clamp(position.dist(mouse), 0.0f, 150.0f);*/
|
||||
/**/
|
||||
/*if(hover_connect){*/
|
||||
/* DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, 255});*/
|
||||
/*} else {*/
|
||||
/* DrawCircle(connector.x, connector.y, 8.0f, (Color){108, 153, 187, (unsigned char)opacity});*/
|
||||
/*}*/
|
||||
if(highlighted) DrawCircleLinesV(position, radius+2, (Color){255, 0, 0, 200});
|
||||
DrawText(std::format("{}", id).c_str(), position.x + 20.0f, position.y + 20.0f, 10, WHITE);
|
||||
}
|
||||
|
||||
+1
-11
@@ -69,17 +69,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
}
|
||||
|
||||
void update() override{
|
||||
if((held() && !picked_up) || (clicked() && !state->keys_down.shift)) select();
|
||||
if(entered()) state->istate = APP::InteractionState::HOVER_NODE;
|
||||
if(exited()) state->istate = APP::InteractionState::HOVER_CANVAS;
|
||||
if(pickedUp()){
|
||||
drag();
|
||||
state->istate = APP::InteractionState::DRAG_NODE;
|
||||
}
|
||||
if(released() && picked_up){
|
||||
putDown();
|
||||
state->istate = APP::InteractionState::HOVER_CANVAS;
|
||||
}
|
||||
BASE::Draggable::update();
|
||||
|
||||
int free_connectors = 0;
|
||||
for(auto c : connectors){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "interactable.h"
|
||||
#include "vmath.h"
|
||||
|
||||
namespace VISEQ::BASE {
|
||||
class Selectable : public Interactable{
|
||||
@@ -13,6 +14,7 @@ namespace VISEQ::BASE {
|
||||
bool copied = false;
|
||||
bool highlighted = false;
|
||||
bool erase = false;
|
||||
Vec2Df selection_offset;
|
||||
|
||||
virtual bool clicked() override {
|
||||
return (selected || hovering()) && IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||
|
||||
Reference in New Issue
Block a user