Context menu is back, but not quite yet.
This commit is contained in:
+6
-1
@@ -87,8 +87,12 @@ namespace VISEQ::GRAPH {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addToSelection(){
|
||||||
|
auto temp_nodes = nodes | RANGE_FILTER([](SPTR_Node n){return n->selected;}) | std::ranges::to<VEC_SPTR_Node>();
|
||||||
|
selected_nodes.insert(selected_nodes.end(), temp_nodes.begin(), temp_nodes.end());
|
||||||
|
}
|
||||||
|
|
||||||
void select(){
|
void select(){
|
||||||
std::cout << "select" << std::endl;
|
|
||||||
auto temp_nodes = nodes | RANGE_FILTER([](SPTR_Node n){return n->select();}) | std::ranges::to<VEC_SPTR_Node>();
|
auto temp_nodes = nodes | RANGE_FILTER([](SPTR_Node n){return n->select();}) | std::ranges::to<VEC_SPTR_Node>();
|
||||||
if(!KEYS_DOWN.shift) selected_nodes.clear();
|
if(!KEYS_DOWN.shift) selected_nodes.clear();
|
||||||
selected_nodes.insert(selected_nodes.end(), temp_nodes.begin(), temp_nodes.end());
|
selected_nodes.insert(selected_nodes.end(), temp_nodes.begin(), temp_nodes.end());
|
||||||
@@ -143,6 +147,7 @@ namespace VISEQ::GRAPH {
|
|||||||
SPTR_Node copyNode(std::shared_ptr<MidiNode> n, Vec2Df position){
|
SPTR_Node copyNode(std::shared_ptr<MidiNode> n, Vec2Df position){
|
||||||
std::cout << "copy midinode" << std::endl;
|
std::cout << "copy midinode" << std::endl;
|
||||||
nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));
|
nodes.insert(nodes.end(), std::make_shared<MidiNode>(*n));
|
||||||
|
nodes.back()->clearConnectors();
|
||||||
nodes.back()->setPosition(position);
|
nodes.back()->setPosition(position);
|
||||||
return nodes.back();
|
return nodes.back();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace VISEQ::APP{
|
namespace VISEQ::APP{
|
||||||
|
|
||||||
enum Interaction {NONE, HOVER, CLICK, HOLD, RELEASE, PICKUP, DRAG, PUTDOWN, SELECT, DESELECT, CONNECT};
|
enum Interaction {NONE, HOVER, CLICK, RIGHTCLICK, HOLD, RELEASE, PICKUP, DRAG, PUTDOWN, SELECT, DESELECT, CONNECT};
|
||||||
|
|
||||||
struct InteractionEvent{
|
struct InteractionEvent{
|
||||||
std::shared_ptr<BASE::Interactable> item;
|
std::shared_ptr<BASE::Interactable> item;
|
||||||
|
|||||||
@@ -210,6 +210,11 @@ namespace VISEQ::INTERACTION{
|
|||||||
|
|
||||||
while(APP::event_queue.size() > 0 && !exit){
|
while(APP::event_queue.size() > 0 && !exit){
|
||||||
auto e = APP::event_queue.front();
|
auto e = APP::event_queue.front();
|
||||||
|
if(e.action == APP::Interaction::RIGHTCLICK){
|
||||||
|
gm->addToSelection();
|
||||||
|
state->context_menu = !state->context_menu;
|
||||||
|
}
|
||||||
|
if(state->context_menu) break;
|
||||||
|
|
||||||
if(e.action == APP::Interaction::HOVER){
|
if(e.action == APP::Interaction::HOVER){
|
||||||
state->mouse_z = e.item->z_index;
|
state->mouse_z = e.item->z_index;
|
||||||
|
|||||||
+10
-1
@@ -67,12 +67,21 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
return GraphItemType::NODE;
|
return GraphItemType::NODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearConnectors(){
|
||||||
|
connectors.clear();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void update() override{
|
void update() override{
|
||||||
if(hovering()) state->pushEvent({getPtr(), APP::Interaction::HOVER});
|
if(hovering()) state->pushEvent({getPtr(), APP::Interaction::HOVER});
|
||||||
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
if(hovering() && clicked()) state->pushEvent({getPtr(), APP::Interaction::PICKUP});
|
||||||
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
if(pickedUp()) state->pushEvent({getPtr(), APP::Interaction::DRAG});
|
||||||
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
if(picked_up && released()) state->pushEvent({getPtr(), APP::Interaction::PUTDOWN});
|
||||||
|
if(hovering() && MOUSE_RIGHT.clicked) {
|
||||||
|
selected = true;
|
||||||
|
config = true;
|
||||||
|
state->pushEvent({getPtr(), APP::Interaction::RIGHTCLICK});
|
||||||
|
}
|
||||||
int free_connectors = 0;
|
int free_connectors = 0;
|
||||||
for(auto c : connectors){
|
for(auto c : connectors){
|
||||||
if(c->partner.expired()) free_connectors++;
|
if(c->partner.expired()) free_connectors++;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ namespace VISEQ::APP{
|
|||||||
InteractionState old_istate = HOVER_CANVAS;
|
InteractionState old_istate = HOVER_CANVAS;
|
||||||
|
|
||||||
int node_mode = 0;
|
int node_mode = 0;
|
||||||
|
bool context_menu = false;
|
||||||
|
|
||||||
bool hovering = false;
|
bool hovering = false;
|
||||||
|
|
||||||
|
|||||||
@@ -103,11 +103,12 @@ namespace VISEQ::APP::UI{
|
|||||||
DrawText(text.c_str(), position.x-offset/2.0f, position.y-(float)size/2.0f+1, size, color );
|
DrawText(text.c_str(), position.x-offset/2.0f, position.y-(float)size/2.0f+1, size, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPerNodeConfig(Camera2D camera){
|
void drawContextMenu(Camera2D camera){
|
||||||
for(auto& n : gm->getSelection() | std::views::filter([](std::shared_ptr<Node> n){ return n->config; })){
|
for(auto n : gm->getSelection() | std::views::filter([](std::shared_ptr<Node> n){ return n->config; })){
|
||||||
Vector2 np = GetWorldToScreen2D((Vector2){n->position.x, n->position.y}, camera);
|
Vector2 np = GetWorldToScreen2D((Vector2){n->position.x, n->position.y}, camera);
|
||||||
|
|
||||||
n->config = !GuiWindowBox((Rectangle){np.x + 10, np.y + 10, 240, 440}, "config");
|
state->context_menu = !GuiWindowBox((Rectangle){np.x + 10, np.y + 10, 240, 440}, "config");
|
||||||
|
n->config = state->context_menu;
|
||||||
|
|
||||||
int option = n->distributionMode;
|
int option = n->distributionMode;
|
||||||
GuiToggleGroup((Rectangle){ np.x + 20, np.y + 40, 73, 20 }, "GEO;RR;RAND", &option);
|
GuiToggleGroup((Rectangle){ np.x + 20, np.y + 40, 73, 20 }, "GEO;RR;RAND", &option);
|
||||||
@@ -195,7 +196,7 @@ namespace VISEQ::APP::UI{
|
|||||||
|
|
||||||
void draw(Vec2Df mouse_pos, Camera2D camera){
|
void draw(Vec2Df mouse_pos, Camera2D camera){
|
||||||
drawSideBar();
|
drawSideBar();
|
||||||
drawPerNodeConfig(camera);
|
if(state->context_menu) drawContextMenu(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user