Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

StyleHandler

File: Rhapsodist/Core/Includes/StyleHandler.js · Namespace: StyleHandler

Overview

StyleHandler builds the CoreLookAndFeel.style object that every paint routine in Core and the Widgets reads from, and applies it to every component in the interface. It reads theme entries from Styles.data, an array you can define in your project’s App/Styles.js.

Writing a theme

A Styles.data entry sets a base palette (mode, bg, surface, raised, text, accent) plus optional per-category overrides (fonts, card, keyboard, alert window, input box, popup menu, scrollbar, toggle switch, text button, peak meter, table, and specific panel IDs). Anything you omit falls back to Rhapsodist’s built-in palette. The macro tag colours are always derived from the palette; there’s no per-category override for them. A properties[<componentId>] block lets a theme recolour one specific component without touching the whole palette.

See Styles for the full schema.

Usage

StyleHandler applies Styles.data[0] automatically once Core.js is included, so a project gets a working theme with no extra call.

Call StyleHandler.setStyle(index) to switch themes at runtime, for example from a menu built with StyleHandler.getStyleNames().

Public API

FunctionDescriptionReturns
getStyleNames()Returns the id of every entry in Styles.data.Array
setStyle(index: number)Applies Styles.data[index]. Runs automatically for index 0 as soon as StyleHandler.js loads, so the first theme is active before anything else in Core paints. There’s no built-in UI for switching themes at runtime beyond calling this directly.—

Internal Reference

FunctionDescriptionReturns
setPalette(properties: JSON)Builds the base palette object (mode, surface0, surface1, bg, raised, text, accent) from a Styles.data entry and stores it on CoreLookAndFeel.style.palette.—
setLookAndFeelStyle(properties: JSON)Builds the rest of CoreLookAndFeel.style (fonts, alert window, input box, popup menu, scrollbar, toggle switch, text button, macro tag, peak meter, table, keyboard) from palette plus any per-category overrides (the macro tag colours are derived from palette alone, with no override), and sets the value-popup style via Content.setValuePopupData().—
setComponentColours(properties: JSON)Applies colours to every component in the interface: generic per-type colours, specific per-ID overrides, pnlCard* overrides, then any properties[componentId] block from the theme, before repainting each component.—
setFloatingTileColours(component: ScriptObject, contentType: string)Sets colours on a ScriptFloatingTile based on its ContentType (e.g. MatrixPeakMeter, PresetBrowser, MidiLearnPanel). Called from setComponentColours().—