From 1c1e6437356bb5086def632605ca070a93c48b61 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 28 Jul 2023 21:38:59 +0400 Subject: [PATCH] Use close icon from group calls in stories tooltip. --- Telegram/SourceFiles/dialogs/dialogs.style | 9 ++++- .../dialogs/ui/dialogs_stories_list.cpp | 35 ++++--------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index 88e1239bee..622016bb8f 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -567,4 +567,11 @@ dialogsStoriesTooltip: ImportantTooltip(defaultImportantTooltip) { } dialogsStoriesTooltipLabel: defaultImportantTooltipLabel; dialogsStoriesTooltipMaxWidth: 200px; -dialogsStoriesTooltipHide: size(14px, 14px); +dialogsStoriesTooltipHide: IconButton(defaultIconButton) { + width: 34px; + height: 20px; + iconPosition: point(-1px, -1px); + icon: icon {{ "calls/video_tooltip", importantTooltipFg }}; + iconOver: icon {{ "calls/video_tooltip", importantTooltipFg }}; + ripple: emptyRippleAnimation; +} diff --git a/Telegram/SourceFiles/dialogs/ui/dialogs_stories_list.cpp b/Telegram/SourceFiles/dialogs/ui/dialogs_stories_list.cpp index f990917213..82854b90b9 100644 --- a/Telegram/SourceFiles/dialogs/ui/dialogs_stories_list.cpp +++ b/Telegram/SourceFiles/dialogs/ui/dialogs_stories_list.cpp @@ -13,10 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/outline_segments.h" #include "ui/text/text_utilities.h" #include "ui/widgets/menu/menu_add_action_callback_factory.h" +#include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/tooltip.h" -#include "ui/abstract_button.h" #include "ui/painter.h" #include "styles/style_dialogs.h" @@ -49,8 +49,7 @@ constexpr auto kStoriesTooltipHideBgOpacity = 0.2; not_null parent, rpl::producer text, Fn hide) { - const auto size = st::dialogsStoriesTooltipHide; - const auto buttonw = size.width(); + const auto size = st::dialogsStoriesTooltipHide.width; const auto skip = st::defaultImportantTooltip.padding.right(); auto result = object_ptr>( parent, @@ -60,36 +59,16 @@ constexpr auto kStoriesTooltipHideBgOpacity = 0.2; st::dialogsStoriesTooltipMaxWidth, st::dialogsStoriesTooltipLabel), (st::defaultImportantTooltip.padding - + QMargins(0, 0, skip + buttonw, 0))); - const auto button = Ui::CreateChild(result.data()); + + QMargins(0, 0, skip + size, 0))); + const auto button = Ui::CreateChild( + result.data(), + st::dialogsStoriesTooltipHide); result->sizeValue( ) | rpl::start_with_next([=](QSize size) { - button->resize(skip * 2 + buttonw, size.height()); + button->resize(button->width(), size.height()); button->moveToRight(0, 0, size.width()); }, button->lifetime()); button->setClickedCallback(std::move(hide)); - button->paintRequest( - ) | rpl::start_with_next([=] { - auto p = QPainter(button); - auto hq = PainterHighQualityEnabler(p); - p.setPen(Qt::NoPen); - p.setBrush(st::importantTooltipFg); - p.setOpacity(kStoriesTooltipHideBgOpacity); - const auto rect = style::centerrect( - button->rect(), - QRect(QPoint(), size)); - const auto center = QRectF(rect).center(); - const auto half = QSizeF(rect.size()) / 6.; - const auto phalf = QPointF(half.width(), half.height()); - const auto mhalf = QPointF(-half.width(), half.height()); - p.drawEllipse(rect); - p.setOpacity(1.); - auto pen = st::importantTooltipFg->p; - pen.setWidthF(style::ConvertScaleExact(sqrtf(2.))); - p.setPen(pen); - p.drawLine(center - phalf, center + phalf); - p.drawLine(center - mhalf, center + mhalf); - }, button->lifetime()); return result; }