Miniwindow minimize fix, resizeborder cursor fix

This commit is contained in:
Henrique Santiago 2012-08-21 22:08:21 -03:00
parent 8d89d1194a
commit 868abf3ef6
2 changed files with 38 additions and 4 deletions

View File

@ -37,6 +37,7 @@ function UIMiniWindow:minimize(dontSave)
self:getChildById('miniwindowScrollBar'):hide() self:getChildById('miniwindowScrollBar'):hide()
self:getChildById('bottomResizeBorder'):hide() self:getChildById('bottomResizeBorder'):hide()
self:getChildById('minimizeButton'):setOn(true) self:getChildById('minimizeButton'):setOn(true)
self.maximizedHeight = self:getHeight()
self:setHeight(self.minimizedHeight) self:setHeight(self.minimizedHeight)
if not dontSave then if not dontSave then
@ -52,7 +53,7 @@ function UIMiniWindow:maximize(dontSave)
self:getChildById('miniwindowScrollBar'):show() self:getChildById('miniwindowScrollBar'):show()
self:getChildById('bottomResizeBorder'):show() self:getChildById('bottomResizeBorder'):show()
self:getChildById('minimizeButton'):setOn(false) self:getChildById('minimizeButton'):setOn(false)
self:setHeight(self:getSettings('height')) self:setHeight(self:getSettings('height') or self.maximizedHeight)
if not dontSave then if not dontSave then
self:setSettings({minimized = false}) self:setSettings({minimized = false})
@ -103,8 +104,12 @@ function UIMiniWindow:setup()
if selfSettings.minimized then if selfSettings.minimized then
self:minimize(true) self:minimize(true)
elseif selfSettings.height then else
self:setHeight(selfSettings.height) if selfSettings.height and self:isResizeable() then
self:setHeight(selfSettings.height)
elseif selfSettings.height and not self:isResizeable() then
self:eraseSettings({height = true})
end
end end
if selfSettings.closed then if selfSettings.closed then
@ -221,11 +226,14 @@ function UIMiniWindow:onFocusChange(focused)
end end
function UIMiniWindow:onHeightChange(height) function UIMiniWindow:onHeightChange(height)
self:setSettings({height = height}) if not self:isOn() then
self:setSettings({height = height})
end
self:fitOnParent() self:fitOnParent()
end end
function UIMiniWindow:getSettings(name) function UIMiniWindow:getSettings(name)
if not self.save then return nil end
local settings = g_settings.getNode('MiniWindows') local settings = g_settings.getNode('MiniWindows')
if settings then if settings then
local selfSettings = settings[self:getId()] local selfSettings = settings[self:getId()]
@ -256,6 +264,26 @@ function UIMiniWindow:setSettings(data)
g_settings.setNode('MiniWindows', settings) g_settings.setNode('MiniWindows', settings)
end end
function UIMiniWindow:eraseSettings(data)
if not self.save then return end
local settings = g_settings.getNode('MiniWindows')
if not settings then
settings = {}
end
local id = self:getId()
if not settings[id] then
settings[id] = {}
end
for key,value in pairs(data) do
settings[id][key] = nil
end
g_settings.setNode('MiniWindows', settings)
end
function UIMiniWindow:saveParent(parent) function UIMiniWindow:saveParent(parent)
local parent = self:getParent() local parent = self:getParent()
if parent then if parent then

View File

@ -17,6 +17,12 @@ function UIResizeBorder:onSetup()
end end
end end
function UIResizeBorder:onDestroy()
if self.hovering then
g_mouse.restoreCursor()
end
end
function UIResizeBorder:onHoverChange(hovered) function UIResizeBorder:onHoverChange(hovered)
if hovered then if hovered then
if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end