Some progress on selecting, hovering but still buggy and not a good design really.

This commit is contained in:
Sebastian
2024-11-17 02:40:31 +01:00
parent 55926a5021
commit e9633ff19d
10 changed files with 99 additions and 37 deletions
+14 -6
View File
@@ -25,17 +25,18 @@ namespace VISEQ::APP::CANVAS {
virtual void drawStart(){
BeginMode2D(camera);
state->hovering = false;
if(hovering()) state->istate = InteractionState::HOVER_CANVAS;
/*state->hovering = false;*/
/*if(hovering()) state->istate = InteractionState::HOVER_CANVAS;*/
}
virtual void drawEnd(){
EndMode2D();
}
void select(){
void select_rect(){
if(state->mouse_left.clicked){
state->selection = (Rectangle){0,0,0,0};
select_start = state->screen_mouse;
state->istate = InteractionState::DRAW_SELECTION;
}
@@ -43,15 +44,18 @@ namespace VISEQ::APP::CANVAS {
if(state->mouse_left.down){
Vec2Df select1 = {state->screen_mouse.x > select_start.x ? select_start.x : state->screen_mouse.x, state->screen_mouse.y > select_start.y ? select_start.y : state->screen_mouse.y};
Vec2Df select2 = {state->screen_mouse.x > select_start.x ? state->screen_mouse.x - select_start.x : select_start.x - state->screen_mouse.x, state->screen_mouse.y > select_start.y ? state->screen_mouse.y - select_start.y : select_start.y - state->screen_mouse.y};
DrawRectangleLines(select1.x, select1.y, select2.x, select2.y, (Color){150,150,150,150});
state->selection = (Rectangle){select1.x, select1.y, select2.x, select2.y};
}
if(state->mouse_left.released){
state->istate = InteractionState::HOVER_CANVAS;
}
}
virtual void draw(){
virtual void update() override {
camera_delta = state->mouse_delta * (-1.0f/camera.zoom);
if(hovering()) drag();
if(state->istate == InteractionState::HOVER_CANVAS || state->istate == InteractionState::DRAW_SELECTION) select();
if(state->istate == InteractionState::HOVER_CANVAS || state->istate == InteractionState::DRAW_SELECTION) select_rect();
float wheel = GetMouseWheelMove();
if(wheel != 0){
@@ -63,6 +67,10 @@ namespace VISEQ::APP::CANVAS {
camera.zoom = Clamp(camera.zoom*scaleFactor, 0.125f, 64.0f);
}
}
}
virtual void draw(){
if(state->istate == InteractionState::DRAW_SELECTION) DrawRectangleLines(state->selection.x, state->selection.y, state->selection.width, state->selection.height, (Color){150,150,150,150});
for(int x = -state->settings.grid*100; x < state->settings.grid*100; x+=state->settings.grid){
for(int y = -state->settings.grid*100; y < state->settings.grid*100; y+=state->settings.grid){