AnnotationToolbarBinder

Producer-side bridge between an AnnotatingController and the coordinator's contextual toolbar slice — the Compose successor to the View AnnotationToolbar's controller binding.

One instance per host. attach on onEnterAnnotatingMode shows the annotation bar and wires the two directions; detach on onExitAnnotatingMode hides it and releases every listener:

  • State-in: annotating-mode changes flip each tool item's isSelected (matched by its tool/variant mapping); undo-history changes flip undo/redo isEnabled through the shared UndoRedoToolbarHelper, which queries canUndo/canRedo on a background thread (with the View bar's 500ms disabled-fallback) so a busy Pdfium mutex never ANRs the main thread.

  • Action-out: ToolbarAction.ItemClicked / ToolbarAction.SubmenuChildClicked route to the controller — tool items enter/toggle annotation creation mode (re-tapping the active tool exits, unless the tap came from an open submenu, matching the View bar), the picker toggles the annotation inspector, close exits the mode, undo/redo hit the fragment's undo manager.

The item list comes from itemFactory (defaults to AnnotationToolbarItems.build, the license/config-filtered tool set). Settings changes refresh the active tool's style-indicator circle and the picker's color preview; annotation selection refreshes the picker (mirroring the View bar's updateStyleIndicatorCircleIcons / updateColorPickerIcons). Docking-position preferences stay host-owned (the mount step restores them).

Constructors

Link copied to clipboard
constructor(coordinator: ToolbarCoordinator, itemFactory: (AnnotatingController) -> PersistentList<ToolbarItem> = AnnotationToolbarItems::build)

Properties

Link copied to clipboard

Whether the bar may be dragged between docks — the Compose successor to the View ContextualToolbar.setDraggable. Takes effect immediately on an attached bar and on every future attach. Non-draggable bars hide the drag handle, freeing its capacity slot for one more item.

Link copied to clipboard

The bar's docking position — the Compose successor to setting the View AnnotationToolbar's layout-params position. null (the default) follows the persisted last-used dock (tablets default LEFT, phones TOP). Setting a value moves an attached bar immediately and pins the dock for future attach calls; the mount persists position changes like a drag would.

Functions

Link copied to clipboard
fun attach(controller: AnnotatingController)

Show the annotation bar for controller and start syncing. Calling attach twice without an intervening detach throws.

Link copied to clipboard
fun detach()

Hide the bar, release all listeners and the writer slot. Idempotent.