Пример #1
0
void CL_ListViewHeader_Impl::on_render(CL_GraphicContext &gc, const CL_Rect &update_rect)
{
	CL_Rect rect = listview_header->get_geometry();
	part_component.render_box(gc, rect.get_size(), update_rect);
	
	// draw listview column headers and backgrounds
	text_height = font.get_text_size(gc, "l").height;
	CL_ListViewColumnHeader col = first_column;
	while (!col.is_null())
	{
		CL_GUIThemePart &part = col.impl->part;
		CL_Rect &crect = col.impl->rect;
		if (display_mode != listview_mode_details)
			crect.right = rect.right;
		part.render_box(gc, crect, update_rect);
		CL_Rect content_rect = part.get_content_box(crect);

		part.render_text(gc, col.get_caption(), content_rect, update_rect);

		col = col.get_next_sibling();

		if (display_mode != listview_mode_details)
			break;
	}
}
Пример #2
0
void CL_CSSLayout::layout(CL_GraphicContext &gc, const CL_Rect &viewport)
{
	impl->throw_if_disposed();

	CL_CSSLayoutGraphics graphics(gc, &impl->resource_cache, impl->viewport);
	impl->box_tree.prepare(&impl->resource_cache);
	impl->layout_tree.create(impl->box_tree.get_root_element());
	impl->layout_tree.layout(&graphics, &impl->resource_cache, viewport.get_size());
	impl->viewport = viewport;
}
Пример #3
0
Slider::Slider(GUI &gui, CL_Rect gui_position) :Panel(gui, gui_position)
{
	component = new CL_Slider(this);
	component->set_geometry(CL_Rect(0, 0, gui_position.get_size()));
	component->set_vertical(false);
	component->set_horizontal(true);
	component->set_min(0);
	component->set_max(1000);
	component->set_tick_count(100);
	component->set_page_step(100);
	component->set_position(0);
	component->set_lock_to_ticks(false);

}
Пример #4
0
void CL_ListView_Impl::on_render(CL_GraphicContext &gc, const CL_Rect &update_rect)
{
	CL_Rect rect = listview->get_geometry();
	part_component.render_box(gc, rect.get_size(), update_rect);
	part_columns_bg.render_box(gc, rect_columns, update_rect);

	listview->push_cliprect(gc, rect_columns_content);

	std::vector<ListViewShownItem> &items = layout->get_shown_items();
	std::vector<ListViewColumn> &columns = layout->get_columns();
	std::vector<ListViewRow> &rows = layout->get_rows();
	renderer->render(gc, columns, rows, items, update_rect);

	listview->pop_cliprect(gc);
}
Пример #5
0
void CL_ListViewIcon::draw(CL_GraphicContext &gc, const CL_Rect &rect, CL_ListViewDisplayMode mode, const CL_Colorf &color)
{
	CL_Sprite sp = get_sprite(mode);
	if (!sp.is_null())
	{
		float scale = 1.0;

		sp.set_color(color);
		//		if (mode == listview_mode_thumbnails && sp.get_frame_size(0) != rect.get_size())
		if (impl->scalable && (sp.get_frame_size(0) != rect.get_size()))
		{
			// Scale to max vertically or horizontally.
			float sx, sy;
			sx = rect.get_width()/float(sp.get_width());
			sy = rect.get_height()/(float)sp.get_height();
			if (sx <= 0 || sy <= 0)
			{
				return;
			}
			scale = cl_min(sx, sy);
			sp.set_scale(scale,scale);
		}

		CL_Rect R = rect;
		CL_Point offset = get_offset(mode);

		R.translate(offset);

		if (!impl->scalable && offset == CL_Point(0,0))
		{
			// center in cell rect.
			int center_offset_x = int((float)rect.get_center().x - (float)rect.left - scale*(float)sp.get_width()/2.0); 
			int center_offset_y = int((float)rect.get_center().y - (float)rect.top - scale*(float)sp.get_height()/2.0); 
			R.left += center_offset_x;
			R.top += center_offset_y;
		}

		if (!impl->scalable)
			sp.draw(gc, (float)R.left, (float)R.top);
		else
			sp.draw(gc, R);

		return;
	}

	CL_PixelBuffer pb = get_pixel_buffer(mode);
	if (!pb.is_null())
	{
		float scale = 1.0;
		float center_offset_x = 0, center_offset_y = 0;

//		if (mode == listview_mode_thumbnails && pb.get_size() != rect.get_size())
		if (impl->scalable && (pb.get_size() != rect.get_size()))
		{
			float sx = 1.0, sy = 1.0;

			// Scale to max vertically or horizontally.
			sx = rect.get_width()/float(pb.get_width());
			sy = rect.get_height()/(float)pb.get_height();
			if (sx <= 0 || sy <= 0)
			{
				return;
			}

			scale = cl_min(sx, sy);

			// center in the rect.
			center_offset_x = (float)rect.get_center().x - (float)rect.left - scale*(float)pb.get_width()/2.0f; 
			center_offset_y = (float)rect.get_center().y - (float)rect.top - scale*(float)pb.get_height()/2.0f; 
		}

		CL_Point offset = get_offset(mode);

		gc.draw_pixels(rect.left + center_offset_x + offset.x, rect.top + center_offset_y + offset.y, scale, scale, pb, pb.get_size(), color);
	}
}