20 #ifndef _STELGUIITEMS_HPP_
21 #define _STELGUIITEMS_HPP_
23 #include <QGraphicsPixmapItem>
24 #include <QGraphicsWidget>
28 class QGraphicsSceneMouseEvent;
30 class QGraphicsTextItem;
47 QMap<const StelProgressController*, QProgressBar*> allBars;
54 Q_INTERFACES(QGraphicsItem)
57 virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
58 virtual QRectF boundingRect()
const;
59 void setOpacity(
double opacity);
61 mutable double lastOpacity;
65 class StelButton :
public QObject,
public QGraphicsPixmapItem
78 StelButton(QGraphicsItem* parent,
const QPixmap& pixOn,
const QPixmap& pixOff,
79 const QPixmap& pixHover=QPixmap(),
80 class StelAction* action=NULL,
bool noBackground=
false);
82 StelButton(QGraphicsItem* parent,
const QPixmap& pixOn,
const QPixmap& pixOff,
83 const QPixmap& pixHover=QPixmap(),
84 const QString& actionId=QString(),
bool noBackground=
false);
94 StelButton(QGraphicsItem* parent,
const QPixmap& pixOn,
const QPixmap& pixOff,
const QPixmap& pixNoChange,
95 const QPixmap& pixHover=QPixmap(),
96 const QString& actionId=QString(),
bool noBackground=
false,
bool isTristate=
true);
99 enum {ButtonStateOff = 0, ButtonStateOn = 1, ButtonStateNoChange = 2};
129 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
130 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
131 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
132 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
134 void animValueChanged(qreal value);
136 void initCtor(
const QPixmap& apixOn,
137 const QPixmap& apixOff,
138 const QPixmap& apixNoChange,
139 const QPixmap& apixHover,
144 int toggleChecked(
int);
150 QPixmap pixBackground;
166 Q_INTERFACES(QGraphicsItem);
170 virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
171 virtual QRectF boundingRect()
const;
173 QRectF boundingRectNoHelpLabel()
const;
178 void buttonHoverChanged(
bool b);
180 QTimeLine* hideTimeLine;
181 QGraphicsSimpleTextItem* helpLabel;
188 Q_INTERFACES(QGraphicsItem);
190 BottomStelBar(QGraphicsItem* parent,
const QPixmap& pixLeft=QPixmap(),
const QPixmap& pixRight=QPixmap(),
const QPixmap& pixMiddle=QPixmap(),
const QPixmap& pixSingle=QPixmap());
192 virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
193 virtual QRectF boundingRect()
const;
194 QRectF boundingRectNoHelpLabel()
const;
200 void addButton(
StelButton* button,
const QString& groupName=
"defaultGroup",
const QString& beforeActionName=
"");
205 void setGroupMargin(
const QString& groupName,
int left,
int right);
209 const QPixmap& pixRight=QPixmap(),
const QPixmap& pixMiddle=QPixmap(),
210 const QPixmap& pixSingle=QPixmap());
217 bool getFlagShowTime() {
return flagShowTime; }
220 bool getFlagShowLocation() {
return flagShowLocation; }
223 bool getFlagShowFps() {
return flagShowFps; }
226 bool getFlagShowFov() {
return flagShowFov; }
229 bool getFlagFovDms() {
return flagFovDms; }
232 bool getFlagTimeJd() {
return flagTimeJd; }
234 void setFlagShowTz(
bool b) { flagShowTZ=b; }
235 bool getFlagShowTz() {
return flagShowTZ; }
242 void buttonHoverChanged(
bool b);
245 void updateText(
bool forceUpdatePos=
false);
246 void updateButtonsGroups();
247 QRectF getButtonsBoundingRect()
const;
248 QGraphicsSimpleTextItem* location;
249 QGraphicsSimpleTextItem* datetime;
250 QGraphicsSimpleTextItem* fov;
251 QGraphicsSimpleTextItem* fps;
255 ButtonGroup() : leftMargin(0), rightMargin(0),
256 pixBackgroundLeft(NULL), pixBackgroundRight(NULL),
257 pixBackgroundMiddle(NULL), pixBackgroundSingle(NULL) {;}
259 QList<StelButton*> elems;
265 QPixmap* pixBackgroundLeft;
266 QPixmap* pixBackgroundRight;
267 QPixmap* pixBackgroundMiddle;
268 QPixmap* pixBackgroundSingle;
271 QMap<QString, ButtonGroup> buttonGroups;
272 QPixmap pixBackgroundLeft;
273 QPixmap pixBackgroundRight;
274 QPixmap pixBackgroundMiddle;
275 QPixmap pixBackgroundSingle;
278 bool flagShowLocation;
285 QGraphicsSimpleTextItem* helpLabel;
294 double getRoundSize()
const {
return roundSize;}
295 void setBackgroundOpacity(
double opacity);
300 #endif // _STELGUIITEMS_HPP_
void setColor(const QColor &c)
Set the color for all the sub elements.
void setFlagShowTime(bool b)
Set whether time must be displayed in the bottom bar.
void setFlagFovDms(bool b)
Set whether DMS format for FOV info must be displayed in the bottom bar.
void setFlagShowLocation(bool b)
Set whether location info must be displayed in the bottom bar.
void setGroupMargin(const QString &groupName, int left, int right)
Set the margin at the left and right of a button group in pixels.
void setFlagShowFov(bool b)
Set whether FOV info must be displayed in the bottom bar.
void setFlagShowFps(bool b)
Set whether FPS info must be displayed in the bottom bar.
void setFlagTimeJd(bool b)
Set whether JD for time info must be displayed in the bottom bar.
void setColor(const QColor &c)
Set the color for all the sub elements.
StelButton * hideButton(const QString &actionName)
Hide the button associated with the action of the passed name.
Maintain the state of a progress bar.
void addButton(StelButton *button, const QString &groupName="defaultGroup", const QString &beforeActionName="")
Add a button in a group in the button bar.
void setGroupBackground(const QString &groupName, const QPixmap &pixLeft=QPixmap(), const QPixmap &pixRight=QPixmap(), const QPixmap &pixMiddle=QPixmap(), const QPixmap &pixSingle=QPixmap())
Set the background of a group.