DI-Guy SDK Documentation  13.8
diguyViewButtonPanel Class Reference

#include <diguyViewButtonPanel.h>

Public Member Functions

const char * get_name ()
 Returns the name of the object. More...
 
int get_position (int *ret_x, int *ret_y)
 Returns the x and y coordinate of the panel. More...
 
int get_width ()
 Returns the width of the panel. More...
 
int get_height ()
 Returns the height of the panel. More...
 
int set_visible (int visible)
 Makes button panel visible or invisible. More...
 
int set_minimized_state (int minimized)
 Makes button panel minimized (or un-minimized). More...
 
int set_position (int x, int y)
 Sets the position of the panel in its parent window. More...
 
int set_dimensions (int w, int h)
 Sets the desired dimensions of the panel. More...
 
int set_depth (int z)
 Sets the desired z depth of the panel. More...
 
int set_justifications (int h, int v)
 Sets the horizontal/vertical justifications of the panel (see description in set_position()). More...
 
int set_spacing (int spacing)
 Sets the spacing between items in panel. More...
 
int set_title (const char *title)
 Sets the display title of the panel. More...
 
int add_button (const char *name, const char *lua_object_name, const char *lua_function_name, const char *style_sheet=NULL)
 Adds a button to the panel and specifies the lua script that should be run upon press. More...
 
int add_button_with_script (const char *name, const char *script, const char *style_sheet=NULL)
 Adds a button to the panel and specifies the lua script that should be run upon press. More...
 
int set_button_name (int index, const char *name)
 Sets the name (text) of button at index n (zero-indexed). More...
 
int set_allow_toggle (int index, int can_toggle)
 Sets whether or not the specified button will be a toggle button. More...
 
int set_selected_button (int index)
 Sets the specified button to be the "selected" one within the panel. More...
 
int set_selected_button_by_name (const char *name)
 Similar to set_selected_button(), but using button name (text). More...
 
int add_int_slider (const char *name, const char *lua_object_name, const char *lua_function_name, int init_val, int min_val, int max_val, const char *style_sheet=NULL)
 Adds an integer slider to the panel and specifies the lua script that should be run upon the slider changing value. More...
 
int add_float_slider (const char *name, const char *lua_object_name, const char *lua_function_name, float init_val, float min_val, float max_val, const char *style_sheet=NULL)
 Adds a continuous floating slider to the panel and specifies the lua script that should be run upon the slider changing value. More...
 
int set_slider_value (const char *name, float value)
 Updates specified slider with the value specified. More...
 
int add_spacer (int pixels)
 Adds a vertical or horizontal spacer element. More...
 
void set_item_visibility (int index, bool visible)
 Change visibility of item specified by index. More...
 
void remove_all_items ()
 Clears all items out of panel. More...
 
void set_open_script (const char *lua_script)
 Sets a Lua script to be called when panel is opened (un-minimized). More...
 
void set_minimize_script (const char *lua_script)
 Sets a Lua script to be called when panel is opened (un-minimized). More...
 
int set_style_sheet (const char *sheet)
 Passes a Qt style sheet to the panel. More...
 

Static Public Member Functions

static diguyViewButtonPanelfind_or_create_instance (const char *name, int horizontal=0, int title=1)
 Returns the named button panel or creates it. More...
 
static diguyViewButtonPanelmake_instance (const char *name, int horizontal=0, int title=1)
 Makes a button panel with the given name and attributes. More...
 
static diguyViewButtonPanelget_instance (const char *name)
 Returns a pointer to the named button panel, if it exists. More...
 
static int destroy_instance (const char *name)
 Destroys named button panel, if found. More...
 
static int destroy_all ()
 Destroys all button panels. More...
 

Private Functions

The functions and variables past this point are for internal use only.

No external access to them is expected or necessary.

class bdiViewButtonPanel
 
bdiViewButtonPanelm_panel
 A pointer to internal data. More...
 
static void set_create_callback (makeButtonPanelCallback *the_callback)
 
bdiViewButtonPanelget_scripted_object ()
 
 diguyViewButtonPanel (bdiViewButtonPanel *panel)
 A private constructor. More...
 
 ~diguyViewButtonPanel ()
 A private destructor. More...
 

Constructor & Destructor Documentation

diguyViewButtonPanel::diguyViewButtonPanel ( bdiViewButtonPanel panel)
private

A private constructor.

diguyViewButtonPanel::~diguyViewButtonPanel ( )
private

A private destructor.

Member Function Documentation

static diguyViewButtonPanel* diguyViewButtonPanel::find_or_create_instance ( const char *  name,
int  horizontal = 0,
int  title = 1 
)
static

Returns the named button panel or creates it.

Parameters
namename of panel (must be unique)
horizontalif 1, make a horizontal panel
titleif 1, show panel title

Returns:

pointer to the button panel

Callable From:

  • C++
  • Script
static diguyViewButtonPanel* diguyViewButtonPanel::make_instance ( const char *  name,
int  horizontal = 0,
int  title = 1 
)
static

Makes a button panel with the given name and attributes.

Parameters
namename of panel (must be unique)
horizontalif 1, make a horizontal panel
titleif 1, show panel title

Returns:

pointer to the button panel

Callable From:

  • C++
  • Script
static diguyViewButtonPanel* diguyViewButtonPanel::get_instance ( const char *  name)
static

Returns a pointer to the named button panel, if it exists.

Otherwise returns NULL.

Parameters
namename of panel

Returns:

pointer to the button panel or NULL

Callable From:

  • C++
  • Script
static int diguyViewButtonPanel::destroy_instance ( const char *  name)
static

Destroys named button panel, if found.

Parameters
namename of panel

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
static int diguyViewButtonPanel::destroy_all ( )
static

Destroys all button panels.

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
const char* diguyViewButtonPanel::get_name ( )

Returns the name of the object.

This pointer will never be NULL.

Returns:

name of the object

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::get_position ( int *  ret_x,
int *  ret_y 
)

Returns the x and y coordinate of the panel.

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::get_width ( )

Returns the width of the panel.

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::get_height ( )

Returns the height of the panel.

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_visible ( int  visible)

Makes button panel visible or invisible.

Parameters
visiblepass 1 to make visible, 0 to make invisible

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_minimized_state ( int  minimized)

Makes button panel minimized (or un-minimized).

Parameters
visiblepass 1 to make minimized, 0 to make full size

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_position ( int  x,
int  y 
)

Sets the position of the panel in its parent window.

Coordinates work differently if panel is right/bottom justified on its x/y (see set_justification()). In that case, the coordinate will imply the position of the panel's right/bottom edge relative to the right/bottom edge of the containing window.

Parameters
xx position, in pixels
yy position, in pixels

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_dimensions ( int  w,
int  h 
)

Sets the desired dimensions of the panel.

Parameters
wwidth, in pixels
hheight, in pixels

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_depth ( int  z)

Sets the desired z depth of the panel.

Parameters
zdepth

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_justifications ( int  h,
int  v 
)

Sets the horizontal/vertical justifications of the panel (see description in set_position()).

Parameters
hhorizontal justification (> 0 for left, 0 for center, < 0 for right)
vvertical justification (> 0 for top, 0 for center, < 0 for bottom)

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_spacing ( int  spacing)

Sets the spacing between items in panel.

Parameters
spacingspacing in pixels

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_title ( const char *  title)

Sets the display title of the panel.

Parameters
titletext to show

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::add_button ( const char *  name,
const char *  lua_object_name,
const char *  lua_function_name,
const char *  style_sheet = NULL 
)

Adds a button to the panel and specifies the lua script that should be run upon press.

Parameters
nametext of button
lua_object_namename of lua table containing function to run
lua_function_namename of lua function to run
style_sheetoptional css to set on button

An example style sheet string: "QPushButton {background-color : rgba( 192, 210, 192, 192 ); }"

Returns:

index of the new button (zero-indexed)

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::add_button_with_script ( const char *  name,
const char *  script,
const char *  style_sheet = NULL 
)

Adds a button to the panel and specifies the lua script that should be run upon press.

Parameters
nametext of button
scriptLua script to run (the script itself)
style_sheetoptional css to set on button

An example style sheet string: "QPushButton {background-color : rgba( 192, 210, 192, 192 ); }"

Returns:

index of the new button (zero-indexed)

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_button_name ( int  index,
const char *  name 
)

Sets the name (text) of button at index n (zero-indexed).

Parameters
indexindex of button (starting from 0)

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_allow_toggle ( int  index,
int  can_toggle 
)

Sets whether or not the specified button will be a toggle button.

A toggle button can be clicked back and forth between an on and off state, whereas a regular button provides only a once-off action.

