2017-06-07 10:09:24 +02:00
|
|
|
#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-09-21 12:15:01 +02:00
|
|
|
#include "messages/messagecolor.hpp"
|
2017-01-05 17:02:05 +01:00
|
|
|
|
2017-01-18 04:52:47 +01:00
|
|
|
#include <stdint.h>
|
2017-01-05 17:02:05 +01:00
|
|
|
#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:
|
2017-01-15 17:25:19 +01:00
|
|
|
enum Type : uint32_t {
|
2017-01-05 16:07:20 +01:00
|
|
|
None = 0,
|
2017-01-15 17:25:19 +01:00
|
|
|
Misc = (1 << 0),
|
|
|
|
Text = (1 << 1),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +01:00
|
|
|
TimestampNoSeconds = (1 << 2),
|
|
|
|
TimestampWithSeconds = (1 << 3),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-01-15 17:25:19 +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),
|
2017-01-15 17:25:19 +01:00
|
|
|
BitsAnimated = (1 << 13),
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-06-16 10:11:44 +02: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),
|
2017-06-26 16:41:20 +02:00
|
|
|
EmojiText = (1 << 24),
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-09-16 00:05:06 +02:00
|
|
|
AlwaysShow = (1 << 25),
|
|
|
|
|
2017-12-19 00:09:38 +01:00
|
|
|
// used in the ChannelView class to make the collapse buttons visible if needed
|
|
|
|
Collapsed = (1 << 26),
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
Default = TimestampNoSeconds | Badges | Username | BitsStatic | FfzEmoteImage |
|
|
|
|
BttvEmoteImage | BttvGifEmoteImage | TwitchEmoteImage | BitsAmount | Text |
|
2017-09-16 00:05:06 +02:00
|
|
|
ButtonBan | ButtonTimeout | AlwaysShow
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
|
|
|
|
2017-02-17 23:51:35 +01:00
|
|
|
Word()
|
|
|
|
{
|
|
|
|
}
|
2017-06-26 16:41:20 +02:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
explicit Word(LazyLoadedImage *_image, Type getType, const QString ©text,
|
2017-01-18 04:33:30 +01:00
|
|
|
const QString &getTooltip, const Link &getLink = Link());
|
2017-09-21 00:54:10 +02:00
|
|
|
explicit Word(const QString &_text, Type getType, const MessageColor &getColor,
|
2017-04-12 17:46:44 +02:00
|
|
|
const QString ©text, 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;
|
2017-09-21 00:54:10 +02:00
|
|
|
const MessageColor &getColor() const;
|
2017-04-12 17:46:44 +02:00
|
|
|
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
|
|
|
|
2017-10-11 10:34:04 +02:00
|
|
|
short getCharWidth(int index) 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;
|
2017-09-21 00:54:10 +02:00
|
|
|
MessageColor 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-10-11 10:34:04 +02:00
|
|
|
std::vector<short> &getCharacterWidthCache() const;
|
2017-09-12 19:06:16 +02:00
|
|
|
mutable std::vector<short> charWidthCache;
|
2017-01-05 16:07:20 +01:00
|
|
|
};
|
2017-03-11 11:32:19 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|