diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 14:48:59 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2023-04-01 16:12:55 -0700 |
commit | 4ab901c92e11f47828bc7f5f16d8d2250812d53f (patch) | |
tree | 288dcf758b377c9b8586a9fc4bd7706d3a91e1f4 /log_browser.lua | |
parent | fd2e5acb464c439325455acb63683d4fa316497c (diff) | |
download | text.love-4ab901c92e11f47828bc7f5f16d8d2250812d53f.tar.gz |
get rid of to_text
I've been misunderstanding what Text objects are. They can render a lot of text with a given line height, word wrap, colors in various places. And I've been creating one for every word :facepalm: Unwinding this will take some time. This is just a first baby step for ad hoc text objects. Turns out I don't need to convert to Text to get something's rendered width, just the Font can do that. Thanks to the LÖVE Discord for educating me: https://discord.com/channels/329400828920070144/330089431379869708/1091535487333826580
Diffstat (limited to 'log_browser.lua')
-rw-r--r-- | log_browser.lua | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/log_browser.lua b/log_browser.lua index 46d84c0..b128ab7 100644 --- a/log_browser.lua +++ b/log_browser.lua @@ -98,21 +98,20 @@ function log_browser.draw(State) local xright = render_stack_right_margin(State, line_index, line, y) if line.section_name then App.color(Section_border_color) - local section_text = to_text(line.section_name) if line.section_begin then local sectiony = y+Section_border_padding_vertical love.graphics.line(xleft,sectiony, xleft,y+State.line_height) love.graphics.line(xright,sectiony, xright,y+State.line_height) love.graphics.line(xleft,sectiony, xleft+50-2,sectiony) - love.graphics.draw(section_text, xleft+50,y) - love.graphics.line(xleft+50+App.width(section_text)+2,sectiony, xright,sectiony) + love.graphics.print(line.section_name, xleft+50,y) + love.graphics.line(xleft+50+App.width(line.section_name)+2,sectiony, xright,sectiony) else assert(line.section_end) local sectiony = y+State.line_height-Section_border_padding_vertical love.graphics.line(xleft,y, xleft,sectiony) love.graphics.line(xright,y, xright,sectiony) love.graphics.line(xleft,sectiony, xleft+50-2,sectiony) - love.graphics.draw(section_text, xleft+50,y) - love.graphics.line(xleft+50+App.width(section_text)+2,sectiony, xright,sectiony) + love.graphics.print(line.section_name, xleft+50,y) + love.graphics.line(xleft+50+App.width(line.section_name)+2,sectiony, xright,sectiony) end else if type(line.data) == 'string' then @@ -148,7 +147,7 @@ function render_stack_left_margin(State, line_index, line, y) love.graphics.print(line.section_stack[i].name, x+State.font_height+5, y+5, --[[vertically]] math.pi/2) end if y > App.screen.height-log_browser.height(State, line_index) then - love.graphics.print(line.section_stack[i].name, x+State.font_height+5, App.screen.height-App.width(to_text(line.section_stack[i].name))-5, --[[vertically]] math.pi/2) + love.graphics.print(line.section_stack[i].name, x+State.font_height+5, App.screen.height-App.width(line.section_stack[i].name)-5, --[[vertically]] math.pi/2) end end return log_browser.left_margin(State, line) @@ -163,7 +162,7 @@ function render_stack_right_margin(State, line_index, line, y) love.graphics.print(line.section_stack[i].name, x, y+5, --[[vertically]] math.pi/2) end if y > App.screen.height-log_browser.height(State, line_index) then - love.graphics.print(line.section_stack[i].name, x, App.screen.height-App.width(to_text(line.section_stack[i].name))-5, --[[vertically]] math.pi/2) + love.graphics.print(line.section_stack[i].name, x, App.screen.height-App.width(line.section_stack[i].name)-5, --[[vertically]] math.pi/2) end end return log_browser.right_margin(State, line) |