mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 12:34:55 +02:00
major UIWidget rewrite with new features
This commit is contained in:
@@ -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'
|
@@ -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
|
||||
|
@@ -1,4 +1,4 @@
|
||||
RectPanel
|
||||
Panel
|
||||
background-color: #111111bb
|
||||
size: 200 200
|
||||
id: toolTip
|
||||
|
@@ -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
|
||||
|
19
modules/core_widgets/uiprogressbar.lua
Normal file
19
modules/core_widgets/uiprogressbar.lua
Normal 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
|
1
modules/core_widgets/uitabbar.lua
Normal file
1
modules/core_widgets/uitabbar.lua
Normal file
@@ -0,0 +1 @@
|
||||
UITabBar = extends(UIWidget)
|
@@ -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
|
||||
|
Reference in New Issue
Block a user