Module vlib.vTable

vTable, or ViewBuilder Table, is a class that makes it easy to create a virtual "table widget" using the Renoise ViewBuilder API.

Functions

set_data (data, preserve_pos) set the dataprovider, while adding an internal id
assign_members (cell, defs, col_key, reserved_keys) assign additional properties to cells - TODO @param reserved_keys (table) skip reserved keys (col_width, etc.)
build () (re)build the actual view, using the current column/row count
cell_factory (ctype, cell_elm) produce a cell of the given type
remove_table () remove existing viewbuilder before rebuilding the table (using the maximum possible table size)
get_cell (row_idx, col_idx) retrieve direct reference to cell object
get_item_by_key (key, val) obtain an item by a specific key/value
get_content_width () get computed width of table, all (absolute) column widths put together
set_num_rows (num) set visible column count, rebuild if needed
get_col_type (idx)
get_col_key (idx) retrieve the key of a column definition
get_col_idx (key) retrieve the idx of a column definition by its key
get_col_width (idx, abs_only) retrieve the absolute width in pixels for a given column
compute_auto_width (idx) compute automatic width of column
get_col_margin (idx)
get_header_data (key)
set_header_data (key, val)
get_header_ctype (key) retrieve a header type by key
set_column_def (key, member, value) specify a single column definition by it's key
autosize_to_contents () call this whenever something has changed that will affect the computed height of the table - if resized (changed size), the external resize handler is invoked, giving the host application a chance to respond

Tables

self.header_cells (table>vTableCell) header cells (by key)
self.cells (table>row>col:vTableCell) table cells accessed like this: cells[row][col]

Fields

self.header_defs (table>table) header definition (by key) Required values: vTable.HEADER_DEF_KEYS + any cell members
self.column_defs (table>table>table) columns definition Required keys: vTable.COLUMN_DEF_KEYS
self.data (table>row>col:variant) the data an extra property, _id, is added runtime
self.show_header (bool) show_header
self.scrollbar_width (int) TODO pass as separate constructor args
self.autosize (bool) automatically resize to fit number of rows
self.num_rows (int) number of visible rows
self.row_height (int) row height
self.header_height (int) header height
self.table_style (string) styles
self.row_offset (int) offset, vertical position in table use set_row_offset() to synchronize with scrollbar
self.on_update_complete (function) define this to perform post-update actions, such as custom row highlighting, tooltips etc.
self.on_resize (function) when table changed size (automatic resize)
self.scrollbar (vScrollbar)
self.rebuild_requested (bool) when table dimensions have changed this will rebuild the table as part of the next update
self.update_requested (bool) TODO lazy updates
self.uid (string) unique identifier for views
self._width (int) width


Functions

set_data (data, preserve_pos)
set the dataprovider, while adding an internal id

Parameters:

  • data (table), indexed array
  • preserve_pos (bool) TODO
assign_members (cell, defs, col_key, reserved_keys)
assign additional properties to cells - TODO @param reserved_keys (table) skip reserved keys (col_width, etc.)

Parameters:

  • cell
  • defs
  • col_key
  • reserved_keys
build ()
(re)build the actual view, using the current column/row count
cell_factory (ctype, cell_elm)
produce a cell of the given type

Parameters:

  • ctype
  • cell_elm
remove_table ()
remove existing viewbuilder before rebuilding the table (using the maximum possible table size)
get_cell (row_idx, col_idx)
retrieve direct reference to cell object

Parameters:

  • row_idx
  • col_idx

Returns:

    vTableCell or nil
get_item_by_key (key, val)
obtain an item by a specific key/value

Parameters:

  • key
  • val

Returns:

  1. table or nil (the matched item, if any)
  2. int or nil (index in the data table)
get_content_width ()
get computed width of table, all (absolute) column widths put together

Returns:

    int
set_num_rows (num)
set visible column count, rebuild if needed

Parameters:

  • num (int)

Returns:

    vTable.CELLTYPE
get_col_type (idx)

Parameters:

  • idx (int)

Returns:

    vTable.CELLTYPE
get_col_key (idx)
retrieve the key of a column definition

Parameters:

  • idx (int)

Returns:

    string or nil
get_col_idx (key)
retrieve the idx of a column definition by its key

Parameters:

  • key (string)

Returns:

    int or nil
get_col_width (idx, abs_only)
retrieve the absolute width in pixels for a given column

Parameters:

  • idx (int)
  • abs_only (bool) only check for absolute values

Returns:

    int
compute_auto_width (idx)
compute automatic width of column

Parameters:

  • idx

Returns:

    int
get_col_margin (idx)

Parameters:

  • idx (int)

Returns:

  1. int
  2. variant or nil
get_header_data (key)

Parameters:

  • key (string)

Returns:

    variant or nil
set_header_data (key, val)

Parameters:

  • key (string)
  • val (variant)
get_header_ctype (key)
retrieve a header type by key

Parameters:

  • key (string)

Returns:

    vLib.vTable.CELLTYPE ???
set_column_def (key, member, value)
specify a single column definition by it's key

Parameters:

  • key (string), the column key
  • member (string), e.g.'notifier'
  • value (variant), e.g. a callback function or other type
autosize_to_contents ()
call this whenever something has changed that will affect the computed height of the table - if resized (changed size), the external resize handler is invoked, giving the host application a chance to respond

Tables

self.header_cells
(table>vTableCell) header cells (by key)
self.cells
(table>row>col:vTableCell) table cells accessed like this: cells[row][col]

Fields

self.header_defs
(table>table) header definition (by key) Required values: vTable.HEADER_DEF_KEYS + any cell members
self.column_defs
(table>table>table) columns definition Required keys: vTable.COLUMN_DEF_KEYS
self.data
(table>row>col:variant) the data an extra property, _id, is added runtime
self.show_header
(bool) show_header
self.scrollbar_width
(int) TODO pass as separate constructor args
self.autosize
(bool) automatically resize to fit number of rows
self.num_rows
(int) number of visible rows
self.row_height
(int) row height
self.header_height
(int) header height
self.table_style
(string) styles
self.row_offset
(int) offset, vertical position in table use set_row_offset() to synchronize with scrollbar
self.on_update_complete
(function) define this to perform post-update actions, such as custom row highlighting, tooltips etc.
self.on_resize
(function) when table changed size (automatic resize)
self.scrollbar
(vScrollbar)
self.rebuild_requested
(bool) when table dimensions have changed this will rebuild the table as part of the next update
self.update_requested
(bool) TODO lazy updates
self.uid
(string) unique identifier for views
self._width
(int) width
generated by LDoc 1.4.2