Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion example/skin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ local checkboxTexture = love.graphics.newImage 'skin/checkbox.png'
local checkboxOff = {checkboxTexture, love.graphics.newQuad(0, 0, 51, 55, 58, 115)}
local checkboxOn = {checkboxTexture, love.graphics.newQuad(0, 55, 58, 60, 58, 115)}
local buttonTexture = love.graphics.newImage 'skin/button.png'
local buttonNormal = {buttonTexture, love.graphics.newQuad(0, 0, 69, 52, 69, 156)}
local buttonActive = {buttonTexture, love.graphics.newQuad(0, 52, 69, 52, 69, 156)}
local buttonHover = {buttonTexture, love.graphics.newQuad(0, 104, 69, 52, 69, 156)}


-- last 4 args are 9-patch t/l/b/r. These are encoded as the number of pixels from the corresponding
-- edge (e.g. "4" for "r" means "4 pixels from the right edge", or w - 4).
local buttonNormal = {buttonTexture, love.graphics.newQuad(0, 0, 69, 52, 69, 156), 25, 12, 22, 12}

local style = {
['text'] = {
['color'] = '#000000'
Expand Down
21 changes: 20 additions & 1 deletion src/nuklear_love.c
Original file line number Diff line number Diff line change
Expand Up @@ -3681,7 +3681,26 @@ static int nk_love_style_push_item(lua_State *L, struct nk_style_item *field)
}
item.type = NK_STYLE_ITEM_COLOR;
item.data.color = nk_love_checkcolor(L, -1);
} else {
} else if (lua_istable(L, -1) && lua_objlen(L, -1) == 6) {
item.type = NK_STYLE_ITEM_NINE_SLICE;

int index = lua_gettop(L);
nk_love_checkImage(L, -1, &item.data.slice.img);

lua_rawgeti(L, index, 3);
item.data.slice.l = lua_tointeger(L, -1);

lua_rawgeti(L, index, 4);
item.data.slice.t = lua_tointeger(L, -1);

lua_rawgeti(L, index, 5);
item.data.slice.r = lua_tointeger(L, -1);

lua_rawgeti(L, index, 6);
item.data.slice.b = lua_tointeger(L, -1);
lua_pop(L, 4);
}
else {
item.type = NK_STYLE_ITEM_IMAGE;
nk_love_checkImage(L, -1, &item.data.image);
}
Expand Down