mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-28 03:20:57 +00:00
Use RectPart(s) instead of ImageRoundCorner(s).
This commit is contained in:
parent
2e421e8aed
commit
e023092744
@ -2512,13 +2512,13 @@ namespace {
|
||||
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
}
|
||||
|
||||
void complexAdjustRect(ImageRoundCorners corners, QRect &rect, RectParts &parts) {
|
||||
if (corners & ImageRoundCorner::TopLeft) {
|
||||
if (!(corners & ImageRoundCorner::BottomLeft)) {
|
||||
void complexAdjustRect(RectParts corners, QRect &rect, RectParts &parts) {
|
||||
if (corners & RectPart::TopLeft) {
|
||||
if (!(corners & RectPart::BottomLeft)) {
|
||||
parts = RectPart::NoTopBottom | RectPart::FullTop;
|
||||
rect.setHeight(rect.height() + msgRadius());
|
||||
}
|
||||
} else if (corners & ImageRoundCorner::BottomLeft) {
|
||||
} else if (corners & RectPart::BottomLeft) {
|
||||
parts = RectPart::NoTopBottom | RectPart::FullBottom;
|
||||
rect.setTop(rect.y() - msgRadius());
|
||||
} else {
|
||||
@ -2528,7 +2528,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners) {
|
||||
void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners) {
|
||||
if (radius == ImageRoundRadius::Ellipse) {
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
@ -2546,7 +2546,7 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners) {
|
||||
void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners) {
|
||||
auto parts = RectPart::Full | RectPart::None;
|
||||
complexAdjustRect(corners, rect, parts);
|
||||
roundRect(p, rect, st::msgInBg, MessageInCorners, nullptr, parts);
|
||||
|
@ -262,8 +262,8 @@ namespace App {
|
||||
#endif // !TDESKTOP_DISABLE_NETWORK_PROXY
|
||||
void setProxySettings(QTcpSocket &socket);
|
||||
|
||||
void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners);
|
||||
void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners);
|
||||
void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners);
|
||||
void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, RectParts corners);
|
||||
|
||||
QImage *cornersMask(ImageRoundRadius radius);
|
||||
void roundRect(Painter &p, int32 x, int32 y, int32 w, int32 h, style::color bg, RoundCorners index, const style::color *shadow = nullptr, RectParts parts = RectPart::Full);
|
||||
|
@ -163,7 +163,7 @@ void SendFilesBox::clipCallback(Media::Clip::Notification notification) {
|
||||
|
||||
if (_gifPreview && _gifPreview->ready() && !_gifPreview->started()) {
|
||||
auto s = QSize(_previewWidth, _previewHeight);
|
||||
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None);
|
||||
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None);
|
||||
}
|
||||
|
||||
update();
|
||||
@ -350,7 +350,7 @@ void SendFilesBox::paintEvent(QPaintEvent *e) {
|
||||
if (_gifPreview && _gifPreview->started()) {
|
||||
auto s = QSize(_previewWidth, _previewHeight);
|
||||
auto paused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : getms());
|
||||
p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), frame);
|
||||
} else {
|
||||
p.drawPixmap(_previewLeft, st::boxPhotoPadding.top(), _preview);
|
||||
@ -619,7 +619,7 @@ void EditCaptionBox::clipCallback(Media::Clip::Notification notification) {
|
||||
|
||||
if (_gifPreview && _gifPreview->ready() && !_gifPreview->started()) {
|
||||
auto s = QSize(_thumbw, _thumbh);
|
||||
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None);
|
||||
_gifPreview->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None);
|
||||
}
|
||||
|
||||
update();
|
||||
@ -686,7 +686,7 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
|
||||
if (_gifPreview && _gifPreview->started()) {
|
||||
auto s = QSize(_thumbw, _thumbh);
|
||||
auto paused = controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
auto frame = _gifPreview->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : getms());
|
||||
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), frame);
|
||||
} else {
|
||||
p.drawPixmap(_thumbx, st::boxPhotoPadding.top(), _thumb);
|
||||
|
@ -490,7 +490,7 @@ void Panel::createUserpicCache(ImagePtr image) {
|
||||
_user->name
|
||||
).paintSquare(p, 0, 0, st::callWidth, st::callWidth);
|
||||
}
|
||||
Images::prepareRound(filled, ImageRoundRadius::Large, ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight);
|
||||
Images::prepareRound(filled, ImageRoundRadius::Large, RectPart::TopLeft | RectPart::TopRight);
|
||||
_userPhoto = App::pixmapFromImageInPlace(std::move(filled));
|
||||
}
|
||||
refreshCacheImageUserPhoto();
|
||||
|
@ -248,7 +248,7 @@ void HistoryMessageReply::paint(Painter &p, const HistoryItem *holder, int x, in
|
||||
auto to = rtlrect(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height(), w + 2 * x);
|
||||
auto previewWidth = replyPreview->width() / cIntRetinaFactor();
|
||||
auto previewHeight = replyPreview->height() / cIntRetinaFactor();
|
||||
auto preview = replyPreview->pixSingle(previewWidth, previewHeight, to.width(), to.height(), ImageRoundRadius::Small, ImageRoundCorner::All, selected ? &st::msgStickerOverlay : nullptr);
|
||||
auto preview = replyPreview->pixSingle(previewWidth, previewHeight, to.width(), to.height(), ImageRoundRadius::Small, RectPart::AllCorners, selected ? &st::msgStickerOverlay : nullptr);
|
||||
p.drawPixmap(to.x(), to.y(), preview);
|
||||
}
|
||||
}
|
||||
|
@ -452,8 +452,8 @@ void HistoryPhoto::draw(Painter &p, const QRect &r, TextSelection selection, Tim
|
||||
}
|
||||
auto inWebPage = (_parent->getMedia() != this);
|
||||
auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
|
||||
auto roundCorners = inWebPage ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None));
|
||||
auto roundCorners = inWebPage ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
|
||||
const auto pix = loaded
|
||||
? _data->full->pixSingle(_pixw, _pixh, width, height, roundRadius, roundCorners)
|
||||
: _data->thumb->pixBlurredSingle(_pixw, _pixh, width, height, roundRadius, roundCorners);
|
||||
@ -623,12 +623,7 @@ void HistoryPhoto::drawGrouped(
|
||||
p.drawPixmap(geometry.topLeft(), *cache);
|
||||
if (selected) {
|
||||
const auto roundRadius = ImageRoundRadius::Large;
|
||||
const auto roundCorners = ImageRoundCorner::None
|
||||
| ((corners & RectPart::TopLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::TopRight) ? ImageRoundCorner::TopRight : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomLeft) ? ImageRoundCorner::BottomLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomRight) ? ImageRoundCorner::BottomRight : ImageRoundCorner::None);
|
||||
App::complexOverlayRect(p, geometry, roundRadius, roundCorners);
|
||||
App::complexOverlayRect(p, geometry, roundRadius, corners);
|
||||
}
|
||||
|
||||
if (radial || (!loaded && !_data->loading())) {
|
||||
@ -997,8 +992,8 @@ void HistoryVideo::draw(Painter &p, const QRect &r, TextSelection selection, Tim
|
||||
|
||||
auto inWebPage = (_parent->getMedia() != this);
|
||||
auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
|
||||
auto roundCorners = inWebPage ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None));
|
||||
auto roundCorners = inWebPage ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
|
||||
QRect rthumb(rtlrect(skipx, skipy, width, height, _width));
|
||||
p.drawPixmap(rthumb.topLeft(), _data->thumb->pixBlurredSingle(_thumbw, 0, width, height, roundRadius, roundCorners));
|
||||
if (selected) {
|
||||
@ -1158,12 +1153,7 @@ void HistoryVideo::drawGrouped(
|
||||
p.drawPixmap(geometry.topLeft(), *cache);
|
||||
if (selected) {
|
||||
const auto roundRadius = ImageRoundRadius::Large;
|
||||
const auto roundCorners = ImageRoundCorner::None
|
||||
| ((corners & RectPart::TopLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::TopRight) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((corners & RectPart::BottomRight) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None);
|
||||
App::complexOverlayRect(p, geometry, roundRadius, roundCorners);
|
||||
App::complexOverlayRect(p, geometry, roundRadius, corners);
|
||||
}
|
||||
|
||||
const auto radialOpacity = (radial && loaded && !_data->uploading())
|
||||
@ -2275,8 +2265,8 @@ int HistoryGif::resizeGetHeight(int width) {
|
||||
auto isRound = _data->isVideoMessage();
|
||||
auto inWebPage = (_parent->getMedia() != this);
|
||||
auto roundRadius = isRound ? ImageRoundRadius::Ellipse : inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
|
||||
auto roundCorners = (isRound || inWebPage) ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None));
|
||||
auto roundCorners = (isRound || inWebPage) ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
|
||||
_gif->start(_thumbw, _thumbh, _width, _height, roundRadius, roundCorners);
|
||||
}
|
||||
} else {
|
||||
@ -2376,8 +2366,8 @@ void HistoryGif::draw(Painter &p, const QRect &r, TextSelection selection, TimeM
|
||||
QRect rthumb(rtlrect(usex + skipx, skipy, usew, height, _width));
|
||||
|
||||
auto roundRadius = isRound ? ImageRoundRadius::Ellipse : isChildMedia ? ImageRoundRadius::Small : ImageRoundRadius::Large;
|
||||
auto roundCorners = (isRound || isChildMedia) ? ImageRoundCorner::All : ((isBubbleTop() ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None));
|
||||
auto roundCorners = (isRound || isChildMedia) ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
|
||||
| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
|
||||
if (animating) {
|
||||
auto paused = App::wnd()->controller()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
|
||||
if (isRound) {
|
||||
@ -5119,8 +5109,8 @@ void HistoryLocation::draw(Painter &p, const QRect &r, TextSelection selection,
|
||||
|
||||
_data->load();
|
||||
auto roundRadius = ImageRoundRadius::Large;
|
||||
auto roundCorners = ((isBubbleTop() && _title.isEmpty() && _description.isEmpty()) ? (ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight) : ImageRoundCorner::None)
|
||||
| (isBubbleBottom() ? (ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight) : ImageRoundCorner::None);
|
||||
auto roundCorners = ((isBubbleTop() && _title.isEmpty() && _description.isEmpty()) ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
|
||||
| (isBubbleBottom() ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None);
|
||||
auto rthumb = QRect(skipx, skipy, width, height);
|
||||
if (_data && !_data->thumb->isNull()) {
|
||||
int32 w = _data->thumb->width(), h = _data->thumb->height();
|
||||
|
@ -168,7 +168,7 @@ void Gif::paint(Painter &p, const QRect &clip, const PaintContext *context) cons
|
||||
QRect r(0, 0, _width, height);
|
||||
if (animating) {
|
||||
if (!_thumb.isNull()) _thumb = QPixmap();
|
||||
auto pixmap = _gif->current(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, ImageRoundCorner::None, context->paused ? 0 : context->ms);
|
||||
auto pixmap = _gif->current(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
p.drawPixmap(r.topLeft(), pixmap);
|
||||
} else {
|
||||
prepareThumb(_width, height, frame);
|
||||
@ -353,7 +353,7 @@ void Gif::clipCallback(Media::Clip::Notification notification) {
|
||||
} else if (_gif->ready() && !_gif->started()) {
|
||||
auto height = st::inlineMediaHeight;
|
||||
auto frame = countFrameSize();
|
||||
_gif->start(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, ImageRoundCorner::None);
|
||||
_gif->start(frame.width(), frame.height(), _width, height, ImageRoundRadius::None, RectPart::None);
|
||||
} else if (_gif->autoPausedGif() && !context()->inlineItemVisible(this)) {
|
||||
_gif.reset();
|
||||
getShownDocument()->forget();
|
||||
@ -1232,7 +1232,7 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
|
||||
|
||||
if (animating) {
|
||||
if (!_thumb.isNull()) _thumb = QPixmap();
|
||||
auto animationThumb = _gif->current(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, ImageRoundCorner::None, context->paused ? 0 : context->ms);
|
||||
auto animationThumb = _gif->current(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, RectPart::None, context->paused ? 0 : context->ms);
|
||||
p.drawPixmapLeft(rthumb.topLeft(), _width, animationThumb);
|
||||
thumbDisplayed = true;
|
||||
}
|
||||
@ -1347,7 +1347,7 @@ void Game::clipCallback(Media::Clip::Notification notification) {
|
||||
_gif.setBad();
|
||||
getResultDocument()->forget();
|
||||
} else if (_gif->ready() && !_gif->started()) {
|
||||
_gif->start(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, ImageRoundCorner::None);
|
||||
_gif->start(_frameSize.width(), _frameSize.height(), st::inlineThumbSize, st::inlineThumbSize, ImageRoundRadius::None, RectPart::None);
|
||||
} else if (_gif->autoPausedGif() && !context()->inlineItemVisible(this)) {
|
||||
_gif.reset();
|
||||
getResultDocument()->forget();
|
||||
|
@ -204,7 +204,7 @@ void Reader::callback(Reader *reader, int32 threadIndex, Notification notificati
|
||||
}
|
||||
}
|
||||
|
||||
void Reader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners) {
|
||||
void Reader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners) {
|
||||
if (managers.size() <= _threadIndex) error();
|
||||
if (_state == State::Error) return;
|
||||
|
||||
@ -224,7 +224,7 @@ void Reader::start(int32 framew, int32 frameh, int32 outerw, int32 outerh, Image
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms) {
|
||||
QPixmap Reader::current(int32 framew, int32 frameh, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners, TimeMs ms) {
|
||||
Expects(outerw > 0);
|
||||
Expects(outerh > 0);
|
||||
|
||||
|
@ -43,7 +43,7 @@ struct FrameRequest {
|
||||
int outerw = 0;
|
||||
int outerh = 0;
|
||||
ImageRoundRadius radius = ImageRoundRadius::None;
|
||||
ImageRoundCorners corners = ImageRoundCorner::TopLeft | ImageRoundCorner::TopRight | ImageRoundCorner::BottomLeft | ImageRoundCorner::BottomRight;
|
||||
RectParts corners = RectPart::AllCorners;
|
||||
};
|
||||
|
||||
enum ReaderSteps {
|
||||
@ -80,8 +80,8 @@ public:
|
||||
return _seekPositionMs;
|
||||
}
|
||||
|
||||
void start(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, ImageRoundCorners corners);
|
||||
QPixmap current(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, ImageRoundCorners corners, TimeMs ms);
|
||||
void start(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, RectParts corners);
|
||||
QPixmap current(int framew, int frameh, int outerw, int outerh, ImageRoundRadius radius, RectParts corners, TimeMs ms);
|
||||
QPixmap current();
|
||||
QPixmap frameOriginal() const {
|
||||
if (auto frame = frameToShow()) {
|
||||
|
@ -216,7 +216,7 @@ bool MediaView::gifShown() const {
|
||||
const_cast<MediaView*>(this)->_videoPaused = _gif->videoPaused();
|
||||
}
|
||||
auto rounding = (_doc && _doc->isVideoMessage()) ? ImageRoundRadius::Ellipse : ImageRoundRadius::None;
|
||||
_gif->start(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::All);
|
||||
_gif->start(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, RectPart::AllCorners);
|
||||
const_cast<MediaView*>(this)->_current = QPixmap();
|
||||
updateMixerVideoVolume();
|
||||
Global::RefVideoVolumeChanged().notify();
|
||||
@ -1664,7 +1664,7 @@ void MediaView::restartVideoAtSeekPosition(TimeMs positionMs) {
|
||||
|
||||
if (_current.isNull()) {
|
||||
auto rounding = (_doc && _doc->isVideoMessage()) ? ImageRoundRadius::Ellipse : ImageRoundRadius::None;
|
||||
_current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::All, getms());
|
||||
_current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, RectPart::AllCorners, getms());
|
||||
}
|
||||
_gif = Media::Clip::MakeReader(_doc, _msgid, [this](Media::Clip::Notification notification) {
|
||||
clipCallback(notification);
|
||||
@ -1812,7 +1812,7 @@ void MediaView::paintEvent(QPaintEvent *e) {
|
||||
QRect imgRect(_x, _y, _w, _h);
|
||||
if (imgRect.intersects(r)) {
|
||||
auto rounding = (_doc && _doc->isVideoMessage()) ? ImageRoundRadius::Ellipse : ImageRoundRadius::None;
|
||||
auto toDraw = _current.isNull() ? _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, ImageRoundCorner::None, ms) : _current;
|
||||
auto toDraw = _current.isNull() ? _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), rounding, RectPart::AllCorners, ms) : _current;
|
||||
if (!_gif && (!_doc || !_doc->sticker() || _doc->sticker()->img->isNull()) && toDraw.hasAlpha()) {
|
||||
p.fillRect(imgRect, _transparentBrush);
|
||||
}
|
||||
|
@ -191,11 +191,11 @@ void prepareCircle(QImage &img) {
|
||||
p.drawPixmap(0, 0, mask);
|
||||
}
|
||||
|
||||
void prepareRound(QImage &image, ImageRoundRadius radius, ImageRoundCorners corners) {
|
||||
void prepareRound(QImage &image, ImageRoundRadius radius, RectParts corners) {
|
||||
if (!static_cast<int>(corners)) {
|
||||
return;
|
||||
} else if (radius == ImageRoundRadius::Ellipse) {
|
||||
Assert(corners == ImageRoundCorners(ImageRoundCorner::All));
|
||||
Assert((corners & RectPart::AllCorners) == RectPart::AllCorners);
|
||||
prepareCircle(image);
|
||||
}
|
||||
Assert(!image.isNull());
|
||||
@ -208,7 +208,7 @@ void prepareRound(QImage &image, ImageRoundRadius radius, ImageRoundCorners corn
|
||||
prepareRound(image, masks, corners);
|
||||
}
|
||||
|
||||
void prepareRound(QImage &image, QImage *cornerMasks, ImageRoundCorners corners) {
|
||||
void prepareRound(QImage &image, QImage *cornerMasks, RectParts corners) {
|
||||
auto cornerWidth = cornerMasks[0].width();
|
||||
auto cornerHeight = cornerMasks[0].height();
|
||||
auto imageWidth = image.width();
|
||||
@ -248,10 +248,10 @@ void prepareRound(QImage &image, QImage *cornerMasks, ImageRoundCorners corners)
|
||||
imageInts += imageIntsAdded;
|
||||
}
|
||||
};
|
||||
if (corners & ImageRoundCorner::TopLeft) maskCorner(intsTopLeft, cornerMasks[0]);
|
||||
if (corners & ImageRoundCorner::TopRight) maskCorner(intsTopRight, cornerMasks[1]);
|
||||
if (corners & ImageRoundCorner::BottomLeft) maskCorner(intsBottomLeft, cornerMasks[2]);
|
||||
if (corners & ImageRoundCorner::BottomRight) maskCorner(intsBottomRight, cornerMasks[3]);
|
||||
if (corners & RectPart::TopLeft) maskCorner(intsTopLeft, cornerMasks[0]);
|
||||
if (corners & RectPart::TopRight) maskCorner(intsTopRight, cornerMasks[1]);
|
||||
if (corners & RectPart::BottomLeft) maskCorner(intsBottomLeft, cornerMasks[2]);
|
||||
if (corners & RectPart::BottomRight) maskCorner(intsBottomRight, cornerMasks[3]);
|
||||
}
|
||||
|
||||
QImage prepareColored(style::color add, QImage image) {
|
||||
@ -329,10 +329,10 @@ QImage prepare(QImage img, int w, int h, Images::Options options, int outerw, in
|
||||
}
|
||||
}
|
||||
auto corners = [](Images::Options options) {
|
||||
return ((options & Images::Option::RoundedTopLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedTopRight) ? ImageRoundCorner::TopRight : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedBottomLeft) ? ImageRoundCorner::BottomLeft : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedBottomRight) ? ImageRoundCorner::BottomRight : ImageRoundCorner::None);
|
||||
return ((options & Images::Option::RoundedTopLeft) ? RectPart::TopLeft : RectPart::None)
|
||||
| ((options & Images::Option::RoundedTopRight) ? RectPart::TopRight : RectPart::None)
|
||||
| ((options & Images::Option::RoundedBottomLeft) ? RectPart::BottomLeft : RectPart::None)
|
||||
| ((options & Images::Option::RoundedBottomRight) ? RectPart::BottomRight : RectPart::None);
|
||||
};
|
||||
if (options & Images::Option::Circled) {
|
||||
prepareCircle(img);
|
||||
@ -461,7 +461,7 @@ const QPixmap &Image::pix(int32 w, int32 h) const {
|
||||
return i.value();
|
||||
}
|
||||
|
||||
const QPixmap &Image::pixRounded(int32 w, int32 h, ImageRoundRadius radius, ImageRoundCorners corners) const {
|
||||
const QPixmap &Image::pixRounded(int32 w, int32 h, ImageRoundRadius radius, RectParts corners) const {
|
||||
checkload();
|
||||
|
||||
if (w <= 0 || !width() || !height()) {
|
||||
@ -471,11 +471,11 @@ const QPixmap &Image::pixRounded(int32 w, int32 h, ImageRoundRadius radius, Imag
|
||||
h *= cIntRetinaFactor();
|
||||
}
|
||||
auto options = Images::Option::Smooth | Images::Option::None;
|
||||
auto cornerOptions = [](ImageRoundCorners corners) {
|
||||
return (corners & ImageRoundCorner::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
auto cornerOptions = [](RectParts corners) {
|
||||
return (corners & RectPart::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & RectPart::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & RectPart::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & RectPart::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
};
|
||||
if (radius == ImageRoundRadius::Large) {
|
||||
options |= Images::Option::RoundedLarge | cornerOptions(corners);
|
||||
@ -612,7 +612,7 @@ const QPixmap &Image::pixBlurredColored(style::color add, int32 w, int32 h) cons
|
||||
return i.value();
|
||||
}
|
||||
|
||||
const QPixmap &Image::pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners, const style::color *colored) const {
|
||||
const QPixmap &Image::pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners, const style::color *colored) const {
|
||||
checkload();
|
||||
|
||||
if (w <= 0 || !width() || !height()) {
|
||||
@ -623,11 +623,11 @@ const QPixmap &Image::pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, Im
|
||||
}
|
||||
|
||||
auto options = Images::Option::Smooth | Images::Option::None;
|
||||
auto cornerOptions = [](ImageRoundCorners corners) {
|
||||
return (corners & ImageRoundCorner::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
auto cornerOptions = [](RectParts corners) {
|
||||
return (corners & RectPart::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & RectPart::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & RectPart::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & RectPart::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
};
|
||||
if (radius == ImageRoundRadius::Large) {
|
||||
options |= Images::Option::RoundedLarge | cornerOptions(corners);
|
||||
@ -656,7 +656,7 @@ const QPixmap &Image::pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, Im
|
||||
return i.value();
|
||||
}
|
||||
|
||||
const QPixmap &Image::pixBlurredSingle(int w, int h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners) const {
|
||||
const QPixmap &Image::pixBlurredSingle(int w, int h, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners) const {
|
||||
checkload();
|
||||
|
||||
if (w <= 0 || !width() || !height()) {
|
||||
@ -667,11 +667,11 @@ const QPixmap &Image::pixBlurredSingle(int w, int h, int32 outerw, int32 outerh,
|
||||
}
|
||||
|
||||
auto options = Images::Option::Smooth | Images::Option::Blurred;
|
||||
auto cornerOptions = [](ImageRoundCorners corners) {
|
||||
return (corners & ImageRoundCorner::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & ImageRoundCorner::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
auto cornerOptions = [](RectParts corners) {
|
||||
return (corners & RectPart::TopLeft ? Images::Option::RoundedTopLeft : Images::Option::None)
|
||||
| (corners & RectPart::TopRight ? Images::Option::RoundedTopRight : Images::Option::None)
|
||||
| (corners & RectPart::BottomLeft ? Images::Option::RoundedBottomLeft : Images::Option::None)
|
||||
| (corners & RectPart::BottomRight ? Images::Option::RoundedBottomRight : Images::Option::None);
|
||||
};
|
||||
if (radius == ImageRoundRadius::Large) {
|
||||
options |= Images::Option::RoundedLarge | cornerOptions(corners);
|
||||
@ -729,10 +729,10 @@ QPixmap Image::pixNoCache(int w, int h, Images::Options options, int outerw, int
|
||||
}
|
||||
|
||||
auto corners = [](Images::Options options) {
|
||||
return ((options & Images::Option::RoundedTopLeft) ? ImageRoundCorner::TopLeft : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedTopRight) ? ImageRoundCorner::TopRight : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedBottomLeft) ? ImageRoundCorner::BottomLeft : ImageRoundCorner::None)
|
||||
| ((options & Images::Option::RoundedBottomRight) ? ImageRoundCorner::BottomRight : ImageRoundCorner::None);
|
||||
return ((options & Images::Option::RoundedTopLeft) ? RectPart::TopLeft : RectPart::None)
|
||||
| ((options & Images::Option::RoundedTopRight) ? RectPart::TopRight : RectPart::None)
|
||||
| ((options & Images::Option::RoundedBottomLeft) ? RectPart::BottomLeft : RectPart::None)
|
||||
| ((options & Images::Option::RoundedBottomRight) ? RectPart::BottomRight : RectPart::None);
|
||||
};
|
||||
if (options & Images::Option::Circled) {
|
||||
Images::prepareCircle(result);
|
||||
|
@ -41,16 +41,6 @@ enum class ImageRoundRadius {
|
||||
Small,
|
||||
Ellipse,
|
||||
};
|
||||
enum class ImageRoundCorner {
|
||||
None = 0x00,
|
||||
TopLeft = 0x01,
|
||||
TopRight = 0x02,
|
||||
BottomLeft = 0x04,
|
||||
BottomRight = 0x08,
|
||||
All = 0x0f,
|
||||
};
|
||||
using ImageRoundCorners = base::flags<ImageRoundCorner>;
|
||||
inline constexpr auto is_flag_type(ImageRoundCorner) { return true; };
|
||||
|
||||
inline uint32 packInt(int32 a) {
|
||||
return (a < 0) ? uint32(int64(a) + 0x100000000LL) : uint32(a);
|
||||
@ -205,8 +195,8 @@ inline bool operator!=(const WebFileImageLocation &a, const WebFileImageLocation
|
||||
namespace Images {
|
||||
|
||||
QImage prepareBlur(QImage image);
|
||||
void prepareRound(QImage &image, ImageRoundRadius radius, ImageRoundCorners corners = ImageRoundCorner::All);
|
||||
void prepareRound(QImage &image, QImage *cornerMasks, ImageRoundCorners corners = ImageRoundCorner::All);
|
||||
void prepareRound(QImage &image, ImageRoundRadius radius, RectParts corners = RectPart::AllCorners);
|
||||
void prepareRound(QImage &image, QImage *cornerMasks, RectParts corners = RectPart::AllCorners);
|
||||
void prepareCircle(QImage &image);
|
||||
QImage prepareColored(style::color add, QImage image);
|
||||
QImage prepareOpaque(QImage image);
|
||||
@ -270,12 +260,12 @@ public:
|
||||
}
|
||||
|
||||
const QPixmap &pix(int32 w = 0, int32 h = 0) const;
|
||||
const QPixmap &pixRounded(int32 w = 0, int32 h = 0, ImageRoundRadius radius = ImageRoundRadius::None, ImageRoundCorners corners = ImageRoundCorner::All) const;
|
||||
const QPixmap &pixRounded(int32 w = 0, int32 h = 0, ImageRoundRadius radius = ImageRoundRadius::None, RectParts corners = RectPart::AllCorners) const;
|
||||
const QPixmap &pixBlurred(int32 w = 0, int32 h = 0) const;
|
||||
const QPixmap &pixColored(style::color add, int32 w = 0, int32 h = 0) const;
|
||||
const QPixmap &pixBlurredColored(style::color add, int32 w = 0, int32 h = 0) const;
|
||||
const QPixmap &pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners = ImageRoundCorner::All, const style::color *colored = nullptr) const;
|
||||
const QPixmap &pixBlurredSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, ImageRoundCorners corners = ImageRoundCorner::All) const;
|
||||
const QPixmap &pixSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners = RectPart::AllCorners, const style::color *colored = nullptr) const;
|
||||
const QPixmap &pixBlurredSingle(int32 w, int32 h, int32 outerw, int32 outerh, ImageRoundRadius radius, RectParts corners = RectPart::AllCorners) const;
|
||||
const QPixmap &pixCircled(int32 w = 0, int32 h = 0) const;
|
||||
const QPixmap &pixBlurredCircled(int32 w = 0, int32 h = 0) const;
|
||||
QPixmap pixNoCache(int w = 0, int h = 0, Images::Options options = 0, int outerw = -1, int outerh = -1, const style::color *colored = nullptr) const;
|
||||
|
@ -84,8 +84,8 @@ enum class RectPart {
|
||||
NoLeft = NoLeftRight | FullRight,
|
||||
NoRight = FullLeft | NoLeftRight,
|
||||
|
||||
CornersMask = TopLeft | TopRight | BottomLeft | BottomRight,
|
||||
SidesMask = Top | Bottom | Left | Right,
|
||||
AllCorners = TopLeft | TopRight | BottomLeft | BottomRight,
|
||||
AllSides = Top | Bottom | Left | Right,
|
||||
|
||||
Full = FullTop | NoTop,
|
||||
};
|
||||
|
@ -983,7 +983,7 @@ QPixmap MediaPreviewWidget::currentImage() const {
|
||||
if (_gif && _gif->started()) {
|
||||
auto s = currentDimensions();
|
||||
auto paused = _controller->isGifPausedAtLeastFor(Window::GifPauseReason::MediaPreview);
|
||||
return _gif->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None, paused ? 0 : getms());
|
||||
return _gif->current(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None, paused ? 0 : getms());
|
||||
}
|
||||
if (_cacheStatus != CacheThumbLoaded && _document->thumb->loaded()) {
|
||||
QSize s = currentDimensions();
|
||||
@ -1022,7 +1022,7 @@ void MediaPreviewWidget::clipCallback(Media::Clip::Notification notification) {
|
||||
|
||||
if (_gif && _gif->ready() && !_gif->started()) {
|
||||
QSize s = currentDimensions();
|
||||
_gif->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, ImageRoundCorner::None);
|
||||
_gif->start(s.width(), s.height(), s.width(), s.height(), ImageRoundRadius::None, RectPart::None);
|
||||
}
|
||||
|
||||
update();
|
||||
|
Loading…
Reference in New Issue
Block a user