mirror of
https://github.com/edubart/otclient.git
synced 2025-10-15 03:54:54 +02:00
@@ -75,7 +75,7 @@ MiniWindow < UIMiniWindow
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 3
|
||||
minimum: 64
|
||||
minimum: 48
|
||||
background: #ffffff88
|
||||
|
||||
MiniWindowContents < ScrollablePanel
|
||||
|
@@ -3,6 +3,7 @@ UIMiniWindow = extends(UIWindow)
|
||||
|
||||
function UIMiniWindow.create()
|
||||
local miniwindow = UIMiniWindow.internalCreate()
|
||||
miniwindow.isSetup = false
|
||||
return miniwindow
|
||||
end
|
||||
|
||||
@@ -103,7 +104,13 @@ function UIMiniWindow:onSetup()
|
||||
if selfSettings.closed then
|
||||
self:close(true)
|
||||
end
|
||||
|
||||
if selfSettings.height then
|
||||
self:setHeight(selfSettings.height)
|
||||
end
|
||||
end
|
||||
|
||||
self.isSetup = true
|
||||
end
|
||||
|
||||
local newParent = self:getParent()
|
||||
@@ -118,6 +125,19 @@ function UIMiniWindow:onSetup()
|
||||
newParent:order()
|
||||
end
|
||||
end
|
||||
|
||||
if newParent and newParent:getClassName() == 'UIMiniWindowContainer' and self:isVisible() then
|
||||
-- not on input event, must rework
|
||||
--newParent:fitAll(self)
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onVisibilityChange(visible)
|
||||
local parent = self:getParent()
|
||||
if visible and parent and parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
-- not on input event, must rework
|
||||
--parent:fitAll(self)
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onDragEnter(mousePos)
|
||||
@@ -215,6 +235,18 @@ function UIMiniWindow:onFocusChange(focused)
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:onGeometryChange(oldRect, rect)
|
||||
if self.isSetup then
|
||||
self:setSettings({height = rect.height})
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
-- not on input event, must rework
|
||||
--parent:fitAll(self)
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:setSettings(data)
|
||||
if not self.save then return end
|
||||
|
||||
@@ -254,12 +286,18 @@ function UIMiniWindow:disableResize()
|
||||
self:getChildById('bottomResizeBorder'):disable()
|
||||
end
|
||||
|
||||
function UIMiniWindow:setMinimumHeight(height)
|
||||
function UIMiniWindow:setContentMinimumHeight(height)
|
||||
local contentsPanel = self:getChildById('contentsPanel')
|
||||
local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
|
||||
|
||||
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||
resizeBorder:setMinimum(height)
|
||||
resizeBorder:setMinimum(minHeight + height)
|
||||
end
|
||||
|
||||
function UIMiniWindow:setMaximumHeight(height)
|
||||
function UIMiniWindow:setContentMaximumHeight(height)
|
||||
local contentsPanel = self:getChildById('contentsPanel')
|
||||
local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
|
||||
|
||||
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||
resizeBorder:setMaximum(height)
|
||||
resizeBorder:setMaximum(minHeight + height)
|
||||
end
|
||||
|
@@ -13,6 +13,63 @@ function UIMiniWindowContainer:getClassName()
|
||||
return 'UIMiniWindowContainer'
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:fitAll(noRemoveChild)
|
||||
if not self:isVisible() then
|
||||
return
|
||||
end
|
||||
|
||||
local sumHeight = 0
|
||||
local children = self:getChildren()
|
||||
for i=1,#children do
|
||||
sumHeight = sumHeight + children[i]:getHeight()
|
||||
end
|
||||
|
||||
local selfHeight = self:getHeight()
|
||||
if sumHeight <= selfHeight then
|
||||
return
|
||||
end
|
||||
|
||||
local removeChildren = {}
|
||||
|
||||
-- try to remove no-save widget
|
||||
for i=#children,1,-1 do
|
||||
if sumHeight < selfHeight then
|
||||
break
|
||||
end
|
||||
|
||||
local child = children[i]
|
||||
if child ~= noRemoveChild and not child.save then
|
||||
local childHeight = child:getHeight()
|
||||
sumHeight = sumHeight - childHeight
|
||||
table.insert(removeChildren, child)
|
||||
end
|
||||
end
|
||||
|
||||
-- try to remove save widget
|
||||
for i=#children,1,-1 do
|
||||
if sumHeight < selfHeight then
|
||||
break
|
||||
end
|
||||
|
||||
local child = children[i]
|
||||
if child ~= noRemoveChild then
|
||||
local childHeight = child:getHeight()
|
||||
sumHeight = sumHeight - childHeight
|
||||
table.insert(removeChildren, child)
|
||||
end
|
||||
end
|
||||
|
||||
-- close widgets
|
||||
for i=1,#removeChildren do
|
||||
removeChildren[i]:close()
|
||||
end
|
||||
|
||||
-- dont let noRemoveChild be bigger than self
|
||||
if noRemoveChild:getHeight() > selfHeight - 20 then
|
||||
noRemoveChild:setHeight(selfHeight - 20)
|
||||
end
|
||||
end
|
||||
|
||||
function UIMiniWindowContainer:onDrop(widget, mousePos)
|
||||
if widget:getClassName() == 'UIMiniWindow' then
|
||||
local oldParent = widget:getParent()
|
||||
|
@@ -92,6 +92,11 @@ function UIResizeBorder:setMaximum(maximum)
|
||||
if self.maximum == self.minimum then
|
||||
self:hide()
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if self:isVisible() and parent:getHeight() > maximum then
|
||||
parent:setHeight(maximum)
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:setMinimum(minimum)
|
||||
@@ -99,6 +104,11 @@ function UIResizeBorder:setMinimum(minimum)
|
||||
if self.maximum == self.minimum then
|
||||
self:hide()
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if self:isVisible() and parent:getHeight() < minimum then
|
||||
parent:setHeight(minimum)
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:getMaximum() return self.maximum end
|
||||
|
@@ -33,6 +33,10 @@ function init()
|
||||
battleButton:setOn(true)
|
||||
g_keyboard.bindKeyDown('Ctrl+B', toggle)
|
||||
|
||||
-- this disables scrollbar auto hiding
|
||||
local scrollbar = battleWindow:getChildById('miniwindowScrollBar')
|
||||
scrollbar:mergeStyle({ ['$!on'] = { }})
|
||||
|
||||
battlePanel = battleWindow:recursiveGetChildById('battlePanel')
|
||||
|
||||
hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
|
||||
|
@@ -31,4 +31,3 @@ ContainerWindow < MiniWindow
|
||||
type: grid
|
||||
cell-size: 34 34
|
||||
flow: true
|
||||
|
||||
|
@@ -88,6 +88,11 @@ function onContainerOpen(container, previousContainer)
|
||||
|
||||
container.window = containerWindow
|
||||
container.itemsPanel = containerPanel
|
||||
|
||||
local layout = containerPanel:getLayout()
|
||||
local cellSize = layout:getCellSize()
|
||||
containerWindow:setContentMinimumHeight(cellSize.height*1)
|
||||
containerWindow:setContentMaximumHeight(cellSize.height*layout:getNumLines())
|
||||
end
|
||||
|
||||
function onContainerClose(container)
|
||||
|
Reference in New Issue
Block a user