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 un-ticked.

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);

item.setColorData(color); 
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

item.isAlphaInUse();

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,
    "staticDataInRAM": false
  }
}

Creating Rgb items manually

const AnyMenuInfo minfoRGB = { "RGB", myId, myEeprom, 0, onRgbChanged };
Rgb32MenuItem menuRGB(&minfoRGB, RgbColor32(0, 0, 0), isAlphaIncluded, nextItemPtr, INFO_LOCATION_PGM);// or INFO_LOCATION_RAM

You can see above an example of how to very simply create an RGB menu item manually in code without designer. See the reference docs for more information.

Other pages within this category

comments powered by Disqus

This site uses cookies to analyse traffic, 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
X

Please use the forum for help with UI & libraries.

This message will be securely transmitted to our servers.