JS8Call-Improved master
Loading...
Searching...
No Matches
PillRenderer.h
Go to the documentation of this file.
1
5
6#ifndef PILLRENDERER_H
7#define PILLRENDERER_H
8
9#include <QObject>
10#include <QString>
11#include <QTextBlockFormat>
12
13class QHelpEvent;
14class QPaintEvent;
17struct PillColorScheme;
18
27class PillRenderer : public QObject {
28 Q_OBJECT
29
30 public:
31 // Pill geometry constants — used by paintPills() and applyPillHighlighting().
32 static constexpr qreal PillHPad = 8.0;
33 static constexpr qreal PillVPad = 3.0;
34 static constexpr qreal PillMaxRadius = 11.0;
35 static constexpr qreal PillMinRadius = 7.0;
36 static constexpr qreal PillMinHPad = 5.0;
37 static constexpr qreal PillMinGap = 5.0;
38
45 explicit PillRenderer(TransmitTextEdit *host, QObject *parent = nullptr);
46
51 void paintPills(QPaintEvent *event);
52
57 bool handleTooltip(QHelpEvent *helpEvent);
58
63
64 void setEnabled(bool enabled);
65 bool isEnabled() const;
66 void setPillColors(const PillColorScheme &scheme);
67 void setSelectedCallsign(const QString &callsign);
68
69 private:
70 void refreshPillState();
71 void applyLineHeight(bool enabled) const;
72 void clearPillLetterSpacing() const;
73 void applyPillLetterSpacing() const;
74
75 TransmitTextEdit *m_host;
76 DirectedMessageHighlighter *m_highlighter;
77 qreal m_defaultDocumentMargin = 0.0;
78 QTextBlockFormat m_defaultBlockFormat;
79 bool m_enabled = true;
80 QString m_selectedCallsign;
81};
82
83#endif // PILLRENDERER_H
Definition DirectedMessageHighlighter.h:18
bool handleTooltip(QHelpEvent *helpEvent)
Handle a tooltip event by hit-testing pill format ranges.
Definition PillRenderer.cpp:223
void applyPillHighlighting()
Run the syntax highlighter and adjust letter-spacing around pills.
Definition PillRenderer.cpp:259
static constexpr qreal PillHPad
Horizontal padding.
Definition PillRenderer.h:32
static constexpr qreal PillVPad
Vertical padding.
Definition PillRenderer.h:33
PillRenderer(TransmitTextEdit *host, QObject *parent=nullptr)
Construct a PillRenderer attached to the given text edit.
Definition PillRenderer.cpp:28
static constexpr qreal PillMinRadius
Minimum corner radius.
Definition PillRenderer.h:35
void paintPills(QPaintEvent *event)
Paint pill backgrounds behind highlighted tokens. Call before the base-class paintEvent so pills appe...
Definition PillRenderer.cpp:56
static constexpr qreal PillMinGap
Minimum gap between adjacent pills.
Definition PillRenderer.h:37
static constexpr qreal PillMaxRadius
Maximum corner radius.
Definition PillRenderer.h:34
static constexpr qreal PillMinHPad
Floor during overlap resolution.
Definition PillRenderer.h:36
Definition TransmitTextEdit.h:22
Background and foreground colors for each pill category.
Definition DirectedMessageHighlighter.h:11