2017-01-18 21:30:23 +01:00
|
|
|
#include "widgets/chatwidgetview.h"
|
2017-04-12 17:46:44 +02:00
|
|
|
#include "channelmanager.h"
|
2017-01-18 01:04:54 +01:00
|
|
|
#include "colorscheme.h"
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "messages/message.h"
|
|
|
|
#include "messages/wordpart.h"
|
2017-04-12 17:46:44 +02:00
|
|
|
#include "settingsmanager.h"
|
|
|
|
#include "ui_userpopup.h"
|
2017-01-18 21:30:23 +01:00
|
|
|
#include "widgets/chatwidget.h"
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-01-18 14:48:42 +01:00
|
|
|
#include <math.h>
|
2017-02-01 16:28:28 +01:00
|
|
|
#include <QDebug>
|
2017-02-07 00:03:15 +01:00
|
|
|
#include <QGraphicsBlurEffect>
|
2017-01-11 01:08:20 +01:00
|
|
|
#include <QPainter>
|
2017-02-07 00:03:15 +01:00
|
|
|
#include <chrono>
|
2017-01-18 01:04:54 +01:00
|
|
|
#include <functional>
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
|
2017-01-17 00:15:44 +01:00
|
|
|
ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
2017-01-11 18:52:09 +01:00
|
|
|
: QWidget()
|
2017-04-12 17:46:44 +02:00
|
|
|
, _chatWidget(parent)
|
|
|
|
, _scrollbar(this)
|
|
|
|
, _userPopupWidget(_chatWidget->getChannel())
|
|
|
|
, _onlyUpdateEmotes(false)
|
|
|
|
, _mouseDown(false)
|
|
|
|
, _lastPressPosition()
|
2017-01-01 02:30:42 +01:00
|
|
|
{
|
2017-02-07 00:03:15 +01:00
|
|
|
this->setAttribute(Qt::WA_OpaquePaintEvent);
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setSmallChange(5);
|
2017-02-17 23:51:35 +01:00
|
|
|
this->setMouseTracking(true);
|
2017-01-22 12:46:35 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
QObject::connect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this,
|
|
|
|
&ChatWidgetView::wordTypeMaskChanged);
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.getCurrentValueChanged().connect([this] { update(); });
|
2017-01-22 12:46:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ChatWidgetView::~ChatWidgetView()
|
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
QObject::disconnect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged,
|
|
|
|
this, &ChatWidgetView::wordTypeMaskChanged);
|
2017-01-01 02:30:42 +01:00
|
|
|
}
|
2017-01-03 21:19:33 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
bool ChatWidgetView::layoutMessages()
|
2017-01-03 21:19:33 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
auto messages = _chatWidget->getMessagesSnapshot();
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
if (messages.getLength() == 0) {
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setVisible(false);
|
2017-02-03 19:31:51 +01:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool showScrollbar = false, redraw = false;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int start = _scrollbar.getCurrentValue();
|
2017-02-03 19:31:51 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
// layout the visible messages in the view
|
|
|
|
if (messages.getLength() > start) {
|
2017-04-12 17:46:44 +02:00
|
|
|
int y = -(messages[start].get()->getHeight() * (fmod(_scrollbar.getCurrentValue(), 1)));
|
2017-02-06 11:38:26 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
for (int i = start; i < messages.getLength(); ++i) {
|
|
|
|
auto messagePtr = messages[i];
|
|
|
|
auto message = messagePtr.get();
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
redraw |= message->layout(this->width(), true);
|
2017-02-02 20:35:12 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
y += message->getHeight();
|
2017-02-03 19:31:51 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
if (y >= height()) {
|
|
|
|
break;
|
|
|
|
}
|
2017-02-03 19:31:51 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-02-06 18:31:25 +01:00
|
|
|
// layout the messages at the bottom to determine the scrollbar thumb size
|
2017-01-26 09:26:18 +01:00
|
|
|
int h = this->height() - 8;
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-02-02 20:35:12 +01:00
|
|
|
for (int i = messages.getLength() - 1; i >= 0; i--) {
|
2017-01-26 07:10:46 +01:00
|
|
|
auto *message = messages[i].get();
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-01-26 07:10:46 +01:00
|
|
|
message->layout(this->width(), true);
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-01-26 07:10:46 +01:00
|
|
|
h -= message->getHeight();
|
|
|
|
|
|
|
|
if (h < 0) {
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setLargeChange((messages.getLength() - i) + (qreal)h / message->getHeight());
|
|
|
|
_scrollbar.setDesiredValue(_scrollbar.getDesiredValue());
|
2017-01-26 07:10:46 +01:00
|
|
|
|
|
|
|
showScrollbar = true;
|
2017-02-01 16:28:28 +01:00
|
|
|
break;
|
2017-01-26 07:10:46 +01:00
|
|
|
}
|
2017-01-26 04:26:40 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setVisible(showScrollbar);
|
2017-01-26 07:10:46 +01:00
|
|
|
|
2017-02-07 00:03:15 +01:00
|
|
|
if (!showScrollbar) {
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setDesiredValue(0);
|
2017-02-07 00:03:15 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
_scrollbar.setMaximum(messages.getLength());
|
2017-01-26 07:10:46 +01:00
|
|
|
|
|
|
|
return redraw;
|
2017-01-26 04:26:40 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void ChatWidgetView::updateGifEmotes()
|
2017-01-16 03:15:07 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
_onlyUpdateEmotes = true;
|
|
|
|
this->update();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScrollBar *ChatWidgetView::getScrollbar()
|
|
|
|
{
|
|
|
|
return &_scrollbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatWidgetView::resizeEvent(QResizeEvent *)
|
|
|
|
{
|
|
|
|
_scrollbar.resize(_scrollbar.width(), height());
|
|
|
|
_scrollbar.move(width() - _scrollbar.width(), 0);
|
2017-01-16 03:15:07 +01:00
|
|
|
|
|
|
|
layoutMessages();
|
2017-02-07 00:03:15 +01:00
|
|
|
|
|
|
|
update();
|
2017-01-03 21:19:33 +01:00
|
|
|
}
|
2017-01-05 16:07:20 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void ChatWidgetView::paintEvent(QPaintEvent *event)
|
2017-01-05 16:07:20 +01:00
|
|
|
{
|
2017-02-03 19:31:51 +01:00
|
|
|
QPainter _painter(this);
|
2017-01-15 16:38:30 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
_painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
2017-01-18 01:04:54 +01:00
|
|
|
|
2017-01-24 20:15:12 +01:00
|
|
|
ColorScheme &scheme = ColorScheme::getInstance();
|
2017-01-18 01:04:54 +01:00
|
|
|
|
2017-02-07 00:03:15 +01:00
|
|
|
// only update gif emotes
|
2017-04-12 17:46:44 +02:00
|
|
|
if (_onlyUpdateEmotes) {
|
|
|
|
_onlyUpdateEmotes = false;
|
2017-02-07 00:03:15 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
for (GifEmoteData &item : _gifEmotes) {
|
2017-02-07 00:03:15 +01:00
|
|
|
_painter.fillRect(item.rect, scheme.ChatBackground);
|
|
|
|
|
|
|
|
_painter.drawPixmap(item.rect, *item.image->getPixmap());
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update all messages
|
2017-04-12 17:46:44 +02:00
|
|
|
_gifEmotes.clear();
|
2017-02-07 00:03:15 +01:00
|
|
|
|
|
|
|
_painter.fillRect(rect(), scheme.ChatBackground);
|
|
|
|
|
2017-01-18 01:04:54 +01:00
|
|
|
// code for tesing colors
|
|
|
|
/*
|
2017-02-03 19:31:51 +01:00
|
|
|
QColor color;
|
2017-01-18 01:04:54 +01:00
|
|
|
static ConcurrentMap<qreal, QImage *> imgCache;
|
|
|
|
|
|
|
|
std::function<QImage *(qreal)> getImg = [&scheme](qreal light) {
|
|
|
|
return imgCache.getOrAdd(light, [&scheme, &light] {
|
|
|
|
QImage *img = new QImage(150, 50, QImage::Format_RGB32);
|
|
|
|
|
|
|
|
QColor color;
|
|
|
|
|
|
|
|
for (int j = 0; j < 50; j++) {
|
|
|
|
for (qreal i = 0; i < 150; i++) {
|
|
|
|
color = QColor::fromHslF(i / 150.0, light, j / 50.0);
|
|
|
|
|
|
|
|
scheme.normalizeColor(color);
|
|
|
|
|
|
|
|
img->setPixelColor(i, j, color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return img;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
for (qreal k = 0; k < 4.8; k++) {
|
|
|
|
auto img = getImg(k / 5);
|
|
|
|
|
|
|
|
painter.drawImage(QRect(k * 150, 0, 150, 150), *img);
|
|
|
|
}
|
|
|
|
|
|
|
|
painter.fillRect(QRect(0, 9, 500, 2), QColor(0, 0, 0));*/
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
auto messages = _chatWidget->getMessagesSnapshot();
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int start = _scrollbar.getCurrentValue();
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-02-02 20:35:12 +01:00
|
|
|
if (start >= messages.getLength()) {
|
2017-01-18 04:33:30 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int y = -(messages[start].get()->getHeight() * (fmod(_scrollbar.getCurrentValue(), 1)));
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-02-02 20:35:12 +01:00
|
|
|
for (int i = start; i < messages.getLength(); ++i) {
|
2017-02-02 22:15:09 +01:00
|
|
|
messages::MessageRef *messageRef = messages[i].get();
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
std::shared_ptr<QPixmap> bufferPtr = messageRef->buffer;
|
|
|
|
QPixmap *buffer = bufferPtr.get();
|
2017-01-13 18:59:11 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
bool updateBuffer = messageRef->updateBuffer;
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
if (buffer == nullptr) {
|
|
|
|
buffer = new QPixmap(this->width(), messageRef->getHeight());
|
|
|
|
bufferPtr = std::shared_ptr<QPixmap>(buffer);
|
|
|
|
updateBuffer = true;
|
|
|
|
}
|
2017-01-11 01:08:20 +01:00
|
|
|
|
2017-02-07 00:03:15 +01:00
|
|
|
// update messages that have been changed
|
2017-02-03 19:31:51 +01:00
|
|
|
if (updateBuffer) {
|
|
|
|
QPainter painter(buffer);
|
|
|
|
painter.fillRect(buffer->rect(), scheme.ChatBackground);
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
for (messages::WordPart const &wordPart : messageRef->getWordParts()) {
|
2017-02-03 19:31:51 +01:00
|
|
|
// image
|
|
|
|
if (wordPart.getWord().isImage()) {
|
2017-04-12 17:46:44 +02:00
|
|
|
messages::LazyLoadedImage &lli = wordPart.getWord().getImage();
|
2017-02-03 19:31:51 +01:00
|
|
|
|
|
|
|
const QPixmap *image = lli.getPixmap();
|
|
|
|
|
|
|
|
if (image != NULL) {
|
2017-04-12 17:46:44 +02:00
|
|
|
painter.drawPixmap(QRect(wordPart.getX(), wordPart.getY(),
|
|
|
|
wordPart.getWidth(), wordPart.getHeight()),
|
|
|
|
*image);
|
2017-02-03 19:31:51 +01:00
|
|
|
}
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
2017-02-03 19:31:51 +01:00
|
|
|
// text
|
|
|
|
else {
|
|
|
|
QColor color = wordPart.getWord().getColor();
|
2017-01-18 01:04:54 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
ColorScheme::getInstance().normalizeColor(color);
|
2017-01-26 07:10:46 +01:00
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
painter.setPen(color);
|
|
|
|
painter.setFont(wordPart.getWord().getFont());
|
2017-01-11 18:52:09 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
painter.drawText(QRectF(wordPart.getX(), wordPart.getY(), 10000, 10000),
|
|
|
|
wordPart.getText(), QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
2017-02-03 19:31:51 +01:00
|
|
|
}
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
2017-02-03 19:31:51 +01:00
|
|
|
|
|
|
|
messageRef->updateBuffer = false;
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
2017-01-07 20:43:55 +01:00
|
|
|
|
2017-02-07 00:03:15 +01:00
|
|
|
// get gif emotes
|
|
|
|
for (messages::WordPart const &wordPart : messageRef->getWordParts()) {
|
|
|
|
if (wordPart.getWord().isImage()) {
|
|
|
|
messages::LazyLoadedImage &lli = wordPart.getWord().getImage();
|
|
|
|
|
|
|
|
if (lli.getAnimated()) {
|
|
|
|
GifEmoteData data;
|
|
|
|
data.image = &lli;
|
2017-04-12 17:46:44 +02:00
|
|
|
QRect rect(wordPart.getX(), wordPart.getY() + y, wordPart.getWidth(),
|
|
|
|
wordPart.getHeight());
|
2017-02-07 00:03:15 +01:00
|
|
|
|
|
|
|
data.rect = rect;
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
_gifEmotes.push_back(data);
|
2017-02-07 00:03:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-03 19:31:51 +01:00
|
|
|
messageRef->buffer = bufferPtr;
|
|
|
|
|
|
|
|
_painter.drawPixmap(0, y, *buffer);
|
|
|
|
|
2017-02-02 22:15:09 +01:00
|
|
|
y += messageRef->getHeight();
|
2017-01-20 06:10:28 +01:00
|
|
|
|
|
|
|
if (y > height()) {
|
|
|
|
break;
|
|
|
|
}
|
2017-01-11 01:08:20 +01:00
|
|
|
}
|
2017-02-07 00:03:15 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
for (GifEmoteData &item : _gifEmotes) {
|
2017-02-07 00:03:15 +01:00
|
|
|
_painter.fillRect(item.rect, scheme.ChatBackground);
|
|
|
|
|
|
|
|
_painter.drawPixmap(item.rect, *item.image->getPixmap());
|
|
|
|
}
|
2017-01-05 16:07:20 +01:00
|
|
|
}
|
2017-01-26 04:26:40 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void ChatWidgetView::wheelEvent(QWheelEvent *event)
|
2017-01-26 04:26:40 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
if (_scrollbar.isVisible()) {
|
|
|
|
_scrollbar.setDesiredValue(
|
|
|
|
_scrollbar.getDesiredValue() -
|
|
|
|
event->delta() / 10.0 * SettingsManager::getInstance().mouseScrollMultiplier.get(),
|
2017-02-06 18:31:25 +01:00
|
|
|
true);
|
|
|
|
}
|
2017-01-26 04:26:40 +01:00
|
|
|
}
|
2017-02-17 23:51:35 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void ChatWidgetView::mouseMoveEvent(QMouseEvent *event)
|
2017-02-17 23:51:35 +01:00
|
|
|
{
|
|
|
|
std::shared_ptr<messages::MessageRef> message;
|
|
|
|
QPoint relativePos;
|
|
|
|
|
|
|
|
if (!tryGetMessageAt(event->pos(), message, relativePos)) {
|
|
|
|
this->setCursor(Qt::ArrowCursor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto _message = message->getMessage();
|
|
|
|
auto user = _message->getUserName();
|
|
|
|
|
|
|
|
messages::Word hoverWord;
|
|
|
|
|
|
|
|
if (!message->tryGetWordPart(relativePos, hoverWord)) {
|
|
|
|
this->setCursor(Qt::ArrowCursor);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = message->getSelectionIndex(relativePos);
|
|
|
|
|
|
|
|
if (hoverWord.getLink().getIsValid()) {
|
|
|
|
this->setCursor(Qt::PointingHandCursor);
|
|
|
|
} else {
|
|
|
|
this->setCursor(Qt::ArrowCursor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
void ChatWidgetView::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
_mouseDown = true;
|
|
|
|
_lastPressPosition = event->screenPos();
|
|
|
|
}
|
|
|
|
|
|
|
|
static float distanceBetweenPoints(const QPointF &p1, const QPointF &p2)
|
|
|
|
{
|
|
|
|
QPointF tmp = p1 - p2;
|
|
|
|
|
|
|
|
float distance = 0.f;
|
|
|
|
distance += tmp.x() * tmp.x();
|
|
|
|
distance += tmp.y() * tmp.y();
|
|
|
|
|
|
|
|
return std::sqrt(distance);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChatWidgetView::mouseReleaseEvent(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
if (!_mouseDown) {
|
|
|
|
// We didn't grab the mouse press, so we shouldn't be handling the mouse
|
|
|
|
// release
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_mouseDown = false;
|
|
|
|
|
|
|
|
float distance = distanceBetweenPoints(_lastPressPosition, event->screenPos());
|
|
|
|
|
|
|
|
qDebug() << "Distance: " << distance;
|
|
|
|
|
|
|
|
if (fabsf(distance) > 15.f) {
|
|
|
|
// It wasn't a proper click, so we don't care about that here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If you clicked and released less than X pixels away, it counts
|
|
|
|
// as a click!
|
|
|
|
|
|
|
|
// show user thing pajaW
|
|
|
|
|
|
|
|
std::shared_ptr<messages::MessageRef> message;
|
|
|
|
QPoint relativePos;
|
|
|
|
|
|
|
|
if (!tryGetMessageAt(event->pos(), message, relativePos)) {
|
|
|
|
// No message at clicked position
|
|
|
|
_userPopupWidget.hide();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto _message = message->getMessage();
|
|
|
|
auto user = _message->getUserName();
|
|
|
|
|
|
|
|
qDebug() << "Clicked " << user << "s message";
|
|
|
|
|
|
|
|
_userPopupWidget.setName(user);
|
|
|
|
_userPopupWidget.move(event->screenPos().toPoint());
|
|
|
|
_userPopupWidget.show();
|
|
|
|
_userPopupWidget.setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ChatWidgetView::tryGetMessageAt(QPoint p, std::shared_ptr<messages::MessageRef> &_message,
|
|
|
|
QPoint &relativePos)
|
2017-02-17 23:51:35 +01:00
|
|
|
{
|
2017-04-12 17:46:44 +02:00
|
|
|
auto messages = _chatWidget->getMessagesSnapshot();
|
2017-02-17 23:51:35 +01:00
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int start = _scrollbar.getCurrentValue();
|
2017-02-17 23:51:35 +01:00
|
|
|
|
|
|
|
if (start >= messages.getLength()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-04-12 17:46:44 +02:00
|
|
|
int y = -(messages[start].get()->getHeight() * (fmod(_scrollbar.getCurrentValue(), 1))) + 12;
|
2017-02-17 23:51:35 +01:00
|
|
|
|
|
|
|
for (int i = start; i < messages.getLength(); ++i) {
|
|
|
|
auto message = messages[i];
|
|
|
|
|
|
|
|
y += message->getHeight();
|
|
|
|
|
|
|
|
if (p.y() < y) {
|
|
|
|
relativePos = QPoint(p.x(), y - p.y());
|
|
|
|
_message = message;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2017-04-12 17:46:44 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|