some window moving

This commit is contained in:
Eduardo Bart
2012-02-06 22:41:53 -02:00
parent 08a88e3842
commit 46df3c7dbe
43 changed files with 165 additions and 51 deletions

View File

@@ -19,12 +19,12 @@ Module
dofile 'uitabbar'
dofile 'uipopupmenu'
dofile 'uiwindow'
dofile 'uiminiwindow'
dofile 'uiminiwindowcontainer'
dofile 'uiitem'
dofile 'uimessagebox'
dofile 'tooltip'
--dofile 'messagebox/messagebox'
ToolTip.init()
onUnload: |

View File

@@ -12,7 +12,7 @@ function UIItem:onDragEnter(mousePos)
return true
end
function UIItem:onDragLeave(widget, mousePos)
function UIItem:onDragLeave(droppedWidget, mousePos)
if self:isVirtual() then return false end
if not self.parsed then
@@ -53,8 +53,9 @@ end
function UIItem:onHoverChange(hovered)
if self:isVirtual() then return end
if g_ui.getDraggingWidget() and self ~= g_ui.getDraggingWidget() then
if hovered then
local dragginWidget = g_ui.getDraggingWidget()
if dragginWidget and self ~= dragginWidget then
if dragginWidget:getClassName() == 'UIItem' and not dragginWidget:isVirtual() and hovered then
self:setBorderWidth(1)
else
self:setBorderWidth(0)

View File

@@ -0,0 +1,30 @@
UIMiniWindow = extends(UIWindow)
function UIMiniWindow.create()
local miniwindow = UIMiniWindow.internalCreate()
return miniwindow
end
function UIMiniWindow:onMousePress(mousePos, mouseButton)
local parent = self:getParent()
if parent:getClassName() ~= 'UIMiniWindowContainer' then
self:raise()
end
end
function UIMiniWindow:onDragEnter(mousePos)
local parent = self:getParent()
if parent:getClassName() == 'UIMiniWindowContainer' then
local containerParent = parent:getParent()
parent:removeChild(self)
containerParent:addChild(self)
end
local oldPos = self:getPosition()
self.movingReference = { x = mousePos.x - oldPos.x, y = mousePos.y - oldPos.y }
self:setPosition(oldPos)
end
function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
-- TODO: drop on other interfaces
end

View File

@@ -0,0 +1,12 @@
UIMiniWindowContainer = extends(UIWidget)
function UIMiniWindowContainer.create()
local container = UIMiniWindowContainer.internalCreate()
container:setFocusable(false)
container:setPhantom(true)
return container
end
function UIMiniWindowContainer:getClassName()
return 'UIMiniWindowContainer'
end

View File

@@ -3,6 +3,7 @@ UIWindow = extends(UIWidget)
function UIWindow.create()
local window = UIWindow.internalCreate()
window:setTextAlign(AlignTopCenter)
window:setDragable(true)
return window
end
@@ -20,6 +21,17 @@ function UIWindow:onMousePress(mousePos, mouseButton)
end
function UIWindow:onGeometryChange(oldRect, newRect)
function UIWindow:onDragEnter(mousePos)
self:breakAnchors()
self.movingReference = { x = mousePos.x - self:getX(), y = mousePos.y - self:getY() }
end
function UIWindow:onDragLeave(droppedWidget, mousePos)
-- TODO: auto detect and reconnect anchors
end
function UIWindow:onDragMove(mousePos, mouseMoved)
local pos = { x = mousePos.x - self.movingReference.x, y = mousePos.y - self.movingReference.y }
self:setPosition(pos)
self:bindRectToParent()
end