mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
211 lines
4 KiB
C++
211 lines
4 KiB
C++
#ifndef WORD_H
|
|
#define WORD_H
|
|
|
|
#include "fonts.h"
|
|
#include "lazyloadedimage.h"
|
|
#include "link.h"
|
|
|
|
#include <QRect>
|
|
#include <QString>
|
|
|
|
#include <stdint.h>
|
|
|
|
class Word
|
|
{
|
|
public:
|
|
enum Type : uint32_t {
|
|
None = 0,
|
|
Misc = (1 << 0),
|
|
Text = (1 << 1),
|
|
|
|
TimestampNoSeconds = (1 << 2),
|
|
TimestampWithSeconds = (1 << 3),
|
|
|
|
TwitchEmoteImage = (1 << 4),
|
|
TwitchEmoteText = (1 << 5),
|
|
BttvEmoteImage = (1 << 6),
|
|
BttvEmoteText = (1 << 7),
|
|
BttvGifEmoteImage = (1 << 8),
|
|
BttvGifEmoteText = (1 << 9),
|
|
FfzEmoteImage = (1 << 10),
|
|
FfzEmoteText = (1 << 11),
|
|
EmoteImages = TwitchEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
|
|
FfzEmoteImage,
|
|
|
|
Bits = (1 << 12),
|
|
BitsAnimated = (1 << 13),
|
|
|
|
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),
|
|
Badges = BadgeStaff | BadgeAdmin | BadgeGlobalMod | BadgeModerator |
|
|
BadgeTurbo | BadgeBroadcaster | BadgePremium |
|
|
BadgeChatterino | BadgeCheer,
|
|
|
|
Username = (1 << 23),
|
|
BitsAmount = (1 << 24),
|
|
|
|
ButtonBan = (1 << 25),
|
|
ButtonTimeout = (1 << 26),
|
|
|
|
EmojiImage = (1 << 27),
|
|
EmojiText = (1 << 28),
|
|
|
|
Default = TimestampNoSeconds | Badges | Username | Bits |
|
|
FfzEmoteImage | BttvEmoteImage | BttvGifEmoteImage |
|
|
TwitchEmoteImage | BitsAmount | Text | ButtonBan |
|
|
ButtonTimeout
|
|
};
|
|
|
|
explicit Word(LazyLoadedImage *m_image, Type type, const QString ©text,
|
|
const QString &tooltip, const Link &link = Link());
|
|
explicit Word(const QString &m_text, Type type, const QColor &color,
|
|
const QString ©text, const QString &tooltip,
|
|
const Link &link = Link());
|
|
|
|
LazyLoadedImage &
|
|
getImage() const
|
|
{
|
|
return *m_image;
|
|
}
|
|
|
|
const QString &
|
|
getText() const
|
|
{
|
|
return m_text;
|
|
}
|
|
|
|
int
|
|
width() const
|
|
{
|
|
return m_width;
|
|
}
|
|
|
|
int
|
|
height() const
|
|
{
|
|
return m_height;
|
|
}
|
|
|
|
void
|
|
setSize(int width, int height)
|
|
{
|
|
m_width = width;
|
|
m_height = height;
|
|
}
|
|
|
|
bool
|
|
isImage() const
|
|
{
|
|
return m_isImage;
|
|
}
|
|
|
|
bool
|
|
isText() const
|
|
{
|
|
return !m_isImage;
|
|
}
|
|
|
|
const QString &
|
|
copyText() const
|
|
{
|
|
return m_copyText;
|
|
}
|
|
|
|
bool
|
|
hasTrailingSpace() const
|
|
{
|
|
return m_hasTrailingSpace;
|
|
}
|
|
|
|
QFont &
|
|
getFont() const
|
|
{
|
|
return Fonts::getFont(m_font);
|
|
}
|
|
|
|
QFontMetrics &
|
|
getFontMetrics() const
|
|
{
|
|
return Fonts::getFontMetrics(m_font);
|
|
}
|
|
|
|
Type
|
|
type() const
|
|
{
|
|
return m_type;
|
|
}
|
|
|
|
const QString &
|
|
tooltip() const
|
|
{
|
|
return m_tooltip;
|
|
}
|
|
|
|
const QColor &
|
|
color() const
|
|
{
|
|
return m_color;
|
|
}
|
|
|
|
const Link &
|
|
link() const
|
|
{
|
|
return m_link;
|
|
}
|
|
|
|
int
|
|
xOffset() const
|
|
{
|
|
return m_xOffset;
|
|
}
|
|
|
|
int
|
|
yOffset() const
|
|
{
|
|
return m_yOffset;
|
|
}
|
|
|
|
void
|
|
setOffset(int xOffset, int yOffset)
|
|
{
|
|
m_xOffset = std::max(0, xOffset);
|
|
m_yOffset = std::max(0, yOffset);
|
|
}
|
|
|
|
std::vector<short> &
|
|
characterWidthCache()
|
|
{
|
|
return m_characterWidthCache;
|
|
}
|
|
|
|
private:
|
|
LazyLoadedImage *m_image;
|
|
QString m_text;
|
|
QColor m_color;
|
|
bool m_isImage;
|
|
|
|
Type m_type;
|
|
QString m_copyText;
|
|
QString m_tooltip;
|
|
|
|
int m_width = 16;
|
|
int m_height = 16;
|
|
int m_xOffset = 0;
|
|
int m_yOffset = 0;
|
|
|
|
bool m_hasTrailingSpace;
|
|
Fonts::Type m_font = Fonts::Medium;
|
|
Link m_link;
|
|
|
|
std::vector<short> m_characterWidthCache;
|
|
};
|
|
|
|
#endif // WORD_H
|