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

Clear only the corners containing widgets. #2305

Closed
wants to merge 1 commit into from

Conversation

arthurgleckler
Copy link

Before, the whole top and bottom twenty-four vertical pixels of the screen were cleared whenever any widget appeared. Now, only the area containing the widgets that appear is cleared.

Before, the whole top and bottom twenty-four vertical pixels of the
screen were cleared whenever any widget appeared.  Now, only the area
containing the widgets that appear is cleared.
@gfwilliams
Copy link
Member

Thanks - although I am a little worried that this may end up causing screen corruption in apps. For example:

Bangle.drawWidgets = (function() {
  if (!global.WIDGETS) return;
  var w=g.getWidth(), h=g.getHeight(), pos={
	  tl:{x:0, y:0, r:0, c:0}, // if r==1, we're right->left
	  tr:{x:w-1, y:0, r:1, c:0},
	  bl:{x:0, y:h-24, r:0, c:0},
	  br:{x:w-1, y:h-24, r:1, c:0}
  }, p;
  for (var wd of WIDGETS) {
    p = pos[wd.area];
  	if (!p || wd.width == 0) continue;
  	wd.x = p.x - p.r*wd.width;
  	wd.y = p.y;
  	p.x += wd.width*(1-2*p.r);
  	p.c++;
  }
  g.reset();
  if (pos.tl.c) g.clearRect(0,0,pos.tl.x,23);
  if (pos.tr.c) g.clearRect(pos.tr.x,0,w-1,23);
  if (pos.bl.c) g.clearRect(0,h-24,pos.bl.x,h-1);
  if (pos.br.c) g.clearRect(pos.br.x,h-24,w-1,h-1);
  try { for (wd of WIDGETS) wd.draw(wd); } catch(e) {print(e);}
});


E.showMessage("Hello", "Title");
Bangle.loadWidgets();
Bangle.drawWidgets();
E.showMessage("Hello", "Title");

image

I think quite a lot more work would need to be done to test and modify apps and other functions before we can really do this.

Out of interest, why do you want it? Do you have some kind of clock that you wanted to draw partially in the widget bar?

@gfwilliams
Copy link
Member

Just to add, a slightly less contrived example is:

// new drawWidgets

g.fillRect(0,0,176,176); // or anything in the background
E.showMenu({
  "< Back": function() {},
  one : function() {},
  two : function() {},
  three : function() {},
  four : function() {},
  five : function() {},
  six : function() {},
});

@arthurgleckler
Copy link
Author

You're absolutely right. Sorry for the confusion.

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

Successfully merging this pull request may close these issues.

None yet

2 participants