本文整理汇总了C++中CL_Rect::get_center方法的典型用法代码示例。如果您正苦于以下问题:C++ CL_Rect::get_center方法的具体用法?C++ CL_Rect::get_center怎么用?C++ CL_Rect::get_center使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CL_Rect
的用法示例。
在下文中一共展示了CL_Rect::get_center方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_icon_rect
CL_Rect CL_ListViewLayoutIcons::get_icon_rect(const CL_Rect &cell_content_rect, CL_ListViewItem item, int offset_x)
{
int icon_x = cell_content_rect.get_center().x - size_icon.width/2;
int icon_y = cell_content_rect.get_center().y - size_icon.height/2;
CL_Rect rect_icon(CL_Point(icon_x, icon_y), size_icon);
return rect_icon;
}
示例2: draw
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);
}
}