refactor + new transitions

This commit is contained in:
kepler155c@gmail.com
2020-04-06 00:12:46 -06:00
parent 7659b81d49
commit 8fe6e0806c
5 changed files with 119 additions and 24 deletions

View File

@@ -0,0 +1,31 @@
local class = require('opus.class')
local UI = require('opus.ui')
UI.MiniSlideOut = class(UI.SlideOut)
UI.MiniSlideOut.defaults = {
UIElement = 'MiniSlideOut',
noFill = true,
backgroundColor = UI.colors.primary,
height = 1,
}
function UI.MiniSlideOut:postInit()
self.close_button = UI.Button {
x = -1,
backgroundColor = self.backgroundColor,
backgroundFocusColor = self.backgroundColor,
text = 'x',
event = 'slide_hide',
noPadding = true,
}
if self.label then
self.label_text = UI.Text {
x = 2,
value = self.label,
}
end
end
function UI.MiniSlideOut:show(...)
UI.SlideOut.show(self, ...)
self:addTransition('slideLeft', { easing = 'outBounce' })
end

View File

@@ -0,0 +1,27 @@
local class = require('opus.class')
local UI = require('opus.ui')
UI.Question = class(UI.MiniSlideOut)
UI.Question.defaults = {
UIElement = 'Question',
accelerators = {
y = 'question_yes',
n = 'question_no',
}
}
function UI.Question:postInit()
local x = self.label and #self.label + 3 or 1
self.yes_button = UI.Button {
x = x,
text = 'Yes',
backgroundColor = UI.colors.primary,
event = 'question_yes',
}
self.no_button = UI.Button {
x = x + 5,
text = 'No',
backgroundColor = UI.colors.primary,
event = 'question_no',
}
end