implement button tooltips on top menu

This commit is contained in:
Eduardo Bart
2011-11-03 17:07:07 -02:00
parent 5988867787
commit 1b9f9bbc7d
12 changed files with 123 additions and 5 deletions

View File

@@ -18,5 +18,6 @@ Module
require 'ui'
require 'gfx'
require 'messagebox/messagebox'
require 'tooltip/tooltip'
return true

View File

@@ -0,0 +1,40 @@
ToolTip = {}
-- private variables
local currentToolTip
-- private functions
local function moveToolTip(tooltip)
local pos = getMouseCursorPos()
pos.y = pos.y + 1
local xdif = getScreenSize().width - (pos.x + tooltip:getWidth())
if xdif < 2 then
pos.x = pos.x - tooltip:getWidth() - 3
else
pos.x = pos.x + 10
end
tooltip:moveTo(pos)
end
-- public functions
function ToolTip.display(text)
ToolTip.hide()
if text then
currentToolTip = UI.loadAndDisplay('/core/tooltip/tooltip.otui', UI.root)
currentToolTip.onMouseMove = moveToolTip
local label = currentToolTip:getChildById('toolTipText')
label:setText(text)
label:resizeToText()
local size = label:getSize()
size.width = size.width + 4
size.height = size.height + 4
currentToolTip:setSize(size)
end
end
function ToolTip.hide()
if currentToolTip then
currentToolTip:destroy()
currentToolTip = nil
end
end

View File

@@ -0,0 +1,9 @@
RectPanel
background-color: #111111bb
size: 200 200
id: toolTip
focusable: false
Label
id: toolTipText
anchors.centerIn: parent