setDefinition method
Swaps in a new definition and repaints — used by the designer so the
live preview tracks edits. Icons are preloaded incrementally (already
decoded icons are kept, so there is no flicker).
Implementation
void setDefinition(RibbonDefinition definition) {
_def = definition;
_preloadIcons();
if (_state.activeTabIndex >= _def.tabs.length) {
_state = _state.copyWith(
activeTabIndex: (_def.tabs.length - 1).clamp(0, 9999),
);
}
repaint();
}