MCPcopy Create free account
hub / github.com/cinder/Cinder / selectNode

Method selectNode

samples/_timeline/VisualDictionary/src/VisualDictionaryApp.cpp:198–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void VisualDictionaryApp::selectNode( list<WordNode>::iterator selectedNode )
199{
200 // have all the nodes but this one disappear
201 for( list<WordNode>::iterator nodeIt = mNodes.begin(); nodeIt != mNodes.end(); ++nodeIt ) {
202 if( nodeIt != selectedNode ) {
203 // copy this node to dying nodes and erase it from the current
204 mDyingNodes.push_back( *nodeIt );
205 timeline().apply( &mDyingNodes.back().mRadius, 0.0f, 0.5f, EaseInQuint() )
206 .finishFn( bind( &WordNode::setShouldBeDeleted, &(mDyingNodes.back()) ) ); // when you're done, mark yourself for deletion
207 }
208 }
209
210 mCurrentNode = *selectedNode;
211 mCurrentNode.setSelected();
212 mNodes.clear();
213
214 Color c = Color( mCurrentNode.mColor().r, mCurrentNode.mColor().g, mCurrentNode.mColor().b );
215 vec2 dirToCenter = ( mCurrentNode.mPos() - getWindowCenter() ) * 0.5f;
216
217 timeline().add( bind( &CenterState::addCircle, &mCenterState, mCurrentNode.getWord(), c, dirToCenter * 0.2f ), timeline().getCurrentTime() + 0.25f );
218
219 // move the selected node towards the center
220
221 timeline().apply( &mCurrentNode.mPos, getWindowCenter() + dirToCenter, 0.3f, EaseInQuint() );
222 timeline().apply( &mCurrentNode.mColor, ColorA( mCurrentNode.mColor().r, mCurrentNode.mColor().g, mCurrentNode.mColor().b, 0.0f ), 0.3f, EaseInAtan( 10 ) );
223
224 // now add all the descendants of the clicked node
225 vector<string> children( mDictionary->getDescendants( mCurrentNode.getWord() ) );
226 layoutWords( children, getLayoutRadius() );
227
228 // mark our currently highlighted node as "none"
229 mMouseOverNode = mNodes.end();
230
231 // once everything is done animating, then we can allow selections, but for now, disable them
232 mEnableSelections = false;
233 std::function<void()> cueAction = bind( &VisualDictionaryApp::enableSelections, this );
234 timeline().add( cueAction, timeline().getEndTime() - 2.0f );
235}
236
237void VisualDictionaryApp::update()
238{

Callers

nothing calls this directly

Calls 15

EaseInQuintClass · 0.85
getWindowCenterFunction · 0.85
EaseInAtanClass · 0.85
backMethod · 0.80
getDescendantsMethod · 0.80
bindFunction · 0.50
ColorFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
applyMethod · 0.45
setSelectedMethod · 0.45

Tested by

no test coverage detected