more defensive resize handling
Thanks John Blommers for the report!
This commit is contained in:
parent
12f5fa9bed
commit
ac4879bb85
25
main.lua
25
main.lua
|
@ -79,6 +79,9 @@ Search_term = nil
|
||||||
Search_text = nil
|
Search_text = nil
|
||||||
Search_backup = nil -- stuff to restore when cancelling search
|
Search_backup = nil -- stuff to restore when cancelling search
|
||||||
|
|
||||||
|
-- resize
|
||||||
|
Last_resize_time = nil
|
||||||
|
|
||||||
end -- App.initialize_globals
|
end -- App.initialize_globals
|
||||||
|
|
||||||
function App.initialize(arg)
|
function App.initialize(arg)
|
||||||
|
@ -148,8 +151,8 @@ function love.resize(w, h)
|
||||||
--? print(("Window resized to width: %d and height: %d."):format(w, h))
|
--? print(("Window resized to width: %d and height: %d."):format(w, h))
|
||||||
App.screen.width, App.screen.height = w, h
|
App.screen.width, App.screen.height = w, h
|
||||||
Line_width = math.min(40*App.width(Em), App.screen.width-50)
|
Line_width = math.min(40*App.width(Em), App.screen.width-50)
|
||||||
-- Should I Text.redraw_all() here to reset text fragments? It doesn't seem
|
Text.redraw_all()
|
||||||
-- to be needed, based on repeatedly resizing the window up and down.
|
Last_resize_time = love.timer.getTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
function initialize_font_settings(font_height)
|
function initialize_font_settings(font_height)
|
||||||
|
@ -183,6 +186,16 @@ function App.draw()
|
||||||
love.graphics.setColor(1, 1, 1)
|
love.graphics.setColor(1, 1, 1)
|
||||||
love.graphics.rectangle('fill', 0, 0, App.screen.width-1, App.screen.height-1)
|
love.graphics.rectangle('fill', 0, 0, App.screen.width-1, App.screen.height-1)
|
||||||
love.graphics.setColor(0, 0, 0)
|
love.graphics.setColor(0, 0, 0)
|
||||||
|
|
||||||
|
-- some hysteresis while resizing
|
||||||
|
if Last_resize_time then
|
||||||
|
if love.timer.getTime() - Last_resize_time < 0.1 then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
Last_resize_time = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
assert(Text.le1(Screen_top1, Cursor1))
|
assert(Text.le1(Screen_top1, Cursor1))
|
||||||
local y = Margin_top
|
local y = Margin_top
|
||||||
--? print('== draw')
|
--? print('== draw')
|
||||||
|
@ -231,6 +244,14 @@ function App.draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function App.update(dt)
|
function App.update(dt)
|
||||||
|
-- some hysteresis while resizing
|
||||||
|
if Last_resize_time then
|
||||||
|
if love.timer.getTime() - Last_resize_time < 0.1 then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
Last_resize_time = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
Drawing.update(dt)
|
Drawing.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,7 @@ scrolling:
|
||||||
persistence:
|
persistence:
|
||||||
draw a line, circle, rectangle, square, polygon, quit, restart. All the shapes you drew should still be visible.
|
draw a line, circle, rectangle, square, polygon, quit, restart. All the shapes you drew should still be visible.
|
||||||
select a point and name it, quit, restart. Name is still visible.
|
select a point and name it, quit, restart. Name is still visible.
|
||||||
|
|
||||||
|
resize:
|
||||||
|
create a file containing a long line of characters without spaces. try
|
||||||
|
resizing the window vertically and horizontally, as far as possible.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user