Skip to content

Instantly share code, notes, and snippets.

@ZieIony
Created October 3, 2020 23:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZieIony/f1b27c0b3fe66b7a82ef881ab3c689a1 to your computer and use it in GitHub Desktop.
Save ZieIony/f1b27c0b3fe66b7a82ef881ab3c689a1 to your computer and use it in GitHub Desktop.
class Control {
void measure();
void layout(float x, float y, float width, float height);
void draw();
void dispatchMouseEvent(MouseEvent event);
}
class ControlGroup {
List<Control> children;
void measure() {
for(Control c : children)
c.measure();
// measure with children
}
void layout(float x, float y, float width, float height) {
super.layout(x, y, width, height);
for(Control c : children)
c.layout(x2, y2, width2, height2);
}
void draw() {
super.draw();
for(Control c : children)
c.draw();
}
void dispatchMouseEvent(MouseEvent event) {
// fire listeners?
for(Control c : children)
c.dispatchMouseEvent(event);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment