SettingsPanel
new SettingsPanel(parentContainer, id, title, options)
UI panel specifically designed for application settings.
The user can add new options to each of the tabs.
Parameters
parentContainer* HTMLElement | The container for this panel. |
id* string | The id to assign this panel. |
title* string | The title of this panel. |
options object | An optional dictionary of options. |
width number | Override panel’s minimum width |
heightAdjustment number | Override panel’s extra content height, to account for non-scrolling elements. |
Methods
setVisible(show)
Sets the new visibility state of this SettingsPanel.
Parameters
show* boolean | The desired visibility state. |
addTab(tabId, tabTitle, options)
Adds a new tab to the panel.
Parameters
tabId* string | id for the tab (DOM element will have an extended ID to ensure uniqueness). |
tabTitle* string | |
options object | optional parameter that allows for additional options for the tab: * tabClassName - class name for the Dom elements* minWidth - min width for the tab* index - index if the tab should be inserted instead of added at the end. |
Returns
type | description |
---|---|
boolean | True if the tab was added to the panel, false otherwise. |
removeTab(tabId)
Removes the given tab from the panel.
Parameters
tabId* string | Tab to remove. |
Returns
type | description |
---|---|
boolean | True if the tab was successfully removed, false otherwise. |
hasTab(tabId)
Returns true if a tab with given id exists.
Parameters
tabId* string | Tab id. |
Returns
type | description |
---|---|
boolean | True if the tab with given id exists, false otherwise. |
selectTab(tabId)
Makes a given tab visible and hides the other ones.
Parameters
tabId* string | Tab to select. |
Returns
type | description |
---|---|
boolean | True if the tab was selected, false otherwise. |
isTabSelected(tabId)
Returns true if the given tab is selected (visible).
Parameters
tabId* string | Tab to check. |
Returns
type | description |
---|---|
boolean | True if the tab is selected, false otherwise. |
addLabel(tabId, name)
Adds a label to the panel.
Parameters
tabId* string | Id of the tab that will contain the button. |
name* string | User facing text. |
Returns
type | description |
---|---|
object | the label control |
addCheckbox(tabId, caption, initialState, onchange, description, options)
Creates a checkbox control and adds it to a given tab.
Parameters
tabId* string | Tab to which to add a new checkbox. |
caption* string | The text associated with the checkbox. |
initialState* boolean | Initial value for the checkbox (checked or not). |
onchange* function | Callback that is called when the checkbox is changed. |
description* | |
options* object, undefined | Additional options: * insertAtIndex - index at which to insert a new checkbox* i18nOptions - additional translation options forwarded to i18n.t |
Returns
type | description |
---|---|
string | ID of a new control. |
addRow(tabId, caption, description, options)
Creates a row control and adds it to a given tab. A row only contains a caption and a descriptions
Parameters
tabId* string | Tab to which to add a new row. |
caption* string | The text associated with the row. |
description* string | Description |
options* object, undefined | Additional options: * insertAtIndex - index at which to insert a new row |
Returns
type | description |
---|---|
string | ID of a new control. |
addSlider(tabId, caption, min, max, initialValue, onchange, options)
Creates a slider control and adds it to a given tab.
Parameters
tabId* string | Tab to which to add a new slider. |
caption* string | The text associated with the slider |
min* number | Min value of the slider. |
max* number | Max value of the slider. |
initialValue* number | Initial value for the slider. |
onchange* function | Callback that is called when the slider value is changed. |
options* object, undefined | Additional options: * insertAtIndex - index at which to insert a new slider |
Returns
type | description |
---|---|
string | ID of a new control. |
addSliderV2(tabId, caption, description, min, max, initialValue, onchange, options)
Creates a row control and a slider control and adds it to a given tab. The slider does not contain the caption or the stepper.
Parameters
tabId* string | Tab to which to add a new slider. |
caption* string | The text associated with the slider |
description* string | The description for the slider |
min* number | Min value of the slider. |
max* number | Max value of the slider. |
initialValue* number | Initial value for the slider. |
onchange* function | Callback that is called when the slider value is changed. |
options* object, undefined | Additional options: * insertAtIndex - index at which to insert a new slider |
Returns
type | description |
---|---|
Array.<string> |
|
addControl(tabId, control, options)
Adds a new control to a given tab.
Parameters
tabId* string | Tab to which to add a new. |
control* object, HTMLElement | Control to add to the given tab. |
options* object, undefined | Additional parameters: * insertAtIndex - index at which to insert a new control* caption - caption for the control |
Returns
type | description |
---|---|
string | ID of the added control. |
removeCheckbox(checkboxId)
Removes a given checkbox from the settings panel.
Parameters
checkboxId* string, Autodesk.Viewing.UI.Control | Checkbox to remove. |
Returns
type | description |
---|---|
boolean | True if the checkbox was removed, false otherwise. |
removeSlider(sliderId)
Removes a given slider from the settings panel.
Parameters
sliderId* string, Autodesk.Viewing.UI.Control | Slider control to remove. |
Returns
type | description |
---|---|
boolean | True if the slider control was removed, false otherwise. |
removeControl(controlId)
Removes a given control from the settings panel.
Parameters
controlId* string, Autodesk.Viewing.UI.Control | The control ID or control instance to remove. |
Returns
type | description |
---|---|
boolean | true if the control was removed, false if the control was not removed. |
getControl(controlId)
Returns a control with a given id.
Parameters
controlId* string | Checkbox id to return. |
Returns
type | description |
---|---|
object | Control object if found, null otherwise. |
getContentSize()
Returns the width and height to be used when resizing the panel to the content.
Returns
type | description |
---|---|
object | {height: number, width: number} . |
sizeToContent(container)
Resizes panel vertically to wrap around the content. It will always leave some room at the bottom to display the toolbar.
Parameters
container* HTMLElement | parent container of settings panel |