By dave | November 11, 2020

An item type that represents a color in the Red Green Blue space, optionally also having an Alpha. Colors are represented as values between 0 and 255 for each part and optionally an additional part for Alpha.

Type information for Rgb32MenuItem

Creating a color menu item using the designer

From the add item dialog choose the RGB Color option. At this point the properties area should look as follows:

image showing the RGB editor

RGB Item Editor UI

The only RGB specific option is alpha, if this color needs an alpha channel tick the box, otherwise leave unticked.

Working with color items in code

To get and set color data as an RgbColor32 we can do the following

RgbColor32 color(255, 255, 255);

RgbColor32 clr = item.getColorData();

On any RgbColor32 structure you can get a HTML color string such as #ffffff for example.

clr.asHtmlString(buffer, bufferSize, alphaNeeded);

You can check if an menu item is using the alpha channel


Creating an RGB menu item from the CLI

To create an RGB menu item from the CLI here is a template command (options in square brackets are optional):

tcmenu create-item --parent 0 --type rgb --eeprom AUTO --name RgbName [--localonly --readonly --hide]

The structure of an RGB menu item in the EMF file is:

  "parentId": 0,
  "type": "rgbItem",
  "item": {
    "includeAlphaChannel": false,
    "name": "RgbName",
    "variableName": "RgbName",
    "id": 13,
    "eepromAddress": 14,
    "readOnly": false,
    "localOnly": false,
    "visible": true

Creating Rgb items manually

RENDERING_CALLBACK_NAME_INVOKE(fnRGBRtCall, rgbAlphaItemRenderFn, "RGB", myEepromLocation, NO_CALLBACK)
Rgb32MenuItem menuRGB(myId, fnRGBRtCall, alphaRequired, NULL);

Above we create a color selection item, the name of the callback method is fnRGBRtCall and most requests pass through to rgbAlphaItemRenderFn. The menu item name will be “RGB” and its menu changed callback is NO_CALLBACK, you could instead define a callback. Change myId to the desired ID and myEepromLocation to a suitable storage location or 0xFFFF.

Other pages within this category

comments powered by Disqus

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.

Send a message

Please use the forum for help with UI & libraries.

This message will be securely transmitted to our servers.