mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 03:24:55 +02:00
ui and graphics changes
* implement draw clipping using opengl stencil buffers * allow to create Widgets by style name with g_ui.createWidgetByStyle * styles can now have children widgets * make proper use of the isNotPathable in pathfinding * add scrollbar skin
This commit is contained in:
@@ -18,11 +18,17 @@ MainWindow
|
||||
TextList
|
||||
id: characterList
|
||||
anchors.fill: parent
|
||||
anchors.bottom: next.top
|
||||
anchors.bottom: accountStatusLabel.top
|
||||
margin-bottom: 5
|
||||
padding: 1
|
||||
focusable: false
|
||||
|
||||
VerticalScrollBar
|
||||
attached-to: characterList
|
||||
anchors.top: characterList.top
|
||||
anchors.bottom: characterList.bottom
|
||||
anchors.right: characterList.right
|
||||
|
||||
Label
|
||||
id: accountStatusLabel
|
||||
text: |-
|
||||
|
@@ -40,4 +40,5 @@ Module
|
||||
dofile 'widgets/uiwindow'
|
||||
dofile 'widgets/uimessagebox'
|
||||
dofile 'widgets/uisplitter'
|
||||
dofile 'widgets/uiscrollbar'
|
||||
|
||||
|
@@ -12,27 +12,12 @@ function displayUI(otui, parent)
|
||||
return g_ui.loadUI(otuiFilePath, parent)
|
||||
end
|
||||
|
||||
function createWidget(style, parent)
|
||||
local className = g_ui.getStyleClass(style)
|
||||
if className == "" then
|
||||
error('could not find style ' .. style)
|
||||
return
|
||||
function createWidget(stylename, parent)
|
||||
if type(parent) == 'string' then
|
||||
parent = rootWidget:recursiveGetChildById(parent)
|
||||
end
|
||||
|
||||
local class = _G[className]
|
||||
if not class then
|
||||
error('could not find widget class ' .. className)
|
||||
return
|
||||
end
|
||||
|
||||
local widget = class.create()
|
||||
if parent then
|
||||
if type(parent) == 'string' then
|
||||
parent = rootWidget:recursiveGetChildById(parent)
|
||||
end
|
||||
parent:addChild(widget)
|
||||
end
|
||||
widget:setStyle(style)
|
||||
local widget = g_ui.createWidgetFromStyle(stylename, parent)
|
||||
--widget:setStyle(stylename)
|
||||
return widget
|
||||
end
|
||||
|
||||
|
30
modules/core_lib/widgets/uiscrollbar.lua
Normal file
30
modules/core_lib/widgets/uiscrollbar.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
UIScrollBar = extends(UIWidget)
|
||||
|
||||
function UIScrollBar.create()
|
||||
local scrollbar = UIScrollBar.internalCreate()
|
||||
scrollbar:setFocusable(false)
|
||||
return scrollbar
|
||||
end
|
||||
|
||||
function UIScrollBar:onSetup()
|
||||
--self.getChildById('upButton').onClick = function() self.navigateUp() end
|
||||
--self.getChildById('upButton').onClick = function() self.navigateDown() end
|
||||
end
|
||||
|
||||
function UIScrollBar:attachWidget(widget)
|
||||
self.attachedWidget = widget
|
||||
end
|
||||
|
||||
function UIScrollBar:onStyleApply(styleName, styleNode)
|
||||
if styleNode['attached-to'] then
|
||||
local id = styleNode['attached-to']
|
||||
local parent = self:getParent()
|
||||
local widget
|
||||
if id == 'parent' then
|
||||
widget = parent
|
||||
elseif parent then
|
||||
widget = parent:getChildById(id)
|
||||
end
|
||||
self:attachWidget(widget)
|
||||
end
|
||||
end
|
@@ -50,9 +50,10 @@ function UISplitter:onMouseRelease(mousePos, mouseButton)
|
||||
end
|
||||
|
||||
function UISplitter:onStyleApply(styleName, styleNode)
|
||||
if styleNode['relative-margin'] then
|
||||
self.relativeMargin = styleNode['relative-margin']
|
||||
end
|
||||
--TODO: relative margins
|
||||
--if styleNode['relative-margin'] then
|
||||
--- self.relativeMargin = styleNode['relative-margin']
|
||||
--end
|
||||
end
|
||||
|
||||
function UISplitter:canUpdateMargin(newMargin)
|
||||
|
@@ -28,3 +28,4 @@ Module
|
||||
importStyle 'styles/comboboxes.otui'
|
||||
importStyle 'styles/spinboxes.otui'
|
||||
importStyle 'styles/messageboxes.otui'
|
||||
importStyle 'styles/scrollbars.otui'
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 197 B |
BIN
modules/core_styles/styles/images/vscrollbar.png
Normal file
BIN
modules/core_styles/styles/images/vscrollbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 350 B |
30
modules/core_styles/styles/scrollbars.otui
Normal file
30
modules/core_styles/styles/scrollbars.otui
Normal file
@@ -0,0 +1,30 @@
|
||||
VerticalScrollBar < UIScrollBar
|
||||
width: 13
|
||||
image-source: images/vscrollbar.png
|
||||
image-clip: 0 39 13 32
|
||||
image-border: 1
|
||||
|
||||
UIButton
|
||||
id: upButton
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
image-source: images/vscrollbar.png
|
||||
image-clip: 0 0 13 13
|
||||
size: 13 13
|
||||
|
||||
UIButton
|
||||
id: downButton
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: parent.right
|
||||
size: 13 13
|
||||
image-source: images/vscrollbar.png
|
||||
image-clip: 0 13 13 13
|
||||
|
||||
//UIButton
|
||||
//id: middleButton
|
||||
//anchors.top: parent.top
|
||||
//anchors.right: parent.right
|
||||
//size: 13 13
|
||||
//margin-top: 30
|
||||
//image-source: images/vscrollbar.png
|
||||
//image-clip: 0 26 13 13
|
Reference in New Issue
Block a user