Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black buttons? #4

Open
vkichline opened this issue Nov 6, 2020 · 2 comments
Open

Black buttons? #4

vkichline opened this issue Nov 6, 2020 · 2 comments

Comments

@vkichline
Copy link

I can create, add and render ezLabels with no trouble, but not ezButtons:

  ezWindow test(50, 50, 220, 80);
  ezButton ok(110, 200, 100, 32, "OK");
  ...
  test.setTextColor(TFT_BLACK);
  test.drawString(testString, 0 , 20);
  test.push();

  ok.colors.text = WHITE;
  ok.push();

(This is your scroll demo, with a button added)
The button renders solid black, until I touch it, then it renders OK in white.
If I omit ok.colors.text = WHITE;, it always remains black, even when touched.
What am I leaving out? I expect the default behavior that renders something readable, as ezLabel does.
The code looks like the default should be black text on white background, with no change when pressed.

@ropg
Copy link
Contributor

ropg commented Nov 7, 2020

This, which I think is what you mean, which renders a default style button for me:

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

ezWindow test(50, 50, 220, 80);
ezButton ok(110, 200, 100, 32, "OK");

String testString = "This is a really freaking long sentence that is not supposed to fit in the window so we can see it scrolls...";

void setup() {
  ez.begin();

  test.spriteBuffer();
  ez.Screen.add(test);
  ez.Screen.focus();
  test.colors.outline = TFT_BLACK;

  test.setTextDatum(TL_DATUM);  
  test.setTextPadding(0);
  test.ezFont(FSSB18);
  test.spriteBuffer(test.textWidth(testString), 80);
  test.setTextColor(TFT_BLACK);
  test.drawString(testString, 0 , 20);
  test.push();

  ok.colors.text = WHITE;
  ok.push();
  
}

void loop() {
  ez.update();
}

(Note that buttons (and all widgets) add the default screen. if you do someOtherWindowOrAnyOtherWidget.add(widget) it will be taken from there and added to the new window/widget) Still need to change some examples to this: they explicitly add where that's not necessary anymore.)

@vkichline
Copy link
Author

That renders no button at all for me. What does work is:

void setup() {
  ez.begin();

  test.spriteBuffer();
  ez.Screen.add(test);
  ok.colors = { RED, BLACK, RED };
  ez.Screen.add(ok);
  ez.Screen.focus();
  test.colors.outline = TFT_BLACK;

  test.setTextDatum(TL_DATUM);
  test.setTextPadding(0);
  test.ezFont(FSSB18);
  test.spriteBuffer(test.textWidth(testString), 80);
  test.setTextColor(TFT_BLACK);
  test.drawString(testString, 0 , 20);
  test.push();
}

I don't understand when to push, and the required order of operation isn't clear. But I think all of that will go away with (excellent) docs. In leu of docs, one can see if the nomenclature is intuitive. Perhaps this is based on a framework I'm not familiar with; I'm having some difficulty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants