diff --git a/modules/client_entergame/characterlist.otui b/modules/client_entergame/characterlist.otui index 764dd8c4..35007fff 100644 --- a/modules/client_entergame/characterlist.otui +++ b/modules/client_entergame/characterlist.otui @@ -30,6 +30,7 @@ MainWindow anchors.bottom: characterList.bottom anchors.right: characterList.right step: 14 + pixels-scroll: true Label id: accountStatusLabel diff --git a/modules/core_lib/widgets/uiscrollbar.lua b/modules/core_lib/widgets/uiscrollbar.lua index a0504ff8..4399f8c9 100644 --- a/modules/core_lib/widgets/uiscrollbar.lua +++ b/modules/core_lib/widgets/uiscrollbar.lua @@ -10,7 +10,7 @@ local function calcValues(self) if self.orientation == 'vertical' then pxrange = (self:getHeight() - decrementButton:getHeight() - decrementButton:getMarginTop() - decrementButton:getMarginBottom() - incrementButton:getHeight() - incrementButton:getMarginTop() - incrementButton:getMarginBottom()) - center = self:getY() + self:getHeight() / 2 + center = self:getY() + math.floor(self:getHeight() / 2) else -- horizontal pxrange = (self:getWidth() - decrementButton:getWidth() - decrementButton:getMarginLeft() - decrementButton:getMarginRight() - incrementButton:getWidth() - incrementButton:getMarginLeft() - incrementButton:getMarginRight()) @@ -18,11 +18,33 @@ local function calcValues(self) end local range = self.maximum - self.minimum + 1 - local proportion = math.min(math.max(range*(self.step/range), 1), range)/range - local px = math.max(math.floor(proportion * pxrange), 10) + + local proportion + + if self.pixelsScroll then + proportion = pxrange/(range+pxrange) + else + proportion = math.min(math.max(self.step, 1), range)/range + end + + local px = math.max(proportion * pxrange, 10) + px = px - px % 2 + 1 + local offset = 0 - if range > 1 then - offset = math.ceil((((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px)) + if range == 0 or self.value == self.minimum then + if self.orientation == 'vertical' then + offset = -math.floor((self:getHeight() - px) / 2) + decrementButton:getMarginRect().height + else + offset = -math.floor((self:getWidth() - px) / 2) + decrementButton:getMarginRect().width + end + elseif range > 1 and self.value == self.maximum then + if self.orientation == 'vertical' then + offset = math.ceil((self:getHeight() - px) / 2) - incrementButton:getMarginRect().height + else + offset = math.ceil((self:getWidth() - px) / 2) - incrementButton:getMarginRect().width + end + elseif range > 1 then + offset = (((self.value - self.minimum) / (range - 1)) - 0.5) * (pxrange - px) end return range, pxrange, px, offset, center @@ -71,6 +93,7 @@ function UIScrollBar.create() scrollbar.maximum = 0 scrollbar.step = 1 scrollbar.orientation = 'vertical' + scrollbar.pixelsScroll = false return scrollbar end @@ -95,6 +118,8 @@ function UIScrollBar:onStyleApply(styleName, styleNode) self:setOrientation(value) elseif name == 'value' then self:setValue(value) + elseif name == 'pixels-scroll' then + self.pixelsScroll = true end end end diff --git a/modules/core_styles/styles/scrollbars.otui b/modules/core_styles/styles/scrollbars.otui index 0e824652..5649330b 100644 --- a/modules/core_styles/styles/scrollbars.otui +++ b/modules/core_styles/styles/scrollbars.otui @@ -20,6 +20,7 @@ VerticalScrollBar < UIScrollBar image-source: images/scrollbar.png image-clip: 39 0 13 65 image-border: 1 + pixels-scroll: true UIButton id: decrementButton diff --git a/modules/game/styles/miniwindow.otui b/modules/game/styles/miniwindow.otui index 29513b6c..2fe51486 100644 --- a/modules/game/styles/miniwindow.otui +++ b/modules/game/styles/miniwindow.otui @@ -50,15 +50,6 @@ MiniWindow < UIMiniWindow $pressed: image-clip: 0 28 14 14 - ResizeBorder - id: bottomResizeBorder - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - height: 4 - minimum: 70 - background: #ffffff88 - VerticalScrollBar id: miniwindowScrollBar anchors.top: parent.top @@ -67,11 +58,21 @@ MiniWindow < UIMiniWindow step: 14 margin-top: 22 margin-right: 2 - margin-bottom: 2 + margin-bottom: 3 + pixels-scroll: true + + ResizeBorder + id: bottomResizeBorder + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: 3 + minimum: 70 + background: #ffffff88 MiniWindowContents < ScrollablePanel anchors.fill: parent - padding: 25 21 2 8 + padding: 25 21 3 8 vertical-scrollbar: miniwindowScrollBar BorderlessGameWindow < UIWindow diff --git a/modules/game_console/console.otui b/modules/game_console/console.otui index dbdddf60..33aaf4a6 100644 --- a/modules/game_console/console.otui +++ b/modules/game_console/console.otui @@ -30,6 +30,7 @@ ConsoleTabBarPanel < TabBarPanel anchors.bottom: parent.bottom anchors.right: parent.right step: 14 + pixels-scroll: true ConsoleTabBarButton < TabBarButton diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 89294bdd..8aa23052 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -112,6 +112,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("isChildLocked", &UIWidget::isChildLocked); g_lua.bindClassMemberFunction("hasChild", &UIWidget::hasChild); g_lua.bindClassMemberFunction("getChildIndex", &UIWidget::getChildIndex); + g_lua.bindClassMemberFunction("getMarginRect", &UIWidget::getMarginRect); g_lua.bindClassMemberFunction("getClippingRect", &UIWidget::getClippingRect); g_lua.bindClassMemberFunction("getChildrenRect", &UIWidget::getChildrenRect); g_lua.bindClassMemberFunction("getAnchoredLayout", &UIWidget::getAnchoredLayout);