-
Notifications
You must be signed in to change notification settings - Fork 1
Styling
theming is usually handled by the internal GNUI style system. but if you so wish to use a custom style, welcome
there are two ways to style a box,
- Directly setting a Nineslice onto a box.
- Using a Theme to style a box.
make a nineslice and set it onto a box.
box:setNineslice(nineslice)
example:
local GNUI = require"GNUI.main"
local atlasTexture = textures["model.atlas"]
local nineslice = GNUI.newNineslice(
atlasTexture,
1,1,5,5, -- UVs (Optional)
2,2,2,2 -- Nineslice Border (Optional)
1,1,1,1 -- Expand (Optional)
)the optional parameters are not required when using the API, simply not filling them will leave them as 0, unless its the UVs, it will automatically get them from the texture dimensions.
Themes in GNUI are very WIP by the time you are reading this, but in a nutshell, they are a way to standardize the look and feel of elements in GNUI.
by default, you dont have to play around with themes, because the default ones are automatically set for you.
Themes work in GNUI by reading the first script in GNUI/Themes/ folder. which is the gntheme.lua file by default.
Looking inside, youll see its a table with functions like the following, this is the data structure of a theme.

the green texts (table) are the classes in which the themes get applied to. and the red ones are the Style Variants, functions that style the class in question.
youll notice certain styles for all classes repeat, its because they are a special type of stying, which we will explore in the next section.
as of now, there are 2 special styles tags. Default and All
- this style gets applied to the class AUTOMATICALLY if no variant is given in
Button.new().
- this style also get applied to the class, but its not affected by any variant in
Button.new(). it will get applied regardless of the variant.
- no style will be applied to the class.
any other style tag is custom, meaning they are applied by the variant parameters in instantiation.
if you want a certain style to be included into the default GNUI, hit me up on discord and ill add it if worthy (most likely yes)
example.
local Button = require"GNUI.element.button"
-- invisible box
local btn1 = Button.new(screen,"none")
-- Both of these are the same
local btn2 = Button.new(screen,"Default")
local btn3 = Button.new(screen,)
Discord: @gn8.