mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 12:04:55 +02:00
Fix scrollbar slider move, outfit exact size, charlist focus
This commit is contained in:
@@ -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
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user