"Fossies" - the Fresh Open Source Software Archive

Member "tdesktop-2.6.1/Telegram/SourceFiles/ui/chat/message_bar.h" (24 Feb 2021, 2827 Bytes) of package /linux/misc/tdesktop-2.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "message_bar.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 This file is part of Telegram Desktop,
    3 the official desktop application for the Telegram messaging service.
    4 
    5 For license and copyright information please follow this link:
    6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
    7 */
    8 #pragma once
    9 
   10 #include "ui/rp_widget.h"
   11 #include "ui/effects/animations.h"
   12 
   13 class Painter;
   14 
   15 namespace style {
   16 struct MessageBar;
   17 } // namespace style
   18 
   19 namespace Ui {
   20 
   21 struct MessageBarContent {
   22     int index = 0;
   23     int count = 1;
   24     QString title;
   25     TextWithEntities text;
   26     QImage preview;
   27 };
   28 
   29 class MessageBar final {
   30 public:
   31     MessageBar(not_null<QWidget*> parent, const style::MessageBar &st);
   32 
   33     void set(MessageBarContent &&content);
   34     void set(rpl::producer<MessageBarContent> content);
   35 
   36     [[nodiscard]] not_null<Ui::RpWidget*> widget() {
   37         return &_widget;
   38     }
   39 
   40     void finishAnimating();
   41 
   42 private:
   43     enum class BodyAnimation : char {
   44         Full,
   45         Text,
   46         None,
   47     };
   48     struct Animation {
   49         Ui::Animations::Simple bodyMoved;
   50         Ui::Animations::Simple imageShown;
   51         Ui::Animations::Simple barScroll;
   52         Ui::Animations::Simple barTop;
   53         QPixmap bodyOrTextFrom;
   54         QPixmap bodyOrTextTo;
   55         QPixmap titleSame;
   56         QPixmap titleFrom;
   57         QPixmap titleTo;
   58         QPixmap imageFrom;
   59         QPixmap imageTo;
   60         BodyAnimation bodyAnimation = BodyAnimation::None;
   61         RectPart movingTo = RectPart::None;
   62     };
   63     struct BarState {
   64         float64 scroll = 0.;
   65         float64 size = 0.;
   66         float64 skip = 0.;
   67         float64 offset = 0.;
   68     };
   69     void setup();
   70     void paint(Painter &p);
   71     void paintLeftBar(Painter &p);
   72     void tweenTo(MessageBarContent &&content);
   73     void updateFromContent(MessageBarContent &&content);
   74     [[nodiscard]] QPixmap prepareImage(const QImage &preview);
   75 
   76     [[nodiscard]] QRect imageRect() const;
   77     [[nodiscard]] QRect titleRangeRect(int from, int till) const;
   78     [[nodiscard]] QRect bodyRect(bool withImage) const;
   79     [[nodiscard]] QRect bodyRect() const;
   80     [[nodiscard]] QRect textRect() const;
   81 
   82     auto makeGrabGuard();
   83     [[nodiscard]] QPixmap grabBodyOrTextPart(BodyAnimation type);
   84     [[nodiscard]] QPixmap grabTitleBase(int till);
   85     [[nodiscard]] QPixmap grabTitlePart(int from);
   86     [[nodiscard]] QPixmap grabTitleRange(int from, int till);
   87     [[nodiscard]] QPixmap grabImagePart();
   88     [[nodiscard]] QPixmap grabBodyPart();
   89     [[nodiscard]] QPixmap grabTextPart();
   90 
   91     [[nodiscard]] BarState countBarState(int index) const;
   92     [[nodiscard]] BarState countBarState() const;
   93     void ensureGradientsCreated(int size);
   94 
   95     [[nodiscard]] static BodyAnimation DetectBodyAnimationType(
   96         Animation *currentAnimation,
   97         const MessageBarContent &currentContent,
   98         const MessageBarContent &nextContent);
   99 
  100     const style::MessageBar &_st;
  101     Ui::RpWidget _widget;
  102     MessageBarContent _content;
  103     rpl::lifetime _contentLifetime;
  104     Ui::Text::String _title, _text;
  105     QPixmap _image, _topBarGradient, _bottomBarGradient;
  106     std::unique_ptr<Animation> _animation;
  107 
  108 };
  109 
  110 } // namespace Ui