Scissor example

Scissor button example
This commit is contained in:
jason 2019-10-17 13:55:42 +08:00 committed by GitHub
parent bf89bf9f08
commit 05dfdb5c34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,6 +11,7 @@ local colorPicker = {value = '#ff0000'}
local property = {value = 6} local property = {value = 6}
local edit = {value = 'Edit text'} local edit = {value = 'Edit text'}
local comboA = {value = 1, items = {'A', 'B', 'C'}} local comboA = {value = 1, items = {'A', 'B', 'C'}}
local scissorActive = false
return function (ui) return function (ui)
if ui:windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then if ui:windowBegin('Overview', 100, 100, 600, 450, 'border', 'movable', 'title') then
@ -49,6 +50,9 @@ return function (ui)
ui:spacing(1) ui:spacing(1)
ui:checkbox('Checkbox A', checkA) ui:checkbox('Checkbox A', checkA)
ui:checkbox('Checkbox B', checkB) ui:checkbox('Checkbox B', checkB)
if ui:button('Scissor') then
scissorActive = not scissorActive
end
ui:groupEnd() ui:groupEnd()
end end
if ui:groupBegin('Group 2', 'border') then if ui:groupBegin('Group 2', 'border') then
@ -104,4 +108,11 @@ return function (ui)
end end
end end
ui:windowEnd() ui:windowEnd()
if(scissorActive) then
love.graphics.setScissor()
love.graphics.clear()
love.graphics.setScissor(130, 130, 500, 400)
else
love.graphics.setScissor()
end
end end