added highlights to the scrollbar

This commit is contained in:
fourtf
2018-01-06 03:48:56 +01:00
parent 99f2d0dd27
commit 20eab57db5
10 changed files with 159 additions and 134 deletions
+33 -1
View File
@@ -132,7 +132,7 @@ public:
return acceptedItems;
}
// replaces a single item, return true if successful
// replace an single item, return index if successful, -1 if unsuccessful
int replaceItem(const T &item, const T &replacement)
{
std::lock_guard<std::mutex> lock(this->mutex);
@@ -166,6 +166,38 @@ public:
return -1;
}
// replace an item at index, return true if worked
bool replaceItem(size_t index, const T &replacement)
{
std::lock_guard<std::mutex> lock(this->mutex);
int x = 0;
for (size_t i = 0; i < this->chunks->size(); i++) {
Chunk &chunk = this->chunks->at(i);
size_t start = i == 0 ? this->firstChunkOffset : 0;
size_t end = i == chunk->size() - 1 ? this->lastChunkEnd : chunk->size();
for (size_t j = start; j < end; j++) {
if (x == index) {
Chunk newChunk = std::make_shared<std::vector<T>>();
newChunk->resize(chunk->size());
for (size_t k = 0; k < chunk->size(); k++) {
newChunk->at(k) = chunk->at(k);
}
newChunk->at(j) = replacement;
this->chunks->at(i) = newChunk;
return x;
}
x++;
}
}
}
// void insertAfter(const std::vector<T> &items, const T &index)
messages::LimitedQueueSnapshot<T> getSnapshot()
+10
View File
@@ -13,6 +13,8 @@
#include <list>
#include <tuple>
typedef chatterino::widgets::ScrollbarHighlight SBHighlight;
namespace chatterino {
namespace messages {
@@ -128,6 +130,14 @@ void Message::updateContent() const
this->content = _content;
}
SBHighlight Message::getScrollBarHighlight() const
{
if (this->getFlags() & Message::Highlighted) {
return SBHighlight(SBHighlight::Highlight);
}
return SBHighlight();
}
namespace {
void AddCurrentTimestamp(Message *message)
+3
View File
@@ -1,6 +1,7 @@
#pragma once
#include "messages/word.hpp"
#include "widgets/helper/scrollbarhighlight.hpp"
#include <chrono>
#include <memory>
@@ -23,6 +24,7 @@ public:
None = 0,
System = (1 << 1),
Timeout = (1 << 2),
Highlighted = (1 << 3),
};
bool containsHighlightedPhrase() const;
@@ -44,6 +46,7 @@ public:
bool getDisableCompactEmotes() const;
void setDisableCompactEmotes(bool value);
void updateContent() const;
widgets::ScrollbarHighlight getScrollBarHighlight() const;
QString loginName;
QString displayName;