2024-10-09 02:01:23 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* VISEQ - Visual Sequencer
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2024-10-13 04:22:09 +02:00
|
|
|
/*Background: (46, 46, 46); #2e2e2e*/
|
|
|
|
|
/*Comments: (121, 121, 121); #797979*/
|
|
|
|
|
/*White: (214, 214, 214); #d6d6d6*/
|
|
|
|
|
/*Yellow: (229, 181, 103); #e5b567*/
|
|
|
|
|
/*Green: (180, 210, 115); #b4d273*/
|
|
|
|
|
/*Orange: (232, 125, 62); #e87d3e*/
|
|
|
|
|
/*Purple: (158, 134, 200); #9e86c8*/
|
|
|
|
|
/*Pink: (176, 82, 121); #b05279*/
|
|
|
|
|
/*Blue: (108, 153, 187); #6c99bb*/
|
|
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
#define RAYGUI_IMPLEMENTATION
|
|
|
|
|
|
2024-10-16 02:26:02 +02:00
|
|
|
#include "datatypes.h"
|
2024-10-23 03:25:57 +02:00
|
|
|
#include <ranges>
|
2024-10-13 04:22:09 +02:00
|
|
|
#include <raylib.h>
|
|
|
|
|
#include <raymath.h>
|
|
|
|
|
|
2024-10-09 02:01:23 +02:00
|
|
|
#include <cstdlib>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
#include "state-manager.h"
|
2024-10-22 01:55:31 +02:00
|
|
|
|
|
|
|
|
AppState app;
|
2024-10-09 02:01:23 +02:00
|
|
|
|
|
|
|
|
Vec2D<float> mouse_pos;
|
|
|
|
|
Vec2D<float> drag_start;
|
|
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
Camera2D camera = { {0} };
|
|
|
|
|
|
2024-10-09 02:01:23 +02:00
|
|
|
bool mouse_clicked = false;
|
|
|
|
|
bool mouse_touched = false;
|
2024-10-13 04:22:09 +02:00
|
|
|
bool mouse_dragging = false;
|
2024-10-09 02:01:23 +02:00
|
|
|
|
|
|
|
|
int main(){
|
|
|
|
|
|
|
|
|
|
srand(time(NULL));
|
|
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
|
|
|
|
|
InitWindow(1920, 1080, "VISEQ");
|
|
|
|
|
|
|
|
|
|
int current_monitor = GetCurrentMonitor();
|
|
|
|
|
int monitor_width = GetMonitorWidth(current_monitor);
|
|
|
|
|
int monitor_height = GetMonitorHeight(current_monitor);
|
2024-10-25 16:41:37 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
SetWindowMonitor(current_monitor);
|
|
|
|
|
SetWindowState(FLAG_WINDOW_RESIZABLE);
|
|
|
|
|
|
|
|
|
|
SetWindowSize(monitor_width - 300, monitor_height - 300);
|
2024-10-13 04:22:09 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
//ToggleFullscreen();
|
2024-10-13 04:22:09 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
app.ui.init();
|
2024-10-13 04:22:09 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
app.settings.fps = 60.0f;
|
2024-10-25 16:41:37 +02:00
|
|
|
app.settings.bpm = 120.0f;
|
2024-10-26 16:31:23 +02:00
|
|
|
app.settings.grid = 120.0f; // 120px for a 16th note
|
2024-10-23 03:25:57 +02:00
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
app.settings.speed = (app.settings.grid * 8.0f) * (app.settings.bpm / 120.f);
|
|
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
app.settings.width = monitor_width;
|
|
|
|
|
app.settings.height = monitor_height;
|
2024-10-25 02:43:41 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
SetTargetFPS(app.settings.fps);
|
2024-10-13 04:22:09 +02:00
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
camera.target = (Vector2){ app.settings.width/2.0f, app.settings.height/2.0f };
|
|
|
|
|
camera.offset = (Vector2){ app.settings.width/2.0f, app.settings.height/2.0f };
|
2024-10-13 04:22:09 +02:00
|
|
|
camera.rotation = 0.0f;
|
2024-10-25 16:41:37 +02:00
|
|
|
camera.zoom = 1.0f;
|
2024-10-09 02:01:23 +02:00
|
|
|
|
2024-10-23 00:23:24 +02:00
|
|
|
for(int i = 0; i < 4; ++i){
|
2024-10-25 16:41:37 +02:00
|
|
|
app.nm.addNode((float)i * app.settings.grid + 10 * app.settings.grid, 5 * app.settings.grid);
|
2024-10-23 00:23:24 +02:00
|
|
|
}
|
|
|
|
|
for(int i = 3; i >= 0; --i){
|
2024-10-25 16:41:37 +02:00
|
|
|
app.nm.addNode((float)i * app.settings.grid + 10 * app.settings.grid, 6 * app.settings.grid);
|
2024-10-09 02:01:23 +02:00
|
|
|
}
|
2024-10-22 01:55:31 +02:00
|
|
|
|
2024-10-23 00:23:24 +02:00
|
|
|
for(int i = 0; i < 8; ++i){
|
2024-10-26 02:14:41 +02:00
|
|
|
app.cm.addConnection(app.nm.nodes[i].id, app.nm.nodes[(i+1) % 8].id);
|
2024-10-23 00:23:24 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
app.sm.addSignalAtNode((app.nm.nodes | std::views::values).front().id);
|
2024-10-25 16:41:37 +02:00
|
|
|
app.sm.startSignalThread();
|
2024-10-22 01:55:31 +02:00
|
|
|
|
2024-10-26 16:31:23 +02:00
|
|
|
enum InteractionState {HOVER_CANVAS, HOVER_NODE, HOVER_CONNECTOR, DRAG_NODE, CONNECT_NODE, DRAW_SELECTION, DELETE_SELECTED_NODES, COPY_SELECTED_NODES, PASTE_SELECTED_NODES};
|
2024-10-25 02:43:41 +02:00
|
|
|
InteractionState istate = HOVER_CANVAS;
|
2024-10-24 21:05:05 +02:00
|
|
|
|
2024-10-23 00:23:24 +02:00
|
|
|
Vec2D<float> select_start;
|
|
|
|
|
Rectangle selection;
|
|
|
|
|
|
2024-10-24 00:39:39 +02:00
|
|
|
|
2024-10-13 04:22:09 +02:00
|
|
|
while(!WindowShouldClose()){
|
2024-10-09 02:01:23 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
BeginDrawing();
|
|
|
|
|
ClearBackground((Color){46,46,46});
|
|
|
|
|
BeginMode2D(camera);
|
2024-10-26 02:14:41 +02:00
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
app.settings.speed = (app.settings.grid * 8.0f) * (app.settings.bpm / 120.f);
|
2024-10-23 03:25:57 +02:00
|
|
|
|
2024-10-13 04:22:09 +02:00
|
|
|
Vector2 mp = GetScreenToWorld2D(GetMousePosition(), camera);
|
2024-10-10 02:59:27 +02:00
|
|
|
Vec2D<float> mouse_pos = {(float)mp.x, (float)mp.y};
|
2024-10-20 23:42:38 +02:00
|
|
|
Vec2D<float> cam_pos = {camera.offset.x, camera.offset.y};
|
|
|
|
|
|
2024-10-13 04:22:09 +02:00
|
|
|
bool mouse_down = IsMouseButtonDown(MOUSE_BUTTON_LEFT);
|
|
|
|
|
bool mouse_clicked = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
|
|
|
|
bool mouse_released = IsMouseButtonReleased(MOUSE_BUTTON_LEFT);
|
2024-10-24 21:05:05 +02:00
|
|
|
|
|
|
|
|
bool mouse_right_down = IsMouseButtonDown(MOUSE_BUTTON_RIGHT);
|
|
|
|
|
bool mouse_right_clicked = IsMouseButtonPressed(MOUSE_BUTTON_RIGHT);
|
|
|
|
|
bool mouse_right_released = IsMouseButtonReleased(MOUSE_BUTTON_RIGHT);
|
2024-10-10 02:59:27 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
Vec2D<float> mouse_delta = {GetMouseDelta().x, GetMouseDelta().y};
|
|
|
|
|
Vec2D<float> delta = mouse_delta * (-1.0f/camera.zoom);
|
2024-10-24 00:39:39 +02:00
|
|
|
|
2024-10-26 02:14:41 +02:00
|
|
|
auto dragging_nodes = app.nm.nodes | std::ranges::views::values | std::ranges::views::filter([](Node n) { return n.dragging;});
|
2024-10-26 16:31:23 +02:00
|
|
|
auto copied_nodes = app.nm.nodes | std::ranges::views::values | std::ranges::views::filter([](Node n) { return n.copied;});
|
2024-10-26 02:14:41 +02:00
|
|
|
auto connecting_nodes = app.nm.nodes | std::ranges::views::values| std::ranges::views::filter([](Node n) { return n.connecting;});
|
|
|
|
|
auto selected_nodes = app.nm.nodes | std::ranges::views::values| std::ranges::views::filter([](Node n) { return n.selected && !n.dragging;});
|
|
|
|
|
auto hovering_nodes = app.nm.nodes | std::ranges::views::values| std::ranges::views::filter([&mouse_pos](Node n) { return CheckCollisionPointCircle(mouse_pos, n.position, n.radius);});
|
|
|
|
|
auto hovering_connectors = app.nm.nodes | std::ranges::views::values| std::ranges::views::filter([&mouse_pos](Node n) { return CheckCollisionPointCircle(mouse_pos, (n.position - ((n.position - mouse_pos)).norm() * (n.radius + 14.0f)), 8.0f);});
|
2024-10-24 00:39:39 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
if(!mouse_down && !mouse_right_down && dragging_nodes.empty() && connecting_nodes.empty() && hovering_nodes.empty() && hovering_connectors.empty()) istate = InteractionState::HOVER_CANVAS;
|
|
|
|
|
if((mouse_clicked || mouse_down || mouse_released) && !mouse_right_down && dragging_nodes.empty() && connecting_nodes.empty() && hovering_nodes.empty() && hovering_connectors.empty()) istate = InteractionState::DRAW_SELECTION;
|
2024-10-24 21:05:05 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
if(!hovering_nodes.empty() && !mouse_down && !mouse_right_down) istate = InteractionState::HOVER_NODE;
|
|
|
|
|
if(!dragging_nodes.empty()) istate = InteractionState::DRAG_NODE;
|
|
|
|
|
if(!hovering_connectors.empty() && istate == InteractionState::HOVER_CANVAS) istate = InteractionState::HOVER_CONNECTOR;
|
|
|
|
|
if(!connecting_nodes.empty()) istate = InteractionState::CONNECT_NODE;
|
2024-10-24 21:05:05 +02:00
|
|
|
|
2024-10-25 17:13:30 +02:00
|
|
|
if(!selected_nodes.empty() && IsKeyPressed(KEY_DELETE)) istate = InteractionState::DELETE_SELECTED_NODES;
|
2024-10-26 16:31:23 +02:00
|
|
|
if(!selected_nodes.empty() && IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_C)) istate = InteractionState::COPY_SELECTED_NODES;
|
|
|
|
|
|
|
|
|
|
if(!copied_nodes.empty() && IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_V)) istate = InteractionState::PASTE_SELECTED_NODES;
|
2024-10-25 17:13:30 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
switch(istate){
|
|
|
|
|
case InteractionState::HOVER_CANVAS:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-27 00:40:57 +02:00
|
|
|
for(auto &n : app.nm.nodes | std::ranges::views::values){
|
|
|
|
|
n.hover_connect = false;
|
|
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
if(mouse_right_down) {
|
|
|
|
|
camera.target = Vector2Add(camera.target, delta);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
case InteractionState::DRAW_SELECTION:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-25 02:43:41 +02:00
|
|
|
if(mouse_clicked){
|
|
|
|
|
select_start = mouse_pos;
|
|
|
|
|
}
|
|
|
|
|
if(mouse_down){
|
|
|
|
|
Vec2D<float> select1 = {mouse_pos.x > select_start.x ? select_start.x : mouse_pos.x, mouse_pos.y > select_start.y ? select_start.y : mouse_pos.y};
|
|
|
|
|
Vec2D<float> select2 = {mouse_pos.x > select_start.x ? mouse_pos.x - select_start.x : select_start.x - mouse_pos.x, mouse_pos.y > select_start.y ? mouse_pos.y - select_start.y : select_start.y - mouse_pos.y};
|
|
|
|
|
DrawRectangleLines(select1.x, select1.y, select2.x, select2.y, (Color){150,150,150,150});
|
|
|
|
|
selection = (Rectangle){select1.x, select1.y, select2.x, select2.y};
|
|
|
|
|
|
2024-10-26 02:14:41 +02:00
|
|
|
for(auto& n : app.nm.nodes | std::views::values){
|
2024-10-25 02:43:41 +02:00
|
|
|
if(CheckCollisionPointRec(n.position, selection)) {
|
|
|
|
|
n.in_rect = true;
|
|
|
|
|
} else {
|
|
|
|
|
n.in_rect = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-24 21:05:05 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
if(mouse_released){
|
2024-10-26 02:14:41 +02:00
|
|
|
for(auto& n : app.nm.nodes | std::views::values){
|
2024-10-25 02:43:41 +02:00
|
|
|
if(CheckCollisionPointRec(n.position, selection)) {
|
|
|
|
|
n.selected = true;
|
|
|
|
|
n.in_rect = false;
|
|
|
|
|
} else {
|
|
|
|
|
if(!IsKeyDown(KEY_LEFT_SHIFT)) n.selected = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
selection = (Rectangle){0,0,0,0};
|
|
|
|
|
}
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
case InteractionState::HOVER_NODE:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-25 02:43:41 +02:00
|
|
|
if(mouse_clicked) {
|
|
|
|
|
if(IsKeyDown(KEY_LEFT_SHIFT)) {
|
|
|
|
|
hovering_nodes.front().selected = true;
|
|
|
|
|
} else {
|
|
|
|
|
hovering_nodes.front().dragging = true;
|
|
|
|
|
hovering_nodes.front().drag_offset = hovering_nodes.front().position - mouse_pos;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(mouse_right_clicked) hovering_nodes.front().config = true;
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
case InteractionState::DRAG_NODE:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-26 16:31:23 +02:00
|
|
|
if(!dragging_nodes.empty()){
|
2024-10-25 02:43:41 +02:00
|
|
|
for(auto &n : selected_nodes){
|
2024-10-26 16:31:23 +02:00
|
|
|
if(!n.picked_up) n.drag_offset = n.position - dragging_nodes.front().position;
|
|
|
|
|
n.picked_up = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(IsKeyDown(KEY_LEFT_CONTROL)) {
|
|
|
|
|
dragging_nodes.front().position = (Vec2D<float>){round((mouse_pos.x+dragging_nodes.front().drag_offset.x)/app.settings.grid)*app.settings.grid, round((mouse_pos.y+dragging_nodes.front().drag_offset.y)/app.settings.grid)*app.settings.grid};
|
|
|
|
|
} else {
|
|
|
|
|
dragging_nodes.front().position = mouse_pos + dragging_nodes.front().drag_offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(auto &n : selected_nodes){
|
|
|
|
|
n.position = dragging_nodes.front().position + n.drag_offset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mouse_released) {
|
|
|
|
|
for(auto &n : dragging_nodes){
|
|
|
|
|
n.dragging = false;
|
|
|
|
|
n.picked_up = false;
|
|
|
|
|
}
|
|
|
|
|
for(auto &n : selected_nodes){
|
|
|
|
|
n.picked_up = false;
|
|
|
|
|
n.dragging = false;
|
|
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
case InteractionState::HOVER_CONNECTOR:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-27 00:40:57 +02:00
|
|
|
hovering_connectors.front().hover_connect = true;
|
2024-10-25 02:43:41 +02:00
|
|
|
if(mouse_clicked) hovering_connectors.front().connecting = true;
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
case InteractionState::CONNECT_NODE:
|
2024-10-25 17:13:30 +02:00
|
|
|
{
|
2024-10-25 02:43:41 +02:00
|
|
|
Vec2D<float> connector_position = connecting_nodes.front().position - ((connecting_nodes.front().position - mouse_pos)).norm() * (connecting_nodes.front().radius + 14.0f);
|
|
|
|
|
|
|
|
|
|
if(connecting_nodes.front().connecting && mouse_down){
|
|
|
|
|
DrawLine(connector_position.x, connector_position.y, mouse_pos.x, mouse_pos.y, (Color){229, 181, 103, 255});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mouse_released) {
|
2024-10-25 16:41:37 +02:00
|
|
|
if(&hovering_nodes.front() != &connecting_nodes.front() && &connecting_nodes.front() != &hovering_connectors.front()){
|
|
|
|
|
if(!hovering_nodes.empty()){
|
2024-10-26 02:14:41 +02:00
|
|
|
app.cm.addConnection(connecting_nodes.front().id, hovering_nodes.front().id);
|
2024-10-25 16:41:37 +02:00
|
|
|
} else if(!hovering_connectors.empty()){
|
2024-10-26 02:14:41 +02:00
|
|
|
app.cm.addConnection(connecting_nodes.front().id, hovering_connectors.front().id);
|
2024-10-25 16:41:37 +02:00
|
|
|
} else {
|
2024-10-26 02:14:41 +02:00
|
|
|
int id = app.nm.addNode(mouse_pos.x, mouse_pos.y);
|
|
|
|
|
app.cm.addConnection(connecting_nodes.front().id, id);
|
2024-10-25 16:41:37 +02:00
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
}
|
|
|
|
|
connecting_nodes.front().connecting = false;
|
2024-10-26 02:14:41 +02:00
|
|
|
istate = InteractionState::HOVER_CANVAS;
|
2024-10-25 02:43:41 +02:00
|
|
|
}
|
|
|
|
|
break;
|
2024-10-25 17:13:30 +02:00
|
|
|
}
|
|
|
|
|
case InteractionState::DELETE_SELECTED_NODES:
|
|
|
|
|
{
|
2024-10-26 02:14:41 +02:00
|
|
|
for(auto &n : selected_nodes){
|
2024-10-25 17:13:30 +02:00
|
|
|
n.erase = true;
|
|
|
|
|
}
|
2024-10-26 02:14:41 +02:00
|
|
|
app.removeNodes();
|
2024-10-25 17:13:30 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2024-10-26 16:31:23 +02:00
|
|
|
case InteractionState::COPY_SELECTED_NODES:
|
|
|
|
|
{
|
|
|
|
|
for(auto &n: copied_nodes){
|
|
|
|
|
n.copied = false;
|
|
|
|
|
}
|
|
|
|
|
for(auto &n: selected_nodes){
|
|
|
|
|
n.copied = true;
|
|
|
|
|
n.selected = false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case InteractionState::PASTE_SELECTED_NODES:
|
|
|
|
|
{
|
|
|
|
|
for(auto &n: copied_nodes){
|
|
|
|
|
n.drag_offset = (n.position - copied_nodes.front().position);
|
|
|
|
|
}
|
|
|
|
|
// app.nm.copyNodes(mouse_pos);
|
|
|
|
|
app.copyNodesAndConnections(mouse_pos);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
};
|
2024-10-20 23:42:38 +02:00
|
|
|
|
|
|
|
|
float wheel = GetMouseWheelMove();
|
2024-10-23 00:23:24 +02:00
|
|
|
if(wheel != 0){
|
2024-10-27 00:40:57 +02:00
|
|
|
if(!hovering_nodes.empty() && IsKeyDown(KEY_LEFT_CONTROL) && !IsKeyDown(KEY_LEFT_ALT)){
|
2024-10-24 21:05:05 +02:00
|
|
|
hovering_nodes.front().midi_note += wheel;
|
2024-10-25 16:41:37 +02:00
|
|
|
if(hovering_nodes.front().midi_note < 0 ) hovering_nodes.front().midi_note = app.sm.midi.midiNotes.size()-1;
|
|
|
|
|
if(hovering_nodes.front().midi_note >= app.sm.midi.midiNotes.size() ) hovering_nodes.front().midi_note = 0;
|
2024-10-27 00:40:57 +02:00
|
|
|
} else if(!hovering_nodes.empty() && IsKeyDown(KEY_LEFT_SHIFT) && !IsKeyDown(KEY_LEFT_ALT)) {
|
|
|
|
|
hovering_nodes.front().midi_velocity += wheel;
|
|
|
|
|
if(hovering_nodes.front().midi_velocity < 0 ) hovering_nodes.front().midi_velocity = 127;
|
|
|
|
|
if(hovering_nodes.front().midi_velocity > 127 ) hovering_nodes.front().midi_velocity = 0;
|
|
|
|
|
} else if(!hovering_nodes.empty() && IsKeyDown(KEY_LEFT_ALT)) {
|
|
|
|
|
float incr = (float)wheel * (IsKeyDown(KEY_LEFT_SHIFT) ? 100.0f : IsKeyDown(KEY_LEFT_CONTROL) ? 1000.0f : 10.0f);
|
|
|
|
|
hovering_nodes.front().midi_gate += incr;
|
|
|
|
|
if(hovering_nodes.front().midi_gate < 0 ) hovering_nodes.front().midi_gate = 0;
|
2024-10-24 00:39:39 +02:00
|
|
|
} else {
|
|
|
|
|
Vector2 mouseWorldPos = GetScreenToWorld2D(GetMousePosition(), camera);
|
|
|
|
|
camera.offset = GetMousePosition();
|
|
|
|
|
camera.target = mouseWorldPos;
|
|
|
|
|
float scaleFactor = 1.0f + (0.25f*fabsf(wheel));
|
|
|
|
|
if (wheel < 0) scaleFactor = 1.0f/scaleFactor;
|
|
|
|
|
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
|
|
|
|
|
}
|
2024-10-20 23:42:38 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
for(int x = -app.settings.grid*100; x < app.settings.grid*100; x+=app.settings.grid){
|
|
|
|
|
for(int y = -app.settings.grid*100; y < app.settings.grid*100; y+=app.settings.grid){
|
2024-10-25 02:43:41 +02:00
|
|
|
DrawPixel(x, y, (Color){130,130,130,200});
|
|
|
|
|
}
|
2024-10-10 02:59:27 +02:00
|
|
|
}
|
2024-10-26 02:14:41 +02:00
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
app.draw(&mouse_pos, &camera);
|
2024-10-23 03:25:57 +02:00
|
|
|
|
2024-10-25 02:43:41 +02:00
|
|
|
EndMode2D();
|
2024-10-24 00:39:39 +02:00
|
|
|
|
2024-10-25 16:41:37 +02:00
|
|
|
app.drawUI(&mouse_pos, &camera);
|
2024-10-13 04:22:09 +02:00
|
|
|
|
|
|
|
|
EndDrawing();
|
2024-10-09 02:01:23 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-13 04:22:09 +02:00
|
|
|
CloseWindow();
|
|
|
|
|
|
|
|
|
|
return 0;
|
2024-10-09 02:01:23 +02:00
|
|
|
}
|
|
|
|
|
|