Browse Source

Update Font:getWidth and lovr.thread.newThread;

bjorn 6 years ago
parent
commit
33d0416a34
3 changed files with 76 additions and 9 deletions
  1. 40 2
      api/init.lua
  2. 12 3
      api/lovr/graphics/Font/getWidth.lua
  3. 24 4
      api/lovr/thread/newThread.lua

+ 40 - 2
api/init.lua

@@ -9952,9 +9952,10 @@ return {
             {
               name = "getWidth",
               summary = "Get the width of a line of text.",
-              description = "Returns the width of a string when rendered using the font, with an optional wrap.  To get the correct units returned, make sure the pixel density is set with `Font:setPixelDensity`.",
+              description = "Returns the width and line count of a string when rendered using the font, with an optional wrap.",
               key = "Font:getWidth",
               module = "lovr.graphics",
+              notes = "To get the correct units returned, make sure the pixel density is set with\n    `Font:setPixelDensity`.",
               variants = {
                 {
                   arguments = {
@@ -9975,6 +9976,11 @@ return {
                       name = "width",
                       type = "number",
                       description = "The maximum width of any line in the text."
+                    },
+                    {
+                      name = "lines",
+                      type = "number",
+                      description = "The number of lines in the wrapped text."
                     }
                   }
                 }
@@ -21225,7 +21231,7 @@ return {
             {
               arguments = {
                 {
-                  name = "body",
+                  name = "code",
                   type = "string",
                   description = "The code to run in the Thread."
                 }
@@ -21237,6 +21243,38 @@ return {
                   description = "The new Thread."
                 }
               }
+            },
+            {
+              arguments = {
+                {
+                  name = "filename",
+                  type = "string",
+                  description = "A file containing code to run in the Thread."
+                }
+              },
+              returns = {
+                {
+                  name = "thread",
+                  type = "Thread",
+                  description = "The new Thread."
+                }
+              }
+            },
+            {
+              arguments = {
+                {
+                  name = "blob",
+                  type = "Blob",
+                  description = "The code to run in the Thread."
+                }
+              },
+              returns = {
+                {
+                  name = "thread",
+                  type = "Thread",
+                  description = "The new Thread."
+                }
+              }
             }
           },
           notes = "The Thread won't start running immediately.  Use `Thread:start` to start it."

+ 12 - 3
api/lovr/graphics/Font/getWidth.lua

@@ -1,8 +1,8 @@
 return {
   summary = 'Get the width of a line of text.',
   description = [[
-    Returns the width of a string when rendered using the font, with an optional wrap.  To get the
-    correct units returned, make sure the pixel density is set with `Font:setPixelDensity`.
+    Returns the width and line count of a string when rendered using the font, with an optional
+    wrap.
   ]],
   arguments = {
     {
@@ -22,6 +22,15 @@ return {
       name = 'width',
       type = 'number',
       description = 'The maximum width of any line in the text.'
+    },
+    {
+      name = 'lines',
+      type = 'number',
+      description = 'The number of lines in the wrapped text.'
     }
-  }
+  },
+  notes = [[
+     To get the correct units returned, make sure the pixel density is set with
+    `Font:setPixelDensity`.
+  ]]
 }

+ 24 - 4
api/lovr/thread/newThread.lua

@@ -2,19 +2,39 @@ return {
   summary = 'Create a new Thread.',
   description = 'Creates a new Thread from Lua code.',
   arguments = {
-    {
-      name = 'body',
+    code = {
+      type = 'string',
+      description = 'The code to run in the Thread.'
+    },
+    filename = {
       type = 'string',
+      description = 'A file containing code to run in the Thread.'
+    },
+    blob = {
+      type = 'Blob',
       description = 'The code to run in the Thread.'
     }
   },
   returns = {
-    {
-      name = 'thread',
+    thread = {
       type = 'Thread',
       description = 'The new Thread.'
     }
   },
+  variants = {
+    {
+      arguments = { 'code' },
+      returns = { 'thread' }
+    },
+    {
+      arguments = { 'filename' },
+      returns = { 'thread' }
+    },
+    {
+      arguments = { 'blob' },
+      returns = { 'thread' }
+    }
+  },
   notes = 'The Thread won\'t start running immediately.  Use `Thread:start` to start it.',
   related = {
     'Thread:start',