mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
/**
|
|
* @file phases_toolbar.h
|
|
* @ingroup GameGraphics
|
|
* @ingroup GameWidgets
|
|
*/
|
|
//! \todo Document this file.
|
|
|
|
#ifndef PHASESTOOLBAR_H
|
|
#define PHASESTOOLBAR_H
|
|
|
|
#include <QGraphicsItem>
|
|
#include <QList>
|
|
#include <QObject>
|
|
#include <QString>
|
|
#include <qtmetamacros.h>
|
|
|
|
class QAction;
|
|
class QTimer;
|
|
|
|
class PhaseButton : public QObject, public QGraphicsItem
|
|
{
|
|
Q_OBJECT
|
|
Q_INTERFACES(QGraphicsItem)
|
|
private:
|
|
QString name;
|
|
bool active, highlightable;
|
|
int activeAnimationCounter;
|
|
QTimer *activeAnimationTimer;
|
|
QAction *doubleClickAction;
|
|
double width;
|
|
|
|
// void updatePixmap(QPixmap &pixmap);
|
|
private slots:
|
|
void updateAnimation();
|
|
|
|
public:
|
|
explicit PhaseButton(const QString &_name,
|
|
QGraphicsItem *parent = nullptr,
|
|
QAction *_doubleClickAction = nullptr,
|
|
bool _highlightable = true);
|
|
[[nodiscard]] QRectF boundingRect() const override;
|
|
void setWidth(double _width);
|
|
void setActive(bool _active);
|
|
[[nodiscard]] bool getActive() const
|
|
{
|
|
return active;
|
|
}
|
|
void triggerDoubleClickAction();
|
|
signals:
|
|
void clicked();
|
|
|
|
protected:
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) override;
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
|
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
|
};
|
|
|
|
class PhasesToolbar : public QObject, public QGraphicsItem
|
|
{
|
|
Q_OBJECT
|
|
Q_INTERFACES(QGraphicsItem)
|
|
private:
|
|
QList<PhaseButton *> buttonList;
|
|
PhaseButton *nextTurnButton;
|
|
double width, height, ySpacing, symbolSize;
|
|
static const int buttonCount = 12;
|
|
static const int spaceCount = 6;
|
|
static const double marginSize;
|
|
void rearrangeButtons();
|
|
|
|
public:
|
|
explicit PhasesToolbar(QGraphicsItem *parent = nullptr);
|
|
[[nodiscard]] QRectF boundingRect() const override;
|
|
void retranslateUi();
|
|
void setHeight(double _height);
|
|
[[nodiscard]] double getWidth() const
|
|
{
|
|
return width;
|
|
}
|
|
[[nodiscard]] int phaseCount() const
|
|
{
|
|
return buttonList.size();
|
|
}
|
|
[[nodiscard]] QString getLongPhaseName(int phase) const;
|
|
public slots:
|
|
void setActivePhase(int phase);
|
|
void triggerPhaseAction(int phase);
|
|
private slots:
|
|
void phaseButtonClicked();
|
|
signals:
|
|
/** @name Intent signals
|
|
* The view reports what the user asked for; GameEventHandler builds the commands.
|
|
* @{
|
|
*/
|
|
void setActivePhaseRequested(int phase);
|
|
void nextTurnRequested();
|
|
void untapAllRequested();
|
|
void drawCardRequested();
|
|
/** @} */
|
|
|
|
protected:
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) override;
|
|
};
|
|
|
|
#endif
|