Fixed issue #79 and some miniwindows bugs
This commit is contained in:
parent
ea4dd2f8e6
commit
f27f005757
|
@ -37,7 +37,6 @@ function UIMiniWindow:minimize(dontSave)
|
|||
self:getChildById('miniwindowScrollBar'):hide()
|
||||
self:getChildById('bottomResizeBorder'):hide()
|
||||
self:getChildById('minimizeButton'):setOn(true)
|
||||
self.savedHeight = self:getHeight()
|
||||
self:setHeight(self.minimizedHeight)
|
||||
|
||||
if not dontSave then
|
||||
|
@ -53,12 +52,17 @@ function UIMiniWindow:maximize(dontSave)
|
|||
self:getChildById('miniwindowScrollBar'):show()
|
||||
self:getChildById('bottomResizeBorder'):show()
|
||||
self:getChildById('minimizeButton'):setOn(false)
|
||||
self:setHeight(self.savedHeight)
|
||||
self:setHeight(self:getSettings('height'))
|
||||
|
||||
if not dontSave then
|
||||
self:setSettings({minimized = false})
|
||||
end
|
||||
|
||||
local parent = self:getParent()
|
||||
if parent and parent:getClassName() == 'UIMiniWindowContainer' then
|
||||
parent:fitAll(self)
|
||||
end
|
||||
|
||||
signalcall(self.onMaximize, self)
|
||||
end
|
||||
|
||||
|
@ -88,7 +92,6 @@ function UIMiniWindow:onSetup()
|
|||
if parent then
|
||||
if parent:getClassName() == 'UIMiniWindowContainer' and selfSettings.index and parent:isOn() then
|
||||
self.miniIndex = selfSettings.index
|
||||
--addEvent(function() parent:scheduleInsert(self, selfSettings.index) end)
|
||||
parent:scheduleInsert(self, selfSettings.index)
|
||||
elseif selfSettings.position then
|
||||
self:setParent(parent)
|
||||
|
@ -100,15 +103,13 @@ function UIMiniWindow:onSetup()
|
|||
|
||||
if selfSettings.minimized then
|
||||
self:minimize(true)
|
||||
elseif selfSettings.height then
|
||||
self:setHeight(selfSettings.height)
|
||||
end
|
||||
|
||||
if selfSettings.closed then
|
||||
self:close(true)
|
||||
end
|
||||
|
||||
if selfSettings.height then
|
||||
self:setHeight(selfSettings.height)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -233,6 +234,17 @@ function UIMiniWindow:onHeightChange(height)
|
|||
end
|
||||
end
|
||||
|
||||
function UIMiniWindow:getSettings(name)
|
||||
local settings = g_settings.getNode('MiniWindows')
|
||||
if settings then
|
||||
local selfSettings = settings[self:getId()]
|
||||
if selfSettings then
|
||||
return selfSettings[name]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function UIMiniWindow:setSettings(data)
|
||||
if not self.save then return end
|
||||
|
||||
|
@ -286,7 +298,9 @@ end
|
|||
function UIMiniWindow:setContentHeight(height)
|
||||
local contentsPanel = self:getChildById('contentsPanel')
|
||||
local minHeight = contentsPanel:getMarginTop() + contentsPanel:getMarginBottom() + contentsPanel:getPaddingTop() + contentsPanel:getPaddingBottom()
|
||||
self:setHeight(minHeight + height)
|
||||
|
||||
local resizeBorder = self:getChildById('bottomResizeBorder')
|
||||
resizeBorder:setParentSize(minHeight + height)
|
||||
end
|
||||
|
||||
function UIMiniWindow:setContentMinimumHeight(height)
|
||||
|
|
|
@ -40,6 +40,7 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
|
|||
addEvent(function() noRemoveChild:setHeight(maximumHeight) end)
|
||||
end
|
||||
|
||||
-- TODO: most likely, minimum and maximum size are not set yet, so code above might not work properly. onSetup event
|
||||
-- TODO: try to resize another widget?
|
||||
-- TODO: try to find another panel?
|
||||
|
||||
|
|
|
@ -9,6 +9,14 @@ function UIResizeBorder.create()
|
|||
return resizeborder
|
||||
end
|
||||
|
||||
function UIResizeBorder:onSetup()
|
||||
if self:getWidth() > self:getHeight() then
|
||||
self.vertical = true
|
||||
else
|
||||
self.vertical = false
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:onHoverChange(hovered)
|
||||
if hovered then
|
||||
if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end
|
||||
|
@ -34,19 +42,21 @@ end
|
|||
|
||||
function UIResizeBorder:onMouseMove(mousePos, mouseMoved)
|
||||
if self:isPressed() then
|
||||
local parent = self:getParent()
|
||||
local newSize = 0
|
||||
if self.vertical then
|
||||
local delta = mousePos.y - self:getY() - self:getHeight()/2
|
||||
local parent = self:getParent()
|
||||
local newSize = math.min(math.max(parent:getHeight() + delta, self.minimum), self.maximum)
|
||||
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
|
||||
local parent = self:getParent()
|
||||
local newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
|
||||
newSize = math.min(math.max(parent:getWidth() + delta, self.minimum), self.maximum)
|
||||
parent:setWidth(newSize)
|
||||
signalcall(parent.onWidthChange, parent, newSize)
|
||||
end
|
||||
|
||||
self:checkBoundary(newSize)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -77,27 +87,41 @@ end
|
|||
|
||||
function UIResizeBorder:setMaximum(maximum)
|
||||
self.maximum = 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
|
||||
self:checkBoundary()
|
||||
end
|
||||
|
||||
function UIResizeBorder:setMinimum(minimum)
|
||||
self.minimum = 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
|
||||
self:checkBoundary()
|
||||
end
|
||||
|
||||
function UIResizeBorder:getMaximum() return self.maximum end
|
||||
function UIResizeBorder:getMinimum() return self.minimum end
|
||||
|
||||
function UIResizeBorder:setParentSize(size)
|
||||
local parent = self:getParent()
|
||||
if self.vertical then
|
||||
parent:setHeight(size)
|
||||
else
|
||||
parent:setWidth(size)
|
||||
end
|
||||
self:checkBoundary(size)
|
||||
end
|
||||
|
||||
function UIResizeBorder:getParentSize()
|
||||
local parent = self:getParent()
|
||||
if self.vertical then
|
||||
return parent:getHeight()
|
||||
else
|
||||
return parent:getWidth()
|
||||
end
|
||||
end
|
||||
|
||||
function UIResizeBorder:checkBoundary(size)
|
||||
size = size or self:getParentSize()
|
||||
if self.maximum == self.minimum and size == self.maximum then
|
||||
self:hide()
|
||||
else
|
||||
self:show()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,10 +7,6 @@ LoginServerUpdateNeeded = 30
|
|||
LoginServerCharacterList = 100
|
||||
|
||||
function ProtocolLogin:login(host, port, accountName, accountPassword)
|
||||
if string.len(accountName) == 0 or string.len(accountPassword) == 0 then
|
||||
signalcall(self.onError, self, tr("You must enter an account name and password."))
|
||||
return
|
||||
end
|
||||
if string.len(host) == 0 or port == nil or port == 0 then
|
||||
signalcall(self.onError, self, tr("You must enter a valid server address and port."))
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue