How to set simpledatafield label depending of the layout ?

Hi
I notice that fields label may vary depending of the layout. For example, you can have 'Last lap distance', or 'l lap dist' if text width is smaller.

How can you achieve this in custom simpledatafield ?

  • I don't think you can do this with a simple data field, as its label is fixed at init time.

    With a complex field, you could use getObscurityFlags() in onLayout() and adjust the text appropriately, as you have complete control over rendering.

  • Yes, in a simple DF, you don't have any control of how things look other than minor control of what's returned from compute.  If you return a Number, a Number font will be used, but if it's a string for example, an alphanumeric font will be used.

  • To be clear, the font is relevant because numerical-only fonts are a lot bigger than fonts which support both numbers and letters. The practical consequence of this is that if you decide to add a suffix to your value such as "km/h", the text will suddenly be a lot smaller.

    And the font that's used isn't literally determined by the return type (e.g. Number or String), it's determined by the characters that are used to render the value. For a numerical value, a numerical font will definitely be used, but for string values, either a numerical or non-numerical font could be used.

    Each device (family) has a set of characters that are available in its numerical fonts. It used to be in a CIQ doc appendix, but that information has been removed afaik.

    While this varies from family to family, at least the following chars should always be available in numerical fonts iirc:

    0 1 2 3 4 5 6 7 8 9 - + .

    e.g. For the 935, the following chars are available in numerical fonts:

    #%+-./0123456789:°

    TL;DR if your string only contains numbers (and/or certain symbols), it will still be rendered using a numerical font.

    EDIT: this is the kind of thing where a simple data field is easier to code than a complex data field. With a simple data field, the font is automatically chosen for you, whereas for a complex data field, you would have to choose the font yourself. And if you tried to print a non-numerical character using a numerical font, the watch would display a box in place of any unavailable character.

  • No worries. Also note that for simple data fields, iirc certain chars (maybe "#") may be available in a numerical font, but the firmware will still use a non-numerical font to render them, because its algorithm for determining what font to use doesn't cover all the available chars (just the basic ones for printing plain numbers). The only way to print these chars in a numerical font (when available), would be to write a complex data field.