Core2ez icon indicating copy to clipboard operation
Core2ez copied to clipboard

Difficulty with ezLabel

Open vkichline opened this issue 5 years ago • 0 comments

I am trying to set up a form with some different attributes. Nothing's working:

#include <M5Core2.h>
#include <Core2ez.h>

ezLabel   label(20, 60, 280, 50, "10000");
int32_t   count = 0;

void setup() {
  ez.begin();
  label.ezFont(FSBI24);
  ez.Screen.add(label);
  ez.Screen.focus();

  ez.Screen.fillScreen(BLACK);
  ez.Screen.setTextColor(WHITE, BLACK);
  ez.Screen.setTextSize(1);
  ez.Screen.drawCentreString("Counter", 160, 4, 4);
  label.colors = { BLACK, WHITE, NODRAW };
  label.setTextDatum(TL_DATUM);
}

void loop() {
  label.text = String(count++, BIN);
  label.draw();
  delay(100);
}

I expect this to show a window with "Counter" centered at the top, and a left-aligned ezLabel below it in a different font. No matter what font I set, the display does not change. label.setTextDatum seems to have no effect. This source code confuses me:

void ezDisplayZone::setFreeFont(const GFXfont *f /* = NULL */) {
  if      (sprite ) sprite ->setFreeFont(f);
  else if (_parent) _parent ->setFreeFont(f);
  else              DISPLAY .setFreeFont(f);
}

...it looks like once I have a parent, all controls MUST be the same font, alignment, etc. Looks like DrawString, etc., do the same, so the attributes of widgets aren't utilized. I would really prefer to have a title a different font that the content. I may need different fonts for, example, a clock or meter with numeric-only fonts. Is there some way for Widgets to use their own properties that I've overlooked?

vkichline avatar Nov 10 '20 22:11 vkichline