Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform 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 <QSize>
15#include <QTextOption>
16
18{
19 Q_OBJECT
20
21public:
22 explicit CardInfoPictureWithTextOverlayWidget(QWidget *parent = nullptr,
23 bool hoverToZoomEnabled = false,
24 bool raiseOnEnter = false,
25 const QColor &textColor = Qt::white,
26 const QColor &outlineColor = Qt::black,
27 int fontSize = 12,
28 Qt::Alignment alignment = Qt::AlignCenter);
29
30 void setOverlayText(const QString &text);
31 void setTextColor(const QColor &color);
32 void setOutlineColor(const QColor &color);
33 void setFontSize(int size);
34 void setTextAlignment(Qt::Alignment alignment);
35 void setHighlighted(bool _highlighted);
36
37 [[nodiscard]] QSize sizeHint() const override;
38signals:
39 void imageClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance);
40
41protected:
42 void paintEvent(QPaintEvent *event) override;
43 void mousePressEvent(QMouseEvent *event) override;
44 [[nodiscard]] QSize minimumSizeHint() const override;
45
46private:
47 void drawOutlinedText(QPainter &painter,
48 const QRect &textRect,
49 const QString &text,
50 const QTextOption &textOption) const;
51
52 QString overlayText;
53 QColor textColor;
56 Qt::Alignment textAlignment;
58};
59
60#endif // CARD_PICTURE_WITH_TEXT_OVERLAY_H
TODO: Document this.
CardInfoPictureWidget(QWidget *parent=nullptr, bool hoverToZoomEnabled=false, bool raiseOnEnter=false)
Constructs a CardInfoPictureWidget.
Definition card_info_picture_widget.cpp:34
bool hoverToZoomEnabled
Definition card_info_picture_widget.h:78
bool raiseOnEnter
Definition card_info_picture_widget.h:79
void setOutlineColor(const QColor &color)
Sets the outline color around the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:58
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:105
Qt::Alignment textAlignment
Definition card_info_picture_with_text_overlay_widget.h:56
bool highlighted
Definition card_info_picture_with_text_overlay_widget.h:57
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:19
int fontSize
Definition card_info_picture_with_text_overlay_widget.h:55
QColor outlineColor
Definition card_info_picture_with_text_overlay_widget.h:54
void setHighlighted(bool _highlighted)
Definition card_info_picture_with_text_overlay_widget.cpp:84
void setTextColor(const QColor &color)
Sets the color of the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:48
QString overlayText
Definition card_info_picture_with_text_overlay_widget.h:52
void setOverlayText(const QString &text)
Sets the overlay text to be displayed on the card.
Definition card_info_picture_with_text_overlay_widget.cpp:38
void imageClicked(QMouseEvent *event, CardInfoPictureWithTextOverlayWidget *instance)
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:229
void mousePressEvent(QMouseEvent *event) override
Definition card_info_picture_with_text_overlay_widget.cpp:94
QSize minimumSizeHint() const override
Provides the minimum recommended size for this widget.
Definition card_info_picture_with_text_overlay_widget.cpp:262
QSize sizeHint() const override
Provides the recommended size for this widget.
Definition card_info_picture_with_text_overlay_widget.cpp:253
QColor textColor
Definition card_info_picture_with_text_overlay_widget.h:53
void setFontSize(int size)
Sets the font size for the overlay text.
Definition card_info_picture_with_text_overlay_widget.cpp:68
void setTextAlignment(Qt::Alignment alignment)
Sets the alignment of the overlay text within the widget.
Definition card_info_picture_with_text_overlay_widget.cpp:78