major UIWidget rewrite with new features

This commit is contained in:
Eduardo Bart
2012-01-10 20:13:40 -02:00
parent 044213c6cd
commit a1374baee1
83 changed files with 1990 additions and 2010 deletions

View File

@@ -5,10 +5,12 @@ Module
website: https://github.com/edubart/otclient
onLoad: |
require 'tooltip/tooltip'
require 'messagebox/messagebox'
require 'uiwidget'
require 'uibutton'
require 'uilabel'
require 'uicheckbox'
require 'uicombobox'
require 'uipopupmenu'
require 'uiprogressbar'
require 'uipopupmenu'
require 'tooltip/tooltip'
require 'messagebox/messagebox'

View File

@@ -13,7 +13,7 @@ local function moveToolTip(tooltip)
else
pos.x = pos.x + 10
end
tooltip:moveTo(pos)
tooltip:setPos(pos)
end
-- public functions
@@ -28,7 +28,7 @@ function ToolTip.display(text)
local size = label:getSize()
size.width = size.width + 4
size.height = size.height + 4
currentToolTip:resize(size)
currentToolTip:setSize(size)
moveToolTip(currentToolTip)
end
end

View File

@@ -1,4 +1,4 @@
RectPanel
Panel
background-color: #111111bb
size: 200 200
id: toolTip

View File

@@ -3,6 +3,12 @@ UICheckBox = extends(UIWidget)
function UICheckBox.create()
local checkbox = UICheckBox.internalCreate()
checkbox:setFocusable(false)
checkbox:setAlign(AlignLeft)
checkbox:setTextAlign(AlignLeft)
return checkbox
end
function UICheckBox:onMouseRelease(mousePos, mouseButton)
if self:isPressed() and self:containsPoint(mousePos) then
self:setChecked(not self:isChecked())
end
end

View File

@@ -0,0 +1,19 @@
UIProgressBar = extends(UIWidget)
function UIProgressBar.create()
local progressbar = UIProgressBar.internalCreate()
progressbar:setFocusable(false)
progressbar:setPhantom(true)
progressbar.percent = 100
return progressbar
end
function UIProgressBar:setPercent(percent)
self:setBackgroundHeight(self:getHeight())
self:setBackgroundWidth((percent * self:getWidth())/100)
self.percent = percent
end
function UIProgressBar:getPercent()
return self.percent
end

View File

@@ -0,0 +1 @@
UITabBar = extends(UIWidget)

View File

@@ -1,19 +1,19 @@
function UIWidget:setMargin(...)
local params = {...}
if #params == 1 then
self:setMarginTop(params[1])
self:setMarginRight(params[1])
self:setMarginBottom(params[1])
self:setMarginLeft(params[1])
elseif #params == 2 then
self:setMarginTop(params[1])
self:setMarginRight(params[2])
self:setMarginBottom(params[1])
self:setMarginLeft(params[2])
elseif #params == 4 then
self:setMarginTop(params[1])
self:setMarginRight(params[2])
self:setMarginBottom(params[3])
self:setMarginLeft(params[4])
end
local params = {...}
if #params == 1 then
self:setMarginTop(params[1])
self:setMarginRight(params[1])
self:setMarginBottom(params[1])
self:setMarginLeft(params[1])
elseif #params == 2 then
self:setMarginTop(params[1])
self:setMarginRight(params[2])
self:setMarginBottom(params[1])
self:setMarginLeft(params[2])
elseif #params == 4 then
self:setMarginTop(params[1])
self:setMarginRight(params[2])
self:setMarginBottom(params[3])
self:setMarginLeft(params[4])
end
end