Fix scrollbar slider move, outfit exact size, charlist focus

This commit is contained in:
Henrique Santiago
2012-08-31 20:33:51 -03:00
parent 18a0d7ab94
commit 23097980a3
12 changed files with 201 additions and 113 deletions

View File

@@ -2,6 +2,11 @@ CharacterWidget < UIWidget
height: 14
focusable: true
background-color: alpha
@onFocusChange: |
local children = self:getChildren()
for i=1,#children do
children[i]:setOn(self:isFocused())
end
$focus:
background-color: #ffffff22
@@ -15,6 +20,10 @@ CharacterWidget < UIWidget
text-auto-resize: true
background-color: alpha
text-offset: 2 0
on: true
$!on:
color: #aaaaaa
Label
id: worldName
@@ -26,6 +35,10 @@ CharacterWidget < UIWidget
text-auto-resize: true
background-color: alpha
&baseText: '(%s)'
on: true
$!on:
color: #aaaaaa
MainWindow
id: charactersWindow

View File

@@ -72,21 +72,20 @@ local function updateSlider(self)
end
end
local function parseSliderPos(self, pos)
local point
local function parseSliderPos(self, pos, move)
local point, delta
if self.orientation == 'vertical' then
point = pos.y
delta = move.y
else
point = pos.x
delta = move.x
end
local range, pxrange, px, offset, center = calcValues(self)
offset = math.min(math.max(point - center, -pxrange/2), pxrange/2)
local newvalue = math.floor(((offset / (pxrange - px)) + 0.5) * (range - 1)) + self.minimum
local newvalue = self.value + delta * (range / (pxrange - px))
self:setValue(newvalue)
-- this function must be reworked, scroll is not that good based on center
end
-- public functions
function UIScrollBar.create()
local scrollbar = UIScrollBar.internalCreate()
@@ -105,7 +104,7 @@ function UIScrollBar:onSetup()
--signalcall(self.onValueChange, self, self.value)
g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end, 300)
g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end, 300)
g_mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos) end)
g_mouse.bindPressMove(self:getChildById('sliderButton'), function(mousePos, mouseMoved) parseSliderPos(self, mousePos, mouseMoved) end)
updateSlider(self)
end

View File

@@ -458,7 +458,7 @@ function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, u
end
function moveStackableItem(item, toPos)
if(countWindow) then
if countWindow then
return
end
if g_keyboard.isCtrlPressed() then
@@ -479,8 +479,17 @@ function moveStackableItem(item, toPos)
scrollbar:setMaximum(count)
scrollbar:setMinimum(1)
scrollbar:setValue(count)
scrollbar.onValueChange = function(self, value) spinbox:setValue(value) end
spinbox.onValueChange = function(self, value) scrollbar:setValue(value) end
local spinBoxValueChange = function(self, value)
scrollbar:setValue(value)
end
spinbox.onValueChange = spinBoxValueChange
scrollbar.onValueChange = function(self, value)
spinbox.onValueChange = nil
spinbox:setValue(math.round(value))
spinbox.onValueChange = spinBoxValueChange
end
local okButton = countWindow:getChildById('buttonOk')
local moveFunc = function()