allow token.tile to be a function

develop
Myk Taylor 2023-02-24 17:16:30 -08:00
parent 816371ca69
commit 1cacc526e3
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
3 changed files with 5 additions and 4 deletions

@ -44,6 +44,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## API ## API
## Lua ## Lua
- ``widgets.Label``: token ``tile`` properties can now be functions that return a value
## Removed ## Removed

@ -4704,8 +4704,8 @@ containing newlines, or a table with the following possible fields:
* ``token.tile = pen`` * ``token.tile = pen``
Specifies a pen or texture index to paint as one tile before the main part of Specifies a pen or texture index (or a function that returns a pen or texture
the token. index) to paint as one tile before the main part of the token.
* ``token.width = ...`` * ``token.width = ...``

@ -1124,8 +1124,8 @@ function render_text(obj,dc,x0,y0,pen,dpen,disabled,hpen,hovered)
if token.tile then if token.tile then
x = x + 1 x = x + 1
if dc then if dc then
local tile_pen = tonumber(token.tile) and local tile = getval(token.tile)
to_pen{tile=token.tile} or token.tile local tile_pen = tonumber(tile) and to_pen{tile=tile} or tile
dc:char(nil, tile_pen) dc:char(nil, tile_pen)
if token.width then if token.width then
dc:advance(token.width-1) dc:advance(token.width-1)