mirror of https://github.com/kepler155c/opus
bugfixes + tweaks for editor 2.0
This commit is contained in:
parent
fc1a308193
commit
d88ef00652
|
@ -9,7 +9,7 @@ kernel.hook('clipboard_copy', function(_, args)
|
|||
keyboard.clipboard = args[1]
|
||||
end)
|
||||
|
||||
keyboard.addHotkey('shift-paste', function()
|
||||
local function queuePaste()
|
||||
local data = keyboard.clipboard
|
||||
|
||||
if type(data) == 'table' then
|
||||
|
@ -20,4 +20,7 @@ keyboard.addHotkey('shift-paste', function()
|
|||
if data then
|
||||
os.queueEvent('paste', data)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
kernel.hook('clipboard_paste', queuePaste)
|
||||
keyboard.addHotkey('shift-paste', queuePaste)
|
||||
|
|
|
@ -73,16 +73,14 @@ function Manager:init()
|
|||
monitor_resize = resize,
|
||||
|
||||
mouse_scroll = function(_, direction, x, y)
|
||||
local ie = Input:translate('mouse_scroll', direction, x, y)
|
||||
|
||||
local currentPage = self:getActivePage()
|
||||
if currentPage then
|
||||
local event = currentPage:pointToChild(x, y)
|
||||
local directions = {
|
||||
[ -1 ] = 'up',
|
||||
[ 1 ] = 'down'
|
||||
}
|
||||
-- revisit - should send out scroll_up and scroll_down events
|
||||
-- let the element convert them to up / down
|
||||
event.element:emit({ type = 'key', key = directions[direction] })
|
||||
event.type = ie.code
|
||||
event.ie = { code = ie.code, x = event.x, y = event.y }
|
||||
event.element:emit(event)
|
||||
currentPage:sync()
|
||||
end
|
||||
end,
|
||||
|
@ -251,10 +249,21 @@ function Manager:click(target, ie)
|
|||
local clickEvent
|
||||
|
||||
if ie.code == 'mouse_drag' then
|
||||
local function getPosition(element, x, y)
|
||||
repeat
|
||||
x = x - element.x + 1
|
||||
y = y - element.y + 1
|
||||
element = element.parent
|
||||
until not element
|
||||
return x, y
|
||||
end
|
||||
|
||||
local x, y = getPosition(self.lastClicked, ie.x, ie.y)
|
||||
|
||||
clickEvent = {
|
||||
element = self.lastClicked,
|
||||
x = ie.x,
|
||||
y = ie.y, -- this is not correct (should be relative to element)
|
||||
x = x,
|
||||
y = y,
|
||||
dx = ie.dx,
|
||||
dy = ie.dy,
|
||||
}
|
||||
|
@ -560,6 +569,7 @@ end
|
|||
function UI.Window:setParent()
|
||||
self.oh, self.ow = self.height, self.width
|
||||
self.ox, self.oy = self.x, self.y
|
||||
self.oex, self.oey = self.ex, self.ey
|
||||
|
||||
self:layout()
|
||||
self:initChildren()
|
||||
|
@ -568,6 +578,7 @@ end
|
|||
function UI.Window:resize()
|
||||
self.height, self.width = self.oh, self.ow
|
||||
self.x, self.y = self.ox, self.oy
|
||||
self.ex, self.ey = self.oex, self.oey
|
||||
|
||||
self:layout()
|
||||
|
||||
|
@ -864,7 +875,6 @@ function UI.Window:release(child)
|
|||
end
|
||||
|
||||
function UI.Window:pointToChild(x, y)
|
||||
-- TODO: get rid of this offx/y mess and scroll canvas instead
|
||||
x = x + self.offx - self.x + 1
|
||||
y = y + self.offy - self.y + 1
|
||||
if self.children then
|
||||
|
|
|
@ -18,14 +18,14 @@ UI.Button.defaults = {
|
|||
focusIndicator = ' ',
|
||||
event = 'button_press',
|
||||
accelerators = {
|
||||
space = 'button_activate',
|
||||
[ ' ' ] = 'button_activate',
|
||||
enter = 'button_activate',
|
||||
mouse_click = 'button_activate',
|
||||
}
|
||||
}
|
||||
function UI.Button:setParent()
|
||||
if not self.width and not self.ex then
|
||||
self.width = #self.text + 2
|
||||
self.width = self.noPadding and #self.text or #self.text + 2
|
||||
end
|
||||
UI.Window.setParent(self)
|
||||
end
|
||||
|
@ -41,7 +41,7 @@ function UI.Button:draw()
|
|||
elseif self.inactive then
|
||||
fg = self:getProperty('textInactiveColor')
|
||||
end
|
||||
local text = ind .. self.text .. ' '
|
||||
local text = self.noPadding and self.text or ind .. self.text .. ' '
|
||||
if self.centered then
|
||||
self:clear(bg)
|
||||
self:centeredWrite(1 + math.floor(self.height / 2), text, bg, fg)
|
||||
|
@ -59,7 +59,7 @@ end
|
|||
|
||||
function UI.Button:eventHandler(event)
|
||||
if event.type == 'button_activate' then
|
||||
self:emit({ type = self.event, button = self })
|
||||
self:emit({ type = self.event, button = self, element = self })
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
|
|
@ -40,9 +40,10 @@ function UI.DropMenu:layout()
|
|||
end
|
||||
|
||||
function UI.DropMenu:enable()
|
||||
local menuBar = self.parent:find(self.menuUid)
|
||||
for _,c in pairs(self.children) do
|
||||
if not c.spacer then
|
||||
c.inactive = not self:getActive(c)
|
||||
if not c.spacer and menuBar then
|
||||
c.inactive = not menuBar:getActive(c)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ function UI.MenuBar:eventHandler(event)
|
|||
x = x,
|
||||
y = y + 1,
|
||||
lastFocus = event.button.uid,
|
||||
menuUid = self.uid,
|
||||
}
|
||||
self.parent:add({ dropmenu = menu })
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@ UI.Page.defaults = {
|
|||
UIElement = 'Page',
|
||||
accelerators = {
|
||||
down = 'focus_next',
|
||||
scroll_down = 'focus_next',
|
||||
enter = 'focus_next',
|
||||
tab = 'focus_next',
|
||||
['shift-tab' ] = 'focus_prev',
|
||||
up = 'focus_prev',
|
||||
scroll_up = 'focus_prev',
|
||||
},
|
||||
backgroundColor = UI.colors.primary,
|
||||
textColor = colors.white,
|
||||
|
|
|
@ -89,11 +89,13 @@ function UI.StatusBar:draw()
|
|||
elseif type(self.values) == 'string' then
|
||||
self:write(1, 1, Util.widthify(' ' .. self.values, self.width))
|
||||
else
|
||||
local s = ''
|
||||
local x = 2
|
||||
self:clear()
|
||||
for _,c in ipairs(self.columns) do
|
||||
s = s .. ' ' .. Util.widthify(tostring(self.values[c.key] or ''), c.cw)
|
||||
local s = Util.widthify(tostring(self.values[c.key] or ''), c.cw)
|
||||
self:write(x, 1, s, c.bg, c.fg)
|
||||
x = x + c.cw + 1
|
||||
end
|
||||
self:write(1, 1, Util.widthify(s, self.width))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ UI.TextEntry.defaults = {
|
|||
focused = false,
|
||||
textColor = colors.white,
|
||||
shadowTextColor = colors.gray,
|
||||
markBackgroundColor = colors.gray,
|
||||
backgroundColor = colors.black, -- colors.lightGray,
|
||||
backgroundFocusColor = colors.black, --lightGray,
|
||||
height = 1,
|
||||
|
@ -84,7 +85,7 @@ function UI.TextEntry:draw()
|
|||
end
|
||||
|
||||
if tx ~= tex then
|
||||
self:write(tx + 2, 1, text:sub(tx + 1, tex), colors.gray, tc)
|
||||
self:write(tx + 2, 1, text:sub(tx + 1, tex), self.markBackgroundColor, tc)
|
||||
end
|
||||
end
|
||||
if self.focused then
|
||||
|
@ -105,6 +106,10 @@ function UI.TextEntry:updateCursor()
|
|||
self:setCursorPos(self.entry.pos - self.entry.scroll + 2, 1)
|
||||
end
|
||||
|
||||
function UI.TextEntry:markAll()
|
||||
self.entry:markAll()
|
||||
end
|
||||
|
||||
function UI.TextEntry:focus()
|
||||
self:draw()
|
||||
if self.focused then
|
||||
|
|
|
@ -20,7 +20,7 @@ end
|
|||
|
||||
function Transition.slideRight(args)
|
||||
local ticks = args.ticks or 10
|
||||
local easing = args.easing or'outQuint'
|
||||
local easing = args.easing or 'outQuint'
|
||||
local pos = { x = -args.canvas.width }
|
||||
local tween = Tween.new(ticks, pos, { x = 1 }, easing)
|
||||
|
||||
|
|
Loading…
Reference in New Issue