MCPcopy Create free account
hub / github.com/audacity/audacity / SetKey

Method SetKey

src/widgets/KeyView.cpp:354–390  ·  view source on GitHub ↗

Sets the key for the given index

Source from the content-addressed store, hash-verified

352// Sets the key for the given index
353//
354bool
355KeyView::SetKey(int index, const NormalizedKeyString & key)
356{
357 // Make sure index is valid
358 if (index < 0 || index >= (int) mNodes.size())
359 {
360 wxASSERT(false);
361 return false;
362 }
363
364 // Cache the node
365 KeyNode & node = mNodes[index];
366
367 // Do not allow setting keys on branches
368 if (node.isparent)
369 {
370 return false;
371 }
372
373 // Set the NEW key
374 node.key = key;
375
376 // Check to see if the key column needs to be expanded
377 int x, y;
378 GetTextExtent(node.key.Display(), &x, &y);
379 if (x > mKeyWidth || y > mLineHeight)
380 {
381 // New key is wider than column so recalc extents (will refresh view)
382 RecalcExtents();
383 return true;
384 }
385
386 // Refresh the view lines
387 RefreshAll();
388
389 return true;
390}
391
392//
393// Sets the key for the given name

Callers 1

SetKeyForSelectedMethod · 0.80

Calls 2

DisplayMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected