2019-06-28 17:50:02 +00:00
|
|
|
local class = require('opus.class')
|
|
|
|
local UI = require('opus.ui')
|
2019-02-06 04:03:57 +00:00
|
|
|
|
|
|
|
UI.SlideOut = class(UI.Window)
|
|
|
|
UI.SlideOut.defaults = {
|
|
|
|
UIElement = 'SlideOut',
|
2020-03-31 15:57:23 +00:00
|
|
|
transitionHint = 'expandUp',
|
|
|
|
modal = true,
|
2019-02-06 04:03:57 +00:00
|
|
|
}
|
|
|
|
function UI.SlideOut:enable()
|
|
|
|
end
|
|
|
|
|
2019-11-15 19:51:44 +00:00
|
|
|
function UI.SlideOut:toggle()
|
|
|
|
if self.enabled then
|
|
|
|
self:hide()
|
|
|
|
else
|
|
|
|
self:show()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-06 04:03:57 +00:00
|
|
|
function UI.SlideOut:show(...)
|
|
|
|
UI.Window.enable(self, ...)
|
|
|
|
self:draw()
|
|
|
|
self:focusFirst()
|
|
|
|
end
|
|
|
|
|
|
|
|
function UI.SlideOut:hide()
|
|
|
|
self:disable()
|
2020-03-31 15:57:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function UI.SlideOut:draw()
|
|
|
|
if not self.noFill then
|
|
|
|
self:fillArea(1, 1, self.width, self.height, string.rep('\127', self.width), colors.black, colors.gray)
|
|
|
|
end
|
|
|
|
self:drawChildren()
|
2019-02-06 04:03:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function UI.SlideOut:eventHandler(event)
|
|
|
|
if event.type == 'slide_show' then
|
|
|
|
self:show()
|
|
|
|
return true
|
|
|
|
|
|
|
|
elseif event.type == 'slide_hide' then
|
|
|
|
self:hide()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2019-11-14 22:43:20 +00:00
|
|
|
|
|
|
|
function UI.SlideOut.example()
|
2020-03-31 15:57:23 +00:00
|
|
|
return UI.Window {
|
|
|
|
y = 3,
|
|
|
|
backgroundColor = 2048,
|
2019-11-14 22:43:20 +00:00
|
|
|
button = UI.Button {
|
2019-11-17 05:12:02 +00:00
|
|
|
x = 2, y = 5,
|
2019-11-14 22:43:20 +00:00
|
|
|
text = 'show',
|
|
|
|
},
|
|
|
|
slideOut = UI.SlideOut {
|
2020-03-31 15:57:23 +00:00
|
|
|
backgroundColor = 16,
|
|
|
|
y = -7, height = 4, x = 3, ex = -3,
|
|
|
|
titleBar = UI.TitleBar {
|
|
|
|
title = 'test',
|
|
|
|
},
|
2019-11-14 22:43:20 +00:00
|
|
|
button = UI.Button {
|
|
|
|
x = 2, y = 2,
|
|
|
|
text = 'hide',
|
2020-03-31 15:57:23 +00:00
|
|
|
--visualize = true,
|
2019-11-14 22:43:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
eventHandler = function (self, event)
|
|
|
|
if event.type == 'button_press' then
|
2019-11-15 19:51:44 +00:00
|
|
|
self.slideOut:toggle()
|
2019-11-14 22:43:20 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
end
|