fix floating window example (#392)

This commit is contained in:
emoney17 2024-03-28 04:24:38 -05:00 committed by GitHub
parent ac19d7e08a
commit bb68d06440
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View File

@ -356,7 +356,8 @@ EXAMPLES = \
scroll_panel/scroll_panel \
style_selector/style_selector \
custom_sliders/custom_sliders \
animation_curve/animation_curve
animation_curve/animation_curve \
floating_window/floating_window \
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))

View File

@ -1,7 +1,7 @@
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "../../raygui.h"
#include "../../src/raygui.h"
#include "../../styles/dark/style_dark.h"
@ -61,9 +61,11 @@ void GuiWindowFloating(Vector2 *position, Vector2 *size, bool *minimized, bool *
}
} else if(*resizing) {
Vector2 mouse_delta = GetMouseDelta();
size->x += mouse_delta.x;
size->y += mouse_delta.y;
Vector2 mouse = GetMousePosition();
if (mouse.x > position->x)
size->x = mouse.x - position->x;
if (mouse.y > position->y)
size->y = mouse.y - position->y;
// clamp window size to an arbitrary minimum value and the window size as the maximum
if(size->x < 100) size->x = 100;
@ -143,4 +145,4 @@ int main(void) {
CloseWindow();
return 0;
}
}