mirror-chatterino2/src/messages/word.hpp

143 lines
3.7 KiB
C++
Raw Normal View History

#pragma once
2017-01-05 16:07:20 +01:00
2017-06-11 09:31:45 +02:00
#include "fontmanager.hpp"
#include "messages/lazyloadedimage.hpp"
#include "messages/link.hpp"
2017-01-18 04:52:47 +01:00
#include <stdint.h>
#include <QRect>
#include <QString>
2017-01-05 16:07:20 +01:00
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2017-01-18 21:30:23 +01:00
2017-01-05 16:07:20 +01:00
class Word
{
public:
enum Type : uint32_t {
2017-01-05 16:07:20 +01:00
None = 0,
Misc = (1 << 0),
Text = (1 << 1),
2017-01-05 16:07:20 +01:00
TimestampNoSeconds = (1 << 2),
TimestampWithSeconds = (1 << 3),
2017-01-05 16:07:20 +01:00
TwitchEmoteImage = (1 << 4),
TwitchEmoteText = (1 << 5),
BttvEmoteImage = (1 << 6),
BttvEmoteText = (1 << 7),
BttvGifEmoteImage = (1 << 8),
BttvGifEmoteText = (1 << 9),
FfzEmoteImage = (1 << 10),
FfzEmoteText = (1 << 11),
2017-04-12 17:46:44 +02:00
EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage | FfzEmoteImage,
2017-01-05 16:07:20 +01:00
2017-01-22 12:46:35 +01:00
BitsStatic = (1 << 12),
BitsAnimated = (1 << 13),
2017-01-05 16:07:20 +01:00
// Slot 1: Twitch
// - Staff badge
// - Admin badge
// - Global Moderator badge
BadgeGlobalAuthority = (1 << 14),
// Slot 2: Twitch
// - Moderator badge
// - Broadcaster badge
BadgeChannelAuthority = (1 << 15),
// Slot 3: Twitch
// - Subscription badges
BadgeSubscription = (1 << 16),
// Slot 4: Twitch
// - Turbo badge
// - Prime badge
// - Bit badges
// - Game badges
BadgeVanity = (1 << 17),
// Slot 5: Chatterino
// - Chatterino developer badge
// - Chatterino donator badge
// - Chatterino top donator badge
BadgeChatterino = (1 << 18),
// Rest of slots: ffz custom badge? bttv custom badge? mywaifu (puke) custom badge?
Badges = BadgeGlobalAuthority | BadgeChannelAuthority | BadgeSubscription | BadgeVanity |
BadgeChatterino,
Username = (1 << 19),
BitsAmount = (1 << 20),
ButtonBan = (1 << 21),
ButtonTimeout = (1 << 22),
EmojiImage = (1 << 23),
EmojiText = (1 << 24),
2017-01-15 16:38:30 +01:00
AlwaysShow = (1 << 25),
2017-04-12 17:46:44 +02:00
Default = TimestampNoSeconds | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount | Text |
ButtonBan | ButtonTimeout | AlwaysShow
2017-01-05 16:07:20 +01:00
};
2017-02-17 23:51:35 +01:00
Word()
{
}
2017-04-12 17:46:44 +02:00
explicit Word(LazyLoadedImage *_image, Type getType, const QString &copytext,
2017-01-18 04:33:30 +01:00
const QString &getTooltip, const Link &getLink = Link());
2017-04-12 17:46:44 +02:00
explicit Word(const QString &_text, Type getType, const QColor &getColor,
const QString &copytext, const QString &getTooltip, const Link &getLink = Link());
LazyLoadedImage &getImage() const;
const QString &getText() const;
int getWidth() const;
int getHeight() const;
void setSize(int _width, int _height);
bool isImage() const;
bool isText() const;
const QString &getCopyText() const;
bool hasTrailingSpace() const;
QFont &getFont() const;
QFontMetrics &getFontMetrics() const;
Type getType() const;
const QString &getTooltip() const;
const QColor &getColor() const;
const Link &getLink() const;
int getXOffset() const;
int getYOffset() const;
void setOffset(int _xOffset, int _yOffset);
2017-09-12 19:06:16 +02:00
int getCharacterLength() const;
2017-04-12 17:46:44 +02:00
std::vector<short> &getCharacterWidthCache() const;
2017-01-15 16:38:30 +01:00
2017-01-05 16:07:20 +01:00
private:
2017-09-12 19:06:16 +02:00
LazyLoadedImage *image;
QString text;
QColor color;
2017-01-18 04:33:30 +01:00
bool _isImage;
2017-01-05 16:07:20 +01:00
2017-09-12 19:06:16 +02:00
Type type;
QString copyText;
QString tooltip;
2017-01-11 01:08:20 +01:00
2017-09-12 19:06:16 +02:00
int width = 16;
int height = 16;
int xOffset = 0;
int yOffset = 0;
2017-01-11 01:08:20 +01:00
2017-09-12 19:06:16 +02:00
bool _hasTrailingSpace = true;
FontManager::Type font = FontManager::Medium;
Link link;
2017-01-15 16:38:30 +01:00
2017-09-12 19:06:16 +02:00
mutable std::vector<short> charWidthCache;
2017-01-05 16:07:20 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino