diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 2dbf79ec48..de24b3ede5 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -2731,11 +2731,11 @@ namespace { void complexAdjustRect(ImageRoundCorners corners, QRect &rect, RectParts &parts) { if (corners & ImageRoundCorner::TopLeft) { if (!(corners & ImageRoundCorner::BottomLeft)) { - parts = RectPart::NoTopBottom | RectPart::TopFull; + parts = RectPart::NoTopBottom | RectPart::FullTop; rect.setHeight(rect.height() + msgRadius()); } } else if (corners & ImageRoundCorner::BottomLeft) { - parts = RectPart::NoTopBottom | RectPart::BottomFull; + parts = RectPart::NoTopBottom | RectPart::FullBottom; rect.setTop(rect.y() - msgRadius()); } else { parts = RectPart::NoTopBottom; diff --git a/Telegram/SourceFiles/app.h b/Telegram/SourceFiles/app.h index bbc75ef495..c7251333b4 100644 --- a/Telegram/SourceFiles/app.h +++ b/Telegram/SourceFiles/app.h @@ -281,28 +281,6 @@ namespace App { #endif // !TDESKTOP_DISABLE_NETWORK_PROXY void setProxySettings(QTcpSocket &socket); - enum class RectPart { - None = 0x000, - TopLeft = 0x001, - Top = 0x002, - TopRight = 0x004, - Left = 0x008, - Center = 0x010, - Right = 0x020, - BottomLeft = 0x040, - Bottom = 0x080, - BottomRight = 0x100, - TopFull = 0x007, - LeftFull = 0x049, - RightFull = 0x124, - BottomFull = 0x1c0, - NoTopBottom = 0x038, - NoLeftRight = 0x092, - Full = 0x1ff, - }; - Q_DECLARE_FLAGS(RectParts, RectPart); - Q_DECLARE_OPERATORS_FOR_FLAGS(RectParts); - void complexOverlayRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners); void complexLocationRect(Painter &p, QRect rect, ImageRoundRadius radius, ImageRoundCorners corners); diff --git a/Telegram/SourceFiles/boxes/abstract_box.cpp b/Telegram/SourceFiles/boxes/abstract_box.cpp index a48427af00..95955ffa37 100644 --- a/Telegram/SourceFiles/boxes/abstract_box.cpp +++ b/Telegram/SourceFiles/boxes/abstract_box.cpp @@ -227,9 +227,9 @@ void AbstractBox::paintEvent(QPaintEvent *e) { auto paintTopRounded = clip.intersects(QRect(0, 0, width(), st::boxRadius)); auto paintBottomRounded = clip.intersects(QRect(0, height() - st::boxRadius, width(), st::boxRadius)); if (paintTopRounded || paintBottomRounded) { - auto parts = qFlags(App::RectPart::None); - if (paintTopRounded) parts |= App::RectPart::TopFull; - if (paintBottomRounded) parts |= App::RectPart::BottomFull; + auto parts = qFlags(RectPart::None); + if (paintTopRounded) parts |= RectPart::FullTop; + if (paintBottomRounded) parts |= RectPart::FullBottom; App::roundRect(p, rect(), st::boxBg, BoxCorners, nullptr, parts); } auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 8d4887ee0f..8f48c6ee55 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -520,7 +520,7 @@ void Panel::createBottomImage() { image.fill(Qt::transparent); { Painter p(&image); - Ui::Shadow::paint(p, QRect(_padding.left(), 0, st::callWidth, bottomHeight - _padding.bottom()), width(), st::callShadow, Ui::Shadow::Side::Left | Ui::Shadow::Side::Right | Ui::Shadow::Side::Bottom); + Ui::Shadow::paint(p, QRect(_padding.left(), 0, st::callWidth, bottomHeight - _padding.bottom()), width(), st::callShadow, RectPart::Left | RectPart::Right | RectPart::Bottom); p.setCompositionMode(QPainter::CompositionMode_Source); p.setBrush(st::callBg); p.setPen(Qt::NoPen); @@ -556,7 +556,7 @@ void Panel::refreshCacheImageUserPhoto() { cache.fill(Qt::transparent); { Painter p(&cache); - Ui::Shadow::paint(p, QRect(_padding.left(), _padding.top(), st::callWidth, st::callWidth), width(), st::callShadow, Ui::Shadow::Side::Top | Ui::Shadow::Side::Left | Ui::Shadow::Side::Right); + Ui::Shadow::paint(p, QRect(_padding.left(), _padding.top(), st::callWidth, st::callWidth), width(), st::callShadow, RectPart::Top | RectPart::Left | RectPart::Right); p.drawPixmapLeft(_padding.left(), _padding.top(), width(), _userPhoto); p.drawPixmapLeft(0, _padding.top() + st::callWidth, width(), _bottomCache); } diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 3699ff1b44..183037cefc 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -384,7 +384,7 @@ void TabbedSelector::paintEvent(QPaintEvent *e) { void TabbedSelector::paintSlideFrame(Painter &p, TimeMs ms) { if (_roundRadius > 0) { auto topPart = QRect(0, 0, width(), _tabsSlider->height() + _roundRadius); - App::roundRect(p, topPart, st::emojiPanBg, ImageRoundRadius::Small, App::RectPart::TopFull | App::RectPart::NoTopBottom); + App::roundRect(p, topPart, st::emojiPanBg, ImageRoundRadius::Small, RectPart::FullTop | RectPart::NoTopBottom); } else { p.fillRect(0, 0, width(), _tabsSlider->height(), st::emojiPanBg); } @@ -398,10 +398,10 @@ void TabbedSelector::paintContent(Painter &p) { auto &bottomBg = showSectionIcons ? st::emojiPanCategories : st::emojiPanBg; if (_roundRadius > 0) { auto topPart = QRect(0, 0, width(), _tabsSlider->height() + _roundRadius); - App::roundRect(p, topPart, st::emojiPanBg, ImageRoundRadius::Small, App::RectPart::TopFull | App::RectPart::NoTopBottom); + App::roundRect(p, topPart, st::emojiPanBg, ImageRoundRadius::Small, RectPart::FullTop | RectPart::NoTopBottom); auto bottomPart = QRect(0, _footerTop - _roundRadius, width(), st::emojiCategory.height + _roundRadius); - auto bottomParts = App::RectPart::NoTopBottom | App::RectPart::BottomFull; + auto bottomParts = RectPart::NoTopBottom | RectPart::FullBottom; App::roundRect(p, bottomPart, bottomBg, ImageRoundRadius::Small, bottomParts); } else { p.fillRect(0, 0, width(), _tabsSlider->height(), st::emojiPanBg); diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index dc3288b1cd..a3185200b4 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -1336,7 +1336,7 @@ void HistoryMessage::draw(Painter &p, const QRect &r, TextSelection selection, T auto r = QRect(left, top, width, height - top - marginBottom()); auto skipTail = isAttachedToNext() || (_media && _media->skipBubbleTail()) || (keyboard != nullptr); - auto displayTail = skipTail ? HistoryLayout::BubbleTail::None : (outbg && !Adaptive::ChatWide()) ? HistoryLayout::BubbleTail::Right : HistoryLayout::BubbleTail::Left; + auto displayTail = skipTail ? RectPart::None : (outbg && !Adaptive::ChatWide()) ? RectPart::Right : RectPart::Left; HistoryLayout::paintBubble(p, r, _history->width, selected, outbg, displayTail); QRect trect(r.marginsAdded(-st::msgPadding)); diff --git a/Telegram/SourceFiles/history/history_service_layout.cpp b/Telegram/SourceFiles/history/history_service_layout.cpp index aa745aacdc..921cae0a06 100644 --- a/Telegram/SourceFiles/history/history_service_layout.cpp +++ b/Telegram/SourceFiles/history/history_service_layout.cpp @@ -351,25 +351,25 @@ void serviceColorsUpdated() { } } -void paintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool outbg, BubbleTail tail) { +void paintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool outbg, RectPart tailSide) { auto &bg = selected ? (outbg ? st::msgOutBgSelected : st::msgInBgSelected) : (outbg ? st::msgOutBg : st::msgInBg); auto &sh = selected ? (outbg ? st::msgOutShadowSelected : st::msgInShadowSelected) : (outbg ? st::msgOutShadow : st::msgInShadow); auto cors = selected ? (outbg ? MessageOutSelectedCorners : MessageInSelectedCorners) : (outbg ? MessageOutCorners : MessageInCorners); - auto parts = App::RectPart::TopFull | App::RectPart::NoTopBottom | App::RectPart::Bottom; - if (tail == BubbleTail::Right) { - parts |= App::RectPart::BottomLeft; + auto parts = RectPart::FullTop | RectPart::NoTopBottom | RectPart::Bottom; + if (tailSide == RectPart::Right) { + parts |= RectPart::BottomLeft; p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height() - st::historyMessageRadius, st::historyMessageRadius, st::historyMessageRadius, bg); auto &tail = selected ? st::historyBubbleTailOutRightSelected : st::historyBubbleTailOutRight; tail.paint(p, rect.x() + rect.width(), rect.y() + rect.height() - tail.height(), outerWidth); p.fillRect(rect.x() + rect.width() - st::historyMessageRadius, rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); - } else if (tail == BubbleTail::Left) { - parts |= App::RectPart::BottomRight; + } else if (tailSide == RectPart::Left) { + parts |= RectPart::BottomRight; p.fillRect(rect.x(), rect.y() + rect.height() - st::historyMessageRadius, st::historyMessageRadius, st::historyMessageRadius, bg); auto &tail = selected ? (outbg ? st::historyBubbleTailOutLeftSelected : st::historyBubbleTailInLeftSelected) : (outbg ? st::historyBubbleTailOutLeft : st::historyBubbleTailInLeft); tail.paint(p, rect.x() - tail.width(), rect.y() + rect.height() - tail.height(), outerWidth); p.fillRect(rect.x() - tail.width(), rect.y() + rect.height(), st::historyMessageRadius + tail.width(), st::msgShadow, sh); } else { - parts |= App::RectPart::BottomFull; + parts |= RectPart::FullBottom; } App::roundRect(p, rect, bg, cors, &sh, parts); } diff --git a/Telegram/SourceFiles/history/history_service_layout.h b/Telegram/SourceFiles/history/history_service_layout.h index 95311b48db..f7152c8a7a 100644 --- a/Telegram/SourceFiles/history/history_service_layout.h +++ b/Telegram/SourceFiles/history/history_service_layout.h @@ -54,11 +54,6 @@ void paintEmpty(Painter &p, int width, int height); void serviceColorsUpdated(); -enum class BubbleTail { - None, - Left, - Right, -}; -void paintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool outbg, BubbleTail tail); +void paintBubble(Painter &p, QRect rect, int outerWidth, bool selected, bool outbg, RectPart tailSide); } // namespace HistoryLayout diff --git a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp index feb9af6bd5..7fb9a7a8e1 100644 --- a/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp +++ b/Telegram/SourceFiles/inline_bots/inline_results_widget.cpp @@ -778,7 +778,7 @@ void Widget::paintEvent(QPaintEvent *e) { void Widget::paintContent(Painter &p) { auto inner = innerRect(); - App::roundRect(p, inner, st::emojiPanBg, ImageRoundRadius::Small, App::RectPart::TopFull | App::RectPart::BottomFull); + App::roundRect(p, inner, st::emojiPanBg, ImageRoundRadius::Small, RectPart::FullTop | RectPart::FullBottom); auto horizontal = horizontalRect(); auto sidesTop = horizontal.y(); diff --git a/Telegram/SourceFiles/layerwidget.cpp b/Telegram/SourceFiles/layerwidget.cpp index 16b4acafba..4e265c5759 100644 --- a/Telegram/SourceFiles/layerwidget.cpp +++ b/Telegram/SourceFiles/layerwidget.cpp @@ -223,20 +223,20 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) { if (_mainMenuCache.isNull() && mainMenuRight > 0) { // All cache images are taken together with their shadows, // so we paint shadow only when there is no cache. - Ui::Shadow::paint(p, myrtlrect(0, 0, mainMenuRight, height()), width(), st::boxRoundShadow, Ui::Shadow::Side::Right); + Ui::Shadow::paint(p, myrtlrect(0, 0, mainMenuRight, height()), width(), st::boxRoundShadow, RectPart::Right); } if (_specialLayerCache.isNull() && !specialLayerBox.isEmpty()) { // All cache images are taken together with their shadows, // so we paint shadow only when there is no cache. - auto sides = Ui::Shadow::Side::Left | Ui::Shadow::Side::Right; + auto sides = RectPart::Left | RectPart::Right; auto topCorners = (specialLayerBox.y() > 0); auto bottomCorners = (specialLayerBox.y() + specialLayerBox.height() < height()); if (topCorners) { - sides |= Ui::Shadow::Side::Top; + sides |= RectPart::Top; } if (bottomCorners) { - sides |= Ui::Shadow::Side::Bottom; + sides |= RectPart::Bottom; } if (topCorners || bottomCorners) { p.setClipRegion(QRegion(rect()) - specialLayerBox.marginsRemoved(QMargins(st::boxRadius, 0, st::boxRadius, 0)) - specialLayerBox.marginsRemoved(QMargins(0, st::boxRadius, 0, st::boxRadius))); @@ -247,8 +247,8 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) { // In case of painting the shadow above the special layer we get // glitches in the corners, so we need to paint the corners once more. p.setClipping(false); - auto parts = (topCorners ? (App::RectPart::TopLeft | App::RectPart::TopRight) : App::RectPart::None) - | (bottomCorners ? (App::RectPart::BottomLeft | App::RectPart::BottomRight) : App::RectPart::None); + auto parts = (topCorners ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None) + | (bottomCorners ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None); App::roundRect(p, specialLayerBox, st::boxBg, BoxCorners, nullptr, parts); } } @@ -387,12 +387,12 @@ void LayerStackWidget::setCacheImages() { auto bodyCache = QPixmap(), mainMenuCache = QPixmap(); auto specialLayerCache = QPixmap(); if (_specialLayer) { - auto sides = Ui::Shadow::Side::Left | Ui::Shadow::Side::Right; + auto sides = RectPart::Left | RectPart::Right; if (_specialLayer->y() > 0) { - sides |= Ui::Shadow::Side::Top; + sides |= RectPart::Top; } if (_specialLayer->y() + _specialLayer->height() < height()) { - sides |= Ui::Shadow::Side::Bottom; + sides |= RectPart::Bottom; } specialLayerCache = Ui::Shadow::grab(_specialLayer, st::boxRoundShadow, sides); } @@ -408,7 +408,7 @@ void LayerStackWidget::setCacheImages() { hideChildren(); bodyCache = myGrab(App::wnd()->bodyWidget()); showChildren(); - mainMenuCache = Ui::Shadow::grab(_mainMenu, st::boxRoundShadow, Ui::Shadow::Side::Right); + mainMenuCache = Ui::Shadow::grab(_mainMenu, st::boxRoundShadow, RectPart::Right); } setAttribute(Qt::WA_OpaquePaintEvent, !bodyCache.isNull()); updateLayerBoxes(); diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index ee035fab4a..1c557298e6 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -79,9 +79,9 @@ void ConnectingWidget::set(const QString &text, const QString &reconnect) { void ConnectingWidget::paintEvent(QPaintEvent *e) { Painter p(this); - auto sides = Ui::Shadow::Side::Top | Ui::Shadow::Side::Right; + auto sides = RectPart::Top | RectPart::Right; Ui::Shadow::paint(p, QRect(0, st::boxRoundShadow.extend.top(), width() - st::boxRoundShadow.extend.right(), height() - st::boxRoundShadow.extend.top()), width(), st::boxRoundShadow, sides); - auto parts = App::RectPart::Top | App::RectPart::TopRight | App::RectPart::Center | App::RectPart::Right; + auto parts = RectPart::Top | RectPart::TopRight | RectPart::Center | RectPart::Right; App::roundRect(p, QRect(-st::boxRadius, st::boxRoundShadow.extend.top(), width() - st::boxRoundShadow.extend.right() + st::boxRadius, height() - st::boxRoundShadow.extend.top() + st::boxRadius), st::boxBg, BoxCorners, nullptr, parts); p.setFont(st::normalFont); diff --git a/Telegram/SourceFiles/media/player/media_player_panel.cpp b/Telegram/SourceFiles/media/player/media_player_panel.cpp index 5562f80e22..eedb054533 100644 --- a/Telegram/SourceFiles/media/player/media_player_panel.cpp +++ b/Telegram/SourceFiles/media/player/media_player_panel.cpp @@ -165,14 +165,13 @@ void Panel::paintEvent(QPaintEvent *e) { } // draw shadow - using Side = Ui::Shadow::Side; auto shadowedRect = myrtlrect(contentLeft(), contentTop(), contentWidth(), contentHeight()); - auto shadowedSides = (rtl() ? Side::Right : Side::Left) | Side::Bottom; + auto shadowedSides = (rtl() ? RectPart::Right : RectPart::Left) | RectPart::Bottom; if (_layout != Layout::Full) { - shadowedSides |= (rtl() ? Side::Left : Side::Right) | Side::Top; + shadowedSides |= (rtl() ? RectPart::Left : RectPart::Right) | RectPart::Top; } Ui::Shadow::paint(p, shadowedRect, width(), st::defaultRoundShadow, shadowedSides); - auto parts = App::RectPart::Full; + auto parts = RectPart::Full; App::roundRect(p, shadowedRect, st::menuBg, MenuCorners, nullptr, parts); } @@ -224,7 +223,7 @@ void Panel::ensureCreated() { setPinCallback(std::move(_pinCallback)); setCloseCallback(std::move(_closeCallback)); - _scrollShadow.create(this, st::mediaPlayerScrollShadow, Ui::Shadow::Side::Bottom); + _scrollShadow.create(this, st::mediaPlayerScrollShadow, RectPart::Bottom); } auto list = object_ptr(this); connect(list, SIGNAL(heightUpdated()), this, SLOT(onListHeightUpdated())); diff --git a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp index 7604d4ff68..53a62e1839 100644 --- a/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp +++ b/Telegram/SourceFiles/media/player/media_player_volume_controller.cpp @@ -141,10 +141,9 @@ void VolumeWidget::paintEvent(QPaintEvent *e) { // draw shadow auto shadowedRect = rect().marginsRemoved(getMargin()); - using ShadowSide = Ui::Shadow::Side; - auto shadowedSides = ShadowSide::Left | ShadowSide::Right | ShadowSide::Bottom; + auto shadowedSides = RectPart::Left | RectPart::Right | RectPart::Bottom; Ui::Shadow::paint(p, shadowedRect, width(), st::defaultRoundShadow, shadowedSides); - auto parts = App::RectPart::NoTopBottom | App::RectPart::BottomFull; + auto parts = RectPart::NoTopBottom | RectPart::FullBottom; App::roundRect(p, QRect(shadowedRect.x(), -st::buttonRadius, shadowedRect.width(), shadowedRect.y() + shadowedRect.height() + st::buttonRadius), st::menuBg, MenuCorners, nullptr, parts); } diff --git a/Telegram/SourceFiles/profile/profile_inner_widget.cpp b/Telegram/SourceFiles/profile/profile_inner_widget.cpp index 119501c346..a54323babd 100644 --- a/Telegram/SourceFiles/profile/profile_inner_widget.cpp +++ b/Telegram/SourceFiles/profile/profile_inner_widget.cpp @@ -48,22 +48,22 @@ void InnerWidget::createBlocks() { auto channel = _peer->asChannel(); auto megagroup = _peer->isMegagroup() ? channel : nullptr; if (user || channel || megagroup) { - _blocks.push_back({ new InfoWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new InfoWidget(this, _peer), RectPart::Right }); } - _blocks.push_back({ new SettingsWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new SettingsWidget(this, _peer), RectPart::Right }); if (chat || channel || megagroup) { - _blocks.push_back({ new InviteLinkWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new InviteLinkWidget(this, _peer), RectPart::Right }); } - _blocks.push_back({ new SharedMediaWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new SharedMediaWidget(this, _peer), RectPart::Right }); if (channel && !megagroup) { - _blocks.push_back({ new ChannelMembersWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new ChannelMembersWidget(this, _peer), RectPart::Right }); } - _blocks.push_back({ new ActionsWidget(this, _peer), BlockSide::Right }); + _blocks.push_back({ new ActionsWidget(this, _peer), RectPart::Right }); if (chat || megagroup) { auto membersWidget = new GroupMembersWidget(this, _peer); connect(membersWidget, SIGNAL(onlineCountUpdated(int)), _cover, SLOT(onOnlineCountUpdated(int))); _cover->onOnlineCountUpdated(membersWidget->onlineCount()); - _blocks.push_back({ membersWidget, BlockSide::Left }); + _blocks.push_back({ membersWidget, RectPart::Left }); } for_const (auto &blockData, _blocks) { connect(blockData.block, SIGNAL(heightUpdated()), this, SLOT(onBlockHeightUpdated())); @@ -118,8 +118,8 @@ void InnerWidget::paintEvent(QPaintEvent *e) { p.fillRect(e->rect(), st::profileBg); if (_mode == Mode::TwoColumn) { - int leftHeight = countBlocksHeight(BlockSide::Left); - int rightHeight = countBlocksHeight(BlockSide::Right); + int leftHeight = countBlocksHeight(RectPart::Left); + int rightHeight = countBlocksHeight(RectPart::Right); int shadowHeight = rightHeight;// qMin(leftHeight, rightHeight); int shadowLeft = _blocksLeft + _leftColumnWidth + _columnDivider; @@ -134,7 +134,7 @@ void InnerWidget::keyPressEvent(QKeyEvent *e) { } } -int InnerWidget::countBlocksHeight(BlockSide countSide) const { +int InnerWidget::countBlocksHeight(RectPart countSide) const { int result = 0; for_const (auto &blockData, _blocks) { if (blockData.side != countSide || blockData.block->isHidden()) { @@ -156,7 +156,7 @@ InnerWidget::Mode InnerWidget::countBlocksMode(int newWidth) const { bool hasLeftWidget = false, hasRightWidget = false; for_const (auto &blockData, _blocks) { if (!blockData.block->isHidden()) { - if (blockData.side == BlockSide::Left) { + if (blockData.side == RectPart::Left) { hasLeftWidget = true; } else { hasRightWidget = true; @@ -187,7 +187,7 @@ int InnerWidget::countLeftColumnWidth(int newWidth) const { } void InnerWidget::refreshBlocksPositions() { - auto layoutBlocks = [this](BlockSide layoutSide, int left) { + auto layoutBlocks = [this](RectPart layoutSide, int left) { int top = _blocksTop; for_const (auto &blockData, _blocks) { if (_mode == Mode::TwoColumn && blockData.side != layoutSide) { @@ -202,9 +202,9 @@ void InnerWidget::refreshBlocksPositions() { top += blockData.block->height(); } }; - layoutBlocks(BlockSide::Left, _blocksLeft); + layoutBlocks(RectPart::Left, _blocksLeft); if (_mode == Mode::TwoColumn) { - layoutBlocks(BlockSide::Right, _blocksLeft + _leftColumnWidth + _columnDivider); + layoutBlocks(RectPart::Right, _blocksLeft + _leftColumnWidth + _columnDivider); } } @@ -214,7 +214,7 @@ void InnerWidget::resizeBlocks(int newWidth) { if (_mode == Mode::OneColumn) { blockWidth -= _blocksLeft; } else { - if (blockData.side == BlockSide::Left) { + if (blockData.side == RectPart::Left) { blockWidth = _leftColumnWidth; } else { blockWidth -= _leftColumnWidth + _columnDivider; @@ -244,11 +244,11 @@ int InnerWidget::resizeGetHeight(int newWidth) { } int InnerWidget::countHeight() const { - int newHeight = _cover->height(); - int leftHeight = countBlocksHeight(BlockSide::Left); - int rightHeight = countBlocksHeight(BlockSide::Right); + auto newHeight = _cover->height(); + auto leftHeight = countBlocksHeight(RectPart::Left); + auto rightHeight = countBlocksHeight(RectPart::Right); - int blocksHeight = (_mode == Mode::OneColumn) ? (leftHeight + rightHeight) : qMax(leftHeight, rightHeight); + auto blocksHeight = (_mode == Mode::OneColumn) ? (leftHeight + rightHeight) : qMax(leftHeight, rightHeight); newHeight += st::profileBlocksTop + blocksHeight + st::profileBlocksBottom; return newHeight; diff --git a/Telegram/SourceFiles/profile/profile_inner_widget.h b/Telegram/SourceFiles/profile/profile_inner_widget.h index 12ce19e638..701b4aaea8 100644 --- a/Telegram/SourceFiles/profile/profile_inner_widget.h +++ b/Telegram/SourceFiles/profile/profile_inner_widget.h @@ -77,14 +77,10 @@ private: OneColumn, TwoColumn, }; - enum class BlockSide { - Left, - Right, - }; int countBlocksLeft(int newWidth) const; Mode countBlocksMode(int newWidth) const; int countLeftColumnWidth(int newWidth) const; - int countBlocksHeight(BlockSide countSide) const; + int countBlocksHeight(RectPart countSide) const; void resizeBlocks(int newWidth); void refreshBlocksPositions(); @@ -110,7 +106,7 @@ private: int _leftColumnWidth = 0; // Caching countLeftColumnWidth() result. struct Block { BlockWidget *block; - BlockSide side; + RectPart side; }; QList _blocks; diff --git a/Telegram/SourceFiles/settings/settings_layer.cpp b/Telegram/SourceFiles/settings/settings_layer.cpp index c10f449485..180449c97a 100644 --- a/Telegram/SourceFiles/settings/settings_layer.cpp +++ b/Telegram/SourceFiles/settings/settings_layer.cpp @@ -89,9 +89,9 @@ void Layer::paintEvent(QPaintEvent *e) { auto paintTopRounded = clip.intersects(QRect(0, 0, width(), st::boxRadius)); auto paintBottomRounded = clip.intersects(QRect(0, height() - st::boxRadius, width(), st::boxRadius)); if (paintTopRounded || paintBottomRounded) { - auto parts = qFlags(App::RectPart::None); - if (paintTopRounded) parts |= App::RectPart::TopFull; - if (paintBottomRounded) parts |= App::RectPart::BottomFull; + auto parts = qFlags(RectPart::None); + if (paintTopRounded) parts |= RectPart::FullTop; + if (paintBottomRounded) parts |= RectPart::FullBottom; App::roundRect(p, rect(), st::boxBg, BoxCorners, nullptr, parts); } auto other = clip.intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius)); diff --git a/Telegram/SourceFiles/ui/twidget.h b/Telegram/SourceFiles/ui/twidget.h index 7de0ea545e..b5b1d2aade 100644 --- a/Telegram/SourceFiles/ui/twidget.h +++ b/Telegram/SourceFiles/ui/twidget.h @@ -55,9 +55,10 @@ enum class RectPart { CornersMask = TopLeft | TopRight | BottomLeft | BottomRight, SidesMask = Top | Bottom | Left | Right, - All = FullTop | NoTop, + Full = FullTop | NoTop, }; Q_DECLARE_FLAGS(RectParts, RectPart); +Q_DECLARE_OPERATORS_FOR_FLAGS(RectParts); inline bool IsTopCorner(RectPart corner) { return (corner == RectPart::TopLeft) || (corner == RectPart::TopRight); diff --git a/Telegram/SourceFiles/ui/widgets/shadow.cpp b/Telegram/SourceFiles/ui/widgets/shadow.cpp index ccb16ca1e0..0054227918 100644 --- a/Telegram/SourceFiles/ui/widgets/shadow.cpp +++ b/Telegram/SourceFiles/ui/widgets/shadow.cpp @@ -22,11 +22,11 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org namespace Ui { -void Shadow::paint(Painter &p, const QRect &box, int outerWidth, const style::Shadow &st, Sides sides) { - auto left = (sides & Side::Left); - auto top = (sides & Side::Top); - auto right = (sides & Side::Right); - auto bottom = (sides & Side::Bottom); +void Shadow::paint(Painter &p, const QRect &box, int outerWidth, const style::Shadow &st, RectParts sides) { + auto left = (sides & RectPart::Left); + auto top = (sides & RectPart::Top); + auto right = (sides & RectPart::Right); + auto bottom = (sides & RectPart::Bottom); if (left) { auto from = box.y(); auto to = from + box.height(); @@ -77,14 +77,14 @@ void Shadow::paint(Painter &p, const QRect &box, int outerWidth, const style::Sh } } -QPixmap Shadow::grab(TWidget *target, const style::Shadow &shadow, Sides sides) { +QPixmap Shadow::grab(TWidget *target, const style::Shadow &shadow, RectParts sides) { myEnsureResized(target); auto rect = target->rect(); auto extend = QMargins( - (sides & Side::Left) ? shadow.extend.left() : 0, - (sides & Side::Top) ? shadow.extend.top() : 0, - (sides & Side::Right) ? shadow.extend.right() : 0, - (sides & Side::Bottom) ? shadow.extend.bottom() : 0 + (sides & RectPart::Left) ? shadow.extend.left() : 0, + (sides & RectPart::Top) ? shadow.extend.top() : 0, + (sides & RectPart::Right) ? shadow.extend.right() : 0, + (sides & RectPart::Bottom) ? shadow.extend.bottom() : 0 ); auto full = QRect(0, 0, extend.left() + rect.width() + extend.right(), extend.top() + rect.height() + extend.bottom()); auto result = QPixmap(full.size() * cIntRetinaFactor()); diff --git a/Telegram/SourceFiles/ui/widgets/shadow.h b/Telegram/SourceFiles/ui/widgets/shadow.h index 8574f229a1..fcce8cc1d1 100644 --- a/Telegram/SourceFiles/ui/widgets/shadow.h +++ b/Telegram/SourceFiles/ui/widgets/shadow.h @@ -38,23 +38,14 @@ private: class Shadow : public TWidget { public: - enum class Side { - Left = 0x01, - Top = 0x02, - Right = 0x04, - Bottom = 0x08, - }; - Q_DECLARE_FLAGS(Sides, Side); - Q_DECLARE_FRIEND_OPERATORS_FOR_FLAGS(Sides); - - Shadow(QWidget *parent, const style::Shadow &st, Sides sides = Side::Left | Side::Top | Side::Right | Side::Bottom) : TWidget(parent) + Shadow(QWidget *parent, const style::Shadow &st, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom) : TWidget(parent) , _st(st) , _sides(sides) { } - static void paint(Painter &p, const QRect &box, int outerWidth, const style::Shadow &st, Sides sides = Side::Left | Side::Top | Side::Right | Side::Bottom); + static void paint(Painter &p, const QRect &box, int outerWidth, const style::Shadow &st, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom); - static QPixmap grab(TWidget *target, const style::Shadow &shadow, Sides sides = Side::Left | Side::Top | Side::Right | Side::Bottom); + static QPixmap grab(TWidget *target, const style::Shadow &shadow, RectParts sides = RectPart::Left | RectPart::Top | RectPart::Right | RectPart::Bottom); protected: void paintEvent(QPaintEvent *e) override { @@ -64,9 +55,8 @@ protected: private: const style::Shadow &_st; - Sides _sides; + RectParts _sides; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(Shadow::Sides); } // namespace Ui diff --git a/Telegram/SourceFiles/ui/widgets/tooltip.cpp b/Telegram/SourceFiles/ui/widgets/tooltip.cpp index 40755973b7..cb0549f5f3 100644 --- a/Telegram/SourceFiles/ui/widgets/tooltip.cpp +++ b/Telegram/SourceFiles/ui/widgets/tooltip.cpp @@ -208,7 +208,7 @@ ImportantTooltip::ImportantTooltip(QWidget *parent, object_ptr content, hide(); } -void ImportantTooltip::pointAt(QRect area, Side side) { +void ImportantTooltip::pointAt(QRect area, RectParts side) { if (_area == area && _side == side) { return; } @@ -239,7 +239,7 @@ void ImportantTooltip::setArea(QRect area) { resize(size); } -void ImportantTooltip::countApproachSide(Side preferSide) { +void ImportantTooltip::countApproachSide(RectParts preferSide) { Expects(parentWidget() != nullptr); auto requiredSpace = countInner().height() + _st.shift; if (_useTransparency) { @@ -253,7 +253,7 @@ void ImportantTooltip::countApproachSide(Side preferSide) { if ((allowedAbove && allowedBelow) || (!allowedAbove && !allowedBelow)) { _side = preferSide; } else { - _side = (allowedAbove ? SideFlag::Up : SideFlag::Down) | (preferSide & (SideFlag::Left | SideFlag::Center | SideFlag::Right)); + _side = (allowedAbove ? RectPart::Top : RectPart::Bottom) | (preferSide & (RectPart::Left | RectPart::Center | RectPart::Right)); } if (_useTransparency) { auto arrow = QImage(QSize(_st.arrow * 2, _st.arrow) * cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied); @@ -270,7 +270,7 @@ void ImportantTooltip::countApproachSide(Side preferSide) { path.lineTo(0, 0); p.fillPath(path, _st.bg); } - if (_side & SideFlag::Down) { + if (_side & RectPart::Bottom) { arrow = std::move(arrow).transformed(QTransform(1, 0, 0, -1, 0, 0)); } _arrow = App::pixmapFromImageInPlace(std::move(arrow)); @@ -345,9 +345,9 @@ void ImportantTooltip::updateGeometry() { auto parent = parentWidget(); auto areaMiddle = _area.x() + (_area.width() / 2); auto left = areaMiddle - (width() / 2); - if (_side & SideFlag::Left) { + if (_side & RectPart::Left) { left = areaMiddle + _st.arrowSkip - width(); - } else if (_side & SideFlag::Right) { + } else if (_side & RectPart::Right) { left = areaMiddle - _st.arrowSkip; } accumulate_min(left, parent->width() - _st.margin.right() - width()); @@ -357,7 +357,7 @@ void ImportantTooltip::updateGeometry() { auto countTop = [this] { auto shift = anim::interpolate(_st.shift, 0, _visibleAnimation.current(_visible ? 1. : 0.)); - if (_side & SideFlag::Up) { + if (_side & RectPart::Top) { return _area.y() - height() - shift; } return _area.y() + _area.height() + shift; @@ -368,7 +368,7 @@ void ImportantTooltip::updateGeometry() { void ImportantTooltip::resizeEvent(QResizeEvent *e) { auto inner = countInner(); auto contentTop = _st.padding.top(); - if (_useTransparency && (_side & SideFlag::Down)) { + if (_useTransparency && (_side & RectPart::Bottom)) { contentTop += _st.arrow; } _content->moveToLeft(_st.padding.left(), contentTop); @@ -399,7 +399,7 @@ void ImportantTooltip::paintEvent(QPaintEvent *e) { } auto areaMiddle = _area.x() + (_area.width() / 2) - x(); auto arrowLeft = areaMiddle - _st.arrow; - if (_side & SideFlag::Up) { + if (_side & RectPart::Top) { p.drawPixmapLeft(arrowLeft, inner.y() + inner.height(), width(), _arrow); } else { p.drawPixmapLeft(arrowLeft, inner.y() - _st.arrow, width(), _arrow); diff --git a/Telegram/SourceFiles/ui/widgets/tooltip.h b/Telegram/SourceFiles/ui/widgets/tooltip.h index 800a8a2285..ec4c6974ec 100644 --- a/Telegram/SourceFiles/ui/widgets/tooltip.h +++ b/Telegram/SourceFiles/ui/widgets/tooltip.h @@ -79,15 +79,7 @@ class ImportantTooltip : public TWidget { public: ImportantTooltip(QWidget *parent, object_ptr content, const style::ImportantTooltip &st); - enum class SideFlag { - Up = 0x01, - Down = 0x02, - Left = 0x04, - Center = 0x08, - Right = 0x0c, - }; - Q_DECLARE_FLAGS(Side, SideFlag); - void pointAt(QRect area, Side preferSide = Side(SideFlag::Up) | SideFlag::Left); + void pointAt(QRect area, RectParts preferSide = RectPart::Top | RectPart::Left); void toggleAnimated(bool visible); void toggleFast(bool visible); @@ -105,7 +97,7 @@ private: void animationCallback(); QRect countInner() const; void setArea(QRect area); - void countApproachSide(Side preferSide); + void countApproachSide(RectParts preferSide); void updateGeometry(); void checkAnimationFinish(); void refreshAnimationCache(); @@ -114,7 +106,7 @@ private: const style::ImportantTooltip &_st; object_ptr _content; QRect _area; - Side _side = Side(SideFlag::Up) | SideFlag::Left; + RectParts _side = RectPart::Top | RectPart::Left; QPixmap _arrow; Animation _visibleAnimation; @@ -125,6 +117,4 @@ private: }; -Q_DECLARE_OPERATORS_FOR_FLAGS(ImportantTooltip::Side); - } // namespace Ui