RibbonCanvasController class

Imperative driver that paints a RibbonDefinition into a <canvas> and translates browser pointer events into RibbonEvents — the Jaspr/web counterpart of Xojo's XjRibbon canvas control.

The RibbonToolbar component renders the <canvas> element; a controller (created in the host app or, later, inside the component lifecycle) owns the paint + interaction loop. See examples / the designer for usage.

Constructors

RibbonCanvasController({required HTMLCanvasElement canvas, required RibbonDefinition definition, required RibbonColors colors, IconRegistry icons = const IconRegistry.empty(), bool darkMode = false, int initialTabIndex = 0, bool initiallyCollapsed = false, void onEvent(RibbonEvent event)?})

Properties

darkMode → bool
final
hashCode → int
The hash code for this object.
no setterinherited
onEvent → void Function(RibbonEvent event)?
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

attach() → void
Connects to the 2D context, preloads icons, paints, and binds events.
detach() → void
Tears down listeners (call when the element leaves the DOM).
getToggleState(String tag) → bool
Current toggle/checkbox state of the item with tag.
hideContextGroup(String contextGroup) → void
Hides all contextual tabs belonging to contextGroup. If the active tab was in that group, the first standard tab becomes active.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openMenuForTag(String tag) → void
Opens the dropdown menu for the active-tab item with tag (programmatic / demo use; normally triggered by clicking the item's arrow). No-op if the item has no menu items.
repaint() → void
Recomputes layout and repaints. Cheap to call on every interaction.
resize(double cssWidth, double cssHeight) → void
Resizes the canvas (CSS pixels) and re-paints — used by the designer when its preview panel resizes.
setActiveTab(int index) → void
Switches to the tab at index (if it is currently visible).
setColors(RibbonColors colors) → void
Replaces the colour palette and repaints. Use with RibbonColors.dark / RibbonColors.light to toggle dark mode at runtime.
setDarkMode(bool enabled) → void
Convenience: toggles between RibbonColors.light and RibbonColors.dark.
setDefinition(RibbonDefinition definition) → void
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).
setIcons(IconRegistry icons) → void
Swaps the icon registry (e.g. after uploading assets in the designer), preloads the new icons, and repaints.
setToggleState(String tag, bool value) → void
Sets the toggle/checkbox state of tag and repaints.
showContextGroup(String contextGroup) → void
Shows all contextual tabs belonging to contextGroup.
toggleContextGroup(String contextGroup) → bool
Toggles contextGroup on/off and returns the new visibility.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited