瀏覽代碼

fix floating window example (#392)

emoney17 1 年之前
父節點
當前提交
bb68d06440
共有 2 個文件被更改,包括 9 次插入6 次删除
  1. 2 1
      examples/Makefile
  2. 7 5
      examples/floating_window/floating_window.c

+ 2 - 1
examples/Makefile

@@ -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))
 

+ 7 - 5
examples/floating_window/floating_window.c

@@ -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;
-}
+}