2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "messages/message.hpp"
|
2017-09-24 18:43:24 +02:00
|
|
|
#include "messages/wordpart.hpp"
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
#include <QPixmap>
|
2017-06-07 10:09:24 +02:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
#include <memory>
|
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
|
|
|
namespace messages {
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
class MessageRef;
|
|
|
|
|
|
|
|
typedef std::shared_ptr<MessageRef> SharedMessageRef;
|
|
|
|
|
2017-02-02 22:15:09 +01:00
|
|
|
class MessageRef
|
|
|
|
{
|
|
|
|
public:
|
2017-04-12 17:46:44 +02:00
|
|
|
MessageRef(SharedMessage message);
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
Message *getMessage();
|
|
|
|
int getHeight() const;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-12-23 21:18:13 +01:00
|
|
|
bool layout(int width, float scale);
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
const std::vector<WordPart> &getWordParts() const;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
std::shared_ptr<QPixmap> buffer = nullptr;
|
|
|
|
bool updateBuffer = false;
|
|
|
|
|
2017-09-24 18:43:24 +02:00
|
|
|
const Word *tryGetWordPart(QPoint point);
|
2017-11-04 13:17:35 +01:00
|
|
|
int getLastCharacterIndex() const;
|
2017-02-17 23:51:35 +01:00
|
|
|
int getSelectionIndex(QPoint position);
|
|
|
|
|
2017-12-19 00:09:38 +01:00
|
|
|
bool isCollapsed() const;
|
|
|
|
void setCollapsed(bool value);
|
|
|
|
int getCollapsedHeight() const;
|
2017-12-23 21:18:13 +01:00
|
|
|
int getCollapsedLineCount() const;
|
2017-12-19 00:09:38 +01:00
|
|
|
|
2018-01-01 23:29:54 +01:00
|
|
|
bool isDisabled() const;
|
|
|
|
|
2017-02-02 22:15:09 +01:00
|
|
|
private:
|
2017-04-12 17:46:44 +02:00
|
|
|
// variables
|
2017-09-21 12:15:01 +02:00
|
|
|
SharedMessage message;
|
2017-09-24 18:43:24 +02:00
|
|
|
std::vector<WordPart> wordParts;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-09-21 12:15:01 +02:00
|
|
|
int height = 0;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-09-21 12:15:01 +02:00
|
|
|
int currentLayoutWidth = -1;
|
|
|
|
int fontGeneration = -1;
|
|
|
|
int emoteGeneration = -1;
|
2017-12-23 21:18:13 +01:00
|
|
|
float scale = -1;
|
2017-10-11 10:34:04 +02:00
|
|
|
|
2017-12-23 21:18:13 +01:00
|
|
|
Word::Flags currentWordTypes = Word::None;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-12-19 00:09:38 +01:00
|
|
|
bool collapsed;
|
|
|
|
int collapsedHeight = 32;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
// methods
|
2017-12-23 21:18:13 +01:00
|
|
|
void rebuild();
|
2017-10-11 10:34:04 +02:00
|
|
|
void actuallyLayout(int width);
|
2017-12-28 17:46:36 +01:00
|
|
|
void _alignWordParts(int lineStart, int lineHeight, int width, int &firstLineHeight);
|
|
|
|
int _updateLineHeight(int currentLineHeight, Word &word, bool overlapEmotes);
|
2017-10-11 10:34:04 +02:00
|
|
|
void updateTextSizes();
|
|
|
|
void updateImageSizes();
|
2017-02-02 22:15:09 +01:00
|
|
|
};
|
2017-05-27 16:16:39 +02:00
|
|
|
|
|
|
|
} // namespace messages
|
|
|
|
} // namespace chatterino
|