aboutsummaryrefslogtreecommitdiff
path: root/src/aotextboxwidgets.cpp
diff options
context:
space:
mode:
authorin1tiate <32779090+in1tiate@users.noreply.github.com>2024-03-03 20:26:39 -0600
committerGitHub <noreply@github.com>2024-03-03 20:26:39 -0600
commitb48ca2455a2c7674859b2d3d8be2896cdc0f3739 (patch)
tree766e221eff743aba3f95071a100e255b28958f69 /src/aotextboxwidgets.cpp
parenta8b28f50707a9cb7f0377e247e332519563237a2 (diff)
Add the ability for shownames to be outlined (#939)
* showname text outline, partial messagebox outline code * your honor i plead oopsie daisies * Focus down code, add config hookups * remove extraneous qDebug calls
Diffstat (limited to 'src/aotextboxwidgets.cpp')
-rw-r--r--src/aotextboxwidgets.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/aotextboxwidgets.cpp b/src/aotextboxwidgets.cpp
new file mode 100644
index 00000000..1a16e8fe
--- /dev/null
+++ b/src/aotextboxwidgets.cpp
@@ -0,0 +1,37 @@
+#include "aotextboxwidgets.h"
+
+AOChatboxLabel::AOChatboxLabel(QWidget *parent) : QLabel(parent) {}
+
+void AOChatboxLabel::paintEvent(QPaintEvent *event)
+{
+ if (is_outlined) {
+ QBrush brush;
+ QPen pen;
+ QPointF baseline(outline_width, fontMetrics().height());
+
+ // Set up brush (base text)
+ brush.setColor(text_color);
+ brush.setStyle(Qt::SolidPattern);
+
+ // Set up outline
+ pen.setColor(outline_color);
+ pen.setWidthF(outline_width);
+
+ QPainterPath path;
+ path.addText(baseline, font(), text());
+
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ // draw outline
+ painter.setPen(pen);
+ painter.drawPath(path);
+ // remove outline pen, then draw text on top
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(brush);
+ painter.drawPath(path);
+ }
+ else {
+ // Use the default renderer
+ QLabel::paintEvent(event);
+ }
+}