本文整理汇总了C++中Painter::fillRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Painter::fillRect方法的具体用法?C++ Painter::fillRect怎么用?C++ Painter::fillRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Painter
的用法示例。
在下文中一共展示了Painter::fillRect方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintOutlinedRect
void PeerListWidget::paintOutlinedRect(Painter &p, int x, int y, int w, int h) const {
auto outlineWidth = _st.button.outlineWidth;
if (outlineWidth) {
p.fillRect(rtlrect(x, y, outlineWidth, h, width()), _st.button.outlineFgOver);
}
p.fillRect(rtlrect(x + outlineWidth, y, w - outlineWidth, h, width()), _st.button.textBgOver);
}
示例2: paintBg
void PopupMenu::paintBg(Painter &p) {
if (_useTransparency) {
Shadow::paint(p, _inner, width(), _st.shadow);
App::roundRect(p, _inner, _st.menu.itemBg, ImageRoundRadius::Small);
} else {
p.fillRect(0, 0, width() - _padding.right(), _padding.top(), _st.shadow.fallback);
p.fillRect(width() - _padding.right(), 0, _padding.right(), height() - _padding.bottom(), _st.shadow.fallback);
p.fillRect(_padding.left(), height() - _padding.bottom(), width() - _padding.left(), _padding.bottom(), _st.shadow.fallback);
p.fillRect(0, _padding.top(), _padding.left(), height() - _padding.top(), _st.shadow.fallback);
p.fillRect(_inner, _st.menu.itemBg);
}
}
示例3: paintUnreadBadge
void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) {
t_assert(rect.height() == st.size);
int index = (st.muted ? 0x03 : 0x00) + (st.active ? 0x02 : (st.selected ? 0x01 : 0x00));
int size = st.size, sizehalf = size / 2;
unreadBadgeStyle.createIfNull();
auto badgeData = unreadBadgeStyle->sizes;
if (st.sizeId > 0) {
t_assert(st.sizeId < UnreadBadgeSizesCount);
badgeData = &unreadBadgeStyle->sizes[st.sizeId];
}
auto bg = unreadBadgeStyle->bg[index];
if (badgeData->left[index].isNull()) {
int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor();
createCircleMask(badgeData, size);
badgeData->left[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = App::pixmapFromImageInPlace(colorizeCircleHalf(badgeData, imgsize, imgsizehalf, imgsize - imgsizehalf, bg));
}
int bar = rect.width() - 2 * sizehalf;
p.drawPixmap(rect.x(), rect.y(), badgeData->left[index]);
if (bar) {
p.fillRect(rect.x() + sizehalf, rect.y(), bar, rect.height(), bg);
}
p.drawPixmap(rect.x() + sizehalf + bar, rect.y(), badgeData->right[index]);
}
示例4: paintHighlight
void Element::paintHighlight(
Painter &p,
int geometryHeight) const {
const auto animms = delegate()->elementHighlightTime(this);
if (!animms
|| animms >= st::activeFadeInDuration + st::activeFadeOutDuration) {
return;
}
const auto top = marginTop();
const auto bottom = marginBottom();
const auto fill = qMin(top, bottom);
const auto skiptop = top - fill;
const auto fillheight = fill + geometryHeight + fill;
const auto dt = (animms > st::activeFadeInDuration)
? (1. - (animms - st::activeFadeInDuration)
/ float64(st::activeFadeOutDuration))
: (animms / float64(st::activeFadeInDuration));
const auto o = p.opacity();
p.setOpacity(o * dt);
p.fillRect(
0,
skiptop,
width(),
fillheight,
st::defaultTextPalette.selectOverlay);
p.setOpacity(o);
}
示例5: width
void MembersBox::Inner::paintDialog(Painter &p, TimeMs ms, PeerData *peer, MemberData *data, bool selected, bool kickSelected) {
UserData *user = peer->asUser();
p.fillRect(0, 0, width(), _rowHeight, selected ? st::contactsBgOver : st::contactsBg);
if (data->ripple) {
data->ripple->paint(p, 0, 0, width(), ms);
if (data->ripple->empty()) {
data->ripple.reset();
}
}
peer->paintUserpicLeft(p, st::contactsPadding.left(), st::contactsPadding.top(), width(), st::contactsPhotoSize);
p.setPen(st::contactsNameFg);
int32 namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
int32 namew = width() - namex - st::contactsPadding.right() - (data->canKick ? (_kickWidth + st::contactsCheckPosition.x() * 2) : 0);
if (peer->isVerified()) {
auto icon = &st::dialogsVerifiedIcon;
namew -= icon->width();
icon->paint(p, namex + qMin(data->name.maxWidth(), namew), st::contactsPadding.top() + st::contactsNameTop, width());
}
data->name.drawLeftElided(p, namex, st::contactsPadding.top() + st::contactsNameTop, namew, width());
if (data->canKick) {
p.setFont(kickSelected ? st::linkOverFont : st::linkFont);
p.setPen(kickSelected ? st::defaultLinkButton.overColor : st::defaultLinkButton.color);
p.drawTextRight(st::contactsPadding.right() + st::contactsCheckPosition.x(), st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, width(), _kickText, _kickWidth);
}
p.setFont(st::contactsStatusFont->f);
p.setPen(data->onlineColor ? st::contactsStatusFgOnline : (selected ? st::contactsStatusFgOver : st::contactsStatusFg));
p.drawTextLeft(namex, st::contactsPadding.top() + st::contactsStatusTop, width(), data->online);
}
示例6: paintDivider
void CoverWidget::paintDivider(Painter &p) {
auto dividerHeight = st::profileDividerLeft.height();
auto divider = rtlrect(0, _dividerTop, width(), dividerHeight, width());
p.fillRect(divider, st::profileDividerBg);
auto dividerFillTop = rtlrect(0, _dividerTop, width(), st::profileDividerTop.height(), width());
st::profileDividerTop.fill(p, dividerFillTop);
auto dividerFillBottom = rtlrect(0, _dividerTop + dividerHeight - st::profileDividerBottom.height(), width(), st::profileDividerBottom.height(), width());
st::profileDividerBottom.fill(p, dividerFillBottom);
}
示例7: paint
void UnreadBar::paint(Painter &p, int y, int w) const {
const auto bottom = y + height();
y += marginTop();
p.fillRect(
0,
y,
w,
height() - marginTop() - st::lineWidth,
st::historyUnreadBarBg);
p.fillRect(
0,
bottom - st::lineWidth,
w,
st::lineWidth,
st::historyUnreadBarBorder);
p.setFont(st::historyUnreadBarFont);
p.setPen(st::historyUnreadBarFg);
int left = st::msgServiceMargin.left();
int maxwidth = w;
if (Adaptive::ChatWide()) {
maxwidth = qMin(
maxwidth,
st::msgMaxWidth
+ 2 * st::msgPhotoSkip
+ 2 * st::msgMargin.left());
}
w = maxwidth;
const auto skip = st::historyUnreadBarHeight
- 2 * st::lineWidth
- st::historyUnreadBarFont->height;
p.drawText(
(w - width) / 2,
y + (skip / 2) + st::historyUnreadBarFont->ascent,
text);
}
示例8: paint
void ServiceMessagePainter::paint(Painter &p, const HistoryService *message, const PaintContext &context, int height) {
int left = 0, width = 0;
message->countPositionAndSize(left, width);
if (width < 1) return;
uint64 fullAnimMs = App::main() ? App::main()->animActiveTimeStart(message) : 0;
if (fullAnimMs > 0 && fullAnimMs <= context.ms) {
int animms = context.ms - fullAnimMs;
if (animms > st::activeFadeInDuration + st::activeFadeOutDuration) {
App::main()->stopAnimActive();
} else {
int skiph = st::msgServiceMargin.top() - st::msgServiceMargin.bottom();
textstyleSet(&st::inTextStyle);
float64 dt = (animms > st::activeFadeInDuration) ? (1 - (animms - st::activeFadeInDuration) / float64(st::activeFadeOutDuration)) : (animms / float64(st::activeFadeInDuration));
float64 o = p.opacity();
p.setOpacity(o * dt);
p.fillRect(0, skiph, message->history()->width, message->height() - skiph, textstyleCurrent()->selectOverlay->b);
p.setOpacity(o);
}
}
textstyleSet(&st::serviceTextStyle);
if (auto media = message->getMedia()) {
height -= st::msgServiceMargin.top() + media->height();
int32 left = st::msgServiceMargin.left() + (width - media->maxWidth()) / 2, top = st::msgServiceMargin.top() + height + st::msgServiceMargin.top();
p.translate(left, top);
media->draw(p, context.clip.translated(-left, -top), message->toMediaSelection(context.selection), context.ms);
p.translate(-left, -top);
}
QRect trect(QRect(left, st::msgServiceMargin.top(), width, height).marginsAdded(-st::msgServicePadding));
paintBubble(p, left, width, message->_text, trect);
if (width > message->maxWidth()) {
left += (width - message->maxWidth()) / 2;
width = message->maxWidth();
}
p.setBrush(Qt::NoBrush);
p.setPen(st::msgServiceColor);
p.setFont(st::msgServiceFont);
message->_text.draw(p, trect.x(), trect.y(), trect.width(), Qt::AlignCenter, 0, -1, context.selection, false);
textstyleRestore();
}
示例9: paintTitle
void AbstractBox::paintTitle(Painter &p, const QString &title, const QString &additional) {
p.setFont(st::boxTitleFont);
if (_blueTitle) {
p.fillRect(0, 0, width(), st::boxTitleHeight, st::boxBlueTitleBg->b);
p.setPen(st::white);
int32 titleWidth = st::boxTitleFont->width(title);
p.drawTextLeft(st::boxBlueTitlePosition.x(), st::boxBlueTitlePosition.y(), width(), title, titleWidth);
if (!additional.isEmpty()) {
p.setFont(st::boxTextFont);
p.setPen(st::boxBlueTitleAdditionalFg);
p.drawTextLeft(st::boxBlueTitlePosition.x() + titleWidth + st::boxBlueTitleAdditionalSkip, st::boxBlueTitlePosition.y(), width(), additional);
}
} else {
p.setPen(st::boxTitleFg);
p.drawTextLeft(st::boxTitlePosition.x(), st::boxTitlePosition.y(), width(), title);
}
}
示例10: paintImportantSwitch
void paintImportantSwitch(Painter &p, Mode current, int fullWidth, bool selected, bool onlyBackground) {
p.fillRect(0, 0, fullWidth, st::dialogsImportantBarHeight, selected ? st::dialogsBgOver : st::dialogsBg);
if (onlyBackground) {
return;
}
p.setFont(st::semiboldFont);
p.setPen(st::dialogsNameFg);
int unreadTop = (st::dialogsImportantBarHeight - st::dialogsUnreadHeight) / 2;
bool mutedHidden = (current == Dialogs::Mode::Important);
QString text = lang(mutedHidden ? lng_dialogs_show_all_chats : lng_dialogs_hide_muted_chats);
int textBaseline = unreadTop + (st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2 + st::dialogsUnreadFont->ascent;
p.drawText(st::dialogsPadding.x(), textBaseline, text);
if (mutedHidden) {
if (int32 unread = App::histories().unreadMutedCount()) {
int unreadRight = fullWidth - st::dialogsPadding.x();
UnreadBadgeStyle st;
st.muted = true;
paintUnreadCount(p, QString::number(unread), unreadRight, unreadTop, st, nullptr);
}
}
}
示例11: draw
void HistoryGame::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const {
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
auto paintw = width(), painth = height();
auto outbg = _parent->hasOutLayout();
bool selected = (selection == FullSelection);
auto &barfg = selected ? (outbg ? st::msgOutReplyBarSelColor : st::msgInReplyBarSelColor) : (outbg ? st::msgOutReplyBarColor : st::msgInReplyBarColor);
auto &semibold = selected ? (outbg ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (outbg ? st::msgOutServiceFg : st::msgInServiceFg);
auto ®ular = selected ? (outbg ? st::msgOutDateFgSelected : st::msgInDateFgSelected) : (outbg ? st::msgOutDateFg : st::msgInDateFg);
QMargins bubble(_attach ? _attach->bubbleMargins() : QMargins());
auto padding = inBubblePadding();
auto tshift = padding.top();
auto bshift = padding.bottom();
paintw -= padding.left() + padding.right();
if (isBubbleBottom() && _attach && _attach->customInfoLayout() && _attach->width() + _parent->skipBlockWidth() > paintw + bubble.left() + bubble.right()) {
bshift += bottomInfoPadding();
}
QRect bar(rtlrect(st::msgPadding.left(), tshift, st::webPageBar, height() - tshift - bshift, width()));
p.fillRect(bar, barfg);
auto lineHeight = unitedLineHeight();
if (_titleLines) {
p.setPen(semibold);
auto endskip = 0;
if (_title.hasSkipBlock()) {
endskip = _parent->skipBlockWidth();
}
_title.drawLeftElided(p, padding.left(), tshift, paintw, width(), _titleLines, style::al_left, 0, -1, endskip, false, selection);
tshift += _titleLines * lineHeight;
}
if (_descriptionLines) {
p.setPen(outbg ? st::webPageDescriptionOutFg : st::webPageDescriptionInFg);
auto endskip = 0;
if (_description.hasSkipBlock()) {
endskip = _parent->skipBlockWidth();
}
_description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(selection));
tshift += _descriptionLines * lineHeight;
}
if (_attach) {
auto attachAtTop = !_titleLines && !_descriptionLines;
if (!attachAtTop) tshift += st::mediaInBubbleSkip;
auto attachLeft = padding.left() - bubble.left();
auto attachTop = tshift - bubble.top();
if (rtl()) attachLeft = width() - attachLeft - _attach->width();
auto attachSelection = selected ? FullSelection : TextSelection { 0, 0 };
p.translate(attachLeft, attachTop);
_attach->draw(p, r.translated(-attachLeft, -attachTop), attachSelection, ms);
auto pixwidth = _attach->width();
auto pixheight = _attach->height();
auto gameW = _gameTagWidth + 2 * st::msgDateImgPadding.x();
auto gameH = st::msgDateFont->height + 2 * st::msgDateImgPadding.y();
auto gameX = pixwidth - st::msgDateImgDelta - gameW;
auto gameY = pixheight - st::msgDateImgDelta - gameH;
App::roundRect(p, rtlrect(gameX, gameY, gameW, gameH, pixwidth), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg);
p.drawTextLeft(gameX + st::msgDateImgPadding.x(), gameY + st::msgDateImgPadding.y(), pixwidth, lang(lng_game_tag).toUpper());
p.translate(-attachLeft, -attachTop);
}
}