本文整理汇总了C++中PixelRect::Offset方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::Offset方法的具体用法?C++ PixelRect::Offset怎么用?C++ PixelRect::Offset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelRect
的用法示例。
在下文中一共展示了PixelRect::Offset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PixelRect
ButtonFrameRenderer::GetDrawingRect(PixelRect rc, bool pressed) const
{
rc.Grow(-2);
if (pressed)
rc.Offset(1, 1);
return rc;
}
示例2: scissor
void
ListControl::DrawItems(Canvas &canvas, unsigned start, unsigned end) const
{
PixelRect rc = item_rect(start);
canvas.SetBackgroundColor(look.list.background_color);
canvas.SetBackgroundTransparent();
canvas.Select(*look.list.font);
#ifdef ENABLE_OPENGL
/* enable clipping */
GLScissor scissor(OpenGL::translate.x,
OpenGL::screen_height - OpenGL::translate.y - canvas.GetHeight() - 1,
scroll_bar.GetLeft(GetSize()), canvas.GetHeight());
#endif
unsigned last_item = std::min(length, end);
const bool focused = HasFocus();
for (unsigned i = start; i < last_item; i++) {
const bool selected = i == cursor;
const bool pressed = selected && drag_mode == DragMode::CURSOR;
canvas.DrawFilledRectangle(rc,
look.list.GetBackgroundColor(selected,
focused,
pressed));
canvas.SetTextColor(look.list.GetTextColor(selected, focused, pressed));
if (item_renderer != nullptr)
item_renderer->OnPaintItem(canvas, rc, i);
if (focused && selected)
canvas.DrawFocusRectangle(rc);
rc.Offset(0, rc.bottom - rc.top);
}
/* paint the bottom part below the last item */
rc.bottom = canvas.GetHeight();
if (rc.bottom > rc.top)
canvas.DrawFilledRectangle(rc, look.list.background_color);
}