about summary refs log tree commit diff stats
path: root/main.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-07 13:19:17 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-07 13:19:17 -0700
commit33ea91f8d98aa299e536d5cd5f5b021b2081a3bf (patch)
tree48260b413eeacfb4454a4bb1c504b4c407968d2b /main.lua
parentbc46cef4e53ba70dfb3c2accabab224827aae9a1 (diff)
downloadlines.love-33ea91f8d98aa299e536d5cd5f5b021b2081a3bf.tar.gz
allow the window to be resized
This still isn't ideal. On my Linux laptop for some reason the window
receives a signal to maximize itself soon after (but sometime after) the
program starts.
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/main.lua b/main.lua
index 3fb69f1..e7b6429 100644
--- a/main.lua
+++ b/main.lua
@@ -87,11 +87,14 @@ function App.initialize(arg)
 
   -- maximize window
   love.window.setMode(0, 0)  -- maximize
-  App.screen.width, App.screen.height = love.window.getMode()
+  App.screen.width, App.screen.height, App.screen.flags = love.window.getMode()
   -- shrink slightly to account for window decoration
   App.screen.width = App.screen.width-100
   App.screen.height = App.screen.height-100
-  love.window.setMode(App.screen.width, App.screen.height)
+  App.screen.flags.resizable = true
+  App.screen.flags.minwidth = math.min(App.screen.width, 200)
+  App.screen.flags.minheight = math.min(App.screen.width, 200)
+  love.window.updateMode(App.screen.width, App.screen.height, App.screen.flags)
 
   initialize_font_settings(20)
 
@@ -110,6 +113,14 @@ function App.initialize(arg)
 
 end  -- App.initialize
 
+function love.resize(w, h)
+--?   print(("Window resized to width: %d and height: %d."):format(w, h))
+  App.screen.width, App.screen.height = w, h
+  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
+  -- to be needed, based on repeatedly resizing the window up and down.
+end
+
 function initialize_font_settings(font_height)
   Font_height = font_height
   love.graphics.setFont(love.graphics.newFont(Font_height))