本文整理汇总了C++中Menu::Get_option方法的典型用法代码示例。如果您正苦于以下问题:C++ Menu::Get_option方法的具体用法?C++ Menu::Get_option怎么用?C++ Menu::Get_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Menu
的用法示例。
在下文中一共展示了Menu::Get_option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Request_size
Vector2 Dropdown_menu_view::Request_size(const Widget& widget) const
{
const Dropdown_menu& dropdown_menu = dynamic_cast<const Dropdown_menu&>(widget);
Vector2 size;
//const Ustring& text = dropdown_menu.Get_text();
Menu *child = dynamic_cast<Menu*>(dropdown_menu.Get_child());
if(child) {
const Ustring& text = child->Get_option(child->Get_selected_option());
size.x = font->Get_ustr_width(text.Astring()) + 6;
}
size.y = al_get_font_line_height(font->Afont()) + 6;
float lh = size.y/4+6;
size.x += size.y/2;
return size;
}
示例2: Render
void Dropdown_menu_view::Render(const Widget& widget) const
{
const Dropdown_menu& dropdown_menu = dynamic_cast<const Dropdown_menu&>(widget);
Vector2 p = widget.Get_position();
Vector2 s = widget.Get_size();
ALLEGRO_COLOR text_color = al_map_rgb_f(1, 1, 1);
ALLEGRO_COLOR tri_color = al_map_rgb_f(1, 1, 1);
ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5);
ALLEGRO_COLOR select_color = al_map_rgb_f(0.0, 0, 0.8);
//const Ustring& text = dropdown_menu.Get_text();
float h = al_get_font_line_height(font->Afont());
Menu *child = dynamic_cast<Menu*>(dropdown_menu.Get_child());
if(child) {
const Ustring& text = child->Get_option(child->Get_selected_option());
float text_width = font->Get_ustr_width(text.Astring());
al_draw_ustr(font->Afont(), text_color, p.x+6+h/2, p.y+3, 0, text.Astring());
}
float top = h*0.25;
float middle = h*0.5;
float bottom = h*0.75;
if(dropdown_menu.Is_open())
{
al_draw_filled_triangle(p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, tri_color);
al_draw_triangle (p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, edge_color, 0);
}
else
{
al_draw_filled_triangle(p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, tri_color);
al_draw_triangle (p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, edge_color, 0);
}
}