本文整理汇总了C++中MenuItem::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItem::draw方法的具体用法?C++ MenuItem::draw怎么用?C++ MenuItem::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItem
的用法示例。
在下文中一共展示了MenuItem::draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Vector
void
Menu::draw_item(DrawingContext& context, int index)
{
float menu_height = get_height();
float menu_width = get_width();
MenuItem* pitem = items[index].get();
float x_pos = pos.x - menu_width/2;
float y_pos = pos.y + 24*index - menu_height/2 + 12;
pitem->draw(context, Vector(x_pos, y_pos), menu_width, active_item == index);
if(active_item == index)
{
float blink = (sinf(real_time * M_PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f;
context.draw_filled_rect(Rectf(Vector(pos.x - menu_width/2 + 10 - 2, y_pos - 12 - 2),
Vector(pos.x + menu_width/2 - 10 + 2, y_pos + 12 + 2)),
Color(1.0f, 1.0f, 1.0f, blink),
14.0f,
LAYER_GUI-10);
context.draw_filled_rect(Rectf(Vector(pos.x - menu_width/2 + 10, y_pos - 12),
Vector(pos.x + menu_width/2 - 10, y_pos + 12)),
Color(1.0f, 1.0f, 1.0f, 0.5f),
12.0f,
LAYER_GUI-10);
}
}
示例2: Vector
void
Menu::draw_item(DrawingContext& context, int index)
{
float menu_height = get_height();
float menu_width_ = get_width();
MenuItem* pitem = items[index].get();
float x_pos = pos.x - menu_width_/2;
float y_pos = pos.y + 24.0f * static_cast<float>(index) - menu_height / 2.0f + 12.0f;
pitem->draw(context, Vector(x_pos, y_pos), static_cast<int>(menu_width_), active_item == index);
if(active_item == index)
{
float blink = (sinf(g_real_time * math::PI * 1.0f)/2.0f + 0.5f) * 0.5f + 0.25f;
context.color().draw_filled_rect(Rectf(Vector(pos.x - menu_width_/2 + 10 - 2, y_pos - 12 - 2),
Vector(pos.x + menu_width_/2 - 10 + 2, y_pos + 12 + 2)),
Color(1.0f, 1.0f, 1.0f, blink),
14.0f,
LAYER_GUI-10);
context.color().draw_filled_rect(Rectf(Vector(pos.x - menu_width_/2 + 10, y_pos - 12),
Vector(pos.x + menu_width_/2 - 10, y_pos + 12)),
Color(1.0f, 1.0f, 1.0f, 0.5f),
12.0f,
LAYER_GUI-10);
}
}