tdesktop/Telegram/SourceFiles/ui/unread_badge.h

76 lines
1.4 KiB
C
Raw Normal View History

2017-12-17 11:04:47 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2017-12-17 11:04:47 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2017-12-17 11:04:47 +00:00
*/
#pragma once
#include "ui/rp_widget.h"
namespace Ui::Text {
class CustomEmoji;
} // namespace Ui::Text
2017-12-17 11:04:47 +00:00
namespace Ui {
class UnreadBadge : public RpWidget {
public:
using RpWidget::RpWidget;
void setText(const QString &text, bool active);
2019-05-26 12:08:34 +00:00
int textBaseline() const;
2017-12-17 11:04:47 +00:00
protected:
void paintEvent(QPaintEvent *e) override;
private:
QString _text;
bool _active = false;
};
class PeerBadge {
public:
PeerBadge();
~PeerBadge();
struct Descriptor {
not_null<PeerData*> peer;
const style::icon *verified = nullptr;
const style::icon *premium = nullptr;
const style::color *scam = nullptr;
2022-08-31 08:29:09 +00:00
const style::color *premiumFg = nullptr;
Fn<void()> customEmojiRepaint;
crl::time now = 0;
bool paused = false;
};
int drawGetWidth(
Painter &p,
QRect rectForName,
int nameWidth,
int outerWidth,
const Descriptor &descriptor);
void unload();
private:
struct EmojiStatus {
DocumentId id = 0;
std::unique_ptr<Ui::Text::CustomEmoji> emoji;
int skip = 0;
};
std::unique_ptr<EmojiStatus> _emojiStatus;
2019-06-23 12:18:33 +00:00
};
2021-01-21 12:39:40 +00:00
QSize ScamBadgeSize(bool fake);
2019-06-23 12:18:33 +00:00
void DrawScamBadge(
2021-01-21 12:39:40 +00:00
bool fake,
2019-06-23 12:18:33 +00:00
Painter &p,
QRect rect,
int outerWidth,
const style::color &color);
2017-12-17 11:04:47 +00:00
} // namespace Ui