mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed message expanding not working
This commit is contained in:
parent
d775123ed0
commit
f72e1b5d82
|
@ -80,6 +80,10 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
|||
|
||||
layoutRequired |= timestampFormatChanged;
|
||||
|
||||
// check if layout was requested manually
|
||||
layoutRequired |= bool(this->flags & RequiresLayout);
|
||||
this->flags &= ~RequiresLayout;
|
||||
|
||||
// check if dpi changed
|
||||
bool scaleChanged = this->scale != scale;
|
||||
layoutRequired |= scaleChanged;
|
||||
|
@ -87,7 +91,7 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
|||
imagesChanged |= scaleChanged;
|
||||
textChanged |= scaleChanged;
|
||||
|
||||
// assert(layoutRequired);
|
||||
// assert(layoutRequired);
|
||||
|
||||
// update word sizes if needed
|
||||
if (imagesChanged) {
|
||||
|
@ -122,7 +126,7 @@ void MessageLayout::actuallyLayout(int width, MessageElement::Flags _flags)
|
|||
if (this->flags & MessageLayout::Expanded ||
|
||||
(_flags & MessageElement::ModeratorTools &&
|
||||
!(this->message->flags & Message::MessageFlags::Disabled))) {
|
||||
messageFlags = (Message::MessageFlags)(messageFlags & ~Message::MessageFlags::Collapsed);
|
||||
messageFlags = Message::MessageFlags(messageFlags & ~Message::MessageFlags::Collapsed);
|
||||
}
|
||||
|
||||
this->container.begin(width, this->scale, messageFlags);
|
||||
|
@ -209,7 +213,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
|||
this->bufferValid = true;
|
||||
}
|
||||
|
||||
void MessageLayout::updateBuffer(QPixmap *buffer, int messageIndex, Selection &selection)
|
||||
void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/, Selection & /*selection*/)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
|
|
|
@ -11,24 +11,27 @@
|
|||
|
||||
#define MARK(x) \
|
||||
qDebug() << BOOST_CURRENT_FUNCTION << __LINE__ \
|
||||
<< static_cast<float>(x.nsecsElapsed()) / 100000.0 << "ms";
|
||||
<< static_cast<float>(x.nsecsElapsed()) / 1000000.0 << "ms";
|
||||
|
||||
class BenchmarkGuard : boost::noncopyable {
|
||||
class BenchmarkGuard : boost::noncopyable
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
QString name;
|
||||
|
||||
public:
|
||||
BenchmarkGuard(const QString &_name)
|
||||
:name(_name)
|
||||
: name(_name)
|
||||
{
|
||||
timer.start();
|
||||
}
|
||||
|
||||
~BenchmarkGuard() {
|
||||
qDebug() << this->name << float(timer.nsecsElapsed()) / 100000.0 << "ms";
|
||||
~BenchmarkGuard()
|
||||
{
|
||||
qDebug() << this->name << float(timer.nsecsElapsed()) / 1000000.0f << "ms";
|
||||
}
|
||||
|
||||
qreal getElapsedMs() {
|
||||
return qreal(timer.nsecsElapsed()) / 100000.0;
|
||||
qreal getElapsedMs()
|
||||
{
|
||||
return qreal(timer.nsecsElapsed()) / 1000000.0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -175,9 +175,10 @@ void ChannelView::layoutMessages()
|
|||
|
||||
void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
||||
{
|
||||
BenchmarkGuard benchmark("layout messages");
|
||||
|
||||
auto app = getApp();
|
||||
|
||||
BENCH(timer)
|
||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||
|
||||
if (messagesSnapshot.getLength() == 0) {
|
||||
|
@ -264,8 +265,6 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar)
|
|||
this->messageWasAdded = false;
|
||||
}
|
||||
|
||||
MARK(timer);
|
||||
|
||||
if (redrawRequired) {
|
||||
this->queueUpdate();
|
||||
}
|
||||
|
@ -580,7 +579,7 @@ bool ChannelView::isPaused()
|
|||
|
||||
void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
||||
{
|
||||
BENCH(timer);
|
||||
BenchmarkGuard benchmark("paint event");
|
||||
|
||||
QPainter painter(this);
|
||||
|
||||
|
@ -588,8 +587,6 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
|
|||
|
||||
// draw messages
|
||||
this->drawMessages(painter);
|
||||
|
||||
MARK(timer);
|
||||
}
|
||||
|
||||
// if overlays is false then it draws the message, if true then it draws things such as the grey
|
||||
|
@ -600,14 +597,14 @@ void ChannelView::drawMessages(QPainter &painter)
|
|||
|
||||
auto messagesSnapshot = this->getMessagesSnapshot();
|
||||
|
||||
size_t start = this->scrollBar.getCurrentValue();
|
||||
size_t start = size_t(this->scrollBar.getCurrentValue());
|
||||
|
||||
if (start >= messagesSnapshot.getLength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int y = -(messagesSnapshot[start].get()->getHeight() *
|
||||
(fmod(this->scrollBar.getCurrentValue(), 1)));
|
||||
int y = int(-(messagesSnapshot[start].get()->getHeight() *
|
||||
(fmod(this->scrollBar.getCurrentValue(), 1))));
|
||||
|
||||
messages::MessageLayout *end = nullptr;
|
||||
bool windowFocused = this->window() == QApplication::activeWindow();
|
||||
|
@ -925,6 +922,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
|
|||
// message under cursor is collapsed
|
||||
if (layout->flags & MessageLayout::Collapsed) {
|
||||
layout->flags |= MessageLayout::Expanded;
|
||||
layout->flags |= MessageLayout::RequiresLayout;
|
||||
|
||||
this->layoutMessages();
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue