void ofxTLPage::removeTrack(ofxTLTrack* track){ if(track == NULL){ ofLogError() << "ofxTLPage::removeTrack -- removing null track!" << endl; return; } for(int i = 0; i < trackList.size(); i++){ if(trackList[i] == track){ trackList.erase(trackList.begin() + i); break; } } for(int i = 0; i < headers.size(); i++){ if(headers[i]->getTrack() == track){ delete headers[i]; headers.erase(headers.begin()+i); tracks.erase(track->getName()); if(track == focusedTrack){ focusedTrack->lostFocus(); focusedTrack = NULL; } //TODO smart pointers this won't be necessary if(track->getCreatedByTimeline()){ delete track; } recalculateHeight(); return; } } ofLogError() << "ofxTLPage::removeTrack -- track named " << track->getName() << " not found!" << endl; }
void ofxTLPage::setContainer(ofVec2f offset, float width){ elementContainerRect.x = offset.x; elementContainerRect.y = offset.y; //containerOffset = offset; //containerWidth = width; elementContainerRect.width = width; recalculateHeight(); }
void ofxTLPage::collapseAllTracks(bool excludeFocusTrack){ for(int i = 0; i < headers.size(); i++){ if(!excludeFocusTrack || focusedTrack != headers[i]->getTrack()){ headers[i]->collapseTrack(); } } recalculateHeight(); }
void ofxTLPage::bringTrackToBottom(ofxTLTrack* track){ for(int i = 0; i < headers.size(); i++){ if(track == headers[i]->getTrack()){ ofxTLTrackHeader* header = headers[i]; for(int j = i; j < headers.size()-1; j++){ headers[j] = headers[j+1]; } headers[headers.size()-1] = header; recalculateHeight(); return; } } ofLogError("ofxTLPage::bringTrackToBottom -- track " + track->getName() + " not found"); }
void ofxTLPage::bringTrackToPos(ofxTLTrack* track, int pos){ for(int i = 0; i < headers.size(); i++){ if(track == headers[i]->getTrack()){ ofxTLTrackHeader* header = headers[i]; for(int j = i; j > pos; j--){ headers[j] = headers[j-1]; } headers[pos] = header; recalculateHeight(); return; } } ofLogError("ofxTLPage::bringTrackToPos -- track " + track->getName() + " not found"); }
void ItemContainer::logic() { if (!isVisible()) return; gcn::Widget::logic(); setEnabled(mInventory->getNumberOfSlotsUsed() != 0); int i = mInventory->getLastUsedSlot(); if (i != mMaxItems) { mMaxItems = i; recalculateHeight(); } }
void ofxTLPage::evenlyDistributeTrackHeights(){ float addedHeightPerTrack = 0; if(!headersAreMinimal)addedHeightPerTrack += headerHeight; if(!footersAreHidden) addedHeightPerTrack += FOOTER_HEIGHT; if(heightBeforeCollapse == 0){ heightBeforeCollapse = trackContainerRect.height - addedHeightPerTrack*headers.size(); } float heightPerTrack = heightBeforeCollapse / headers.size(); for(int i = 0; i < headers.size(); i++){ ofRectangle trackRect = headers[i]->getTrack()->getDrawRect(); trackRect.height = heightPerTrack; headers[i]->getTrack()->setDrawRect(trackRect); } if(heightBeforeCollapse != 0){ recalculateHeight(); heightBeforeCollapse = 0; } cout << endl; }
void ofxTLPage::expandFocusedTrack(){ if(focusedTrack == NULL){ return; } float staticSpacePerTrack = 0; if(!headersAreMinimal)staticSpacePerTrack += headerHeight; if(!footersAreHidden) staticSpacePerTrack += FOOTER_HEIGHT; float newHeight = trackContainerRect.height - headers.size()*staticSpacePerTrack; ofRectangle trackRect = focusedTrack->getDrawRect(); trackRect.height = newHeight; focusedTrack->setDrawRect(trackRect); for(int i = 0; i < headers.size(); i++){ if(headers[i]->getTrack() != focusedTrack){ headers[i]->collapseTrack(); } } recalculateHeight(); }
void ofxTLPage::setHeaderHeight(float newHeaderHeight){ headerHeight = newHeaderHeight; recalculateHeight(); }
void ofxTLPage::collapseAllTracks(){ for(int i = 0; i < headers.size(); i++){ headers[i]->collapseTrack(); } recalculateHeight(); }
void ofxTLPage::hideFooters(bool hide){ if(hide != footersAreHidden){ footersAreHidden = hide; recalculateHeight(); } }
void ofxTLPage::setMinimalHeaders(bool minimal){ if(minimal != headersAreMinimal){ headersAreMinimal = minimal; recalculateHeight(); } }
void ItemContainer::widgetResized(const gcn::Event &event) { recalculateHeight(); }
void ofxTLPage::setContainer(ofVec2f offset, float width) { containerOffset = offset; containerWidth = width; recalculateHeight(); }
void ofxTLPage::collapseAllElements(){ for(int i = 0; i < headers.size(); i++){ headers[i]->collapseElement(); } recalculateHeight(); }