mirror-chatterino2/src/messages/messageref.hpp

56 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
2017-06-11 09:31:45 +02:00
#include "messages/message.hpp"
2017-09-24 18:43:24 +02:00
#include "messages/wordpart.hpp"
#include <QPixmap>
#include <memory>
2017-04-14 17:52:22 +02:00
namespace chatterino {
namespace messages {
2017-04-12 17:46:44 +02:00
class MessageRef;
typedef std::shared_ptr<MessageRef> SharedMessageRef;
class MessageRef
{
public:
2017-04-12 17:46:44 +02:00
MessageRef(SharedMessage message);
2017-04-12 17:46:44 +02:00
Message *getMessage();
int getHeight() const;
bool layout(int width, bool enableEmoteMargins = true);
2017-04-12 17:46:44 +02:00
const std::vector<WordPart> &getWordParts() const;
std::shared_ptr<QPixmap> buffer = nullptr;
bool updateBuffer = false;
2017-09-24 18:43:24 +02:00
const Word *tryGetWordPart(QPoint point);
2017-02-17 23:51:35 +01:00
int getSelectionIndex(QPoint position);
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-09-21 12:15:01 +02:00
int height = 0;
2017-09-21 12:15:01 +02:00
int currentLayoutWidth = -1;
int fontGeneration = -1;
2017-08-12 15:58:46 +02:00
/* TODO(pajlada): Re-implement
2017-09-21 12:15:01 +02:00
int emoteGeneration = -1;
2017-08-12 15:58:46 +02:00
*/
2017-09-21 12:15:01 +02:00
Word::Type currentWordTypes = Word::None;
2017-04-12 17:46:44 +02:00
// methods
void alignWordParts(int lineStart, int lineHeight, int width);
};
2017-05-27 16:16:39 +02:00
} // namespace messages
} // namespace chatterino