PaletteObjectManager Class Reference

The PaletteObjectManager JavaScript global object. Provides access to palette list (PaletteList) and palette (Palette) objects. More...

Public Slots

Load palette lists.
PaletteListgetPaletteListByElementId (int id)
 Loads the element palette list specified by the element ID 'id' and return the corresponding PaletteList object. More...
 
PaletteListgetScenePaletteList ()
 Loads the scene palette list and return the corresponding PaletteList object. More...
 
For loaded palette lists.
int getNumPaletteLists ()
 Returns the number of loaded palette lists. More...
 
PaletteListgetPaletteListByIndex (int index)
 Returns a PaletteList object for the loaded palette list at position 'index'. More...
 
PaletteListgetPaletteListById (String id)
 Returns a PaletteList object for the loaded palette list with the specified list ID. More...
 
Palettes.
PalettegetPalette (String id)
 Returns a Palette object for the loaded palette with the specified palette ID. More...
 
bool removePaletteReferencesAndDeleteOnDisk (String id)
 

Detailed Description

The PaletteObjectManager JavaScript global object. Provides access to palette list (PaletteList) and palette (Palette) objects.

function isScenePaletteList(paletteList)
{
// Palette list with an element id of -1 are scene palette lists.
return paletteList.elementId == -1;
}
function getMyPalette()
{
// Find the first element palette list that owns a palette named "MyPalette"
var numPaletteLists = PaletteObjectManager.getNumPaletteLists();
for(var i=0; i < numPaletteLists; ++i)
{
if(isScenePaletteList(paletteList))
continue;
for(var j=0; j < paletteList.numPalettes; ++j)
{
var palette = paletteList.getPaletteByIndex(j);
if(palette.getName() == "MyPalette")
return palette;
}
}
}

Member Function Documentation

◆ getNumPaletteLists

int PaletteObjectManager::getNumPaletteLists ( )
slot

Returns the number of loaded palette lists.

Returns
Returns the number of loaded palette lists.

◆ getPalette

Palette* PaletteObjectManager::getPalette ( String  id)
slot

Returns a Palette object for the loaded palette with the specified palette ID.

Parameters
id: The ID of palette to retrieve.
Returns
Returns a Palette object for the loaded palette with the specified palette ID.

◆ getPaletteListByElementId

PaletteList* PaletteObjectManager::getPaletteListByElementId ( int  id)
slot

Loads the element palette list specified by the element ID 'id' and return the corresponding PaletteList object.

If the palette list isn't already loaded, the method will load the palette list from the disk.

Parameters
id: The element ID.
Returns
Returns the element palette list of the element which has the given ID.

◆ getPaletteListById

PaletteList* PaletteObjectManager::getPaletteListById ( String  id)
slot

Returns a PaletteList object for the loaded palette list with the specified list ID.

Parameters
id: The ID of palette list to retrieve.
Returns
Returns a PaletteList object for the loaded palette list with the specified list ID.

◆ getPaletteListByIndex

PaletteList* PaletteObjectManager::getPaletteListByIndex ( int  index)
slot

Returns a PaletteList object for the loaded palette list at position 'index'.

Parameters
index: The index of palette list to retrieve.
Returns
Returns a PaletteList object for the loaded palette list at position 'index'.

◆ getScenePaletteList

PaletteList* PaletteObjectManager::getScenePaletteList ( )
slot

Loads the scene palette list and return the corresponding PaletteList object.

If the palette list isn't already loaded, the method will load the palette list from the disk.

Returns
The scene palette list of the scene.

◆ removePaletteReferencesAndDeleteOnDisk

bool PaletteObjectManager::removePaletteReferencesAndDeleteOnDisk ( String  id)
slot

Removes a palette from the scene and all elements, and schedule the file for deletion on next save. The method needs to acquire the locks for the palette and each palette list, and throws a JavaScript exception if it can't get ownership. Returns true on success. Deleting the palette on disk may affect any drawing which link to the palette, even in other projects.

Parameters
id: The ID of palette to remove.
Returns
Returns true if the palette is successfully removed.