Allow to overwrite draw function per widget
This commit is contained in:
parent
18880de088
commit
4f3d285218
9 changed files with 16 additions and 9 deletions
|
@ -11,7 +11,7 @@ return function(core, text, ...)
|
|||
h = h or opt.font:getHeight() + 4
|
||||
|
||||
opt.state = core:registerHitbox(opt.id, x,y,w,h)
|
||||
core:registerDraw(core.theme.Button, text, opt, x,y,w,h)
|
||||
core:registerDraw(opt.draw or core.theme.Button, text, opt, x,y,w,h)
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
|
@ -15,7 +15,7 @@ return function(core, checkbox, ...)
|
|||
if hit then
|
||||
checkbox.checked = not checkbox.checked
|
||||
end
|
||||
core:registerDraw(core.theme.Checkbox, checkbox, opt, x,y,w,h)
|
||||
core:registerDraw(opt.draw or core.theme.Checkbox, checkbox, opt, x,y,w,h)
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
|
@ -111,6 +111,9 @@ The following code will create this UI:
|
|||
-- nested content, whichever is bigger
|
||||
suit.layout:push(suit.layout:row())
|
||||
|
||||
-- change cell padding to 3 pixels in either direction
|
||||
suit.layout:padding(3)
|
||||
|
||||
-- put a slider in the cell
|
||||
-- the inner cell will be 160 px wide and 20 px high
|
||||
suit.Slider(slider, suit.layout:col(160, 20))
|
||||
|
|
|
@ -116,7 +116,7 @@ Used to provide the last four arguments to a widget, e.g.::
|
|||
|
||||
|
||||
Precomputed Layouts
|
||||
------------------
|
||||
-------------------
|
||||
|
||||
Apart from immediate mode layouts, you can specify layouts in advance.
|
||||
The specification is a table of tables, where each inner table follows the
|
||||
|
|
|
@ -164,8 +164,10 @@ Common Options
|
|||
``"bottom"``. Defaults to ``"middle"``.
|
||||
|
||||
``color``
|
||||
Table overwriting the color. Undefined colors default to the theme colors.
|
||||
A table to overwrite the color. Undefined colors default to the theme colors.
|
||||
|
||||
``draw``
|
||||
A function to replace the drawing function. Refer to :doc:`themes` for more information about the function signatures.
|
||||
|
||||
|
||||
Common Return States
|
||||
|
|
|
@ -28,8 +28,10 @@ return function(core, normal, ...)
|
|||
img = opt.hovered
|
||||
end
|
||||
|
||||
core:registerDraw(love.graphics.setColor, 255,255,255)
|
||||
core:registerDraw(love.graphics.draw, img, x,y)
|
||||
core:registerDraw(opt.draw or function(img,x,y, r,g,b,a)
|
||||
love.graphics.setColor(r,g,b,a)
|
||||
love.graphics.draw(img,x,y)
|
||||
end, img, x,y, love.graphics.getColor())
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
|
@ -86,7 +86,7 @@ return function(core, input, ...)
|
|||
input.drawoffset = text_width - w
|
||||
end
|
||||
|
||||
core:registerDraw(core.theme.Input, input, opt, x,y,w,h)
|
||||
core:registerDraw(opt.draw or core.theme.Input, input, opt, x,y,w,h)
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
|
@ -11,7 +11,7 @@ return function(core, text, ...)
|
|||
h = h or opt.font:getHeight() + 4
|
||||
|
||||
opt.state = core:registerHitbox(opt.id, x,y,w,h)
|
||||
core:registerDraw(core.theme.Label, text, opt, x,y,w,h)
|
||||
core:registerDraw(opt.draw or core.theme.Label, text, opt, x,y,w,h)
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
|
@ -41,7 +41,7 @@ return function(core, info, ...)
|
|||
end
|
||||
end
|
||||
|
||||
core:registerDraw(core.theme.Slider, fraction, opt, x,y,w,h)
|
||||
core:registerDraw(opt.draw or core.theme.Slider, fraction, opt, x,y,w,h)
|
||||
|
||||
return {
|
||||
id = opt.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue