Cafu Engine
ComponentBaseT Class Reference

This is the base class for the components that a window is composed/aggregated of. More...

Inheritance diagram for ComponentBaseT:

Public Member Functions

any get (string var_name)
 Returns the value of an attribute (a member variable) of this class. More...
 
 set (string var_name, any new_value)
 Sets an attribute (a member variable) of this class to a new value. More...
 
string GetExtraMessage (string var_name)
 Returns the result of VarBaseT::GetExtraMessage() for the given member variable. More...
 
 interpolate (string var_name, number start_value, number end_value, number time)
 Schedules a value for interpolation between a start and end value over a given period of time. More...
 

Detailed Description

This is the base class for the components that a window is composed/aggregated of.

Components are the basic building blocks of a window: their composition defines the properties, the behaviour, and thus virtually every aspect of the window.

Components of this type are never instantiated directly, but always indirectly through one of the derived classes.

Implementing C++ Class:
cf::GuiSys::ComponentBaseT

Member Function Documentation

any get ( string  var_name)

Returns the value of an attribute (a member variable) of this class.

The variables of this class are also referred to as "Public Attributes" or "Member Data", and include the variables of the concrete, derived component class as well as those of its base classes. (However, there is currently only one base class, ComponentBaseT, which adds methods such as get() and set(), but adds no additional variables to its derived classes.)

At this time, it is not yet possible to write script code like this:

local w = border_component.Width --// We're working on it, but at this time,
local r, g, b = border_component.Color --// these two lines are not valid code.

but instead, we have to write it like this:

local w = border_component:get("Width")
local r, g, b = border_component:get("Color")
Parameters
var_nameThe name of the variable whose value is to be retrieved.
Returns
The value of the queried variable (possibly a tuple if the value itself is a tuple, see the text above for an example).
string GetExtraMessage ( string  var_name)

Returns the result of VarBaseT::GetExtraMessage() for the given member variable.

This is currently only used with ComponentModelT components, in order to learn why loading a specific model may have failed:

model_component:set("Name", "Players/Trinity/Trinity.cmdl")
local msg = model_component:GetExtraMessage("Name")
if (msg != "") then
print("There was an error when loading this model: " .. msg)
end
interpolate ( string  var_name,
number  start_value,
number  end_value,
number  time 
)

Schedules a value for interpolation between a start and end value over a given period of time.

Only variables that are floating-point numbers and variables that are tuples whose elements are floating-point numbers can be interpolated. (These are the variables whose underlying C++ type is float, double, Vector2fT or Vector3fT.) For variables that are tuples, you must append one of the suffixes .x, .y, .z to determine the first, second or third element for interpolation. Alternatively, the suffixes .r, .g, .b are more naturally used with color tuples, and work exactly alike.

Example
function ButtonOK:OnMouseEnter()
self:GetComponent("Text"):interpolate("Scale", 0.4, 0.45, 500)
self:GetComponent("Border"):interpolate("Color.r", 0.2, 1.0, 750)
self:GetComponent("Image"):interpolate("Alpha", 1.0, 0.0, 750)
self:GetTransform():interpolate("Pos.y", 10, 220, 700)
end
Parameters
var_nameThe name of the window attribute to interpolate. Also see set() for details.
start_valueThe start value.
end_valueThe end value.
timeThe time in milliseconds to interpolate the variable from start_value to end_value.
set ( string  var_name,
any  new_value 
)

Sets an attribute (a member variable) of this class to a new value.

The variables of this class are also referred to as "Public Attributes" or "Member Data", and include the variables of the concrete, derived component class as well as those of its base classes. (However, there is currently only one base class, ComponentBaseT, which adds methods such as get() and set(), but adds no additional variables to its derived classes.)

At this time, it is not yet possible to write script code like this:

border_component.Width = w --// We're working on it, but at this time,
border_component.Color = r, g, b --// these two lines are not valid code.

but instead, we have to write it like this:

border_component:set("Width", w)
border_component:set("Color", r, g, b)
Parameters
var_nameThe name of the variable whose value is to be set.
new_valueThe new value that is assigned to the variable. Note that this can be a tuple if the value itself is a tuple as shown in the example above.