Parameters
indexindex of button (starting from 0)
can_toggletrue if toggle button

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_selected_button ( int  index)

Sets the specified button to be the "selected" one within the panel.

The selected button may have a special appearance depending on style sheet. See notes for set_style_sheet().

Parameters
indexindex of button (starting from 0)

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_selected_button_by_name ( const char *  name)

Similar to set_selected_button(), but using button name (text).

Parameters
namename (text) of button

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::add_int_slider ( const char *  name,
const char *  lua_object_name,
const char *  lua_function_name,
int  init_val,
int  min_val,
int  max_val,
const char *  style_sheet = NULL 
)

Adds an integer slider to the panel and specifies the lua script that should be run upon the slider changing value.

lua function should be:

function lua_object_name:lua_function_name(value)
Parameters
nametext of label description
lua_object_namename of lua table containing function to run
lua_function_namename of lua function to run

Returns:

index of the new slider (zero-indexed)

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::add_float_slider ( const char *  name,
const char *  lua_object_name,
const char *  lua_function_name,
float  init_val,
float  min_val,
float  max_val,
const char *  style_sheet = NULL 
)

Adds a continuous floating slider to the panel and specifies the lua script that should be run upon the slider changing value.

lua function should be:

function lua_object_name:lua_function_name(value)
Parameters
nametext of label description
lua_object_namename of lua table containing function to run
lua_function_namename of lua function to run

Returns:

index of the new slider (zero-indexed)

Callable From:

  • C++
  • Script
int diguyViewButtonPanel::set_slider_value ( const char *  name,
float  value 
)

Updates specified slider with the value specified.

Parameters
namename of slider
valuevalue of slider
int diguyViewButtonPanel::add_spacer ( int  pixels)

Adds a vertical or horizontal spacer element.

void diguyViewButtonPanel::set_item_visibility ( int  index,
bool  visible 
)

Change visibility of item specified by index.

void diguyViewButtonPanel::remove_all_items ( )

Clears all items out of panel.

void diguyViewButtonPanel::set_open_script ( const char *  lua_script)

Sets a Lua script to be called when panel is opened (un-minimized).

Parameters
lua_scriptthe entire script
void diguyViewButtonPanel::set_minimize_script ( const char *  lua_script)

Sets a Lua script to be called when panel is opened (un-minimized).

Parameters
lua_scriptthe entire script
int diguyViewButtonPanel::set_style_sheet ( const char *  sheet)

Passes a Qt style sheet to the panel.

Sample one (user must replace "MAIN_BG_COLOR" and other tags with meaningful values):

**

Note
   "isSelected" used to set visual properties of selected button

-------------—

basic_style = [[
* {
background-color : rgba( 192, 192, 192, 192 );
color : white;
}
QFrame#m_button_frame {
background-color : MAIN_BG_COLOR;
}
QLabel#m_title_label {
color : white;
}
QPushButton {
color : BUTTON_TEXT_COLOR;
background-color : BUTTON_BG_COLOR;
}
QPushButton[isSelected="true"] {
color : BUTTON_SELECTED_TEXT_COLOR;
background-color : BUTTON_SELECTED_BG_COLOR;
}
]];

Sample two (user must replace "MAIN_BG_COLOR" and other tags with meaningful values):

**

Note
 "isToggled" used to set visual properties on button that is
 toggled on

-------------—

basic_style = [[
* {
background-color : rgba( 192, 192, 192, 192 );
color : white;
}
QFrame#m_button_frame {
background-color : MAIN_BG_COLOR;
}
QLabel#m_title_label {
color : white;
}
QPushButton {
color : BUTTON_TEXT_COLOR;
background-color : BUTTON_BG_COLOR;
}
QPushButton[isToggled="true"] {
color : BUTTON_TOGGLED_TEXT_COLOR;
background-color : BUTTON_TOGGLED_BG_COLOR;
}
]];

Parameters
sheetthe style sheet

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script

bdiViewButtonPanel* diguyViewButtonPanel::get_scripted_object ( )
inline
static void diguyViewButtonPanel::set_create_callback ( makeButtonPanelCallback the_callback)
static

Friends And Related Function Documentation

friend class bdiViewButtonPanel
friend

Member Data Documentation

bdiViewButtonPanel* diguyViewButtonPanel::m_panel
protected

A pointer to internal data.


The documentation for this class was generated from the following file: