improved handling of relayouting messages

This commit is contained in:
fourtf
2018-06-04 16:10:54 +02:00
parent bd5f9853f9
commit 7ad4e36dbb
10 changed files with 87 additions and 126 deletions
+2 -2
View File
@@ -147,10 +147,10 @@ void Image::loadImage()
loadedEventQueued = true;
QTimer::singleShot(500, [] {
getApp()->emotes->incGeneration();
getApp()->windows->incGeneration();
auto app = getApp();
app->windows->layoutVisibleChatWidgets();
app->windows->layoutChannelViews();
loadedEventQueued = false;
});
}
+11 -38
View File
@@ -3,6 +3,7 @@
#include "application.hpp"
#include "singletons/emotemanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/windowmanager.hpp"
#include "util/benchmark.hpp"
#include <QApplication>
@@ -59,52 +60,24 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
layoutRequired |= widthChanged;
this->currentLayoutWidth_ = width;
// check if emotes changed
bool imagesChanged = this->emoteGeneration_ != app->emotes->getGeneration();
layoutRequired |= imagesChanged;
this->emoteGeneration_ = app->emotes->getGeneration();
// check if text changed
bool textChanged = this->fontGeneration_ != app->fonts->getGeneration();
layoutRequired |= textChanged;
this->fontGeneration_ = app->fonts->getGeneration();
// check if layout state changed
if (this->layoutState_ != app->windows->getGeneration()) {
layoutRequired = true;
this->flags |= RequiresBufferUpdate;
this->layoutState_ = app->windows->getGeneration();
}
// check if work mask changed
bool wordMaskChanged = this->currentWordFlags_ != flags; // app->settings->getWordTypeMask();
layoutRequired |= wordMaskChanged;
layoutRequired |= this->currentWordFlags_ != flags;
this->currentWordFlags_ = flags; // app->settings->getWordTypeMask();
// check if timestamp format changed
bool timestampFormatChanged = this->timestampFormat_ != app->settings->timestampFormat;
this->timestampFormat_ = app->settings->timestampFormat.getValue();
layoutRequired |= timestampFormatChanged;
// check if layout was requested manually
layoutRequired |= bool(this->flags & RequiresLayout);
this->flags &= ~RequiresLayout;
this->flags &= decltype(RequiresLayout)(~RequiresLayout);
// check if dpi changed
bool scaleChanged = this->scale_ != scale;
layoutRequired |= scaleChanged;
layoutRequired |= this->scale_ != scale;
this->scale_ = scale;
imagesChanged |= scaleChanged;
textChanged |= scaleChanged;
// update word sizes if needed
if (imagesChanged) {
// this->container.updateImages();
this->flags |= MessageLayout::RequiresBufferUpdate;
}
if (textChanged) {
// this->container.updateText();
this->flags |= MessageLayout::RequiresBufferUpdate;
}
if (widthChanged || wordMaskChanged) {
this->deleteBuffer();
}
// return if no layout is required
if (!layoutRequired) {
return false;
@@ -112,7 +85,7 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
int oldHeight = this->container_.getHeight();
this->actuallyLayout(width, flags);
if (this->container_.getHeight() != oldHeight) {
if (widthChanged || this->container_.getHeight() != oldHeight) {
this->deleteBuffer();
}
this->invalidateBuffer();
+1 -3
View File
@@ -67,9 +67,7 @@ private:
int height_ = 0;
int currentLayoutWidth_ = -1;
int fontGeneration_ = -1;
int emoteGeneration_ = -1;
QString timestampFormat_;
int layoutState_ = -1;
float scale_ = -1;
unsigned int bufferUpdatedCount_ = 0;