some rework in UIWidget input

This commit is contained in:
Eduardo Bart
2012-03-26 10:34:43 -03:00
parent 532e8e3e39
commit 9309d6e7f3
13 changed files with 139 additions and 132 deletions

View File

@@ -22,13 +22,14 @@ MainWindow
margin-bottom: 5
padding: 1
focusable: false
vertical-scrollbar: characterListScrollBar
VerticalScrollBar
attached-to: characterList
id: characterListScrollBar
anchors.top: characterList.top
anchors.bottom: characterList.bottom
anchors.right: characterList.right
maximum: 0
step: 14
Label
id: accountStatusLabel

View File

@@ -17,7 +17,7 @@ function Mouse.restoreCursor()
end
function Mouse.isPressed()
return g_ui.getPressedWidget() == nil
return g_ui.getPressedWidget() ~= nil
end
function Mouse.bindAutoPress(widget, callback)

View File

@@ -33,7 +33,9 @@ function UIScrollArea:updateScrollBars()
if scrollbar then
if self.inverted then
scrollbar:setMinimum(-scrollheight)
scrollbar:setMaximum(0)
else
scrollbar:setMinimum(0)
scrollbar:setMaximum(scrollheight)
end
end
@@ -50,10 +52,8 @@ end
function UIScrollArea:setVerticalScrollBar(scrollbar)
self.verticalScrollBar = scrollbar
scrollbar:setMaximum(0)
self.verticalScrollBar.onValueChange = function(scrollbar, value)
local virtualOffset = self:getVirtualOffset()
if self.inverted then value = -value end
virtualOffset.y = value
self:setVirtualOffset(virtualOffset)
end
@@ -72,3 +72,14 @@ end
function UIScrollArea:onLayoutUpdate()
self:updateScrollBars()
end
function UIScrollArea:onMouseWheel(mousePos, mouseWheel)
if self.verticalScrollBar then
if mouseWheel == MouseWheelUp then
self.verticalScrollBar:decrement()
else
self.verticalScrollBar:increment()
end
end
return true
end

View File

@@ -22,7 +22,7 @@ local function calcValues(self)
local px = math.max(math.floor(proportion * pxrange), 10)
local offset = 0
if range > 1 then
offset = (((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px)
offset = math.ceil((((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px))
end
return range, pxrange, px, offset, center
@@ -153,6 +153,15 @@ function UIScrollBar:onGeometryChange()
updateSlider(self)
end
function UIScrollBar:onMouseWheel(mousePos, mouseWheel)
if mouseWheel == MouseWheelUp then
self:decrement()
else
self:increment()
end
return true
end
function UIScrollBar:getMaximum() return self.maximum end
function UIScrollBar:getMinimum() return self.minimum end
function UIScrollBar:getValue() return self.value end

View File

@@ -46,7 +46,6 @@ function UISplitter:onMouseRelease(mousePos, mouseButton)
if not self:isHovered() then
Mouse.restoreCursor()
end
self:ungrabMouse()
end
function UISplitter:onStyleApply(styleName, styleNode)

View File

@@ -215,10 +215,6 @@ function Console.terminate()
Console = nil
end
function Console.debug()
print(#channels)
end
function Console.clear()
for channelid, channelname in pairs(channels) do
if channelid ~= 0 then

View File

@@ -12,7 +12,6 @@ ConsoleTabBarPanel < TabBarPanel
ScrollablePanel
id: consoleBuffer
// height = max lines * 14
anchors.fill: parent
margin-right: 12
vertical-scrollbar: consoleScrollBar