Skip to main content

Media Viewer Tool Strip

Overview

The Media Viewer includes a vertical tool strip along the left edge of the widget, to the left of the vertical pixel ruler. It follows an Inkscape/Photoshop-style layout where tools are square icon buttons with exclusive selection.

Layout

The Media_Widget grid places the tool strip in column 0 spanning three rows:

Col 0 Col 1 Col 2
Tool strip (row span 3) Tool options bar (col span 2)
Ruler corner Horizontal ruler
Vertical ruler Graphics view

See Media Viewer Tool Options Bar for contextual controls above the horizontal ruler.

Components

Component Location Role
MediaToolStrip_Widget Media_Widget/UI/Tools Vertical toolbar with exclusive QButtonGroup
MediaToolId Media_Widget/UI/Tools Tool identifiers (None, Select, Pen, Eraser, Smooth)
Media_KeymapActions Media_Widget/Core Keymap dispatch for tool switching and pen options
MediaToolIcons Media_Widget/UI/Tools Programmatic placeholder icons

Selection API

  • activeTool() returns the current MediaToolId (None, Select, Pen, or Eraser)
  • setActiveTool(MediaToolId) updates the checked button (or unchecks all for None)
  • activeToolChanged(MediaToolId) is emitted when the user selects or deactivates a tool
  • Clicking the active tool button again sets MediaToolId::None

Media_Widget wires activeMediaTool in state; MediaSelectToolController enables unified canvas selection only when Select is active. The Pen tool routes Ctrl+click / Alt+click line edits through MediaLine_Widget. The Eraser tool removes line vertices or mask pixels under the hover circle via MediaLine_Widget and MediaMask_Widget.

Keyboard Shortcuts

Tool switching is registered in MediaWidgetRegistration.cpp and dispatched through handleMediaKeyAction() in Media_KeymapActions.cpp via the Media_Window KeyActionAdapter. Default bindings (Inkscape-style):

Action ID Default Key
media.tool.select S
media.tool.pen P
media.tool.eraser E
media.tool.smooth Shift+S
media.tool.none Escape
media.pen.cycle_append_endpoint X (Pen tool active only)

Keyboard tool keys always activate the named tool. Escape deselects the active tool (equivalent to clicking the active toolbar button again). See Media Keymap Actions.

Adding Tools

  1. Add a value to MediaToolId
  2. Provide an icon (programmatic helper or resource file)
  3. Register the button in MediaToolStrip_Widget’s constructor via _addToolButton()