More fixes to miniwindow

This commit is contained in:
Henrique Santiago
2012-08-21 18:40:47 -03:00
parent f27f005757
commit 8d89d1194a
12 changed files with 39 additions and 17 deletions

View File

@@ -66,7 +66,7 @@ function UIMiniWindow:maximize(dontSave)
signalcall(self.onMaximize, self)
end
function UIMiniWindow:onSetup()
function UIMiniWindow:setup()
self:getChildById('closeButton').onClick =
function()
self:close()
@@ -126,16 +126,11 @@ function UIMiniWindow:onSetup()
end
end
if newParent and newParent:getClassName() == 'UIMiniWindowContainer' and self:isVisible() then
newParent:fitAll(self)
end
self:fitOnParent()
end
function UIMiniWindow:onVisibilityChange(visible)
local parent = self:getParent()
if visible and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
self:fitOnParent()
end
function UIMiniWindow:onDragEnter(mousePos)
@@ -227,11 +222,7 @@ end
function UIMiniWindow:onHeightChange(height)
self:setSettings({height = height})
local parent = self:getParent()
if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
self:fitOnParent()
end
function UIMiniWindow:getSettings(name)
@@ -295,6 +286,24 @@ function UIMiniWindow:disableResize()
self:getChildById('bottomResizeBorder'):disable()
end
function UIMiniWindow:fitOnParent()
local parent = self:getParent()
if self:isVisible() and parent and parent:getClassName() == 'UIMiniWindowContainer' then
parent:fitAll(self)
end
end
function UIMiniWindow:setParent(parent)
UIWidget.setParent(self, parent)
self:saveParent(parent)
self:fitOnParent()
end
function UIMiniWindow:setHeight(height)
UIWidget.setHeight(self, height)
signalcall(self.onHeightChange, self, height)
end
function UIMiniWindow:setContentHeight(height)
local contentsPanel = self:getChildById('contentsPanel')
local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
@@ -328,3 +337,8 @@ function UIMiniWindow:getMaximumHeight()
local resizeBorder = self:getChildById('bottomResizeBorder')
return resizeBorder:getMaximum()
end
function UIMiniWindow:isResizeable()
local resizeBorder = self:getChildById('bottomResizeBorder')
return resizeBorder:isVisible() and resizeBorder:isEnabled()
end

View File

@@ -35,7 +35,7 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
-- try to resize noRemoveChild
local maximumHeight = selfHeight - (sumHeight - noRemoveChild:getHeight())
if noRemoveChild:getMinimumHeight() <= maximumHeight then
if noRemoveChild:isResizeable() and noRemoveChild:getMinimumHeight() <= maximumHeight then
sumHeight = sumHeight - noRemoveChild:getHeight() + maximumHeight
addEvent(function() noRemoveChild:setHeight(maximumHeight) end)
end

View File

@@ -48,12 +48,10 @@ function UIResizeBorder:onMouseMove(mousePos, mouseMoved)
local delta = mousePos.y - self:getY() - self:getHeight()/2
newSize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum)
parent:setHeight(newSize)
signalcall(parent.onHeightChange, parent, newSize)
else
local delta = mousePos.x - self:getX() - self:getWidth()/2
newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
parent:setWidth(newSize)
signalcall(parent.onWidthChange, parent, newSize)
end
self:checkBoundary(newSize)