本文整理汇总了C++中Layout::Add_widget方法的典型用法代码示例。如果您正苦于以下问题:C++ Layout::Add_widget方法的具体用法?C++ Layout::Add_widget怎么用?C++ Layout::Add_widget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::Add_widget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
al_init();
al_install_mouse();
al_install_keyboard();
al_init_image_addon();
al_init_font_addon();
al_init_ttf_addon();
al_init_primitives_addon();
al_set_new_display_flags(ALLEGRO_WINDOWED|ALLEGRO_RESIZABLE);
ALLEGRO_DISPLAY *display = al_create_display(640, 480);
ALLEGRO_DISPLAY *tooldisplay = al_create_display(200, 480);
al_set_window_position(tooldisplay, 10, 0);
al_set_window_position(display, 220, 0);
ALLEGRO_DISPLAY *current_display = tooldisplay;
ALLEGRO_TIMER* timer = al_create_timer(1);
ALLEGRO_EVENT_QUEUE *event_queue = al_create_event_queue();
al_register_event_source(event_queue, (ALLEGRO_EVENT_SOURCE *)display);
al_register_event_source(event_queue, (ALLEGRO_EVENT_SOURCE *)tooldisplay);
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_mouse_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
ALLEGRO_FONT* font = al_load_font("data/DejaVuSans.ttf", 12, 0);
if(!font)
font = al_load_font("examples/data/DejaVuSans.ttf", 12, 0);
Layout layout;
Layout_controller layout_controller;
layout_controller.Set_layout(&layout);
Tree* widget_tree = layout_controller.Get_skin().Clone<Tree>("tree");
widget_tree->Set_text("Desktop");
widget_tree->Select();
Widget* root_widget = layout_controller.Get_skin().Clone<Desktop>("desktop");
root_widget->Set_position(Vector2(0, 0));
root_widget->Set_size(Vector2(640, 480));
layout_controller.Set_tree(widget_tree, root_widget);
layout_controller.Set_root(root_widget);
layout_controller.Set_root_tree(widget_tree);
layout_controller.Select_tree(widget_tree);
layout.Set_skin(&layout_controller.Get_skin());
layout.Add_widget("root", root_widget, NULL);
Editor_controller editor_controller;
editor_controller.Set_layout_display(display);
editor_controller.Set_layout_controller(layout_controller);
editor_controller.Load(layout_controller.Get_skin());
//FPS
Label* fps_label = layout_controller.Get_skin().Clone<Label>("label");
fps_label->Set_text("FPS: 100");
//Main vbox
Vertical_box* toolvbox = layout_controller.Get_skin().Clone<Vertical_box>("vertical box");
toolvbox->Add(editor_controller.Get_root());
toolvbox->Add(fps_label);
Slider_box* slider_box = layout_controller.Get_skin().Clone<Slider_box>("slider box");
slider_box->Set_child(toolvbox);
Desktop* desktop = layout_controller.Get_skin().Clone<Desktop>("desktop");
desktop->Set_child(slider_box);
desktop->Set_position(Vector2(0, 0));
desktop->Set_size(Vector2(200, 480));
Widget* toolroot = desktop;
al_start_timer(timer);
bool quit = false;
while (!quit)
{
ALLEGRO_EVENT event;
al_wait_for_event(event_queue, &event);
if (ALLEGRO_EVENT_KEY_DOWN == event.type)
{
if (ALLEGRO_KEY_ESCAPE == event.keyboard.keycode)
{
quit=true;
}
}
if (ALLEGRO_EVENT_DISPLAY_CLOSE == event.type)
{
quit=true;
}
if (ALLEGRO_EVENT_DISPLAY_RESIZE == event.type)
{
al_acknowledge_resize(event.display.source);
if(event.display.source == display)
layout_controller.Get_root()->Set_size(Vector2(event.display.width-20, event.display.height-20));
}
if (ALLEGRO_EVENT_DISPLAY_SWITCH_IN == event.type)
//.........这里部分代码省略.........