Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 3.93 KB

README.md

File metadata and controls

79 lines (56 loc) · 3.93 KB

ivoirax

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.ivoirax

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

ivoirax

A JavaFX piano component.

Features

  • Simple piano display component.
  • Display a configurable number of octaves.
  • Capture key press/release events.
  • Available in horizontal and vertical forms.
  • Written in pure Java 21.
  • OSGi-ready.
  • JPMS-ready.
  • ISC license.

Usage

Add a IvHorizontalPiano or IvVerticalPiano to your JavaFX layouts. Set a IvKeyEventHandlerType function to receive key events.

Key Terminology

Keys are divided into naturals (the white keys) and accidentals (the black keys), mirroring the standard names from music theory.

The reason for avoiding white/black terminology is that the piano controls allow for complete control over key colors, and so keys may not actually be "black" or "white":

colors

Events

The piano controls publish events in response to user input. The following events are published:

  • IvKeyEnter; the mouse cursor has moved over a specific key.
  • IvKeyExit; the mouse cursor is no longer over the specific key that it was previously over.
  • IvKeyPressed; the user has pressed the primary mouse button whilst over a key.
  • IvKeyReleased; the user has released the primary mouse button whilst over a key that was previously pressed.

The implementation attempts to provide sensible semantics with regard to event delivery for individual keys. For example, for a given key k, the implementation won't publish a IvKeyReleased event for k before it publishes a IvKeyPressed event for k. Due to the somewhat non-deterministic nature of input event handling between the underlying platforms, the implementation can't make many guarantees on the ordering between events for different keys. For a given key k, the implementation can largely be trusted to publish events in the following orders:

IvKeyEnter k ⇒ IvKeyPressed k ⇒ IvKeyReleased k ⇒ IvKeyExit k

IvKeyEnter k ⇒ IvKeyExit k

Demo

A demo application is included.

Ivoirax