Codea 2.6.3 (137) & (138)

Layout module

  • Layout module, see documentation under Display chapter
  • orientationChanged will no longer be called
  • sizeChanged will be called instead
  • Use the layout module to get safe area insets and size classes too

System font support

  • You can now use the special strings:
    • SYSTEM_FONT_REGULAR
    • Available weights:
    • THIN / LIGHT / ULTRALIGHT / REGULAR / MEDIUM / SEMIBOLD / BOLD / HEAVY / BLACK
    • In the font() function to specify use of the system font
  • This will allow you to use the iOS system font (San Francisco). This is different to using a fixed font file, as iOS will dynamically change between SF Display and SF Text at certain point sizes for readability. Use this font to mimic the system font appearance in your code
  • The exact strings and names here might change in a future beta

Fixes

  • Fixes crash in Froggy example when jumping on logs

@dave1707 it allows you to access the system font like this:

font("SYSTEM_FONT_REGULAR")
font("SYSTEM_FONT_MEDIUM")
font("SYSTEM_FONT_BLACK")
-- etc

The system font is “special” in that it’s really two fonts which are selected based on the current point size. This is how iOS renders text throughout its UI. So these strings let you mimic that behaviour.

I’m thinking of using exposing constants for these strings and putting them in the font picker properly. But for now you can use the strings directly.

Layout just gives you access to information about the safe area and size class.

So if you do this:

function sizeChanged(w, h) 
    if layout.horizontal == layout.COMPACT then 
        print("Using compact layout")
    else
        print("Using regular layout")
    end
end

It should print that you’re using compact if you invoke split view and make the Codea portion of the screen small enough (depending on iPad model).

This is how most iOS apps decide when to change their layout characteristics. So I thought exposing it to Codea would be good too.

@Simeon Can you give an example of the System Font Support. I can’t get it to work so I probably don’t understand the changes.

The Froggy example works OK. You have to do Restore Examples for the changes to take affect.

The sizeChanged works OK.

I haven’t figured out the Layout module yet. Tried split screen, but no luck yet.

PS. I guess the iPad doesn’t have any safe areas.

On safe areas it mostly applies to the iPhone X style devices and the latest iPads (for the on-screen home indicator at the bottom of the screen).

@Simeon Thanks. I was totally trying to use the THIN, BOLD, HEAVY, etc wrong. As for the safe areas, I figured it wasn’t for my iPads.

Codea 2.6.3 (138)

The OSC code seems to work. Now to try linking 2 ipad together.

PS. No trouble at all sending messages to another iPad and see them there.

@Simeon Is there a max size of the message being sent for OSC.

@dave1707 I don’t know, that’s a really good question. I’m going to have to look into the spec now.

Thank you for trying it out so fast. Is the API reasonably easy to use? Would you make any changes to it?

Here’s an example using OSC. Load this on both iPads and fill in the iPad address of the other iPad. Start both programs and slide your finger around the screen. The sprite on the other iPad will move.

@Simeon It seems really easy to use. I’ll have to play with it more to see if it needs changes. So far I don’t think so.

function setup()
    host = osc.start()  -- address of this ipad
    print(host)
    osc.host = "192.168.254.15"  -- put address of other ipad here
    x,y=0,0      
end

function draw()
    background(0)
    sprite("Planet Cute:Character Horn Girl",x,y)
end

function osc.listen(address, ...)
    arg={...}
    x=arg[1]
    y=arg[2]
end

function touched(t)
    if t.state==MOVING then
        osc.send("/",t.x,t.y)
    end
end

@Simeon Something weird going on. If I have airplane mode on and run the above code on my iPad Pro, Codea crashes. On my iPad Air, it doesn’t and prints the host iPad address.

Oh that’s an awesome little example!

Thanks for finding the crash, I’ll make sure I debug in airplane mode tonight.

@Simeon This has probably existed in all the releases, but it probably needs fixing. If I enter something in name and press print name, I print the name in between two *. If I press clear name, the name is cleared because when I press print name, there isn’t anything between the *. But the name field isn’t cleared and I have to press backspace to clear the text area. Or is there some way to clear that area that I’m overlooking.

function setup()
    parameter.text("name")
    parameter.action("print name",prt)
    parameter.action("clear name",clr)
end

function draw()
    background(40, 40, 50)    
end

function prt()
    print("*"..name.."*")
end

function clr()
    name=""
end

@Simeon - trivial issue but I find the error message produced above the new project name field, when there is an existing file of that name, is small and difficult to see against a dark background. A brighter colour may show up better.

Also, this may be just me, but I find sometimes when I have just edited something (usually inside brackets) like changing a value and trying to run it gives an error and the edit has disappeared. It’s happened several times but not consistently.

@Bri_G I agree about that, it’s a leftover from the very first version of Codea which didn’t even have complicated backgrounds.

I’ll try to reproduce the second issue by editing/running very fast. Perhaps the autosave hadn’t kicked in before the run command hit and it somehow used the old version.