当前位置: 首页>>代码示例>>C++>>正文


C++ Widget::Render方法代码示例

本文整理汇总了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);
}
开发者ID:trezker,项目名称:SWAG,代码行数:34,代码来源:horizontal_paned_view.cpp

示例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);
}
开发者ID:trezker,项目名称:SWAG,代码行数:34,代码来源:vertical_paned_view.cpp

示例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();
    }
}
开发者ID:Hybris95,项目名称:cerberus,代码行数:20,代码来源:widget.cpp

示例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);
		}
	}
开发者ID:trezker,项目名称:SWAG,代码行数:101,代码来源:main.cpp


注:本文中的Widget::Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。