added highlights to the scrollbar
This commit is contained in:
@@ -233,7 +233,7 @@ void ChannelView::updateGifEmotes()
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar &ChannelView::getScrollBar()
|
||||
Scrollbar &ChannelView::getScrollBar()
|
||||
{
|
||||
return this->scrollBar;
|
||||
}
|
||||
@@ -395,6 +395,8 @@ void ChannelView::setChannel(std::shared_ptr<Channel> newChannel)
|
||||
this->highlightedMessageReceived.invoke();
|
||||
}
|
||||
|
||||
this->scrollBar.addHighlight(message->getScrollBarHighlight());
|
||||
|
||||
this->messageWasAdded = true;
|
||||
this->layoutMessages();
|
||||
});
|
||||
@@ -416,6 +418,14 @@ void ChannelView::setChannel(std::shared_ptr<Channel> newChannel)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<ScrollbarHighlight> highlights;
|
||||
highlights.reserve(messages.size());
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
highlights.push_back(messages.at(i)->getScrollBarHighlight());
|
||||
}
|
||||
|
||||
this->scrollBar.addHighlightsAtStart(highlights);
|
||||
|
||||
this->messageWasAdded = true;
|
||||
this->layoutMessages();
|
||||
});
|
||||
@@ -436,6 +446,8 @@ void ChannelView::setChannel(std::shared_ptr<Channel> newChannel)
|
||||
newChannel->messageReplaced.connect([this](size_t index, SharedMessage replacement) {
|
||||
SharedMessageRef newItem(new MessageRef(replacement));
|
||||
|
||||
this->scrollBar.replaceHighlight(index, replacement->getScrollBarHighlight());
|
||||
|
||||
this->messages.replaceItem(this->messages.getSnapshot()[index], newItem);
|
||||
this->layoutMessages();
|
||||
});
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
void updateGifEmotes();
|
||||
void queueUpdate();
|
||||
ScrollBar &getScrollBar();
|
||||
Scrollbar &getScrollBar();
|
||||
QString getSelectedText();
|
||||
bool hasSelection();
|
||||
void clearSelection();
|
||||
@@ -94,7 +94,7 @@ private:
|
||||
|
||||
std::vector<GifEmoteData> gifEmotes;
|
||||
|
||||
ScrollBar scrollBar;
|
||||
Scrollbar scrollBar;
|
||||
RippleEffectLabel *goToBottom;
|
||||
|
||||
// This variable can be used to decide whether or not we should render the "Show latest
|
||||
|
||||
@@ -5,16 +5,32 @@
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
ScrollBarHighlight::ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent,
|
||||
Style _style, QString _tag)
|
||||
: themeManager(parent->themeManager)
|
||||
, position(_position)
|
||||
// , colorIndex(std::max(0, std::min(this->themeManager.HighlightColorCount, _colorIndex)))
|
||||
, colorIndex(0)
|
||||
, style(_style)
|
||||
, tag(_tag)
|
||||
ScrollbarHighlight::ScrollbarHighlight()
|
||||
: color(Color::Highlight)
|
||||
, style(Style::None)
|
||||
{
|
||||
}
|
||||
|
||||
ScrollbarHighlight::ScrollbarHighlight(Color _color, Style _style)
|
||||
: color(_color)
|
||||
, style(_style)
|
||||
{
|
||||
}
|
||||
|
||||
ScrollbarHighlight::Color ScrollbarHighlight::getColor() const
|
||||
{
|
||||
return this->color;
|
||||
}
|
||||
|
||||
ScrollbarHighlight::Style ScrollbarHighlight::getStyle() const
|
||||
{
|
||||
return this->style;
|
||||
}
|
||||
|
||||
bool ScrollbarHighlight::isNull() const
|
||||
{
|
||||
return this->style == None;
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -3,51 +3,23 @@
|
||||
#include "QString"
|
||||
|
||||
namespace chatterino {
|
||||
namespace singletons {
|
||||
class ThemeManager;
|
||||
}
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class ScrollBar;
|
||||
|
||||
class ScrollBarHighlight
|
||||
class ScrollbarHighlight
|
||||
{
|
||||
public:
|
||||
enum Style { Default, Left, Right, SingleLine };
|
||||
enum Style : char { None, Default, Line };
|
||||
enum Color : char { Highlight };
|
||||
|
||||
ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default,
|
||||
QString _tag = "");
|
||||
ScrollbarHighlight();
|
||||
ScrollbarHighlight(Color _color, Style _style = Default);
|
||||
|
||||
singletons::ThemeManager &themeManager;
|
||||
|
||||
double getPosition()
|
||||
{
|
||||
return this->position;
|
||||
}
|
||||
|
||||
int getColorIndex()
|
||||
{
|
||||
return this->colorIndex;
|
||||
}
|
||||
|
||||
Style getStyle()
|
||||
{
|
||||
return this->style;
|
||||
}
|
||||
|
||||
QString getTag()
|
||||
{
|
||||
return this->tag;
|
||||
}
|
||||
|
||||
ScrollBarHighlight *next = nullptr;
|
||||
Color getColor() const;
|
||||
Style getStyle() const;
|
||||
bool isNull() const;
|
||||
|
||||
private:
|
||||
double position;
|
||||
int colorIndex;
|
||||
Color color;
|
||||
Style style;
|
||||
QString tag;
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
|
||||
Reference in New Issue
Block a user