Ui enhancements 2.0 (#31)

* canvas overhaul

* minor tweaks

* list mode for overview

* bugfixes + tweaks for editor 2.0

* minor tweaks

* more editor work

* refactor + new transitions

* use layout() where appropriate and cleanup

* mouse triple click + textEntry scroll ind

* cleanup

* cleanup + theme editor

* color rework + cleanup

* changes for deprecated ui methods

* can now use named colors
This commit was merged in pull request #31.
This commit is contained in:
kepler155c
2020-04-21 22:40:59 -06:00
committed by GitHub
parent cdd0b6c4d2
commit 7224d441ca
92 changed files with 2471 additions and 1773 deletions

View File

@@ -17,7 +17,13 @@ UI.ScrollBar.defaults = {
ey = -1,
}
function UI.ScrollBar:draw()
local view = self.parent:getViewArea()
local parent = self.target or self.parent --self:find(self.target)
local view = parent:getViewArea()
self:clear()
-- ...
self:write(1, 1, ' ', view.fill)
if view.totalHeight > view.height then
local maxScroll = view.totalHeight - view.height
@@ -27,7 +33,7 @@ function UI.ScrollBar:draw()
local row = view.y
if not view.static then -- does the container scroll ?
self.height = view.totalHeight
self:reposition(self.x, self.y, self.width, view.totalHeight)
end
for i = 1, view.height - 2 do
@@ -56,16 +62,17 @@ end
function UI.ScrollBar:eventHandler(event)
if event.type == 'mouse_click' or event.type == 'mouse_doubleclick' then
if event.x == 1 then
local view = self.parent:getViewArea()
local parent = self.target or self.parent --self:find(self.target)
local view = parent:getViewArea()
if view.totalHeight > view.height then
if event.y == view.y then
self:emit({ type = 'scroll_up'})
parent:emit({ type = 'scroll_up'})
elseif event.y == view.y + view.height - 1 then
self:emit({ type = 'scroll_down'})
parent:emit({ type = 'scroll_down'})
else
local percent = (event.y - view.y) / (view.height - 2)
local y = math.floor((view.totalHeight - view.height) * percent)
self:emit({ type = 'scroll_to', offset = y })
parent :emit({ type = 'scroll_to', offset = y })
end
end
return true