mirror-chatterino2/messages/word.h

121 lines
3.2 KiB
C
Raw Normal View History

2017-01-05 16:07:20 +01:00
#ifndef WORD_H
#define WORD_H
2017-04-12 17:46:44 +02:00
#include "fontmanager.h"
2017-01-18 21:30:23 +01:00
#include "messages/lazyloadedimage.h"
#include "messages/link.h"
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
BadgeStaff = (1 << 14),
BadgeAdmin = (1 << 15),
BadgeGlobalMod = (1 << 16),
BadgeModerator = (1 << 17),
BadgeTurbo = (1 << 18),
BadgeBroadcaster = (1 << 19),
BadgePremium = (1 << 20),
BadgeChatterino = (1 << 21),
BadgeCheer = (1 << 22),
2017-04-12 17:46:44 +02:00
Badges = BadgeStaff | BadgeAdmin | BadgeGlobalMod | BadgeModerator | BadgeTurbo |
BadgeBroadcaster | BadgePremium | BadgeChatterino | BadgeCheer,
2017-01-05 20:49:33 +01:00
Username = (1 << 23),
BitsAmount = (1 << 24),
2017-01-05 20:49:33 +01:00
ButtonBan = (1 << 25),
ButtonTimeout = (1 << 26),
2017-01-15 16:38:30 +01:00
EmojiImage = (1 << 27),
EmojiText = (1 << 28),
2017-01-15 16:38:30 +01:00
2017-04-12 17:46:44 +02:00
Default = TimestampNoSeconds | Badges | Username | BitsStatic | FfzEmoteImage |
BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount | Text |
ButtonBan | ButtonTimeout
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);
std::vector<short> &getCharacterWidthCache() const;
2017-01-15 16:38:30 +01:00
2017-01-05 16:07:20 +01:00
private:
2017-04-12 17:46:44 +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-04-12 17:46:44 +02:00
Type _type;
QString _copyText;
QString _tooltip;
2017-01-11 01:08:20 +01:00
2017-04-12 17:46:44 +02:00
int _width = 16;
int _height = 16;
int _xOffset = 0;
int _yOffset = 0;
2017-01-11 01:08:20 +01:00
2017-01-18 04:33:30 +01:00
bool _hasTrailingSpace;
2017-04-12 17:46:44 +02:00
FontManager::Type _font = FontManager::Medium;
Link _link;
2017-01-15 16:38:30 +01:00
2017-04-12 17:46:44 +02:00
mutable std::vector<short> _characterWidthCache;
2017-01-05 16:07:20 +01:00
};
2017-04-14 17:52:22 +02:00
} // namespace messages
} // namespace chatterino
2017-01-05 16:07:20 +01:00
2017-01-11 18:52:09 +01:00
#endif // WORD_H