|
|
@ -124,6 +124,10 @@ Container::~Container() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Container::update(Screen *screen) { |
|
|
|
void Container::update(Screen *screen) { |
|
|
|
|
|
|
|
if (!firstUpdateCompleted_) { |
|
|
|
|
|
|
|
offsetChildren(0, y_); |
|
|
|
|
|
|
|
firstUpdateCompleted_ = true; |
|
|
|
|
|
|
|
} |
|
|
|
for (int i = 0; i < componentCount_; i++) { |
|
|
|
for (int i = 0; i < componentCount_; i++) { |
|
|
|
components_[i]->update(screen); |
|
|
|
components_[i]->update(screen); |
|
|
|
} |
|
|
|
} |
|
|
@ -155,10 +159,33 @@ void Container::add(Component *component, int8_t x, int8_t y) { |
|
|
|
componentsLength_ = newComponentsLength; |
|
|
|
componentsLength_ = newComponentsLength; |
|
|
|
} |
|
|
|
} |
|
|
|
components_[componentCount_++] = component; |
|
|
|
components_[componentCount_++] = component; |
|
|
|
|
|
|
|
if (firstUpdateCompleted_) { |
|
|
|
|
|
|
|
// TODO: if the first update has already completed we need to update
|
|
|
|
|
|
|
|
// incoming components locations as they are added
|
|
|
|
|
|
|
|
} |
|
|
|
component->setLocation(x, y); |
|
|
|
component->setLocation(x, y); |
|
|
|
component->repaint(); |
|
|
|
component->repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Container::offsetChildren(int x, int y) { |
|
|
|
|
|
|
|
for (int i = 0; i < componentCount_; i++) { |
|
|
|
|
|
|
|
Component *c = components_[i]; |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Serial.print("Moving "); |
|
|
|
|
|
|
|
Serial.print(c->description()); |
|
|
|
|
|
|
|
Serial.print(" from "); |
|
|
|
|
|
|
|
Serial.print(c->x(), DEC); |
|
|
|
|
|
|
|
Serial.print(", "); |
|
|
|
|
|
|
|
Serial.print(c->y(), DEC); |
|
|
|
|
|
|
|
Serial.print(" to "); |
|
|
|
|
|
|
|
Serial.print(c->x() + x, DEC); |
|
|
|
|
|
|
|
Serial.print(", "); |
|
|
|
|
|
|
|
Serial.println(c->y() + y, DEC); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
c->setLocation(c->x() + x, c->y() + y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Component *Container::nextFocusHolder(Component *focusHolder, bool reverse) { |
|
|
|
Component *Container::nextFocusHolder(Component *focusHolder, bool reverse) { |
|
|
|
bool focusHolderFound = false; |
|
|
|
bool focusHolderFound = false; |
|
|
|
return nextFocusHolder(focusHolder, reverse, &focusHolderFound); |
|
|
|
return nextFocusHolder(focusHolder, reverse, &focusHolderFound); |
|
|
@ -437,14 +464,6 @@ ScrollContainer::~ScrollContainer() { |
|
|
|
free(clearLine); |
|
|
|
free(clearLine); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ScrollContainer::add(Component *component, int8_t x, int8_t y) { |
|
|
|
|
|
|
|
Container::add(component, x, y); |
|
|
|
|
|
|
|
if (firstUpdateCompleted_) { |
|
|
|
|
|
|
|
// TODO: if the first update has already completed we need to update
|
|
|
|
|
|
|
|
// incoming components locations as they are added
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ScrollContainer::dirty() { |
|
|
|
bool ScrollContainer::dirty() { |
|
|
|
if (Container::dirty()) { |
|
|
|
if (Container::dirty()) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -452,32 +471,6 @@ bool ScrollContainer::dirty() { |
|
|
|
return scrollNeeded(); |
|
|
|
return scrollNeeded(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ScrollContainer::update(Screen *screen) { |
|
|
|
|
|
|
|
if (!firstUpdateCompleted_) { |
|
|
|
|
|
|
|
offsetChildren(0, y_); |
|
|
|
|
|
|
|
firstUpdateCompleted_ = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScrollContainer::offsetChildren(int x, int y) { |
|
|
|
|
|
|
|
for (int i = 0; i < componentCount_; i++) { |
|
|
|
|
|
|
|
Component *c = components_[i]; |
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Serial.print("Moving "); |
|
|
|
|
|
|
|
Serial.print(c->description()); |
|
|
|
|
|
|
|
Serial.print(" from "); |
|
|
|
|
|
|
|
Serial.print(c->x(), DEC); |
|
|
|
|
|
|
|
Serial.print(", "); |
|
|
|
|
|
|
|
Serial.print(c->y(), DEC); |
|
|
|
|
|
|
|
Serial.print(" to "); |
|
|
|
|
|
|
|
Serial.print(c->x() + x, DEC); |
|
|
|
|
|
|
|
Serial.print(", "); |
|
|
|
|
|
|
|
Serial.println(c->y() + y, DEC); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
c->setLocation(c->x() + x, c->y() + y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ScrollContainer::scrollNeeded() { |
|
|
|
bool ScrollContainer::scrollNeeded() { |
|
|
|
// see if the focus holder has changed since the last check
|
|
|
|
// see if the focus holder has changed since the last check
|
|
|
|
Component *focusHolder = screen_->focusHolder(); |
|
|
|
Component *focusHolder = screen_->focusHolder(); |
|
|
|