2024-10-15 02:59:26 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
#include "datatypes.h"
|
|
|
|
|
#include "interactable.h"
|
2024-11-14 00:55:09 +01:00
|
|
|
#include "vmath.h"
|
2024-10-15 02:59:26 +02:00
|
|
|
#include "raylib.h"
|
|
|
|
|
#include "raymath.h"
|
2024-12-09 01:40:13 +01:00
|
|
|
#include "state.h"
|
2024-10-15 02:59:26 +02:00
|
|
|
|
2024-11-02 15:52:16 +01:00
|
|
|
inline bool ViButton(Vec2Df mp, float x, float y, float radius, Color color){
|
2024-10-15 02:59:26 +02:00
|
|
|
DrawCircle(x,y,radius, color);
|
|
|
|
|
return (Vector2Distance(mp, (Vector2){x,y}) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
|
|
|
|
}
|
2024-10-25 02:43:41 +02:00
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-02 15:52:16 +01:00
|
|
|
inline bool ViSegButton(Vec2Df mp, float x, float y, float start_angle, float end_angle, float radius, Color color){
|
2024-10-25 02:43:41 +02:00
|
|
|
DrawCircleSector((Vector2){x,y},radius, start_angle, end_angle, 5, color);
|
|
|
|
|
return (Vector2Distance(mp, (Vector2){x,y}) < radius && IsMouseButtonPressed(MOUSE_BUTTON_LEFT));
|
|
|
|
|
}
|
2024-12-09 01:40:13 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 19:34:23 +02:00
|
|
|
inline void DrawText(std::string text, Vec2Df position, float text_size, Color color){
|
|
|
|
|
DrawText(text.c_str(), position.x, position.y-text_size/2.0f, text_size, color);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-09 01:40:13 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|