mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Added grid span feature, fixes
- Grid span feature - Added offset from parent to update each element (for correct positioning relative to each parent) - OnClick event rework - Multichoice: new function GetChoiceIndex - Added positioning of items in the grid using the align parameter in AddItem - Correct positioning of multichoice-arrow image - Fixed stencil test for list - Fixed a bug that can trigger OnClick events again, even if the mouse cursor is not already hovering over the object - Fixed a bug where "backspace" leads to an incorrect positioning of the entry if the text is overflowed 'textinput' element
This commit is contained in:
parent
ad3d8a5042
commit
edab2be4c7
@ -12,23 +12,42 @@ function example.func(loveframes, centerarea)
|
|||||||
grid:SetPos(5, 30)
|
grid:SetPos(5, 30)
|
||||||
grid:SetRows(5)
|
grid:SetRows(5)
|
||||||
grid:SetColumns(5)
|
grid:SetColumns(5)
|
||||||
grid:SetCellWidth(25)
|
grid:SetCellWidth(45)
|
||||||
grid:SetCellHeight(25)
|
grid:SetCellHeight(45)
|
||||||
grid:SetCellPadding(5)
|
grid:SetCellPadding(2)
|
||||||
grid:SetItemAutoSize(true)
|
grid:SetItemAutoSize(true)
|
||||||
|
|
||||||
local id = 1
|
grid:SetItemAutoSize(true)
|
||||||
|
|
||||||
for i=1, 5 do
|
grid:ColSpanAt(1, 1, 5)
|
||||||
for n=1, 5 do
|
grid:RowSpanAt(1, 1, 3)
|
||||||
|
|
||||||
|
grid:RowSpanAt(4, 1, 2)
|
||||||
|
grid:ColSpanAt(4, 1, 2)
|
||||||
|
|
||||||
|
grid:ColSpanAt(5, 3, 2)
|
||||||
|
|
||||||
|
local list = loveframes.Create('list')
|
||||||
|
grid:AddItem(list, 1, 1)
|
||||||
|
|
||||||
|
for i = 1, 10 do
|
||||||
local button = loveframes.Create("button")
|
local button = loveframes.Create("button")
|
||||||
button:SetSize(15, 15)
|
button:SetText(tostring(i))
|
||||||
button:SetText(id)
|
list:AddItem(button)
|
||||||
grid:AddItem(button, i, n)
|
|
||||||
id = id + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local button = loveframes.Create("button")
|
||||||
|
button:SetText('4, 1')
|
||||||
|
grid:AddItem(button, 4, 1, 'center')
|
||||||
|
|
||||||
|
local button = loveframes.Create("button")
|
||||||
|
button:SetText('5, 5')
|
||||||
|
grid:AddItem(button, 5, 5, 'left')
|
||||||
|
|
||||||
|
local button = loveframes.Create("button")
|
||||||
|
button:SetText(('5, 3'))
|
||||||
|
grid:AddItem(button, 5, 3, 'right')
|
||||||
|
|
||||||
grid.OnSizeChanged = function(object)
|
grid.OnSizeChanged = function(object)
|
||||||
frame:SetSize(object:GetWidth() + 10, object:GetHeight() + 35)
|
frame:SetSize(object:GetWidth() + 10, object:GetHeight() + 35)
|
||||||
frame:CenterWithinArea(unpack(centerarea))
|
frame:CenterWithinArea(unpack(centerarea))
|
||||||
|
@ -244,13 +244,10 @@ function loveframes.mousereleased(x, y, button)
|
|||||||
base:mousereleased(x, y, button)
|
base:mousereleased(x, y, button)
|
||||||
|
|
||||||
-- reset the hover object
|
-- reset the hover object
|
||||||
if button == 1 then
|
|
||||||
loveframes.downobject = false
|
loveframes.downobject = false
|
||||||
loveframes.selectedobject = false
|
loveframes.selectedobject = false
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: wheelmoved(x, y)
|
- func: wheelmoved(x, y)
|
||||||
- desc: called when the player moves a mouse wheel
|
- desc: called when the player moves a mouse wheel
|
||||||
|
@ -820,7 +820,7 @@ function newobject:CheckHover()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check if the object is being hovered
|
-- check if the object is being hovered
|
||||||
if hoverobject == self and type ~= "base" then
|
if selfcol and hoverobject == self and type ~= "base" then
|
||||||
self.hover = true
|
self.hover = true
|
||||||
else
|
else
|
||||||
self.hover = false
|
self.hover = false
|
||||||
@ -1066,11 +1066,27 @@ end
|
|||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: SetAlwaysUpdate(bool)
|
- func: SetAlwaysUpdate(bool)
|
||||||
- desc: sets the object's skin
|
- desc: sets the object will always update
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:SetAlwaysUpdate(bool)
|
function newobject:SetAlwaysUpdate(bool)
|
||||||
|
|
||||||
|
local children = self.children
|
||||||
|
local internals = self.internals
|
||||||
|
|
||||||
self.alwaysupdate = bool
|
self.alwaysupdate = bool
|
||||||
|
|
||||||
|
if children then
|
||||||
|
for k, v in ipairs(children) do
|
||||||
|
v:SetAlwaysUpdate(bool)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if internals then
|
||||||
|
for k, v in ipairs(internals) do
|
||||||
|
v:SetAlwaysUpdate(bool)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -26,8 +26,11 @@ function newobject:initialize()
|
|||||||
self.toggleable = false
|
self.toggleable = false
|
||||||
self.toggle = false
|
self.toggle = false
|
||||||
self.OnClick = nil
|
self.OnClick = nil
|
||||||
|
self.OnMouseOver = nil
|
||||||
|
self.OnMouseOut = nil
|
||||||
self.groupIndex = 0
|
self.groupIndex = 0
|
||||||
self.checked = false
|
self.checked = false
|
||||||
|
self.mouseover = false
|
||||||
|
|
||||||
self:SetDrawFunc()
|
self:SetDrawFunc()
|
||||||
end
|
end
|
||||||
@ -57,18 +60,27 @@ function newobject:update(dt)
|
|||||||
self:CheckHover()
|
self:CheckHover()
|
||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
local down = self.down
|
|
||||||
local downobject = loveframes.downobject
|
local downobject = loveframes.downobject
|
||||||
local parent = self.parent
|
local parent = self.parent
|
||||||
local base = loveframes.base
|
local base = loveframes.base
|
||||||
local update = self.Update
|
local update = self.Update
|
||||||
|
local onmouseover = self.OnMouseOver
|
||||||
|
local onmouseout = self.OnMouseOut
|
||||||
|
|
||||||
if not hover then
|
if not hover then
|
||||||
self.down = false
|
self.down = false
|
||||||
if downobject == self then
|
if downobject == self then
|
||||||
self.hover = true
|
self.hover = true
|
||||||
end
|
end
|
||||||
|
if onmouseout and self.mouseover then
|
||||||
|
onmouseout(self)
|
||||||
|
self.mouseover = false
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
if onmouseover and not self.mouseover then
|
||||||
|
onmouseover(self)
|
||||||
|
self.mouseover = true
|
||||||
|
end
|
||||||
if downobject == self then
|
if downobject == self then
|
||||||
self.down = true
|
self.down = true
|
||||||
end
|
end
|
||||||
@ -76,8 +88,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
@ -107,7 +119,7 @@ function newobject:mousepressed(x, y, button)
|
|||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
|
|
||||||
if hover and button == 1 then
|
if hover then
|
||||||
local baseparent = self:GetBaseParent()
|
local baseparent = self:GetBaseParent()
|
||||||
if baseparent and baseparent.type == "frame" then
|
if baseparent and baseparent.type == "frame" then
|
||||||
baseparent:MakeTop()
|
baseparent:MakeTop()
|
||||||
@ -116,6 +128,7 @@ function newobject:mousepressed(x, y, button)
|
|||||||
loveframes.downobject = self
|
loveframes.downobject = self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.pressed_button = button
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -143,7 +156,7 @@ function newobject:mousereleased(x, y, button)
|
|||||||
local enabled = self.enabled
|
local enabled = self.enabled
|
||||||
local onclick = self.OnClick
|
local onclick = self.OnClick
|
||||||
|
|
||||||
if hover and down and clickable and button == 1 then
|
if hover and down and clickable and self.pressed_button == button then
|
||||||
if enabled then
|
if enabled then
|
||||||
if self.groupIndex ~= 0 then
|
if self.groupIndex ~= 0 then
|
||||||
local baseparent = self.parent
|
local baseparent = self.parent
|
||||||
@ -159,7 +172,7 @@ function newobject:mousereleased(x, y, button)
|
|||||||
self.checked = true
|
self.checked = true
|
||||||
end
|
end
|
||||||
if onclick then
|
if onclick then
|
||||||
onclick(self, x, y)
|
onclick(self, x, y, self.pressed_button)
|
||||||
end
|
end
|
||||||
if self.toggleable then
|
if self.toggleable then
|
||||||
local ontoggle = self.OnToggle
|
local ontoggle = self.OnToggle
|
||||||
|
@ -15,8 +15,8 @@ local newobject = loveframes.NewObject("checkbox", "loveframes_object_checkbox",
|
|||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:initialize()
|
function newobject:initialize()
|
||||||
self.type = "checkbox"
|
self.type = "checkbox"
|
||||||
self.width = 0
|
self.width = 16
|
||||||
self.height = 0
|
self.height = 16
|
||||||
self.boxwidth = 16
|
self.boxwidth = 16
|
||||||
self.boxheight = 16
|
self.boxheight = 16
|
||||||
self.font = loveframes.basicfont
|
self.font = loveframes.basicfont
|
||||||
|
@ -62,9 +62,9 @@ function newobject:update(dt)
|
|||||||
self:CheckHover()
|
self:CheckHover()
|
||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base and parent.type ~= "list" then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if open and curobject then
|
if open and curobject then
|
||||||
|
@ -75,8 +75,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
@ -482,7 +482,7 @@ end
|
|||||||
- func: GetMouseWheelScrollAmount()
|
- func: GetMouseWheelScrollAmount()
|
||||||
- desc: gets the scroll amount of the mouse wheel
|
- desc: gets the scroll amount of the mouse wheel
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetMouseWheelScrollAmount()
|
||||||
|
|
||||||
return self.mousewheelscrollamount
|
return self.mousewheelscrollamount
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ local newobject = loveframes.NewObject("grid", "loveframes_object_grid", true)
|
|||||||
- desc: initializes the object
|
- desc: initializes the object
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:initialize()
|
function newobject:initialize()
|
||||||
|
|
||||||
self.type = "grid"
|
self.type = "grid"
|
||||||
self.width = 100
|
self.width = 100
|
||||||
self.height = 100
|
self.height = 100
|
||||||
@ -28,6 +27,8 @@ function newobject:initialize()
|
|||||||
self.itemautosize = false
|
self.itemautosize = false
|
||||||
self.children = {}
|
self.children = {}
|
||||||
self.OnSizeChanged = nil
|
self.OnSizeChanged = nil
|
||||||
|
self.rowspans = {}
|
||||||
|
self.colspans = {}
|
||||||
|
|
||||||
self:SetDrawFunc()
|
self:SetDrawFunc()
|
||||||
end
|
end
|
||||||
@ -62,12 +63,10 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
local cw = self.cellwidth + (self.cellpadding * 2)
|
|
||||||
local ch = self.cellheight + (self.cellpadding * 2)
|
|
||||||
local prevwidth = self.prevwidth
|
local prevwidth = self.prevwidth
|
||||||
local prevheight = self.prevheight
|
local prevheight = self.prevheight
|
||||||
|
|
||||||
@ -78,16 +77,13 @@ function newobject:update(dt)
|
|||||||
local onsizechanged = self.OnSizeChanged
|
local onsizechanged = self.OnSizeChanged
|
||||||
self.prevwidth = self.width
|
self.prevwidth = self.width
|
||||||
self.prevheight = self.height
|
self.prevheight = self.height
|
||||||
|
self:_update_children_position()
|
||||||
if onsizechanged then
|
if onsizechanged then
|
||||||
onsizechanged(self)
|
onsizechanged(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
local x = 0 + ((cw * v.gridcolumn) - cw ) + (cw/2 - v.width/2)
|
|
||||||
local y = 0 + ((ch * v.gridrow) - ch) + (ch/2 - v.height/2)
|
|
||||||
v.staticx = x
|
|
||||||
v.staticy = y
|
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,6 +92,34 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function newobject:_update_children_position()
|
||||||
|
for k, v in ipairs(self.children) do
|
||||||
|
local rs, cs = self:GetCellSpanSize(v.gridrow, v.gridcolumn)
|
||||||
|
local csw = cs * self.cellwidth + (cs * self.cellpadding * 2)
|
||||||
|
local csh = rs * self.cellheight + (rs * self.cellpadding * 2)
|
||||||
|
|
||||||
|
local cw = self.cellwidth + (self.cellpadding * 2)
|
||||||
|
local ch = self.cellheight + (self.cellpadding * 2)
|
||||||
|
|
||||||
|
local x
|
||||||
|
local y = ((ch * v.gridrow) - ch) + (csh/2 - v.height/2)
|
||||||
|
|
||||||
|
if
|
||||||
|
v.align == 'center' then
|
||||||
|
x = (cw * (v.gridcolumn - 1)) + (csw/2 - v.width/2)
|
||||||
|
elseif
|
||||||
|
v.align == 'right' then
|
||||||
|
x = (cw * (v.gridcolumn - 1)) + (csw - v.width) - self.cellpadding
|
||||||
|
elseif
|
||||||
|
v.align == 'left' then
|
||||||
|
x = self.cellpadding + (cw * (v.gridcolumn - 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
v.staticx = x
|
||||||
|
v.staticy = y
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: mousepressed(x, y, button)
|
- func: mousepressed(x, y, button)
|
||||||
- desc: called when the player presses a mouse button
|
- desc: called when the player presses a mouse button
|
||||||
@ -157,11 +181,77 @@ function newobject:mousereleased(x, y, button)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: RowSpanAt(row, col, size)
|
||||||
|
- desc: expands the size of the row at position
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:RowSpanAt(row, col, size)
|
||||||
|
|
||||||
|
self.colspans[col] = self.colspans[col] or {}
|
||||||
|
local colsize = self.colspans[col][row]
|
||||||
|
local s = colsize or 1
|
||||||
|
|
||||||
|
for i = col, col + s - 1 do
|
||||||
|
for j = row, row + size - 1 do
|
||||||
|
self.rowspans[i] = self.rowspans[i] or {}
|
||||||
|
self.colspans[i] = self.colspans[i] or {}
|
||||||
|
|
||||||
|
self.rowspans[i][j] = -1
|
||||||
|
self.colspans[i][j] = -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.rowspans[col][row] = size
|
||||||
|
self.colspans[col][row] = colsize
|
||||||
|
return self
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: ColSpanAt(row, col, size)
|
||||||
|
- desc: expands the size of the column at position
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:ColSpanAt(row, col, size)
|
||||||
|
|
||||||
|
self.rowspans[col] = self.rowspans[col] or {}
|
||||||
|
local rowsize = self.rowspans[col][row]
|
||||||
|
local s = rowsize or 1
|
||||||
|
|
||||||
|
for i = col, col + size - 1 do
|
||||||
|
for j = row, row + s - 1 do
|
||||||
|
self.rowspans[i] = self.rowspans[i] or {}
|
||||||
|
self.colspans[i] = self.colspans[i] or {}
|
||||||
|
|
||||||
|
self.rowspans[i][j] = -1
|
||||||
|
self.colspans[i][j] = -1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.rowspans[col][row] = rowsize
|
||||||
|
self.colspans[col][row] = size
|
||||||
|
return self
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: GetCellSpanSize(row, col, size)
|
||||||
|
- desc: get span size of cell
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:GetCellSpanSize(row, col)
|
||||||
|
|
||||||
|
self.rowspans[col] = self.rowspans[col] or {}
|
||||||
|
local rs = self.rowspans[col][row] or 1
|
||||||
|
self.colspans[col] = self.colspans[col] or {}
|
||||||
|
local cs = self.colspans[col][row] or 1
|
||||||
|
return rs, cs
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: AddItem(object, row, column)
|
- func: AddItem(object, row, column)
|
||||||
- desc: adds and item to the object
|
- desc: adds and item to the object
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:AddItem(object, row, column)
|
function newobject:AddItem(object, row, col, align)
|
||||||
|
|
||||||
local itemautosize = self.itemautosize
|
local itemautosize = self.itemautosize
|
||||||
local children = self.children
|
local children = self.children
|
||||||
@ -171,13 +261,21 @@ function newobject:AddItem(object, row, column)
|
|||||||
table.insert(children, object)
|
table.insert(children, object)
|
||||||
object.parent = self
|
object.parent = self
|
||||||
object.gridrow = row
|
object.gridrow = row
|
||||||
object.gridcolumn = column
|
object.gridcolumn = col
|
||||||
|
object.align = align or 'center'
|
||||||
|
|
||||||
if itemautosize then
|
if itemautosize then
|
||||||
local cw = self.cellwidth + (self.cellpadding * 2)
|
if object.type == 'text' or object.type == 'checkbox' then
|
||||||
local ch = self.cellheight + (self.cellpadding * 2)
|
return self
|
||||||
|
end
|
||||||
|
local rs, cs = self:GetCellSpanSize(row, col)
|
||||||
|
local cw = cs * self.cellwidth + (self.cellpadding * 2)
|
||||||
|
local ch = rs * self.cellheight + (self.cellpadding * 2)
|
||||||
object.width = cw - (self.cellpadding * 2)
|
object.width = cw - (self.cellpadding * 2)
|
||||||
object.height = ch - (self.cellpadding * 2)
|
object.height = ch - (self.cellpadding * 2)
|
||||||
|
|
||||||
|
if object.CalculateSize then object:CalculateSize() end
|
||||||
|
if object.RedoLayout then object:RedoLayout() end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
@ -62,8 +62,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
|
@ -77,8 +77,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
|
@ -263,7 +263,7 @@ function newobject:CalculateSize()
|
|||||||
end
|
end
|
||||||
self.extraheight = self.itemheight - height
|
self.extraheight = self.itemheight - height
|
||||||
if not self.vbar then
|
if not self.vbar then
|
||||||
local newbar = loveframes.objects["scrollbody"]:new(self, "vertical")
|
local newbar = loveframes.objects["scrollbody"]:new(self, "vertical", true)
|
||||||
table.insert(self.internals, newbar)
|
table.insert(self.internals, newbar)
|
||||||
self.vbar = true
|
self.vbar = true
|
||||||
newbar:GetScrollBar().autoscroll = parent.autoscroll
|
newbar:GetScrollBar().autoscroll = parent.autoscroll
|
||||||
@ -290,7 +290,7 @@ function newobject:CalculateSize()
|
|||||||
end
|
end
|
||||||
self.extrawidth = self.itemwidth - width
|
self.extrawidth = self.itemwidth - width
|
||||||
if not self.hbar then
|
if not self.hbar then
|
||||||
local newbar = loveframes.objects["scrollbody"]:new(self, "horizontal")
|
local newbar = loveframes.objects["scrollbody"]:new(self, "horizontal", true)
|
||||||
table.insert(self.internals, newbar)
|
table.insert(self.internals, newbar)
|
||||||
self.hbar = true
|
self.hbar = true
|
||||||
self.itemheight = self.itemheight + newbar.height
|
self.itemheight = self.itemheight + newbar.height
|
||||||
|
@ -55,8 +55,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if parentinternals[1] ~= self then
|
if parentinternals[1] ~= self then
|
||||||
|
@ -53,9 +53,10 @@ function newobject:update(dt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:CheckHover()
|
|
||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
|
self:CheckHover()
|
||||||
|
|
||||||
local parent = self.parent
|
local parent = self.parent
|
||||||
local option_type = self.option_type
|
local option_type = self.option_type
|
||||||
local activated = self.activated
|
local activated = self.activated
|
||||||
@ -96,8 +97,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
@ -125,6 +126,7 @@ function newobject:mousepressed(x, y, button)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.down = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -148,7 +150,7 @@ function newobject:mousereleased(x, y, button)
|
|||||||
|
|
||||||
local hover = self.hover
|
local hover = self.hover
|
||||||
local option_type = self.option_type
|
local option_type = self.option_type
|
||||||
if hover and option_type ~= "divider" and button == 1 then
|
if hover and option_type ~= "divider" and button == 1 and self.down then
|
||||||
local func = self.func
|
local func = self.func
|
||||||
if func then
|
if func then
|
||||||
local text = self.text
|
local text = self.text
|
||||||
@ -156,8 +158,9 @@ function newobject:mousereleased(x, y, button)
|
|||||||
end
|
end
|
||||||
local basemenu = self.parent:GetBaseMenu()
|
local basemenu = self.parent:GetBaseMenu()
|
||||||
basemenu:SetVisible(false)
|
basemenu:SetVisible(false)
|
||||||
|
self.hover = false
|
||||||
end
|
end
|
||||||
|
self.down = false
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
|
@ -341,7 +341,7 @@ function newobject:CalculateSize()
|
|||||||
if self.itemheight > height then
|
if self.itemheight > height then
|
||||||
self.extraheight = self.itemheight - height
|
self.extraheight = self.itemheight - height
|
||||||
if not vbar then
|
if not vbar then
|
||||||
local scroll = loveframes.objects["scrollbody"]:new(self, "vertical")
|
local scroll = loveframes.objects["scrollbody"]:new(self, "vertical", true)
|
||||||
table.insert(self.internals, scroll)
|
table.insert(self.internals, scroll)
|
||||||
self.vbar = true
|
self.vbar = true
|
||||||
end
|
end
|
||||||
|
@ -125,8 +125,9 @@ function newobject:initialize(parent, bartype)
|
|||||||
-- apply template properties to the object
|
-- apply template properties to the object
|
||||||
loveframes.ApplyTemplatesToObject(self)
|
loveframes.ApplyTemplatesToObject(self)
|
||||||
self:SetDrawFunc()
|
self:SetDrawFunc()
|
||||||
end
|
|
||||||
|
|
||||||
|
self:SetAlwaysUpdate(true)
|
||||||
|
end
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: update(deltatime)
|
- func: update(deltatime)
|
||||||
- desc: updates the object
|
- desc: updates the object
|
||||||
|
@ -145,10 +145,12 @@ function newobject:mousepressed(x, y, button)
|
|||||||
|
|
||||||
if self.hover and button == 1 then
|
if self.hover and button == 1 then
|
||||||
local time = os.time()
|
local time = os.time()
|
||||||
if self.lastclick + 0.40 > time then
|
if self.lastclick + 0.30 > time then
|
||||||
self.open = not self.open
|
self.open = not self.open
|
||||||
end
|
self.lastclick = 0
|
||||||
|
else
|
||||||
self.lastclick = time
|
self.lastclick = time
|
||||||
|
end
|
||||||
local onselectnode = self.tree.OnSelectNode
|
local onselectnode = self.tree.OnSelectNode
|
||||||
self.tree.selectednode = self
|
self.tree.selectednode = self
|
||||||
if onselectnode then
|
if onselectnode then
|
||||||
@ -181,6 +183,16 @@ function newobject:mousereleased(x, y, button)
|
|||||||
v:mousereleased(x, y, button)
|
v:mousereleased(x, y, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.hover then
|
||||||
|
if button == 2 then
|
||||||
|
local onselectnoderightclick = self.tree.OnSelectNodeRightClick
|
||||||
|
self.tree.selectednode = self
|
||||||
|
if onselectnoderightclick then
|
||||||
|
onselectnoderightclick(self.parent, self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
@ -271,6 +283,13 @@ function newobject:RemoveNode(id)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function newobject:SetSelected()
|
||||||
|
|
||||||
|
self.tree.selectednode = self
|
||||||
|
return self
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: SetOpen(bool)
|
- func: SetOpen(bool)
|
||||||
- desc: sets whether or not the object is open
|
- desc: sets whether or not the object is open
|
||||||
|
@ -53,8 +53,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
|
@ -39,6 +39,9 @@ function newobject:initialize()
|
|||||||
self.children = {}
|
self.children = {}
|
||||||
self.OnScroll = nil
|
self.OnScroll = nil
|
||||||
|
|
||||||
|
self.scrollx = loveframes.objects["scrollbody"]:new(self, "horizontal")
|
||||||
|
self.scrolly = loveframes.objects["scrollbody"]:new(self, "vertical")
|
||||||
|
|
||||||
self:SetDrawFunc()
|
self:SetDrawFunc()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,34 +79,35 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(internals) do
|
for k, v in ipairs(internals) do
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
for _, p in pairs(self:GetParents()) do
|
--[[for _, p in pairs(self:GetParents()) do
|
||||||
v.x = v.x - (p.offsetx or 0)
|
v.x = v.x - (p.offsetx or 0)
|
||||||
v.y = v.y - (p.offsety or 0)
|
v.y = v.y - (p.offsety or 0)
|
||||||
end
|
end]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local x = self.x
|
local x = self.x
|
||||||
local y = self.y
|
local y = self.y
|
||||||
local width = self.width
|
|
||||||
local height = self.height
|
|
||||||
local offsetx = self.offsetx
|
local offsetx = self.offsetx
|
||||||
local offsety = self.offsety
|
local offsety = self.offsety
|
||||||
|
local width = self.width
|
||||||
|
local height = self.height
|
||||||
|
|
||||||
for k, v in ipairs(children) do
|
for k, v in ipairs(children) do
|
||||||
v:update(dt)
|
v:update(dt)
|
||||||
v:SetClickBounds(x, y, width, height)
|
v:SetClickBounds(x, y, width, height)
|
||||||
v.x = (v.parent.x + v.staticx) - offsetx
|
--v.x = (v.parent.x + v.staticx) - offsetx
|
||||||
v.y = (v.parent.y + v.staticy) - offsety
|
--v.y = (v.parent.y + v.staticy) - offsety
|
||||||
for _, p in pairs(self:GetParents()) do
|
|
||||||
|
--[[for _, p in pairs(self:GetParents()) do
|
||||||
v.x = v.x - (p.offsetx or 0)
|
v.x = v.x - (p.offsetx or 0)
|
||||||
v.y = v.y - (p.offsety or 0)
|
v.y = v.y - (p.offsety or 0)
|
||||||
end
|
end]]
|
||||||
if display == "vertical" then
|
if display == "vertical" then
|
||||||
if v.lastheight ~= v.height then
|
if v.lastheight ~= v.height then
|
||||||
self:CalculateSize()
|
self:CalculateSize()
|
||||||
@ -135,9 +139,6 @@ function newobject:draw()
|
|||||||
local y = self.y
|
local y = self.y
|
||||||
local width = self.width
|
local width = self.width
|
||||||
local height = self.height
|
local height = self.height
|
||||||
local stencilfunc = function()
|
|
||||||
love.graphics.rectangle("fill", x, y, width, height)
|
|
||||||
end
|
|
||||||
|
|
||||||
self:SetDrawOrder()
|
self:SetDrawOrder()
|
||||||
|
|
||||||
@ -145,9 +146,9 @@ function newobject:draw()
|
|||||||
if drawfunc then
|
if drawfunc then
|
||||||
drawfunc(self)
|
drawfunc(self)
|
||||||
end
|
end
|
||||||
|
local scx, scy, scw, sch = love.graphics.getScissor()
|
||||||
|
|
||||||
love.graphics.stencil(stencilfunc)
|
love.graphics.intersectScissor(x, y, width, height)
|
||||||
love.graphics.setStencilTest("greater", 0)
|
|
||||||
|
|
||||||
local children = self.children
|
local children = self.children
|
||||||
if children then
|
if children then
|
||||||
@ -159,7 +160,7 @@ function newobject:draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setStencilTest()
|
love.graphics.setScissor(scx, scy, scw, sch)
|
||||||
|
|
||||||
local drawfunc = self.DrawOver or self.drawoverfunc
|
local drawfunc = self.DrawOver or self.drawoverfunc
|
||||||
if drawfunc then
|
if drawfunc then
|
||||||
@ -348,15 +349,16 @@ function newobject:CalculateSize()
|
|||||||
if itemheight > height then
|
if itemheight > height then
|
||||||
self.extraheight = itemheight - height
|
self.extraheight = itemheight - height
|
||||||
if not vbar then
|
if not vbar then
|
||||||
local scrollbar = loveframes.objects["scrollbody"]:new(self, display)
|
table.insert(internals, self.scrolly)
|
||||||
table.insert(internals, scrollbar)
|
|
||||||
self.vbar = true
|
self.vbar = true
|
||||||
self:GetScrollBar().autoscroll = self.autoscroll
|
local bar = self:GetScrollBar()
|
||||||
|
bar.autoscroll = self.autoscroll
|
||||||
|
bar:ScrollTo(0)
|
||||||
|
self.scrolly:update(0)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if vbar then
|
if vbar then
|
||||||
local bar = internals[1]
|
self.scrolly:Remove()
|
||||||
bar:Remove()
|
|
||||||
self.vbar = false
|
self.vbar = false
|
||||||
self.offsety = 0
|
self.offsety = 0
|
||||||
end
|
end
|
||||||
@ -416,13 +418,13 @@ function newobject:RedoLayout()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #children > 0 then
|
if #children > 0 then
|
||||||
|
local scrollbar = self:GetScrollBar()
|
||||||
if display == "vertical" then
|
if display == "vertical" then
|
||||||
if horizontalstacking then
|
if horizontalstacking then
|
||||||
local curwidth = padding
|
local curwidth = padding
|
||||||
local curheight = padding
|
local curheight = padding
|
||||||
local maxwidth = self.width - padding * 2
|
local maxwidth = self.width - padding * 2
|
||||||
local prevheight = 0
|
local prevheight = 0
|
||||||
local scrollbar = self:GetScrollBar()
|
|
||||||
if scrollbar then
|
if scrollbar then
|
||||||
maxwidth = maxwidth - scrollbar.width
|
maxwidth = maxwidth - scrollbar.width
|
||||||
end
|
end
|
||||||
@ -451,7 +453,7 @@ function newobject:RedoLayout()
|
|||||||
v.staticx = padding
|
v.staticx = padding
|
||||||
v.staticy = starty
|
v.staticy = starty
|
||||||
v.lastheight = itemheight
|
v.lastheight = itemheight
|
||||||
if vbar then
|
if vbar and scrollbar.visible then
|
||||||
if itemwidth + padding > (width - scrollbodywidth) then
|
if itemwidth + padding > (width - scrollbodywidth) then
|
||||||
v:SetWidth((width - scrollbodywidth) - (padding * 2))
|
v:SetWidth((width - scrollbodywidth) - (padding * 2))
|
||||||
end
|
end
|
||||||
@ -476,7 +478,7 @@ function newobject:RedoLayout()
|
|||||||
local retainsize = v.retainsize
|
local retainsize = v.retainsize
|
||||||
v.staticx = startx
|
v.staticx = startx
|
||||||
v.staticy = padding
|
v.staticy = padding
|
||||||
if hbar then
|
if hbar and scrollbar.visible then
|
||||||
if itemheight + padding > (height - scrollbodyheight) then
|
if itemheight + padding > (height - scrollbodyheight) then
|
||||||
v:SetHeight((height - scrollbodyheight) - (padding * 2))
|
v:SetHeight((height - scrollbodyheight) - (padding * 2))
|
||||||
end
|
end
|
||||||
@ -743,7 +745,7 @@ end
|
|||||||
- func: GetMouseWheelScrollAmount()
|
- func: GetMouseWheelScrollAmount()
|
||||||
- desc: gets the scroll amount of the mouse wheel
|
- desc: gets the scroll amount of the mouse wheel
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetMouseWheelScrollAmount()
|
||||||
|
|
||||||
return self.mousewheelscrollamount
|
return self.mousewheelscrollamount
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in ipairs(self.internals) do
|
for k, v in ipairs(self.internals) do
|
||||||
@ -120,7 +120,6 @@ end
|
|||||||
- desc: called when the player presses a mouse button
|
- desc: called when the player presses a mouse button
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:mousepressed(x, y, button)
|
function newobject:mousepressed(x, y, button)
|
||||||
|
|
||||||
local state = loveframes.state
|
local state = loveframes.state
|
||||||
local selfstate = self.state
|
local selfstate = self.state
|
||||||
|
|
||||||
@ -134,6 +133,10 @@ function newobject:mousepressed(x, y, button)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local internals = self.internals
|
||||||
|
for k, v in ipairs(internals) do
|
||||||
|
v:mousepressed(x, y, button)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
|
@ -65,8 +65,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
@ -251,6 +251,21 @@ function newobject:GetChoice()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[---------------------------------------------------------
|
||||||
|
- func: GetChoiceIndex()
|
||||||
|
- desc: gets the current choice index
|
||||||
|
--]]---------------------------------------------------------
|
||||||
|
function newobject:GetChoiceIndex()
|
||||||
|
|
||||||
|
local choices = self.choices
|
||||||
|
for i, v in ipairs(choices) do
|
||||||
|
if self.choice == v then
|
||||||
|
return i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--[[---------------------------------------------------------
|
--[[---------------------------------------------------------
|
||||||
- func: SetText(text)
|
- func: SetText(text)
|
||||||
- desc: sets the object's text
|
- desc: sets the object's text
|
||||||
@ -310,7 +325,7 @@ end
|
|||||||
- func: GetMouseWheelScrollAmount()
|
- func: GetMouseWheelScrollAmount()
|
||||||
- desc: gets the scroll amount of the mouse wheel
|
- desc: gets the scroll amount of the mouse wheel
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetMouseWheelScrollAmount()
|
||||||
|
|
||||||
return self.mousewheelscrollamount
|
return self.mousewheelscrollamount
|
||||||
|
|
||||||
|
@ -109,8 +109,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- completion check
|
-- completion check
|
||||||
|
@ -80,8 +80,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
self:CheckHover()
|
self:CheckHover()
|
||||||
@ -642,7 +642,7 @@ end
|
|||||||
- func: GetMouseWheelScrollAmount()
|
- func: GetMouseWheelScrollAmount()
|
||||||
- desc: gets the scroll amount of the mouse wheel
|
- desc: gets the scroll amount of the mouse wheel
|
||||||
--]]---------------------------------------------------------
|
--]]---------------------------------------------------------
|
||||||
function newobject:GetButtonScrollAmount()
|
function newobject:GetMouseWheelScrollAmount()
|
||||||
|
|
||||||
return self.mousewheelscrollamount
|
return self.mousewheelscrollamount
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
if update then
|
if update then
|
||||||
|
@ -183,7 +183,7 @@ function newobject:update(dt)
|
|||||||
local itemheight = self.itemheight
|
local itemheight = self.itemheight
|
||||||
if itemheight > height then
|
if itemheight > height then
|
||||||
if not vbar then
|
if not vbar then
|
||||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "vertical")
|
local scrollbody = loveframes.objects["scrollbody"]:new(self, "vertical", true)
|
||||||
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
||||||
table.insert(self.internals, scrollbody)
|
table.insert(self.internals, scrollbody)
|
||||||
self.vbar = true
|
self.vbar = true
|
||||||
@ -211,7 +211,7 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
if itemwidth > width then
|
if itemwidth > width then
|
||||||
if not hbar then
|
if not hbar then
|
||||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "horizontal")
|
local scrollbody = loveframes.objects["scrollbody"]:new(self, "horizontal", true)
|
||||||
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
scrollbody.internals[1].internals[1].autoscroll = self.autoscroll
|
||||||
table.insert(self.internals, scrollbody)
|
table.insert(self.internals, scrollbody)
|
||||||
self.hbar = true
|
self.hbar = true
|
||||||
@ -567,7 +567,6 @@ function newobject:RunKey(key, istext)
|
|||||||
local numlines = #lines
|
local numlines = #lines
|
||||||
local curline = lines[line]
|
local curline = lines[line]
|
||||||
local text = curline
|
local text = curline
|
||||||
local ckey = ""
|
|
||||||
local font = self.font
|
local font = self.font
|
||||||
local swidth = self.width
|
local swidth = self.width
|
||||||
local textoffsetx = self.textoffsetx
|
local textoffsetx = self.textoffsetx
|
||||||
@ -663,14 +662,14 @@ function newobject:RunKey(key, istext)
|
|||||||
|
|
||||||
-- key input checking system
|
-- key input checking system
|
||||||
if key == "backspace" then
|
if key == "backspace" then
|
||||||
ckey = key
|
|
||||||
if alltextselected then
|
if alltextselected then
|
||||||
self:Clear()
|
self:Clear()
|
||||||
self.alltextselected = false
|
self.alltextselected = false
|
||||||
indicatornum = self.indicatornum
|
indicatornum = self.indicatornum
|
||||||
else
|
else
|
||||||
|
local removed_text = ''
|
||||||
if text ~= "" and indicatornum ~= 0 then
|
if text ~= "" and indicatornum ~= 0 then
|
||||||
text = self:RemoveFromText(indicatornum)
|
text, removed_text = self:RemoveFromText(indicatornum)
|
||||||
self:MoveIndicator(-1)
|
self:MoveIndicator(-1)
|
||||||
lines[line] = text
|
lines[line] = text
|
||||||
end
|
end
|
||||||
@ -693,9 +692,9 @@ function newobject:RunKey(key, istext)
|
|||||||
local cwidth = 0
|
local cwidth = 0
|
||||||
if masked then
|
if masked then
|
||||||
local maskchar = self.maskchar
|
local maskchar = self.maskchar
|
||||||
cwidth = font:getWidth(loveframes.utf8.gsub(text, ".", maskchar))
|
cwidth = font:getWidth(loveframes.utf8.gsub(removed_text, ".", maskchar))
|
||||||
else
|
else
|
||||||
cwidth = font:getWidth(text)
|
cwidth = font:getWidth(removed_text)
|
||||||
end
|
end
|
||||||
if self.offsetx > 0 then
|
if self.offsetx > 0 then
|
||||||
self.offsetx = self.offsetx - cwidth
|
self.offsetx = self.offsetx - cwidth
|
||||||
@ -707,7 +706,6 @@ function newobject:RunKey(key, istext)
|
|||||||
if not editable then
|
if not editable then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ckey = key
|
|
||||||
if alltextselected then
|
if alltextselected then
|
||||||
self:Clear()
|
self:Clear()
|
||||||
self.alltextselected = false
|
self.alltextselected = false
|
||||||
@ -727,7 +725,6 @@ function newobject:RunKey(key, istext)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif key == "return" or key == "kpenter" then
|
elseif key == "return" or key == "kpenter" then
|
||||||
ckey = key
|
|
||||||
-- call onenter if it exists
|
-- call onenter if it exists
|
||||||
if onenter then
|
if onenter then
|
||||||
onenter(self, text)
|
onenter(self, text)
|
||||||
@ -765,7 +762,6 @@ function newobject:RunKey(key, istext)
|
|||||||
if alltextselected then
|
if alltextselected then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
ckey = key
|
|
||||||
self.lines[self.line] = self:AddIntoText(self.tabreplacement, self.indicatornum)
|
self.lines[self.line] = self:AddIntoText(self.tabreplacement, self.indicatornum)
|
||||||
self:MoveIndicator(loveframes.utf8.len(self.tabreplacement))
|
self:MoveIndicator(loveframes.utf8.len(self.tabreplacement))
|
||||||
end
|
end
|
||||||
@ -1031,9 +1027,10 @@ function newobject:RemoveFromText(p)
|
|||||||
local curline = lines[line]
|
local curline = lines[line]
|
||||||
local text = curline
|
local text = curline
|
||||||
local part1 = loveframes.utf8.sub(text, 1, p - 1)
|
local part1 = loveframes.utf8.sub(text, 1, p - 1)
|
||||||
|
local removed_part = loveframes.utf8.sub(text, p, p + 1)
|
||||||
local part2 = loveframes.utf8.sub(text, p + 1)
|
local part2 = loveframes.utf8.sub(text, p + 1)
|
||||||
local new = part1 .. part2
|
local new = part1 .. part2
|
||||||
return new
|
return new, removed_part
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
-- move to parent if there is a parent
|
-- move to parent if there is a parent
|
||||||
if parent ~= base then
|
if parent ~= base then
|
||||||
self.x = self.parent.x + self.staticx
|
self.x = self.parent.x + self.staticx - (parent.offsetx or 0)
|
||||||
self.y = self.parent.y + self.staticy
|
self.y = self.parent.y + self.staticy - (parent.offsety or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.itemwidth = 0
|
self.itemwidth = 0
|
||||||
@ -92,7 +92,7 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
if self.itemheight > self.height then
|
if self.itemheight > self.height then
|
||||||
if not self.vbar then
|
if not self.vbar then
|
||||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "vertical")
|
local scrollbody = loveframes.objects["scrollbody"]:new(self, "vertical", true)
|
||||||
table.insert(self.internals, scrollbody)
|
table.insert(self.internals, scrollbody)
|
||||||
self.vbar = true
|
self.vbar = true
|
||||||
if self.hbar then
|
if self.hbar then
|
||||||
@ -119,7 +119,7 @@ function newobject:update(dt)
|
|||||||
|
|
||||||
if self.itemwidth > self.width then
|
if self.itemwidth > self.width then
|
||||||
if not self.hbar then
|
if not self.hbar then
|
||||||
local scrollbody = loveframes.objects["scrollbody"]:new(self, "horizontal")
|
local scrollbody = loveframes.objects["scrollbody"]:new(self, "horizontal", true)
|
||||||
table.insert(self.internals, scrollbody)
|
table.insert(self.internals, scrollbody)
|
||||||
self.hbar = true
|
self.hbar = true
|
||||||
if self.vbar then
|
if self.vbar then
|
||||||
@ -174,6 +174,8 @@ function newobject:draw()
|
|||||||
stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height - 16) end
|
stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height - 16) end
|
||||||
elseif self.vbar and self.hbar then
|
elseif self.vbar and self.hbar then
|
||||||
stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width - 16, self.height - 16) end
|
stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width - 16, self.height - 16) end
|
||||||
|
else
|
||||||
|
stencilfunc = function() love.graphics.rectangle("fill", self.x, self.y, self.width, self.height) end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetDrawOrder()
|
self:SetDrawOrder()
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 177 B |
Binary file not shown.
Before Width: | Height: | Size: 223 B After Width: | Height: | Size: 176 B |
@ -853,7 +853,7 @@ function skin.multichoice(object)
|
|||||||
skin.PrintText(choice, x + 5, y + height/2 - theight/2)
|
skin.PrintText(choice, x + 5, y + height/2 - theight/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.draw(image, x + width - 20, y + 5)
|
love.graphics.draw(image, x + width - 20, y + (height - 16) / 2)
|
||||||
|
|
||||||
love.graphics.setColor(border)
|
love.graphics.setColor(border)
|
||||||
skin.OutlinedRectangle(x, y, width, height)
|
skin.OutlinedRectangle(x, y, width, height)
|
||||||
@ -1540,8 +1540,6 @@ function skin.grid(object)
|
|||||||
local skin = object:GetSkin()
|
local skin = object:GetSkin()
|
||||||
local x = object:GetX()
|
local x = object:GetX()
|
||||||
local y = object:GetY()
|
local y = object:GetY()
|
||||||
local width = object:GetWidth()
|
|
||||||
local height = object:GetHeight()
|
|
||||||
|
|
||||||
--love.graphics.setColor(colors.hl4)
|
--love.graphics.setColor(colors.hl4)
|
||||||
--love.graphics.rectangle("fill", x-1, y-1, width+2, height+2)
|
--love.graphics.rectangle("fill", x-1, y-1, width+2, height+2)
|
||||||
@ -1551,24 +1549,37 @@ function skin.grid(object)
|
|||||||
local cw = object.cellwidth + (object.cellpadding * 2)
|
local cw = object.cellwidth + (object.cellpadding * 2)
|
||||||
local ch = object.cellheight + (object.cellpadding * 2)
|
local ch = object.cellheight + (object.cellpadding * 2)
|
||||||
|
|
||||||
for i=1, object.rows do
|
local row = 1
|
||||||
for n=1, object.columns do
|
while row <= object.rows do
|
||||||
|
local col = 1
|
||||||
|
while col <= object.columns do
|
||||||
|
local cs = (object.colspans[col] or {})[row] or 1
|
||||||
|
local rs = (object.rowspans[col] or {})[row] or 1
|
||||||
|
|
||||||
|
if rs ~= -1 and cs ~= -1 then
|
||||||
local ovt = false
|
local ovt = false
|
||||||
local ovl = false
|
local ovl = false
|
||||||
if i > 1 then
|
if row > 1 then
|
||||||
ovt = true
|
ovt = true
|
||||||
end
|
end
|
||||||
if n > 1 then
|
if col > 1 then
|
||||||
ovl = true
|
ovl = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local x = cx + (col - 1) * cw
|
||||||
|
local y = cy + (row - 1) * ch
|
||||||
|
local w = cw * cs
|
||||||
|
local h = ch * rs
|
||||||
|
|
||||||
love.graphics.setColor(skin.controls.color_back1)
|
love.graphics.setColor(skin.controls.color_back1)
|
||||||
love.graphics.rectangle("fill", cx, cy, cw, ch)
|
love.graphics.rectangle("fill", x, y, w, h)
|
||||||
love.graphics.setColor(skin.controls.color_back3)
|
love.graphics.setColor(skin.controls.color_back3)
|
||||||
skin.OutlinedRectangle(cx, cy, cw, ch, ovt, false, ovl, false)
|
skin.OutlinedRectangle(x, y, w, h, ovt, false, ovl, false)
|
||||||
cx = cx + cw
|
|
||||||
end
|
end
|
||||||
cx = x
|
col = col + 1
|
||||||
cy = cy + ch
|
|
||||||
|
end
|
||||||
|
row = row + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -1723,15 +1734,18 @@ function skin.treenodebutton(object)
|
|||||||
local leftpadding = 15 * object.parent.level
|
local leftpadding = 15 * object.parent.level
|
||||||
local image
|
local image
|
||||||
|
|
||||||
|
local fore = skin.controls.color_fore0
|
||||||
|
if object.parent.tree.selectednode == object.parent then
|
||||||
|
fore = {1, 1, 1, 1}
|
||||||
|
end
|
||||||
if object.parent.open then
|
if object.parent.open then
|
||||||
image = skin.images["tree-node-button-close.png"]
|
image = skin.images["tree-node-button-close.png"]
|
||||||
else
|
else
|
||||||
image = skin.images["tree-node-button-open.png"]
|
image = skin.images["tree-node-button-open.png"]
|
||||||
end
|
end
|
||||||
|
|
||||||
--image:setFilter("nearest", "nearest")
|
--image:setFilter("nearest", "nearest")
|
||||||
|
love.graphics.setColor(fore)
|
||||||
love.graphics.setColor(skin.controls.color_image)
|
--love.graphics.setColor(skin.controls.color_image)
|
||||||
love.graphics.draw(image, object.x, object.y)
|
love.graphics.draw(image, object.x, object.y)
|
||||||
|
|
||||||
object:SetPos(2 + leftpadding, 3)
|
object:SetPos(2 + leftpadding, 3)
|
||||||
|
Loading…
Reference in New Issue
Block a user