Good working protoype with config nodes and a experimental channel setting ui.
This commit is contained in:
@@ -1,15 +1,76 @@
|
||||
#pragma once
|
||||
|
||||
#include "datatypes.h"
|
||||
#include "interactable.h"
|
||||
#include "vmath.h"
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "state.h"
|
||||
|
||||
inline bool ViButton(Vec2Df mp, float x, float y, float radius, Color color){
|
||||
DrawCircle(x,y,radius, color);
|
||||
return (Vector2Distance(mp, (Vector2){x,y}) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
||||
}
|
||||
|
||||
inline bool ViButton(Vec2Df mp, Vec2Df position, float radius, Color color){
|
||||
return ViButton(mp, position.x, position.y, radius, color);
|
||||
}
|
||||
|
||||
inline bool ViButtonText(Vec2Df mp, Vec2Df position, float radius, Color color, std::string text, float text_size, Color text_color){
|
||||
float offset = MeasureText(text.c_str(), text_size);
|
||||
DrawCircle(position.x, position.y, radius, color);
|
||||
DrawText(text.c_str(), position.x-offset/2.0f, position.y - text_size/2, text_size, text_color);
|
||||
return (Vector2Distance(mp, position) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
||||
}
|
||||
|
||||
inline bool ViSegButton(Vec2Df mp, float x, float y, float start_angle, float end_angle, float radius, Color color){
|
||||
DrawCircleSector((Vector2){x,y},radius, start_angle, end_angle, 5, color);
|
||||
return (Vector2Distance(mp, (Vector2){x,y}) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
||||
}
|
||||
|
||||
inline void DrawCenteredText(std::string text, Vec2Df position, float text_size, Color color){
|
||||
float offset = MeasureText(text.c_str(), text_size);
|
||||
DrawText(text.c_str(), position.x-offset/2.0f, position.y-text_size/2.0f, text_size, color);
|
||||
}
|
||||
|
||||
namespace VISEQ::APP::UI{
|
||||
|
||||
class Button : public BASE::Interactable{
|
||||
public:
|
||||
Button() {}
|
||||
Button(Vec2Df position, Color color) : color(color), position(position) {}
|
||||
Color color = VS_COLOR_YELLOW;
|
||||
Color hover_color = VS_COLOR_SUN;
|
||||
Vec2Df position = {0,0};
|
||||
std::string text = "";
|
||||
Color text_color = VS_COLOR_BROWN;
|
||||
float text_size = 10;
|
||||
virtual void draw() = 0;
|
||||
virtual GRAPH::GraphItemType getType() override {return GRAPH::GraphItemType::VS_BUTTON;}
|
||||
};
|
||||
|
||||
class ButtonRound : public Button{
|
||||
public:
|
||||
ButtonRound() {}
|
||||
ButtonRound(Vec2Df position, float radius, Color color) : Button(position, color), radius(radius){}
|
||||
|
||||
std::shared_ptr<APP::State> state = APP::State::get();
|
||||
|
||||
float radius = 0.0f;
|
||||
virtual bool hovering() override {
|
||||
return CheckCollisionPointCircle(SCREEN_MOUSE, position, radius);
|
||||
}
|
||||
|
||||
virtual void pickUp() override {}
|
||||
virtual void pickUp(Vec2Df position) override {}
|
||||
virtual void drag(Vec2Df position) override {}
|
||||
virtual void putDown() override {}
|
||||
|
||||
virtual void draw() override {
|
||||
float offset = MeasureText(text.c_str(), text_size);
|
||||
if(!hovering()) DrawCircle(position.x, position.y, radius, color);
|
||||
else DrawCircle(position.x, position.y, radius, hover_color);
|
||||
if(text != "") DrawText(text.c_str(), position.x-offset/2.0f, position.y - text_size/2, text_size, text_color);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user