orbit ui done
This commit is contained in:
+23
-17
@@ -69,28 +69,34 @@ namespace VISEQ::GRAPH::NODES {
|
|||||||
float last = 0;
|
float last = 0;
|
||||||
|
|
||||||
void init(){
|
void init(){
|
||||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.note, position, VS_COLOR_GREEN, "NOTE"));
|
float orbit_1 = radius + 25.0f;
|
||||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
float orbit_2 = orbit_1 + 20.0f;
|
||||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", 10, 30000, 40, 300));
|
float orbit_3 = orbit_2 + 20.0f;
|
||||||
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.velocity, position, VS_COLOR_PURPLE, "VELOCITY"));
|
float orbit_4 = orbit_3 + 20.0f;
|
||||||
|
float orbit_5 = orbit_4 + 30.0f;
|
||||||
|
|
||||||
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.control, position, VS_COLOR_SUN, "CONTROL"));
|
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.note, position, VS_COLOR_GREEN, "NOTE", orbit_5, 12));
|
||||||
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.value, position, VS_COLOR_GREEN, "VALUE"));
|
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.gate, position, VS_COLOR_RED, "GATE", orbit_3, 30, 10, 30000, 40, 300));
|
||||||
|
midiNoteHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiNote.velocity, position, VS_COLOR_PURPLE, "VELOCITY", orbit_4, 32));
|
||||||
|
|
||||||
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.program, position, VS_COLOR_SUN, "PROGRAM"));
|
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.control, position, VS_COLOR_SUN, "CONTROL", orbit_3, 32));
|
||||||
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.value, position, VS_COLOR_GREEN, "VALUE"));
|
midiCCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiCC.value, position, VS_COLOR_GREEN, "VALUE", orbit_4, 32));
|
||||||
|
|
||||||
midiPitchBendHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPitchBend.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.program, position, VS_COLOR_SUN, "PROGRAM", orbit_3, 32));
|
||||||
midiPitchBendHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPitchBend.value, position, VS_COLOR_GREEN, "VALUE", -8192, 8192, 40, 300));
|
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
|
midiPCHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPC.value, position, VS_COLOR_GREEN, "VALUE", orbit_4, 32));
|
||||||
|
|
||||||
midiAftertouchHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiAftertouch.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
midiPitchBendHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPitchBend.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
midiAftertouchHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiAftertouch.value, position, VS_COLOR_GREEN, "VALUE"));
|
midiPitchBendHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPitchBend.value, position, VS_COLOR_GREEN, "VALUE", orbit_3, 256, -8192, 8192, 40, 300));
|
||||||
|
|
||||||
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.channel, position, VS_COLOR_PINK, "CHANNEL", 1, 16, 40, 150));
|
midiAftertouchHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiAftertouch.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.value, position, VS_COLOR_GREEN, "VALUE"));
|
midiAftertouchHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiAftertouch.value, position, VS_COLOR_GREEN, "VALUE", orbit_3, 32));
|
||||||
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.note, position, VS_COLOR_SUN, "NOTE"));
|
|
||||||
|
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.channel, position, VS_COLOR_PINK, "CHANNEL", orbit_1, 1, 1, 16, 40, 150));
|
||||||
|
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.value, position, VS_COLOR_GREEN, "VALUE", orbit_4, 32));
|
||||||
|
midiPolyPressureHandles.emplace_back(std::make_shared<NodeHandle<int>>(midiPolyPressure.note, position, VS_COLOR_SUN, "NOTE", orbit_5, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MidiNode> getPtr(){
|
std::shared_ptr<MidiNode> getPtr(){
|
||||||
|
|||||||
+32
-18
@@ -16,8 +16,8 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
class NodeHandle : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<NodeHandle<T>>{
|
class NodeHandle : public BASE::Draggable, public GraphItem, public std::enable_shared_from_this<NodeHandle<T>>{
|
||||||
public:
|
public:
|
||||||
NodeHandle() {}
|
NodeHandle() {}
|
||||||
NodeHandle(T &_assignedValue, Vec2Df parentPos, Color _col, std::string name) : assignedValueRef(_assignedValue), parentPosition(parentPos), col(_col), name(name) {init();}
|
NodeHandle(T &_assignedValue, Vec2Df parentPos, Color _col, std::string name, float orbit, int steps) : assignedValueRef(_assignedValue), parentPosition(parentPos), col(_col), name(name), orbit(orbit), steps(steps) {init();}
|
||||||
NodeHandle(T &_assignedValue, Vec2Df parentPos, Color _col, std::string name, float min, float max, float minDist, float maxDist) : assignedValueRef(_assignedValue), parentPosition(parentPos), col(_col), name(name), minValue(min), maxValue(max), minDistance(minDist), maxDistance(maxDist) {init();}
|
NodeHandle(T &_assignedValue, Vec2Df parentPos, Color _col, std::string name, float orbit, int steps, float min, float max, float minDist, float maxDist) : assignedValueRef(_assignedValue), parentPosition(parentPos), col(_col), name(name), minValue(min), maxValue(max), minDistance(minDist), maxDistance(maxDist), orbit(orbit), steps(steps) {init();}
|
||||||
|
|
||||||
virtual GRAPH::GraphItemType getType() override {
|
virtual GRAPH::GraphItemType getType() override {
|
||||||
return GraphItemType::HANDLE;
|
return GraphItemType::HANDLE;
|
||||||
@@ -40,6 +40,8 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
|
|
||||||
float radius = 10.0f;
|
float radius = 10.0f;
|
||||||
float orbit = 0.0f;
|
float orbit = 0.0f;
|
||||||
|
int steps = 1;
|
||||||
|
float angle_g = 0;
|
||||||
|
|
||||||
Vec2Df minP;
|
Vec2Df minP;
|
||||||
Vec2Df maxP;
|
Vec2Df maxP;
|
||||||
@@ -48,7 +50,7 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
bool visible = false;
|
bool visible = false;
|
||||||
|
|
||||||
void init(){
|
void init(){
|
||||||
position = parentPosition.orbitAtAngle(minDistance, DEG2RAD * GetRandomValue(0, 360)) - parentPosition;
|
position = parentPosition.orbitAtAngle(orbit, 0) - parentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
void assignValue(T &value){
|
void assignValue(T &value){
|
||||||
@@ -60,16 +62,13 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void drag(Vec2Df mouse_pos) override {
|
virtual void drag(Vec2Df mouse_pos) override {
|
||||||
if(KEYS_DOWN.shift) {
|
float range = maxValue - minValue;
|
||||||
orbit = (parentPosition + position).dist(parentPosition);
|
float stepping = 360 / range;
|
||||||
position = parentPosition.orbitAlongVector(SCREEN_MOUSE, orbit) - parentPosition;
|
if(KEYS_DOWN.shift) stepping = steps;
|
||||||
} else {
|
float angle = Vector2Angle((SCREEN_MOUSE - parentPosition), Vector2(0,1)) * RAD2DEG;
|
||||||
float step = (maxDistance - minDistance) / (maxValue - minValue);
|
float stepped_angle = (round(angle / stepping) * stepping) * DEG2RAD;
|
||||||
orbit = round(parentPosition.dist(SCREEN_MOUSE) / step) * step;
|
//position = parentPosition.orbitAlongVector(SCREEN_MOUSE, orbit) - parentPosition;
|
||||||
position = parentPosition.orbitAlongVector(maxP, orbit) - parentPosition;
|
position = parentPosition.orbitAtAngle(orbit, stepped_angle) - parentPosition;
|
||||||
}
|
|
||||||
if(distance() >= maxDistance) position = parentPosition.orbitAlongVector(maxP, maxDistance) - parentPosition;
|
|
||||||
if(distance() <= minDistance) position = parentPosition.orbitAlongVector(maxP, minDistance) - parentPosition;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lock(){
|
void lock(){
|
||||||
@@ -87,7 +86,11 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateAssignedValue(){
|
void updateAssignedValue(){
|
||||||
assignedValueRef = (T)Remap((float)(parentPosition + position).dist(parentPosition), minDistance, maxDistance, minValue, maxValue);
|
//T value = (T)Remap((float)(parentPosition + position).dist(parentPosition), minDistance, maxDistance, minValue, maxValue);
|
||||||
|
float angle = 360 - (Vector2Angle(position, Vector2(0,1)) * RAD2DEG + 180);
|
||||||
|
angle_g = angle;
|
||||||
|
T value = (T)Remap(angle, 0, 360, minValue, maxValue);
|
||||||
|
assignedValueRef = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool hovering() override {
|
virtual bool hovering() override {
|
||||||
@@ -115,12 +118,23 @@ namespace VISEQ::GRAPH::NODES{
|
|||||||
Color dcol = ColorBrightness(col, -0.5f);
|
Color dcol = ColorBrightness(col, -0.5f);
|
||||||
Color dyncol = show ? col : dcol;
|
Color dyncol = show ? col : dcol;
|
||||||
|
|
||||||
DrawLineV(minP, maxP, dcol);
|
//DrawLineV(minP, maxP, dcol);
|
||||||
//DrawLineV(parentPosition, minP, VS_COLOR_LIGHTGREY);
|
//DrawLineV(parentPosition, minP, VS_COLOR_LIGHTGREY);
|
||||||
DrawCircleV(minP, 3.0f, dyncol);
|
//DrawCircleV(minP, 3.0f, dyncol);
|
||||||
DrawCircleV(maxP, 3.0f, dyncol);
|
//DrawCircleV(maxP, 3.0f, dyncol);
|
||||||
|
if(steps > 0){
|
||||||
|
for(int i = 0; i < 360; i += steps){
|
||||||
|
Vec2Df pos = parentPosition.orbitAtAngle(orbit, DEG2RAD * i);
|
||||||
|
Vec2Df pos1 = parentPosition.orbitAtAngle(orbit - 4.0f, DEG2RAD * i);
|
||||||
|
//DrawCircleV(pos, 1.0f, dyncol);
|
||||||
|
DrawLineV(pos, pos1, dyncol);
|
||||||
|
}
|
||||||
|
}
|
||||||
DrawCircleV(position + parentPosition, radius, dyncol);
|
DrawCircleV(position + parentPosition, radius, dyncol);
|
||||||
if(show) VISEQ::HELPER::DrawSuperText(name, minP, maxP, 0.5f, 8.0f, 10.0f, dyncol);
|
DrawCircleLinesV(parentPosition, (parentPosition + position).dist(parentPosition), dyncol);
|
||||||
|
VISEQ::HELPER::DrawSuperText(std::format("{}", assignedValueRef), position + parentPosition, position + parentPosition + Vec2Df(50,0), 1, 0, 8, dyncol);
|
||||||
|
|
||||||
|
//if(show) VISEQ::HELPER::DrawSuperText(name, minP, maxP, 0.5f, 8.0f, 10.0f, dyncol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user