From e41d70aa2721de7bea3d45803d70ac2ee6f42d90 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Sat, 12 May 2012 23:57:27 -0400 Subject: [PATCH] Version 0.9.1.2 - Alpha (see changelog.txt) --- changelog.txt | 14 +++++++++++ init.lua | 8 +++++-- objects/base.lua | 11 ++++++++- objects/button.lua | 13 ++++++++++ objects/checkbox.lua | 16 +++++++++++++ objects/collapsiblecategory.lua | 8 ++++++- objects/imagebutton.lua | 13 ++++++++++ objects/internal/closebutton.lua | 14 +++++++++++ .../internal/columnlist/coulmnlist-header.lua | 13 ++++++++++ .../internal/multichoice/multichoice-row.lua | 24 +++++++++++++++++-- objects/internal/scrollable/scrollbar.lua | 1 + objects/internal/scrollable/scrollbutton.lua | 13 ++++++++++ objects/internal/sliderbutton.lua | 14 +++++++++++ objects/internal/tabbutton.lua | 5 ++-- objects/list.lua | 22 +++++++++++++---- objects/multichoice.lua | 1 + objects/tabs.lua | 17 +++++++++++++ objects/textinput.lua | 8 +++++++ 18 files changed, 202 insertions(+), 13 deletions(-) diff --git a/changelog.txt b/changelog.txt index d42c992..8ba4787 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,17 @@ +================================================ +Version 0.9.1.2 - Alpha (May 12 - 2012) +================================================ +[ADDED] a system for preventing objects from being hovered over when another object is being pressed or is "down" +[ADDED] "down" property for the checkbox object +[ADDED] "down" property for the collapsible category object +[ADDED] a new method for the tabs object: SetToolTipFont(font) + +[FIXED] list:GetScrollBar() crashing when the list had no scroll bar +[FIXED] not being able to move the text input blinker to the front or end of the it's text by clicking on it's whitespace +[FIXED] the multichoice row object being "down" when mouse buttons other than the left mouse button were pressed + +[CHANGED] collapsible category opening and closing system (will now only open or close when "down") + ================================================ Version 0.9.1 - Alpha (May 8 - 2012) ================================================ diff --git a/init.lua b/init.lua index dece2bb..78ff562 100644 --- a/init.lua +++ b/init.lua @@ -9,7 +9,7 @@ loveframes = {} -- library info loveframes.info = {} loveframes.info.author = "Nikolai Resokav" -loveframes.info.version = "0.9.1" +loveframes.info.version = "0.9.1.2" loveframes.info.stage = "Alpha" -- library configurations @@ -20,8 +20,8 @@ loveframes.config["ACTIVESKIN"] = "Blue" loveframes.config["INDEXSKINIMAGES"] = true loveframes.config["DEBUG"] = true --- drawcount loveframes.drawcount = 0 +loveframes.hoverobject = false --[[--------------------------------------------------------- - func: load() @@ -115,6 +115,10 @@ function loveframes.mousereleased(x, y, button) object:mousereleased(x, y, button) + if button == "l" then + loveframes.hoverobject = false + end + end --[[--------------------------------------------------------- diff --git a/objects/base.lua b/objects/base.lua index 3f4f32a..1a09909 100644 --- a/objects/base.lua +++ b/objects/base.lua @@ -577,6 +577,7 @@ function base:CheckHover() local x, y = love.mouse.getPosition() local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height) + local hoverobject = loveframes.hoverobject -- is the mouse inside the object? if selfcol == true then @@ -584,7 +585,15 @@ function base:CheckHover() local top = self:IsTopCollision() if top == true then - self.hover = true + if hoverobject == false then + self.hover = true + else + if hoverobject == self then + self.hover = true + else + self.hover = false + end + end else self.hover = false end diff --git a/objects/button.lua b/objects/button.lua index 3a9f298..5953478 100644 --- a/objects/button.lua +++ b/objects/button.lua @@ -39,6 +39,18 @@ function button:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -97,6 +109,7 @@ function button:mousepressed(x, y, button) end self.down = true + loveframes.hoverobject = self end diff --git a/objects/checkbox.lua b/objects/checkbox.lua index bcf0cda..e634e1e 100644 --- a/objects/checkbox.lua +++ b/objects/checkbox.lua @@ -22,6 +22,7 @@ function checkbox:initialize() self.checked = false self.lastvalue = false self.internal = false + self.down = true self.internals = {} self.OnChanged = nil @@ -41,6 +42,18 @@ function checkbox:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -127,6 +140,9 @@ function checkbox:mousepressed(x, y, button) baseparent:MakeTop() end + self.down = true + loveframes.hoverobject = self + end end diff --git a/objects/collapsiblecategory.lua b/objects/collapsiblecategory.lua index a704e35..433fa00 100644 --- a/objects/collapsiblecategory.lua +++ b/objects/collapsiblecategory.lua @@ -21,6 +21,7 @@ function collapsiblecategory:initialize() self.padding = 5 self.internal = false self.open = false + self.down = false self.children = {} self.OnOpenedClosed = nil @@ -115,6 +116,9 @@ function collapsiblecategory:mousepressed(x, y, button) if baseparent and baseparent.type == "frame" then baseparent:MakeTop() end + + self.down = true + loveframes.hoverobject = self end @@ -147,7 +151,7 @@ function collapsiblecategory:mousereleased(x, y, button) local open = self.open local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1) - if hover == true and button == "l" and col == true then + if hover == true and button == "l" and col == true and self.down == true then if open == true then self:SetOpen(false) @@ -155,6 +159,8 @@ function collapsiblecategory:mousereleased(x, y, button) self:SetOpen(true) end + self.down = false + end if self.open == true then diff --git a/objects/imagebutton.lua b/objects/imagebutton.lua index fce2570..9bc29cc 100644 --- a/objects/imagebutton.lua +++ b/objects/imagebutton.lua @@ -40,6 +40,18 @@ function imagebutton:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -98,6 +110,7 @@ function imagebutton:mousepressed(x, y, imagebutton) end self.down = true + loveframes.hoverobject = self end diff --git a/objects/internal/closebutton.lua b/objects/internal/closebutton.lua index 26192e6..788d4b5 100644 --- a/objects/internal/closebutton.lua +++ b/objects/internal/closebutton.lua @@ -37,6 +37,18 @@ function closebutton:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -95,6 +107,8 @@ function closebutton:mousepressed(x, y, button) end self.down = true + loveframes.hoverobject = self + end end diff --git a/objects/internal/columnlist/coulmnlist-header.lua b/objects/internal/columnlist/coulmnlist-header.lua index d8a1a80..5167dff 100644 --- a/objects/internal/columnlist/coulmnlist-header.lua +++ b/objects/internal/columnlist/coulmnlist-header.lua @@ -60,6 +60,18 @@ function columnlistheader:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -114,6 +126,7 @@ function columnlistheader:mousepressed(x, y, button) end self.down = true + loveframes.hoverobject = self end diff --git a/objects/internal/multichoice/multichoice-row.lua b/objects/internal/multichoice/multichoice-row.lua index 0845eb7..bf01f91 100644 --- a/objects/internal/multichoice/multichoice-row.lua +++ b/objects/internal/multichoice/multichoice-row.lua @@ -21,7 +21,6 @@ function multichoicerow:initialize() self.internal = true self.down = false self.canclick = false - self.OnClick = nil end @@ -39,6 +38,18 @@ function multichoicerow:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -84,7 +95,12 @@ function multichoicerow:mousepressed(x, y, button) return end - self.down = true + if self.hover == true and button == "l" then + + self.down = true + loveframes.hoverobject = self + + end end @@ -107,6 +123,10 @@ function multichoicerow:mousereleased(x, y, button) end +--[[--------------------------------------------------------- + - func: SetText(text) + - desc: sets the object's text +--]]--------------------------------------------------------- function multichoicerow:SetText(text) self.text = text diff --git a/objects/internal/scrollable/scrollbar.lua b/objects/internal/scrollable/scrollbar.lua index c24a797..0cc62a0 100644 --- a/objects/internal/scrollable/scrollbar.lua +++ b/objects/internal/scrollable/scrollbar.lua @@ -218,6 +218,7 @@ function scrollbar:mousepressed(x, y, button) self.clickx = x self.clicky = y self.dragging = true + loveframes.hoverobject = self end diff --git a/objects/internal/scrollable/scrollbutton.lua b/objects/internal/scrollable/scrollbutton.lua index 662aebf..e08310d 100644 --- a/objects/internal/scrollable/scrollbutton.lua +++ b/objects/internal/scrollable/scrollbutton.lua @@ -37,6 +37,18 @@ function scrollbutton:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -96,6 +108,7 @@ function scrollbutton:mousepressed(x, y, scrollbutton) end self.down = true + loveframes.hoverobject = self end diff --git a/objects/internal/sliderbutton.lua b/objects/internal/sliderbutton.lua index 09978a0..89b2ff1 100644 --- a/objects/internal/sliderbutton.lua +++ b/objects/internal/sliderbutton.lua @@ -47,6 +47,18 @@ function sliderbutton:update(dt) self:CheckHover() + if self.hover == false then + self.down = false + elseif self.hover == true then + if loveframes.hoverobject == self then + self.down = true + end + end + + if self.down == false and loveframes.hoverobject == self then + self.hover = true + end + -- move to parent if there is a parent if self.parent ~= loveframes.base then self.x = self.parent.x + self.staticx @@ -131,6 +143,8 @@ function sliderbutton:mousepressed(x, y, button) self.dragging = true self.startx = self.staticx self.clickx = x + loveframes.hoverobject = self + end end diff --git a/objects/internal/tabbutton.lua b/objects/internal/tabbutton.lua index a5d02c1..5d65b4f 100644 --- a/objects/internal/tabbutton.lua +++ b/objects/internal/tabbutton.lua @@ -26,8 +26,8 @@ function tabbutton:initialize(parent, text, tabnumber, tip, image) self.image = nil if tip then - local tooltip = tooltip:new(self, tip) - tooltip:SetFollowCursor(false) + self.tooltip = tooltip:new(self, tip) + self.tooltip:SetFollowCursor(false) end if image then @@ -121,6 +121,7 @@ function tabbutton:mousepressed(x, y, button) end self.down = true + loveframes.hoverobject = self end diff --git a/objects/list.lua b/objects/list.lua index a6ff6c1..57f17ce 100644 --- a/objects/list.lua +++ b/objects/list.lua @@ -259,8 +259,9 @@ function list:CalculateSize() self.extra = self.itemheight - height if vbar == false then - table.insert(self.internals, scrollbody:new(self, display)) - self:GetScrollBar().autoscroll = self.autoscroll + local scrollbar = scrollbody:new(self, display) + scrollbar.autoscroll = self.autoscroll + table.insert(self.internals, scrollbar) self.vbar = true end @@ -287,8 +288,9 @@ function list:CalculateSize() self.extra = self.itemwidth - width if hbar == false then - table.insert(self.internals, scrollbody:new(self, display)) - self:GetScrollBar().autoscroll = self.autoscroll + local scrollbar = scrollbody:new(self, display) + scrollbar.autoscroll = self.autoscroll + table.insert(self.internals, scrollbar) self.hbar = true end @@ -501,7 +503,17 @@ end --]]--------------------------------------------------------- function list:GetScrollBar() - return self.internals[1].internals[1].internals[1] + if self.vbar == true or self.hbar == true then + + local scrollbar = self.internals[1].internals[1].internals[1] + + return scrollbar + + else + + return false + + end end diff --git a/objects/multichoice.lua b/objects/multichoice.lua index 00cd521..591809a 100644 --- a/objects/multichoice.lua +++ b/objects/multichoice.lua @@ -100,6 +100,7 @@ function multichoice:mousepressed(x, y, button) self.haslist = true self.list = multichoicelist:new(self) + loveframes.hoverobject = self end diff --git a/objects/tabs.lua b/objects/tabs.lua index 08d0aa8..7ebc52e 100644 --- a/objects/tabs.lua +++ b/objects/tabs.lua @@ -25,6 +25,7 @@ function tabs:initialize() self.tabheight = 25 self.autosize = true self.internal = false + self.tooltipfont = love.graphics.newFont(10) self.tabs = {} self.internals = {} self.children = {} @@ -404,4 +405,20 @@ function tabs:SetTabHeight(height) end +end + +--[[--------------------------------------------------------- + - func: SetToolTipFont(font) + - desc: sets the height of the tab buttons +--]]--------------------------------------------------------- +function tabs:SetToolTipFont(font) + + for k, v in ipairs(self.internals) do + + if v.type == "tabbutton" and v.tooltip then + v.tooltip:SetFont(font) + end + + end + end \ No newline at end of file diff --git a/objects/textinput.lua b/objects/textinput.lua index a142e14..39609a0 100644 --- a/objects/textinput.lua +++ b/objects/textinput.lua @@ -395,6 +395,14 @@ function textinput:GetTextCollisions(x, y) break end + if x < tx then + self:MoveBlinker(0, true) + end + + if x > (tx + width) then + self:MoveBlinker(#self.text, true) + end + end end