Cleaned core gui files
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
--[[-- Core Module - Gui
|
||||
- Used to define new gui elements and gui event handlers
|
||||
- Common defines that are used by other modules, non of these are used internally
|
||||
@module Gui
|
||||
]]
|
||||
|
||||
local Gui = require 'expcore.gui.prototype'
|
||||
|
||||
--[[-- Draw a flow that has custom element alignments, default is right align
|
||||
--- Defines.
|
||||
-- @section defines
|
||||
|
||||
--[[-- Draw a flow used to align its child elements, default is right align
|
||||
@element Gui.alignment
|
||||
@tparam LuaGuiElement parent the parent element that the alignment flow will be added to
|
||||
@tparam LuaGuiElement parent the parent element to which the alignment will be added
|
||||
@tparam[opt='alignment'] string name the name of the alignment flow which is added
|
||||
@tparam[opt='right'] string horizontal_align the horizontal alignment of the elements in the flow
|
||||
@tparam[opt='center'] string vertical_align the vertical alignment of the elements in the flow
|
||||
@tparam[opt='alignment'] string name the name of the alignment flow
|
||||
@treturn LuaGuiElement the alignment flow that was created
|
||||
|
||||
@usage-- Adding a right align flow
|
||||
@@ -21,13 +24,13 @@ local alignment = Gui.alignment(element,'example_center_top_alignment','center',
|
||||
|
||||
]]
|
||||
Gui.alignment =
|
||||
Gui.element(function(_,parent,_,_,name)
|
||||
Gui.element(function(_,parent,name,_,_)
|
||||
return parent.add{
|
||||
name = name or 'alignment',
|
||||
type = 'flow',
|
||||
}
|
||||
end)
|
||||
:style(function(style,_,horizontal_align,vertical_align,_)
|
||||
:style(function(style,_,_,horizontal_align,vertical_align)
|
||||
style.padding = {1,2}
|
||||
style.vertical_align = vertical_align or 'center'
|
||||
style.horizontal_align = horizontal_align or 'right'
|
||||
@@ -37,18 +40,18 @@ end)
|
||||
|
||||
--[[-- Draw a scroll pane that has a table inside of it
|
||||
@element Gui.scroll_table
|
||||
@tparam LuaGuiElement parent the parent element that the scroll table will be added to
|
||||
@tparam LuaGuiElement parent the parent element to which the scroll table will be added
|
||||
@tparam number height the maximum height for the scroll pane
|
||||
@tparam number column_count the number of columns that the table will have
|
||||
@tparam[opt='scroll'] string name the name of the scroll pane that is added, the table is always called 'table'
|
||||
@tparam[opt='scroll'] string name the name of the scroll pane that is added, the table is always called "table"
|
||||
@treturn LuaGuiElement the table that was created
|
||||
|
||||
@usage-- Adding a scroll table with max height of 200 and column count of 3
|
||||
local scroll_table = Gui.scroll_table(element,'example_scroll_table',200,3)
|
||||
local scroll_table = Gui.scroll_table(element,200,3)
|
||||
|
||||
]]
|
||||
Gui.scroll_table =
|
||||
Gui.element(function(_,parent,_,column_count,name)
|
||||
Gui.element(function(_,parent,height,column_count,name)
|
||||
-- Draw the scroll
|
||||
local scroll_pane =
|
||||
parent.add{
|
||||
@@ -60,6 +63,12 @@ Gui.element(function(_,parent,_,column_count,name)
|
||||
style = 'scroll_pane_under_subheader'
|
||||
}
|
||||
|
||||
-- Set the style of the scroll pane
|
||||
local scroll_style = scroll_pane.style
|
||||
scroll_style.padding = {1,3}
|
||||
scroll_style.maximal_height = height
|
||||
scroll_style.horizontally_stretchable = true
|
||||
|
||||
-- Draw the table
|
||||
local scroll_table =
|
||||
scroll_pane.add{
|
||||
@@ -71,35 +80,27 @@ Gui.element(function(_,parent,_,column_count,name)
|
||||
-- Return the scroll table
|
||||
return scroll_table
|
||||
end)
|
||||
:style(function(style,element,height,_,_)
|
||||
-- Change the style of the scroll
|
||||
local scroll_style = element.parent.style
|
||||
scroll_style.padding = {1,3}
|
||||
scroll_style.maximal_height = height
|
||||
scroll_style.horizontally_stretchable = true
|
||||
:style{
|
||||
padding = 0,
|
||||
cell_padding = 0,
|
||||
vertical_align = 'center',
|
||||
horizontally_stretchable = true
|
||||
}
|
||||
|
||||
-- Change the style of the table
|
||||
style.padding = 0
|
||||
style.cell_padding = 0
|
||||
style.vertical_align = 'center'
|
||||
style.horizontally_stretchable = true
|
||||
end)
|
||||
|
||||
--[[-- Used to add a header to a frame, this has the option for a custom right alignment flow for buttons
|
||||
--[[-- Used to add a frame with the header style, has the option for a right alignment flow for buttons
|
||||
@element Gui.header
|
||||
@tparam LuaGuiElement parent the parent element that the header will be added to
|
||||
@tparam LuaGuiElement parent the parent element to which the header will be added
|
||||
@tparam ?string|Concepts.LocalizedString caption the caption that will be shown on the header
|
||||
@tparam[opt] ?string|Concepts.LocalizedString tooltip the tooltip that will be shown on the header
|
||||
@tparam[opt=false] boolean add_alignment when true an alignment flow will be added for buttons
|
||||
@tparam[opt='header'] string name the name of the header that is being added, the alignment is always called 'alignment'
|
||||
@tparam[opt=false] boolean add_alignment when true an alignment flow will be added to the header
|
||||
@tparam[opt='header'] string name the name of the header that is being added, the alignment is always called "alignment"
|
||||
@treturn LuaGuiElement either the header or the header alignment if add_alignment is true
|
||||
|
||||
@usage-- Adding a custom header with a label
|
||||
local header_alignment = Gui.header(
|
||||
local header = Gui.header(
|
||||
element,
|
||||
'Example Caption',
|
||||
'Example Tooltip',
|
||||
true
|
||||
'Example Tooltip'
|
||||
)
|
||||
|
||||
]]
|
||||
@@ -134,21 +135,20 @@ Gui.element(function(_,parent,caption,tooltip,add_alignment,name)
|
||||
return add_alignment and Gui.alignment(header) or header
|
||||
end)
|
||||
|
||||
--[[-- Used to add a footer to a frame, this has the option for a custom right alignment flow for buttons
|
||||
@element Gui.header
|
||||
@tparam LuaGuiElement parent the parent element that the footer will be added to
|
||||
--[[-- Used to add a frame with the footer style, has the option for a right alignment flow for buttons
|
||||
@element Gui.footer
|
||||
@tparam LuaGuiElement parent the parent element to which the footer will be added
|
||||
@tparam ?string|Concepts.LocalizedString caption the caption that will be shown on the footer
|
||||
@tparam[opt] ?string|Concepts.LocalizedString tooltip the tooltip that will be shown on the footer
|
||||
@tparam[opt=false] boolean add_alignment when true an alignment flow will be added for buttons
|
||||
@tparam[opt='footer'] string name the name of the footer that is being added, the alignment is always called 'alignment'
|
||||
@tparam[opt=false] boolean add_alignment when true an alignment flow will be added to the footer
|
||||
@tparam[opt='footer'] string name the name of the footer that is being added, the alignment is always called "alignment"
|
||||
@treturn LuaGuiElement either the footer or the footer alignment if add_alignment is true
|
||||
|
||||
@usage-- Adding a custom footer with a label
|
||||
local header_alignment = Gui.footer(
|
||||
local footer = Gui.footer(
|
||||
element,
|
||||
'Example Caption',
|
||||
'Example Tooltip',
|
||||
true
|
||||
'Example Tooltip'
|
||||
)
|
||||
|
||||
]]
|
||||
@@ -183,10 +183,10 @@ Gui.element(function(_,parent,caption,tooltip,add_alignment,name)
|
||||
return add_alignment and Gui.alignment(footer) or footer
|
||||
end)
|
||||
|
||||
--[[-- Used for left frame to add a nice boarder to them and contain them
|
||||
--[[-- Used for left frames to give them a nice boarder
|
||||
@element Gui.container
|
||||
@tparam LuaGuiElement parent the parent element that the container will be added to
|
||||
@tparam string name the name that you want to give the outer frame, often just event_trigger for a left frame
|
||||
@tparam LuaGuiElement parent the parent element to which the container will be added
|
||||
@tparam string name the name that you want to give to the outer frame, often just event_trigger
|
||||
@tparam number width the minimal width that the frame will have
|
||||
|
||||
@usage-- Adding a container as a base
|
||||
|
||||
Reference in New Issue
Block a user