Use push/pop mechanism for cursors

This commit is contained in:
Eduardo Bart
2013-01-25 11:47:51 -02:00
parent 3a47c4f2e1
commit a144174c41
10 changed files with 45 additions and 29 deletions

View File

@@ -19,7 +19,7 @@ end
function UIResizeBorder:onDestroy()
if self.hovering then
g_mouse.restoreCursor()
g_mouse.popCursor(self.cursortype)
end
end
@@ -27,19 +27,20 @@ function UIResizeBorder:onHoverChange(hovered)
if hovered then
if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end
if self:getWidth() > self:getHeight() then
g_mouse.setCursor('vertical')
self.vertical = true
self.cursortype = 'vertical'
else
g_mouse.setCursor('horizontal')
self.vertical = false
self.cursortype = 'horizontal'
end
g_mouse.pushCursor(self.cursortype)
self.hovering = true
if not self:isPressed() then
g_effects.fadeIn(self)
end
else
if not self:isPressed() and self.hovering then
g_mouse.restoreCursor()
g_mouse.popCursor(self.cursortype)
g_effects.fadeOut(self)
self.hovering = false
end
@@ -67,7 +68,7 @@ end
function UIResizeBorder:onMouseRelease(mousePos, mouseButton)
if not self:isHovered() then
g_mouse.restoreCursor()
g_mouse.popCursor(self.cursortype)
g_effects.fadeOut(self)
self.hovering = false
end

View File

@@ -14,19 +14,20 @@ function UISplitter:onHoverChange(hovered)
if hovered and (self:canUpdateMargin(margin + 1) ~= margin or self:canUpdateMargin(margin - 1) ~= margin) then
if g_mouse.isCursorChanged() or g_mouse.isPressed() then return end
if self:getWidth() > self:getHeight() then
g_mouse.setCursor('vertical')
self.vertical = true
self.cursortype = 'vertical'
else
g_mouse.setCursor('horizontal')
self.vertical = false
self.cursortype = 'horizontal'
end
self.hovering = true
g_mouse.pushCursor(self.cursortype)
if not self:isPressed() then
g_effects.fadeIn(self)
end
else
if not self:isPressed() and self.hovering then
g_mouse.restoreCursor()
g_mouse.popCursor(self.cursortype)
g_effects.fadeOut(self)
self.hovering = false
end
@@ -67,7 +68,7 @@ end
function UISplitter:onMouseRelease(mousePos, mouseButton)
if not self:isHovered() then
g_mouse.restoreCursor()
g_mouse.popCursor(self.cursortype)
g_effects.fadeOut(self)
self.hovering = false
end

View File

@@ -222,7 +222,7 @@ function onChooseItemMouseRelease(self, mousePosition, mouseButton)
show()
g_mouse.restoreCursor()
g_mouse.popCursor('target')
self:ungrabMouse()
self:destroy()
end
@@ -235,7 +235,7 @@ function startChooseItem()
connect(mouseGrabberWidget, { onMouseRelease = onChooseItemMouseRelease })
mouseGrabberWidget:grabMouse()
g_mouse.setCursor('target-cursor')
g_mouse.pushCursor('target-cursor')
hide()
end

View File

@@ -296,7 +296,7 @@ function onMouseGrabberRelease(self, mousePosition, mouseButton)
end
selectedThing = nil
g_mouse.restoreCursor()
g_mouse.popCursor('target')
self:ungrabMouse()
return true
end
@@ -331,14 +331,14 @@ function startUseWith(thing)
selectedType = 'use'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.setCursor('target')
g_mouse.pushCursor('target')
end
function startTradeWith(thing)
selectedType = 'trade'
selectedThing = thing
mouseGrabberWidget:grabMouse()
g_mouse.setCursor('target')
g_mouse.pushCursor('target')
end
function createThingMenu(menuPosition, lookThing, useThing, creatureThing)

View File

@@ -17,7 +17,7 @@ function UIGameMap:onDragEnter(mousePos)
self.currentDragThing = thing
g_mouse.setCursor('target')
g_mouse.pushCursor('target')
self.allowNextRelease = false
return true
end
@@ -25,7 +25,7 @@ end
function UIGameMap:onDragLeave(droppedWidget, mousePos)
self.currentDragThing = nil
self.hoveredWho = nil
g_mouse.restoreCursor()
g_mouse.popCursor('target')
return true
end

View File

@@ -6,14 +6,14 @@ function UIItem:onDragEnter(mousePos)
self:setBorderWidth(1)
self.currentDragThing = item
g_mouse.setCursor('target')
g_mouse.pushCursor('target')
return true
end
function UIItem:onDragLeave(droppedWidget, mousePos)
if self:isVirtual() then return false end
self.currentDragThing = nil
g_mouse.restoreCursor()
g_mouse.popCursor('target')
self:setBorderWidth(0)
self.hoveredWho = nil
return true