本文整理汇总了C++中rocket::core::Element::GetOffsetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Element::GetOffsetWidth方法的具体用法?C++ Element::GetOffsetWidth怎么用?C++ Element::GetOffsetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rocket::core::Element
的用法示例。
在下文中一共展示了Element::GetOffsetWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Rocket_GetProperty
void Rocket_GetProperty( const char *name, void *out, int len, rocketVarType_t type )
{
if ( activeElement )
{
const Rocket::Core::Property *property = activeElement->GetProperty( name );
if ( !property )
{
return;
}
switch ( type )
{
case ROCKET_STRING:
{
char *string = ( char * ) out;
if ( property )
{
Q_strncpyz( string, property->Get<Rocket::Core::String>().CString(), len );
}
return;
}
case ROCKET_FLOAT:
{
float *f = ( float * ) out;
if ( len != sizeof( float ) )
{
return;
}
// HACK: special case for width and height specified in non absolute units
if ( !Q_stricmp( "width", name ) && property->unit & Rocket::Core::Property::RELATIVE_UNIT )
{
float base_size = 0;
Rocket::Core::Element *parent = activeElement;
while ( ( parent = parent->GetParentNode() ) )
{
if ( ( base_size = parent->GetOffsetWidth() ) != 0 )
{
*f = activeElement->ResolveProperty( "width", base_size );
return;
}
}
}
if ( !Q_stricmp( "height", name ) && property->unit & Rocket::Core::Property::RELATIVE_UNIT )
{
float base_size = 0;
Rocket::Core::Element *parent = activeElement;
while ( ( parent = parent->GetParentNode() ) )
{
if ( ( base_size = parent->GetOffsetHeight() ) != 0 )
{
*f = activeElement->ResolveProperty( "height", base_size );
return;
}
}
}
*f = property->Get<float>();
return;
}
case ROCKET_INT:
{
int *i = ( int * ) out;
if ( len != sizeof( int ) )
{
return;
}
*i = property->Get<int>();
return;
}
case ROCKET_COLOR:
{
vec_t *outColor = ( vec_t * ) out;
if ( len != sizeof( vec4_t ) )
{
return;
}
Rocket::Core::Colourb color = property->Get<Rocket::Core::Colourb>();
outColor[ 0 ] = color.red, outColor[ 1 ] = color.green, outColor[ 2 ] = color.blue, outColor[ 3 ] = color.alpha;
Vector4Scale( outColor, 1 / 255.0f, outColor );
return;
}
}
}
}