From 11264bb14ec4c1e1c760f29aebd19822f218c3e5 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 30 Oct 2014 19:34:05 -0400 Subject: [PATCH 1/4] Add ability to enable/disable system cursors --- init.lua | 143 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/init.lua b/init.lua index 8d7af98..f6635ea 100644 --- a/init.lua +++ b/init.lua @@ -22,6 +22,7 @@ loveframes.config["DEFAULTSKIN"] = "Blue" loveframes.config["ACTIVESKIN"] = "Blue" loveframes.config["INDEXSKINIMAGES"] = true loveframes.config["DEBUG"] = false +loveframes.config["ENABLE_SYSTEM_CURSORS"] = false -- misc library vars loveframes.state = "none" @@ -84,84 +85,86 @@ function loveframes.update(dt) end end - local hoverobject = loveframes.hoverobject - local arrow = love.mouse.getSystemCursor("arrow") - local curcursor = love.mouse.getCursor() - if hoverobject then - local ibeam = love.mouse.getSystemCursor("ibeam") - local mx, my = love.mouse.getPosition() - if hoverobject.type == "textinput" and not loveframes.resizeobject then - if curcursor ~= ibeam then - love.mouse.setCursor(ibeam) - end - elseif hoverobject.type == "frame" then - if not hoverobject.dragging and hoverobject.canresize then - if loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y, my, 5, 1, 5, 1) then - local sizenwse = love.mouse.getSystemCursor("sizenwse") - if curcursor ~= sizenwse then - love.mouse.setCursor(sizenwse) - end - elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then - local sizenwse = love.mouse.getSystemCursor("sizenwse") - if curcursor ~= sizenwse then - love.mouse.setCursor(sizenwse) - end - elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y, my, 5, 1, 5, 1) then - local sizenesw = love.mouse.getSystemCursor("sizenesw") - if curcursor ~= sizenesw then - love.mouse.setCursor(sizenesw) - end - elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then - local sizenesw = love.mouse.getSystemCursor("sizenesw") - if curcursor ~= sizenesw then - love.mouse.setCursor(sizenesw) - end - elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y, my, hoverobject.width - 10, 1, 2, 1) then - local sizens = love.mouse.getSystemCursor("sizens") - if curcursor ~= sizens then - love.mouse.setCursor(sizens) - end - elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y + hoverobject.height - 2, my, hoverobject.width - 10, 1, 2, 1) then - local sizens = love.mouse.getSystemCursor("sizens") - if curcursor ~= sizens then - love.mouse.setCursor(sizens) - end - elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then - local sizewe = love.mouse.getSystemCursor("sizewe") - if curcursor ~= sizewe then - love.mouse.setCursor(sizewe) - end - elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 2, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then - local sizewe = love.mouse.getSystemCursor("sizewe") - if curcursor ~= sizewe then - love.mouse.setCursor(sizewe) - end - else - if not loveframes.resizeobject then - local arrow = love.mouse.getSystemCursor("arrow") - if curcursor ~= arrow then - love.mouse.setCursor(arrow) + if loveframes.config["ENABLE_SYSTEM_CURSORS"] then + local hoverobject = loveframes.hoverobject + local arrow = love.mouse.getSystemCursor("arrow") + local curcursor = love.mouse.getCursor() + if hoverobject then + local ibeam = love.mouse.getSystemCursor("ibeam") + local mx, my = love.mouse.getPosition() + if hoverobject.type == "textinput" and not loveframes.resizeobject then + if curcursor ~= ibeam then + love.mouse.setCursor(ibeam) + end + elseif hoverobject.type == "frame" then + if not hoverobject.dragging and hoverobject.canresize then + if loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y, my, 5, 1, 5, 1) then + local sizenwse = love.mouse.getSystemCursor("sizenwse") + if curcursor ~= sizenwse then + love.mouse.setCursor(sizenwse) + end + elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then + local sizenwse = love.mouse.getSystemCursor("sizenwse") + if curcursor ~= sizenwse then + love.mouse.setCursor(sizenwse) + end + elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 5, mx, hoverobject.y, my, 5, 1, 5, 1) then + local sizenesw = love.mouse.getSystemCursor("sizenesw") + if curcursor ~= sizenesw then + love.mouse.setCursor(sizenesw) + end + elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + hoverobject.height - 5, my, 5, 1, 5, 1) then + local sizenesw = love.mouse.getSystemCursor("sizenesw") + if curcursor ~= sizenesw then + love.mouse.setCursor(sizenesw) + end + elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y, my, hoverobject.width - 10, 1, 2, 1) then + local sizens = love.mouse.getSystemCursor("sizens") + if curcursor ~= sizens then + love.mouse.setCursor(sizens) + end + elseif loveframes.util.BoundingBox(hoverobject.x + 5, mx, hoverobject.y + hoverobject.height - 2, my, hoverobject.width - 10, 1, 2, 1) then + local sizens = love.mouse.getSystemCursor("sizens") + if curcursor ~= sizens then + love.mouse.setCursor(sizens) + end + elseif loveframes.util.BoundingBox(hoverobject.x, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then + local sizewe = love.mouse.getSystemCursor("sizewe") + if curcursor ~= sizewe then + love.mouse.setCursor(sizewe) + end + elseif loveframes.util.BoundingBox(hoverobject.x + hoverobject.width - 2, mx, hoverobject.y + 5, my, 2, 1, hoverobject.height - 10, 1) then + local sizewe = love.mouse.getSystemCursor("sizewe") + if curcursor ~= sizewe then + love.mouse.setCursor(sizewe) + end + else + if not loveframes.resizeobject then + local arrow = love.mouse.getSystemCursor("arrow") + if curcursor ~= arrow then + love.mouse.setCursor(arrow) + end end end end + elseif hoverobject.type == "text" and hoverobject.linkcol and not loveframes.resizeobject then + local hand = love.mouse.getSystemCursor("hand") + if curcursor ~= hand then + love.mouse.setCursor(hand) + end end - elseif hoverobject.type == "text" and hoverobject.linkcol and not loveframes.resizeobject then - local hand = love.mouse.getSystemCursor("hand") - if curcursor ~= hand then - love.mouse.setCursor(hand) + if curcursor ~= arrow then + if hoverobject.type ~= "textinput" and hoverobject.type ~= "frame" and not hoverobject.linkcol and not loveframes.resizeobject then + love.mouse.setCursor(arrow) + elseif hoverobject.type ~= "textinput" and curcursor == ibeam then + love.mouse.setCursor(arrow) + end end - end - if curcursor ~= arrow then - if hoverobject.type ~= "textinput" and hoverobject.type ~= "frame" and not hoverobject.linkcol and not loveframes.resizeobject then - love.mouse.setCursor(arrow) - elseif hoverobject.type ~= "textinput" and curcursor == ibeam then + else + if curcursor ~= arrow and not loveframes.resizeobject then love.mouse.setCursor(arrow) end end - else - if curcursor ~= arrow and not loveframes.resizeobject then - love.mouse.setCursor(arrow) - end end loveframes.collisions = {} From 06fc817c85fca1c4d802583b3a1d3e805ba9b7bd Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 30 Oct 2014 19:46:18 -0400 Subject: [PATCH 2/4] Set ENABLE_SYSTEM_CURSORS to true --- New Text Document.txt | 9 +++++++++ init.lua | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 New Text Document.txt diff --git a/New Text Document.txt b/New Text Document.txt new file mode 100644 index 0000000..cced9a3 --- /dev/null +++ b/New Text Document.txt @@ -0,0 +1,9 @@ +elseif (love.keyboard.isDown("lctrl") or love.keyboard.isDown("rctrl")) and lines[line] ~= "" then + if multiline then + self:ClearLine(self.line) + self.indicatornum = 0 + indicatornum = self.indicatornum + else + self:Clear() + indicatornum = self.indicatornum + end \ No newline at end of file diff --git a/init.lua b/init.lua index f6635ea..79115f2 100644 --- a/init.lua +++ b/init.lua @@ -22,7 +22,7 @@ loveframes.config["DEFAULTSKIN"] = "Blue" loveframes.config["ACTIVESKIN"] = "Blue" loveframes.config["INDEXSKINIMAGES"] = true loveframes.config["DEBUG"] = false -loveframes.config["ENABLE_SYSTEM_CURSORS"] = false +loveframes.config["ENABLE_SYSTEM_CURSORS"] = true -- misc library vars loveframes.state = "none" From c3bd9936b5b4af8d485b73a16bdfe4f49eb573be Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Thu, 30 Oct 2014 19:56:52 -0400 Subject: [PATCH 3/4] This file wasn't meant to be in the previous commit --- New Text Document.txt | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 New Text Document.txt diff --git a/New Text Document.txt b/New Text Document.txt deleted file mode 100644 index cced9a3..0000000 --- a/New Text Document.txt +++ /dev/null @@ -1,9 +0,0 @@ -elseif (love.keyboard.isDown("lctrl") or love.keyboard.isDown("rctrl")) and lines[line] ~= "" then - if multiline then - self:ClearLine(self.line) - self.indicatornum = 0 - indicatornum = self.indicatornum - else - self:Clear() - indicatornum = self.indicatornum - end \ No newline at end of file From f93991b1ef49cf45d0cc374b8363f3695a579007 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Sat, 1 Nov 2014 14:27:21 -0400 Subject: [PATCH 4/4] Implement loveframes.dragobject --- init.lua | 1 + objects/frame.lua | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/init.lua b/init.lua index 79115f2..3f64ed5 100644 --- a/init.lua +++ b/init.lua @@ -34,6 +34,7 @@ loveframes.modalobject = false loveframes.inputobject = false loveframes.downobject = false loveframes.resizeobject = false +loveframes.dragobject = false loveframes.hover = false loveframes.input_cursor_set = false loveframes.prevcursor = nil diff --git a/objects/frame.lua b/objects/frame.lua index f4ff33f..a093ebc 100644 --- a/objects/frame.lua +++ b/objects/frame.lua @@ -506,12 +506,14 @@ function newobject:mousepressed(x, y, button) self.clicky = y - self.staticy end self.dragging = true + loveframes.dragobject = self end end if not self.resizing and self.canresize and loveframes.hoverobject == self then if loveframes.util.BoundingBox(self.x, x, self.y, y, 5, 1, 5, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "top_left" self.resizex = x self.resizey = y @@ -541,6 +543,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x + self.width - 5, x, self.y, y, 5, 1, 5, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "top_right" self.resizex = x self.resizey = y @@ -556,6 +559,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x, x, self.y + self.height - 5, y, 5, 1, 5, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "bottom_left" self.resizex = x self.resizey = y @@ -571,6 +575,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x + 5, x, self.y, y, self.width - 10, 1, 2, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "top" self.resizex = x self.resizey = y @@ -583,6 +588,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x + 5, x, self.y + self.height - 2, y, self.width - 10, 1, 2, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "bottom" self.resizex = x self.resizey = y @@ -595,6 +601,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x, x, self.y + 5, y, 2, 1, self.height - 10, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "left" self.resizex = x self.resizey = y @@ -607,6 +614,7 @@ function newobject:mousepressed(x, y, button) elseif loveframes.util.BoundingBox(self.x + self.width - 2, x, self.y + 5, y, 2, 1, self.height - 10, 1) then self.resizing = true self.dragging = false + loveframes.dragobject = false self.resize_mode = "right" self.resizex = x self.resizey = y @@ -656,6 +664,7 @@ function newobject:mousereleased(x, y, button) local internals = self.internals self.dragging = false + loveframes.dragobject = false if self.resizing then self.resizex = 0