本文整理汇总了C++中Widget::Render方法的典型用法代码示例。如果您正苦于以下问题:C++ Widget::Render方法的具体用法?C++ Widget::Render怎么用?C++ Widget::Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::Render方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void Horizontal_paned_view::Render(const Widget& widget) const
{
const Horizontal_paned& horizontal_paned = dynamic_cast<const Horizontal_paned&>(widget);
Widget* left = horizontal_paned.Get_left();
Widget* right = horizontal_paned.Get_right();
Widget_view* view;
int clip_x, clip_y, clip_w, clip_h;
al_get_clipping_rectangle(&clip_x, &clip_y, &clip_w, &clip_h);
if(left)
{
Vector2 p = left->Get_position();
Vector2 s = left->Get_size();
al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
left->Render();
}
if(right)
{
Vector2 p = right->Get_position();
Vector2 s = right->Get_size();
al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
right->Render();
}
al_set_clipping_rectangle(clip_x, clip_y, clip_w, clip_h);
Vector2 p = widget.Get_position();
Vector2 s = widget.Get_size();
float pane = p.x+horizontal_paned.Get_pane_position();
ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);
al_draw_filled_rectangle(pane, p.y+1, pane+6, p.y+s.y, bg_color);
al_draw_rectangle(pane, p.y+1, pane+6, p.y+s.y, edge_color, 0);
al_draw_line(pane+2, p.y+s.y/2-10, pane+2, p.y+s.y/2+10, edge_color, 0);
al_draw_line(pane+4, p.y+s.y/2-10, pane+4, p.y+s.y/2+10, edge_color, 0);
}
示例2: Render
void Vertical_paned_view::Render(const Widget& widget) const
{
const Vertical_paned& vertical_paned = dynamic_cast<const Vertical_paned&>(widget);
Widget* top = vertical_paned.Get_top();
Widget* bottom = vertical_paned.Get_bottom();
Widget_view* view;
int clip_x, clip_y, clip_w, clip_h;
al_get_clipping_rectangle(&clip_x, &clip_y, &clip_w, &clip_h);
if(top)
{
Vector2 p = top->Get_position();
Vector2 s = top->Get_size();
al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
top->Render();
}
if(bottom)
{
Vector2 p = bottom->Get_position();
Vector2 s = bottom->Get_size();
al_set_clipping_rectangle(p.x, p.y, s.x, s.y);
bottom->Render();
}
al_set_clipping_rectangle(clip_x, clip_y, clip_w, clip_h);
Vector2 p = widget.Get_position();
Vector2 s = widget.Get_size();
float pane = p.y+vertical_paned.Get_pane_position()+1;
ALLEGRO_COLOR bg_color = al_map_rgb_f(0.7, 0.7, 0.7);
ALLEGRO_COLOR edge_color = al_map_rgb_f(0.3, 0.3, 0.3);
al_draw_filled_rectangle(p.x, pane, p.x+s.x-1, pane+6, bg_color);
al_draw_rectangle(p.x, pane, p.x+s.x-1, pane+6, edge_color, 0);
al_draw_line(p.x+s.x/2-10, pane+2, p.x+s.x/2+10, pane+2, edge_color, 0);
al_draw_line(p.x+s.x/2-10, pane+4, p.x+s.x/2+10, pane+4, edge_color, 0);
}
示例3: Render
void Widget::Render ()
{
SDL_Rect absolutePosition = GetAbsolutePosition();
if ( m_cachedSurfaceID != INVALID_SURFACE_ID )
g_graphics->Blit ( m_cachedSurfaceID, NULL, g_graphics->GetScreen(), &absolutePosition ); // FLAG
for ( size_t i = 0; i < m_widgets.size(); i++ )
{
Widget *widget = m_widgets[i];
CrbReleaseAssert ( widget );
widget->Update();
if ( widget->m_expired )
{
m_widgets.remove ( i-- );
delete widget;
continue;
}
widget->Render();
}
}
示例4: main
//.........这里部分代码省略.........
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)
{
current_display = event.display.source;
}
if(current_display == tooldisplay)
{
toolroot->Handle_event(event);
}
if(current_display == display)
{
layout_controller.Get_root()->Handle_event(event);
}
if(ALLEGRO_EVENT_TIMER == event.type) {
double dt = al_get_timer_speed(timer);
editor_controller.Update();
layout_controller.Get_skin().Update(dt);
al_set_target_backbuffer(display);
layout_controller.Get_root()->Render();
al_flip_display();
al_clear_to_color(al_map_rgb(0, 0, 0));
al_set_target_backbuffer(tooldisplay);
toolroot->Render();
al_flip_display();
al_clear_to_color(al_map_rgb(0, 0, 0));
double fps = 1 / dt;
std::stringstream ss;
ss<<fps;
std::string fps_string;
ss>>fps_string;
fps_label->Set_text((std::string("FPS: ")+fps_string).c_str());
if(dt < 1 && event.timer.count < al_get_timer_count(timer) - 4)
{
dt = dt * 1.1;
al_set_timer_speed(timer, dt);
//print("Tick too fast, setting speed to " .. timer_speed);
}
if(event.timer.count == al_get_timer_count(timer))
{
dt = dt * 0.9;
al_set_timer_speed(timer, dt);
//print("Tick too fast, setting speed to " .. timer_speed);
}
al_rest(0.001);
}
}