mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Compare commits
3 commits
afc52ad994
...
9b2bf17a0c
Author | SHA1 | Date | |
---|---|---|---|
9b2bf17a0c | |||
7604d7ea4a | |||
7b2ba5ed97 |
|
@ -132,6 +132,7 @@
|
|||
- Dev: Fix `NotebookTab` emitting updates for every message. (#5068)
|
||||
- Dev: Added benchmark for parsing and building recent messages. (#5071)
|
||||
- Dev: Boost is depended on as a header-only library when using conan. (#5107)
|
||||
- Dev: Added signal to invalidate paint buffers of channel views without forcing a relayout. (#5123)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit ad12188bd3e94ffd3ee95ebb97b67b915857c471
|
||||
Subproject commit 53be0788a000960dbbc34350315e20ad1e194970
|
|
@ -74,7 +74,8 @@ int MessageLayout::getWidth() const
|
|||
|
||||
// Layout
|
||||
// return true if redraw is required
|
||||
bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
||||
bool MessageLayout::layout(int width, float scale, MessageElementFlags flags,
|
||||
bool shouldInvalidateBuffer)
|
||||
{
|
||||
// BenchmarkGuard benchmark("MessageLayout::layout()");
|
||||
|
||||
|
@ -108,6 +109,11 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
|
|||
|
||||
if (!layoutRequired)
|
||||
{
|
||||
if (shouldInvalidateBuffer)
|
||||
{
|
||||
this->invalidateBuffer();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ public:
|
|||
|
||||
MessageLayoutFlags flags;
|
||||
|
||||
bool layout(int width, float scale_, MessageElementFlags flags);
|
||||
bool layout(int width, float scale_, MessageElementFlags flags,
|
||||
bool shouldInvalidateBuffer);
|
||||
|
||||
// Painting
|
||||
MessagePaintResult paint(const MessagePaintContext &ctx);
|
||||
|
|
|
@ -211,6 +211,11 @@ void WindowManager::forceLayoutChannelViews()
|
|||
this->layoutChannelViews(nullptr);
|
||||
}
|
||||
|
||||
void WindowManager::invalidateChannelViewBuffers(Channel *channel)
|
||||
{
|
||||
this->invalidateBuffersRequested.invoke(channel);
|
||||
}
|
||||
|
||||
void WindowManager::repaintVisibleChatWidgets(Channel *channel)
|
||||
{
|
||||
this->layoutRequested.invoke(channel);
|
||||
|
@ -407,10 +412,10 @@ void WindowManager::initialize(Settings &settings, const Paths &paths)
|
|||
this->forceLayoutChannelViews();
|
||||
});
|
||||
settings.alternateMessages.connect([this](auto, auto) {
|
||||
this->forceLayoutChannelViews();
|
||||
this->invalidateChannelViewBuffers();
|
||||
});
|
||||
settings.separateMessages.connect([this](auto, auto) {
|
||||
this->forceLayoutChannelViews();
|
||||
this->invalidateChannelViewBuffers();
|
||||
});
|
||||
settings.collpseMessagesMinLines.connect([this](auto, auto) {
|
||||
this->forceLayoutChannelViews();
|
||||
|
|
|
@ -66,6 +66,10 @@ public:
|
|||
// This is called, for example, when the emote scale or timestamp format has
|
||||
// changed
|
||||
void forceLayoutChannelViews();
|
||||
|
||||
// Tell a channel (or all channels if channel is nullptr) to invalidate all paint buffers
|
||||
void invalidateChannelViewBuffers(Channel *channel = nullptr);
|
||||
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
void repaintGifEmotes();
|
||||
|
||||
|
@ -124,6 +128,9 @@ public:
|
|||
// This signal fires whenever views rendering a channel, or all views if the
|
||||
// channel is a nullptr, need to redo their layout
|
||||
pajlada::Signals::Signal<Channel *> layoutRequested;
|
||||
// This signal fires whenever views rendering a channel, or all views if the
|
||||
// channel is a nullptr, need to invalidate their paint buffers
|
||||
pajlada::Signals::Signal<Channel *> invalidateBuffersRequested;
|
||||
|
||||
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
||||
|
||||
|
|
|
@ -425,6 +425,16 @@ void ChannelView::initializeSignals()
|
|||
}
|
||||
});
|
||||
|
||||
this->signalHolder_.managedConnect(
|
||||
getIApp()->getWindows()->invalidateBuffersRequested,
|
||||
[this](Channel *channel) {
|
||||
if (this->isVisible() &&
|
||||
(channel == nullptr || this->channel_.get() == channel))
|
||||
{
|
||||
this->invalidateBuffers();
|
||||
}
|
||||
});
|
||||
|
||||
this->signalHolder_.managedConnect(getIApp()->getFonts()->fontChanged,
|
||||
[this] {
|
||||
this->queueLayout();
|
||||
|
@ -590,6 +600,12 @@ void ChannelView::queueUpdate(const QRect &area)
|
|||
this->update(area);
|
||||
}
|
||||
|
||||
void ChannelView::invalidateBuffers()
|
||||
{
|
||||
this->bufferInvalidationQueued_ = true;
|
||||
this->queueLayout();
|
||||
}
|
||||
|
||||
void ChannelView::queueLayout()
|
||||
{
|
||||
if (this->isVisible())
|
||||
|
@ -651,12 +667,13 @@ void ChannelView::layoutVisibleMessages(
|
|||
{
|
||||
const auto &message = messages[i];
|
||||
|
||||
redrawRequired |=
|
||||
message->layout(layoutWidth, this->scale(), flags);
|
||||
redrawRequired |= message->layout(layoutWidth, this->scale(), flags,
|
||||
this->bufferInvalidationQueued_);
|
||||
|
||||
y += message->getHeight();
|
||||
}
|
||||
}
|
||||
this->bufferInvalidationQueued_ = false;
|
||||
|
||||
if (redrawRequired)
|
||||
{
|
||||
|
@ -685,7 +702,7 @@ void ChannelView::updateScrollbar(
|
|||
{
|
||||
auto *message = messages[i].get();
|
||||
|
||||
message->layout(layoutWidth, this->scale(), flags);
|
||||
message->layout(layoutWidth, this->scale(), flags, false);
|
||||
|
||||
h -= message->getHeight();
|
||||
|
||||
|
@ -1656,7 +1673,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
|
|||
else
|
||||
{
|
||||
snapshot[i - 1]->layout(this->getLayoutWidth(),
|
||||
this->scale(), this->getFlags());
|
||||
this->scale(), this->getFlags(),
|
||||
false);
|
||||
scrollFactor = 1;
|
||||
currentScrollLeft = snapshot[i - 1]->getHeight();
|
||||
}
|
||||
|
@ -1690,7 +1708,8 @@ void ChannelView::wheelEvent(QWheelEvent *event)
|
|||
else
|
||||
{
|
||||
snapshot[i + 1]->layout(this->getLayoutWidth(),
|
||||
this->scale(), this->getFlags());
|
||||
this->scale(), this->getFlags(),
|
||||
false);
|
||||
|
||||
scrollFactor = 1;
|
||||
currentScrollLeft = snapshot[i + 1]->getHeight();
|
||||
|
|
|
@ -148,7 +148,9 @@ public:
|
|||
bool hasSourceChannel() const;
|
||||
|
||||
LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();
|
||||
|
||||
void queueLayout();
|
||||
void invalidateBuffers();
|
||||
|
||||
void clearMessages();
|
||||
|
||||
|
@ -270,6 +272,7 @@ private:
|
|||
bool canReplyToMessages() const;
|
||||
|
||||
bool layoutQueued_ = false;
|
||||
bool bufferInvalidationQueued_ = false;
|
||||
|
||||
bool lastMessageHasAlternateBackground_ = false;
|
||||
bool lastMessageHasAlternateBackgroundReverse_ = true;
|
||||
|
|
Loading…
Reference in a new issue