2017-02-02 22:15:09 +01:00
|
|
|
#ifndef MESSAGEREF_H
|
|
|
|
#define MESSAGEREF_H
|
|
|
|
|
|
|
|
#include "messages/message.h"
|
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
#include <QPixmap>
|
|
|
|
#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
|
|
|
|
|
|
|
bool layout(int width, bool enableEmoteMargins = true);
|
|
|
|
|
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-02-17 23:51:35 +01:00
|
|
|
bool tryGetWordPart(QPoint point, messages::Word &word);
|
|
|
|
|
|
|
|
int getSelectionIndex(QPoint position);
|
|
|
|
|
2017-02-02 22:15:09 +01:00
|
|
|
private:
|
2017-04-12 17:46:44 +02:00
|
|
|
// variables
|
|
|
|
SharedMessage _message;
|
|
|
|
std::vector<messages::WordPart> _wordParts;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int _height = 0;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int _currentLayoutWidth = -1;
|
|
|
|
int _fontGeneration = -1;
|
|
|
|
int _emoteGeneration = -1;
|
|
|
|
Word::Type _currentWordTypes = Word::None;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
// methods
|
2017-02-02 22:15:09 +01:00
|
|
|
void alignWordParts(int lineStart, int lineHeight);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MESSAGEREF_H
|