Better centered text. Pass by reference for midi variable is not going to work with json serialization.
This commit is contained in:
@@ -489,19 +489,8 @@ namespace VISEQ::GRAPH {
|
||||
}
|
||||
}
|
||||
|
||||
void drawNodeUI(){
|
||||
|
||||
}
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(GraphManager, nodes, edges, selected_nodes)
|
||||
|
||||
/*inline void to_json(json& j, const GraphManager& G){*/
|
||||
/* j = json{{"nodes", G.nodes}, {"edges", G.edges}};*/
|
||||
/*}*/
|
||||
/**/
|
||||
/*inline void from_json(const json& j, GraphManager& G){*/
|
||||
/* j.at("nodes").template get_to<VEC_SPTR_Node>(G.nodes);*/
|
||||
/*}*/
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "vmath.h"
|
||||
#include <raymath.h>
|
||||
#include <string>
|
||||
|
||||
namespace VISEQ::HELPER{
|
||||
inline void DrawSuperText(std::string text, Vec2Df start, Vec2Df end, float pos, float dist, float size, Color col){
|
||||
float d = start.dist(end);
|
||||
Vector2 text_length = MeasureTextEx(GetFontDefault(), text.c_str(), size, 2.0f);
|
||||
|
||||
Vec2Df middle_handle = start + (end - start) * ((d - text_length.x)*pos)/d;
|
||||
Vec2Df text_position = middle_handle + (start - end).norm().orth() * dist;
|
||||
|
||||
float rotation = Vector2Angle((Vector2){1,0}, (end - start)) * RAD2DEG;
|
||||
DrawTextPro(GetFontDefault(), text.c_str(), text_position, (Vector2){0,0}, rotation, size, 2.0f, col);
|
||||
}
|
||||
}
|
||||
+6
-17
@@ -72,7 +72,7 @@ namespace VISEQ::GRAPH::NODES {
|
||||
void init(){
|
||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.note, position, VS_COLOR_GREEN, "NOTE"));
|
||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.channel, position, VS_COLOR_PINK, "CHANNEL", 0, 15, 40, 150));
|
||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", 0, 30000, 40, 300));
|
||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", 10, 30000, 40, 300));
|
||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.velocity, position, VS_COLOR_PURPLE, "VELOCITY"));
|
||||
|
||||
|
||||
@@ -348,22 +348,9 @@ namespace VISEQ::GRAPH::NODES {
|
||||
DrawRing(position, radius, radius + 4, 0.0f - 90.0f, (360.0f/127.0f) * getNotes().velocity - 90.0f, 24, (Color){158, 134, 200, 255});
|
||||
DrawCircleLinesV(position, radius + 4, (Color){100, 100, 100, 255});
|
||||
|
||||
float midi_gate_map = round((255.f / getNotes().gate) * fade);
|
||||
|
||||
Color gate_color = VS_COLOR_GREEN;
|
||||
|
||||
switch(mode){
|
||||
case 0:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){180, 210, 115, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
case 1:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){229, 181, 103, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
case 2:{
|
||||
gate_color = ColorAlphaBlend(VS_COLOR_RED, (Color){232, 125, 62, (unsigned char)Clamp(255 - midi_gate_map, 0, 255)}, WHITE);
|
||||
break;}
|
||||
}
|
||||
if(!picked_up && !selected && !in_selection_rect && !hovering()) DrawCircle(position.x, position.y, radius, gate_color);
|
||||
float trigger_alpha = (1.f / getNotes().gate) * fade;
|
||||
|
||||
if(!picked_up && !selected && !in_selection_rect && !hovering()) DrawCircle(position.x, position.y, radius, ColorLerp(state->mode_color, VS_COLOR_RED, trigger_alpha));
|
||||
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});
|
||||
|
||||
@@ -372,6 +359,8 @@ namespace VISEQ::GRAPH::NODES {
|
||||
|
||||
if(selected) DrawCircleLinesV(position, radius+8, (Color){158, 255, 210, 255});
|
||||
|
||||
/*if(fade > 0) DrawCircle(position.x, position.y, radius, ColorAlpha(VS_COLOR_RED, trigger_alpha));*/
|
||||
|
||||
if(KEYS_DOWN.alt){
|
||||
float value = 0;
|
||||
int offset_gate = 0;
|
||||
|
||||
+10
-7
@@ -3,6 +3,7 @@
|
||||
#include "datatypes.h"
|
||||
#include "draggable.h"
|
||||
#include "graph-item.h"
|
||||
#include "helper.h"
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "state.h"
|
||||
@@ -108,21 +109,23 @@ namespace VISEQ::GRAPH::NODES{
|
||||
|
||||
virtual void draw() override {
|
||||
if(!locked && visible){
|
||||
bool show = hovering() || picked_up;
|
||||
Color dcol = ColorBrightness(col, -0.5f);
|
||||
Color dyncol = show ? col : dcol;
|
||||
|
||||
DrawLineV(minP, maxP, dcol);
|
||||
DrawLineV(parentPosition, minP, VS_COLOR_LIGHTGREY);
|
||||
DrawCircleV(minP, 3.0f, dcol);
|
||||
DrawCircleV(maxP, 3.0f, dcol);
|
||||
DrawCircleV(position + parentPosition, radius, hovering() ? col : dcol);
|
||||
Vec2Df text_position = maxP.center(minP) + (minP - maxP).norm().orth() * 6.0f;
|
||||
float rotation = Vector2Angle((Vector2){1,0}, (minP - maxP)) * RAD2DEG;
|
||||
DrawTextPro(GetFontDefault(), name.c_str(), text_position, (Vector2){0,0}, rotation, 10.0f, 2.0f, hovering() ? col : dcol);
|
||||
//DrawLineV(parentPosition, minP, VS_COLOR_LIGHTGREY);
|
||||
DrawCircleV(minP, 3.0f, dyncol);
|
||||
DrawCircleV(maxP, 3.0f, dyncol);
|
||||
DrawCircleV(position + parentPosition, radius, dyncol);
|
||||
if(show) VISEQ::HELPER::DrawSuperText(name, minP, maxP, 0.5f, 8.0f, 10.0f, dyncol);
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool select() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
// NLOHMANN_DEFINE_TYPE_INTRUSIVE(NodeHandle<T>, position, parentPosition, col, name, minValue, maxValue, minDistance, maxDistance);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace VISEQ::APP{
|
||||
float fps;
|
||||
float speed = 16.0f;
|
||||
int gui_selected_midi_out;
|
||||
Color mode_colors[7] = {VS_COLOR_GREEN, VS_COLOR_SUN, VS_COLOR_PINK, VS_COLOR_ORANGE, VS_COLOR_PURPLE, VS_COLOR_LIGHTGREY, (Color){0,0,0,0}};
|
||||
};
|
||||
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(AppSettings, width, height, grid, bpm, fps, speed, gui_selected_midi_out)
|
||||
|
||||
@@ -84,6 +85,8 @@ namespace VISEQ::APP{
|
||||
Vec2Df mouse_delta;
|
||||
|
||||
Vec2Df selection_origin;
|
||||
|
||||
Color mode_color = settings.mode_colors[0];
|
||||
|
||||
void pushEvent(InteractionEvent e){
|
||||
event_queue.push_back(e);
|
||||
@@ -132,6 +135,8 @@ namespace VISEQ::APP{
|
||||
screen_mouse = {round(mouse_pos.x), round(mouse_pos.y)};
|
||||
raw_mouse = {GetMousePosition().x, GetMousePosition().y};
|
||||
mod_mouse = {round(mouse_pos.x), round(mouse_pos.y)};
|
||||
|
||||
mode_color = settings.mode_colors[node_mode];
|
||||
|
||||
if(keys_down.ctrl) {
|
||||
mod_mouse.x = round(mouse_pos.x / settings.grid) * settings.grid;
|
||||
|
||||
@@ -99,9 +99,9 @@ namespace VISEQ::APP::UI{
|
||||
|
||||
std::string shorts[6] = {"NT","CC","PC","PB","AT","PP"};
|
||||
for(int i = 0; i < 6; ++i){
|
||||
Color col = VS_COLOR_GREEN;
|
||||
if(state->node_mode == i) col = VS_COLOR_SUN;
|
||||
Color col = state->settings.mode_colors[i];
|
||||
Vec2Df pos = {state->settings.width - (6.0f*75.0f) + i*75.0f, state->settings.height - 75.0f};
|
||||
DrawRing(pos, 30.0f, 34.0f, 0.0f, 360.0f, 24, state->node_mode == i ? VS_COLOR_WHITE : (Color){0,0,0,0});
|
||||
DrawCircleV(pos, 30.0f, col);
|
||||
DrawCenteredText(shorts[i], pos, 20, WHITE);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace VISEQ::APP::UI{
|
||||
float offset = MeasureText(text.c_str(), size);
|
||||
DrawText(text.c_str(), position.x-offset/2.0f, position.y-(float)size/2.0f+1, size, color );
|
||||
}
|
||||
|
||||
|
||||
void drawContextMenu(Camera2D camera){
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user