parent
0bb991e14e
commit
ab7400c51d
|
@ -75,7 +75,7 @@ MiniWindow < UIMiniWindow
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: 3
|
height: 3
|
||||||
minimum: 64
|
minimum: 48
|
||||||
background: #ffffff88
|
background: #ffffff88
|
||||||
|
|
||||||
MiniWindowContents < ScrollablePanel
|
MiniWindowContents < ScrollablePanel
|
||||||
|
|
|
@ -3,6 +3,7 @@ UIMiniWindow = extends(UIWindow)
|
||||||
|
|
||||||
function UIMiniWindow.create()
|
function UIMiniWindow.create()
|
||||||
local miniwindow = UIMiniWindow.internalCreate()
|
local miniwindow = UIMiniWindow.internalCreate()
|
||||||
|
miniwindow.isSetup = false
|
||||||
return miniwindow
|
return miniwindow
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,9 +104,15 @@ function UIMiniWindow:onSetup()
|
||||||
if selfSettings.closed then
|
if selfSettings.closed then
|
||||||
self:close(true)
|
self:close(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if selfSettings.height then
|
||||||
|
self:setHeight(selfSettings.height)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.isSetup = true
|
||||||
|
end
|
||||||
|
|
||||||
local newParent = self:getParent()
|
local newParent = self:getParent()
|
||||||
|
|
||||||
self.miniLoaded = true
|
self.miniLoaded = true
|
||||||
|
@ -118,6 +125,19 @@ function UIMiniWindow:onSetup()
|
||||||
newParent:order()
|
newParent:order()
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
function UIMiniWindow:onDragEnter(mousePos)
|
function UIMiniWindow:onDragEnter(mousePos)
|
||||||
|
@ -215,6 +235,18 @@ function UIMiniWindow:onFocusChange(focused)
|
||||||
end
|
end
|
||||||
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)
|
function UIMiniWindow:setSettings(data)
|
||||||
if not self.save then return end
|
if not self.save then return end
|
||||||
|
|
||||||
|
@ -254,12 +286,18 @@ function UIMiniWindow:disableResize()
|
||||||
self:getChildById('bottomResizeBorder'):disable()
|
self:getChildById('bottomResizeBorder'):disable()
|
||||||
end
|
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')
|
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||||
resizeBorder:setMinimum(height)
|
resizeBorder:setMinimum(minHeight + height)
|
||||||
end
|
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')
|
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||||
resizeBorder:setMaximum(height)
|
resizeBorder:setMaximum(minHeight + height)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,6 +13,63 @@ function UIMiniWindowContainer:getClassName()
|
||||||
return 'UIMiniWindowContainer'
|
return 'UIMiniWindowContainer'
|
||||||
end
|
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)
|
function UIMiniWindowContainer:onDrop(widget, mousePos)
|
||||||
if widget:getClassName() == 'UIMiniWindow' then
|
if widget:getClassName() == 'UIMiniWindow' then
|
||||||
local oldParent = widget:getParent()
|
local oldParent = widget:getParent()
|
||||||
|
|
|
@ -92,6 +92,11 @@ function UIResizeBorder:setMaximum(maximum)
|
||||||
if self.maximum == self.minimum then
|
if self.maximum == self.minimum then
|
||||||
self:hide()
|
self:hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local parent = self:getParent()
|
||||||
|
if self:isVisible() and parent:getHeight() > maximum then
|
||||||
|
parent:setHeight(maximum)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIResizeBorder:setMinimum(minimum)
|
function UIResizeBorder:setMinimum(minimum)
|
||||||
|
@ -99,6 +104,11 @@ function UIResizeBorder:setMinimum(minimum)
|
||||||
if self.maximum == self.minimum then
|
if self.maximum == self.minimum then
|
||||||
self:hide()
|
self:hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local parent = self:getParent()
|
||||||
|
if self:isVisible() and parent:getHeight() < minimum then
|
||||||
|
parent:setHeight(minimum)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function UIResizeBorder:getMaximum() return self.maximum end
|
function UIResizeBorder:getMaximum() return self.maximum end
|
||||||
|
|
|
@ -33,6 +33,10 @@ function init()
|
||||||
battleButton:setOn(true)
|
battleButton:setOn(true)
|
||||||
g_keyboard.bindKeyDown('Ctrl+B', toggle)
|
g_keyboard.bindKeyDown('Ctrl+B', toggle)
|
||||||
|
|
||||||
|
-- this disables scrollbar auto hiding
|
||||||
|
local scrollbar = battleWindow:getChildById('miniwindowScrollBar')
|
||||||
|
scrollbar:mergeStyle({ ['$!on'] = { }})
|
||||||
|
|
||||||
battlePanel = battleWindow:recursiveGetChildById('battlePanel')
|
battlePanel = battleWindow:recursiveGetChildById('battlePanel')
|
||||||
|
|
||||||
hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
|
hidePlayersButton = battleWindow:recursiveGetChildById('hidePlayers')
|
||||||
|
|
|
@ -31,4 +31,3 @@ ContainerWindow < MiniWindow
|
||||||
type: grid
|
type: grid
|
||||||
cell-size: 34 34
|
cell-size: 34 34
|
||||||
flow: true
|
flow: true
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,11 @@ function onContainerOpen(container, previousContainer)
|
||||||
|
|
||||||
container.window = containerWindow
|
container.window = containerWindow
|
||||||
container.itemsPanel = containerPanel
|
container.itemsPanel = containerPanel
|
||||||
|
|
||||||
|
local layout = containerPanel:getLayout()
|
||||||
|
local cellSize = layout:getCellSize()
|
||||||
|
containerWindow:setContentMinimumHeight(cellSize.height*1)
|
||||||
|
containerWindow:setContentMaximumHeight(cellSize.height*layout:getNumLines())
|
||||||
end
|
end
|
||||||
|
|
||||||
function onContainerClose(container)
|
function onContainerClose(container)
|
||||||
|
|
|
@ -600,6 +600,9 @@ void Application::registerLuaFunctions()
|
||||||
g_lua.bindClassMemberFunction<UIGridLayout>("setFlow", &UIGridLayout::setFlow);
|
g_lua.bindClassMemberFunction<UIGridLayout>("setFlow", &UIGridLayout::setFlow);
|
||||||
g_lua.bindClassMemberFunction<UIGridLayout>("setNumColumns", &UIGridLayout::setNumColumns);
|
g_lua.bindClassMemberFunction<UIGridLayout>("setNumColumns", &UIGridLayout::setNumColumns);
|
||||||
g_lua.bindClassMemberFunction<UIGridLayout>("setNumLines", &UIGridLayout::setNumLines);
|
g_lua.bindClassMemberFunction<UIGridLayout>("setNumLines", &UIGridLayout::setNumLines);
|
||||||
|
g_lua.bindClassMemberFunction<UIGridLayout>("getNumColumns", &UIGridLayout::getNumColumns);
|
||||||
|
g_lua.bindClassMemberFunction<UIGridLayout>("getNumLines", &UIGridLayout::getNumLines);
|
||||||
|
g_lua.bindClassMemberFunction<UIGridLayout>("getCellSize", &UIGridLayout::getCellSize);
|
||||||
g_lua.bindClassMemberFunction<UIGridLayout>("isUIGridLayout", &UIGridLayout::isUIGridLayout);
|
g_lua.bindClassMemberFunction<UIGridLayout>("isUIGridLayout", &UIGridLayout::isUIGridLayout);
|
||||||
|
|
||||||
// UIAnchorLayout
|
// UIAnchorLayout
|
||||||
|
|
|
@ -37,7 +37,6 @@ void UIGridLayout::applyStyle(const OTMLNodePtr& styleNode)
|
||||||
{
|
{
|
||||||
UILayout::applyStyle(styleNode);
|
UILayout::applyStyle(styleNode);
|
||||||
|
|
||||||
|
|
||||||
for(const OTMLNodePtr& node : styleNode->children()) {
|
for(const OTMLNodePtr& node : styleNode->children()) {
|
||||||
if(node->tag() == "cell-size")
|
if(node->tag() == "cell-size")
|
||||||
setCellSize(node->value<Size>());
|
setCellSize(node->value<Size>());
|
||||||
|
@ -83,8 +82,13 @@ bool UIGridLayout::internalUpdate()
|
||||||
Point topLeft = clippingRect.topLeft();
|
Point topLeft = clippingRect.topLeft();
|
||||||
|
|
||||||
int numColumns = m_numColumns;
|
int numColumns = m_numColumns;
|
||||||
if(m_flow && m_cellSize.width() > 0)
|
if(m_flow && m_cellSize.width() > 0) {
|
||||||
numColumns = clippingRect.width() / (m_cellSize.width() + m_cellSpacing);
|
numColumns = clippingRect.width() / (m_cellSize.width() + m_cellSpacing);
|
||||||
|
if(numColumns > 0) {
|
||||||
|
m_numColumns = numColumns;
|
||||||
|
m_numLines = std::ceil(widgets.size() / (float)numColumns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(numColumns <= 0)
|
if(numColumns <= 0)
|
||||||
numColumns = 1;
|
numColumns = 1;
|
||||||
|
|
|
@ -45,6 +45,10 @@ public:
|
||||||
void setFitChildren(bool enable) { m_fitChildren = enable; update(); }
|
void setFitChildren(bool enable) { m_fitChildren = enable; update(); }
|
||||||
void setFlow(bool enable) { m_flow = enable; update(); }
|
void setFlow(bool enable) { m_flow = enable; update(); }
|
||||||
|
|
||||||
|
Size getCellSize() { return m_cellSize; }
|
||||||
|
int getNumColumns() { return m_numColumns; }
|
||||||
|
int getNumLines() { return m_numLines; }
|
||||||
|
|
||||||
virtual bool isUIGridLayout() { return true; }
|
virtual bool isUIGridLayout() { return true; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -61,4 +65,3 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -180,7 +180,11 @@ void Game::processOpenContainer(int containerId, const ItemPtr& containerItem, c
|
||||||
m_containers[containerId] = container;
|
m_containers[containerId] = container;
|
||||||
container->onAddItems(items);
|
container->onAddItems(items);
|
||||||
|
|
||||||
|
// we might want to close a container here
|
||||||
|
enableBotCall();
|
||||||
container->onOpen(previousContainer);
|
container->onOpen(previousContainer);
|
||||||
|
disableBotCall();
|
||||||
|
|
||||||
if(previousContainer)
|
if(previousContainer)
|
||||||
previousContainer->onClose();
|
previousContainer->onClose();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue