Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
card_info_picture_with_text_overlay_widget.h
Go to the documentation of this file.
1
7
8#ifndef CARD_PICTURE_WITH_TEXT_OVERLAY_H
9#define CARD_PICTURE_WITH_TEXT_OVERLAY_H
10
12
13#include <QColor>
14#include <QString>
15#include <QTextOption>
16#include <qnamespace.h>
17#include <qtmetamacros.h>
18
19class QPainter;
20class QRect;
21class QWidget;
22
24{
25 Q_OBJECT
26
27public:
28 explicit CardInfoPictureWithTextOverlayWidget(QWidget *parent = nullptr,
29 bool hoverToZoomEnabled = false,
30 bool raiseOnEnter = false,
31 const QColor &textColor = Qt::white,
32 const QColor &outlineColor = Qt::black,
33 int fontSize = 12,
34 Qt::Alignment alignment = Qt::AlignCenter);
35
36 void setOverlayText(const QString &text);
37 void setTextColor(const QColor &color);
38 void setOutlineColor(const QColor &color);
39 void setFontSize(int size);
40 void setTextAlignment(Qt::Alignment alignment);
41 void setHighlighted(bool _highlighted);
42
43 [[nodiscard]] QSize sizeHint() const override;
44
45protected:
46 void paintEvent(QPaintEvent *event) override;
47 void mousePressEvent(QMouseEvent *event) override;
48 [[nodiscard]] QSize minimumSizeHint() const override;
49
50private:
51 void drawOutlinedText(QPainter &painter,
52 const QRect &textRect,
53 const QString &text,
54 const QTextOption &textOption) const;
55
56 QString overlayText;
57 QColor textColor;
60 Qt::Alignment textAlignment;
62};
63
64#endif // CARD_PICTURE_WITH_TEXT_OVERLAY_H
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:74
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:75
bool raiseOnEnter
Definition card_info_picture_widget.h:76
void setOutlineColor(const QColor &color)
Sets the outline color around the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:74
void paintEvent(QPaintEvent *event) override
Paints the widget, including both the card image and the text overlay.
Definition card_info_picture_with_text_overlay_widget.cpp:121
Qt::Alignment textAlignment
Definition card_info_picture_with_text_overlay_widget.h:60
bool highlighted
Definition card_info_picture_with_text_overlay_widget.h:61
CardInfoPictureWithTextOverlayWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false, const QColor &textColor=Qt::white, const QColor &outlineColor=Qt::black, int fontSize=12, Qt::Alignment alignment=Qt::AlignCenter)
Constructs a CardPictureWithTextOverlay widget.
Definition card_info_picture_with_text_overlay_widget.cpp:35
int fontSize
Definition card_info_picture_with_text_overlay_widget.h:59
QColor outlineColor
Definition card_info_picture_with_text_overlay_widget.h:58
void setHighlighted(bool _highlighted)
Definition card_info_picture_with_text_overlay_widget.cpp:100
void setTextColor(const QColor &color)
Sets the color of the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:64
QString overlayText
Definition card_info_picture_with_text_overlay_widget.h:56
void setOverlayText(const QString &text)
Sets the overlay text to be displayed on the card.
Definition card_info_picture_with_text_overlay_widget.cpp:54
void drawOutlinedText(QPainter &painter, const QRect &textRect, const QString &text, const QTextOption &textOption) const
Draws text with an outline for visibility.
Definition card_info_picture_with_text_overlay_widget.cpp:247
void mousePressEvent(QMouseEvent *event) override
Definition card_info_picture_with_text_overlay_widget.cpp:110
QSize minimumSizeHint() const override
Provides the minimum recommended size for this widget.
Definition card_info_picture_with_text_overlay_widget.cpp:280
QSize sizeHint() const override
Provides the recommended size for this widget.
Definition card_info_picture_with_text_overlay_widget.cpp:271
QColor textColor
Definition card_info_picture_with_text_overlay_widget.h:57
void setFontSize(int size)
Sets the font size for the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:84
void setTextAlignment(Qt::Alignment alignment)
Sets the alignment of the overlay text within the widget.
Definition card_info_picture_with_text_overlay_widget.cpp:94
Definition color.proto:4