Remove getApp and getSettings calls from Message-Rendering (#4535)
* refactor: remove singletons from message rendering
* chore: add changelog entry
* Disable the `cppcoreguidelines-avoid-const-or-ref-data-members` clang-tidy check
* auto *app
* Selection is a struct, not a class
* Use ChannelView's `signalHolder_` instead of `channelConnections_`
* Remove `applySettings` step, instead just connect & set each setting individually
* rename & constify some context values
* Handle empty "last message color" setting value better (as it was
originally in this pr before I removed that change :-)
* unrelated mini refactor cleanup
* let painSelection handle size_t instead of int
* Add some more comments to the MessageLayoutContext structs
---------
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
|
||||
namespace pajlada::Signals {
|
||||
class SignalHolder;
|
||||
} // namespace pajlada::Signals
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ColorProvider;
|
||||
class Theme;
|
||||
class Settings;
|
||||
struct Selection;
|
||||
|
||||
// TODO: Figure out if this could be a subset of Theme instead (e.g. Theme::MessageColors)
|
||||
struct MessageColors {
|
||||
QColor regular;
|
||||
QColor alternate;
|
||||
QColor disabled;
|
||||
QColor selection;
|
||||
QColor system;
|
||||
|
||||
QColor messageSeperator;
|
||||
|
||||
QColor focusedLastMessageLine;
|
||||
QColor unfocusedLastMessageLine;
|
||||
|
||||
void applyTheme(Theme *theme);
|
||||
};
|
||||
|
||||
// TODO: Explore if we can let settings own this
|
||||
struct MessagePreferences {
|
||||
QColor lastMessageColor;
|
||||
Qt::BrushStyle lastMessagePattern{};
|
||||
|
||||
bool enableRedeemedHighlight{};
|
||||
bool enableElevatedMessageHighlight{};
|
||||
bool enableFirstMessageHighlight{};
|
||||
bool enableSubHighlight{};
|
||||
|
||||
bool alternateMessages{};
|
||||
bool separateMessages{};
|
||||
|
||||
void connectSettings(Settings *settings,
|
||||
pajlada::Signals::SignalHolder &holder);
|
||||
};
|
||||
|
||||
struct MessagePaintContext {
|
||||
QPainter &painter;
|
||||
const Selection &selection;
|
||||
const ColorProvider &colorProvider;
|
||||
const MessageColors &messageColors;
|
||||
const MessagePreferences &preferences;
|
||||
|
||||
// width of the area we have to draw on
|
||||
const int canvasWidth{};
|
||||
// whether the painting should be treated as if this view's window is focused
|
||||
const bool isWindowFocused{};
|
||||
// whether the painting should be treated as if this view is the special mentions view
|
||||
const bool isMentions{};
|
||||
|
||||
// y coordinate we're currently painting at
|
||||
int y{};
|
||||
|
||||
// Index of the message that is currently being painted
|
||||
// This index refers to the snapshot being used in the painting
|
||||
size_t messageIndex{};
|
||||
|
||||
bool isLastReadMessage{};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user