From b5c752d87ab23e686e006793391ddfda108c1279 Mon Sep 17 00:00:00 2001 From: Lemonymous <10490534+Lemonymous@users.noreply.github.com> Date: Tue, 25 Oct 2022 16:35:29 +0200 Subject: [PATCH] Change draggable ui resize handle Change `less`/`greater` signs to `less or equal`/`greater or equal`, so resize handle size includes the edge pixels. --- scripts/mod_loader/ui/widgets/draggable.lua | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/mod_loader/ui/widgets/draggable.lua b/scripts/mod_loader/ui/widgets/draggable.lua index 985043f2..2770b400 100644 --- a/scripts/mod_loader/ui/widgets/draggable.lua +++ b/scripts/mod_loader/ui/widgets/draggable.lua @@ -16,10 +16,11 @@ function UiDraggable:isEdge(mx, my) end local resizeHandle = self.__resizeHandle - return mx < self.screenx + resizeHandle or - my < self.screeny + resizeHandle or - mx > self.screenx + self.w - resizeHandle or - my > self.screeny + self.h - resizeHandle + return false + or my <= self.screeny + resizeHandle + or mx <= self.screenx + resizeHandle + or mx >= self.screenx + self.w - resizeHandle + or my >= self.screeny + self.h - resizeHandle end local RESIZE_DIR_TOPLEFT = 0 @@ -37,21 +38,21 @@ local function getResizeDirection(self, mx, my) -- use double the resize handle size to make corners easier to click local rh2 = resizeHandle * 2 - if ox < rh2 and oy < rh2 then + if ox <= rh2 and oy <= rh2 then return RESIZE_DIR_TOPLEFT - elseif ox > self.w - rh2 and oy < rh2 then + elseif ox >= self.w - rh2 and oy <= rh2 then return RESIZE_DIR_TOPRIGHT - elseif ox > self.w - rh2 and oy > self.h - rh2 then + elseif ox >= self.w - rh2 and oy >= self.h - rh2 then return RESIZE_DIR_BOTRIGHT - elseif ox < rh2 and oy > self.h - rh2 then + elseif ox <= rh2 and oy >= self.h - rh2 then return RESIZE_DIR_BOTLEFT - elseif oy < resizeHandle then + elseif oy <= resizeHandle then return RESIZE_DIR_TOP - elseif oy > self.h - resizeHandle then + elseif oy >= self.h - resizeHandle then return RESIZE_DIR_BOT - elseif ox < resizeHandle then + elseif ox <= resizeHandle then return RESIZE_DIR_LEFT - elseif ox > self.w - resizeHandle then + elseif ox >= self.w - resizeHandle then return RESIZE_DIR_RIGHT end