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);
89 StelButton(QGraphicsItem* parent,
const QPixmap& pixOn,
const QPixmap& pixOff,
90 const QPixmap& pixHover,
91 const QString& actionId,
bool noBackground=
false);
101 StelButton(QGraphicsItem* parent,
const QPixmap& pixOn,
const QPixmap& pixOff,
const QPixmap& pixNoChange,
102 const QPixmap& pixHover,
103 const QString& actionId=QString(),
bool noBackground=
false,
bool isTristate=
true);
106 enum {ButtonStateOff = 0, ButtonStateOn = 1, ButtonStateNoChange = 2};
119 void setBackgroundPixmap(
const QPixmap& newBackground);
133 void hoverChanged(
bool b);
137 void setChecked(
int b);
138 void setChecked(
bool b) { setChecked((
int)b); }
141 virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
142 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
143 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
144 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
146 void animValueChanged(qreal value);
148 void initCtor(
const QPixmap& apixOn,
149 const QPixmap& apixOff,
150 const QPixmap& apixNoChange,
151 const QPixmap& apixHover,
156 int toggleChecked(
int);
162 QPixmap pixBackground;
165 bool flagChangeFocus;
179 Q_INTERFACES(QGraphicsItem)
183 virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
184 virtual QRectF boundingRect()
const;
186 QRectF boundingRectNoHelpLabel()
const;
188 void setColor(
const QColor& c);
191 void buttonHoverChanged(
bool b);
193 QTimeLine* hideTimeLine;
194 QGraphicsSimpleTextItem* helpLabel;
195 QGraphicsPixmapItem* helpLabelPixmap;
202 Q_INTERFACES(QGraphicsItem)
204 BottomStelBar(QGraphicsItem* parent,
const QPixmap& pixLeft=QPixmap(),
const QPixmap& pixRight=QPixmap(),
const QPixmap& pixMiddle=QPixmap(),
const QPixmap& pixSingle=QPixmap());
206 virtual void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
207 virtual QRectF boundingRect()
const;
208 QRectF boundingRectNoHelpLabel()
const;
214 void addButton(
StelButton* button,
const QString& groupName=
"defaultGroup",
const QString& beforeActionName=
"");
216 StelButton* hideButton(
const QString& actionName);
219 void setGroupMargin(
const QString& groupName,
int left,
int right);
222 void setGroupBackground(
const QString& groupName,
const QPixmap& pixLeft=QPixmap(),
223 const QPixmap& pixRight=QPixmap(),
const QPixmap& pixMiddle=QPixmap(),
224 const QPixmap& pixSingle=QPixmap());
227 void setColor(
const QColor& c);
231 bool getFlagShowTime() {
return flagShowTime; }
234 bool getFlagShowLocation() {
return flagShowLocation; }
237 bool getFlagShowFps() {
return flagShowFps; }
240 bool getFlagShowFov() {
return flagShowFov; }
243 bool getFlagFovDms() {
return flagFovDms; }
246 bool getFlagTimeJd() {
return flagTimeJd; }
248 void setFlagShowTz(
bool b) { flagShowTZ=b; }
249 bool getFlagShowTz() {
return flagShowTZ; }
256 void buttonHoverChanged(
bool b);
259 void updateText(
bool forceUpdatePos=
false);
260 void updateButtonsGroups();
261 QRectF getButtonsBoundingRect()
const;
263 QGraphicsSimpleTextItem* location;
264 QGraphicsSimpleTextItem* datetime;
265 QGraphicsSimpleTextItem* fov;
266 QGraphicsSimpleTextItem* fps;
269 QGraphicsPixmapItem* locationPixmap;
270 QGraphicsPixmapItem* datetimePixmap;
271 QGraphicsPixmapItem* fovPixmap;
272 QGraphicsPixmapItem* fpsPixmap;
278 ButtonGroup() : leftMargin(0), rightMargin(0),
279 pixBackgroundLeft(NULL), pixBackgroundRight(NULL),
280 pixBackgroundMiddle(NULL), pixBackgroundSingle(NULL) {;}
282 QList<StelButton*> elems;
288 QPixmap* pixBackgroundLeft;
289 QPixmap* pixBackgroundRight;
290 QPixmap* pixBackgroundMiddle;
291 QPixmap* pixBackgroundSingle;
294 QMap<QString, ButtonGroup> buttonGroups;
295 QPixmap pixBackgroundLeft;
296 QPixmap pixBackgroundRight;
297 QPixmap pixBackgroundMiddle;
298 QPixmap pixBackgroundSingle;
301 bool flagShowLocation;
308 QGraphicsSimpleTextItem* helpLabel;
309 QGraphicsPixmapItem* helpLabelPixmap;
318 double getRoundSize()
const {
return roundSize;}
319 void setBackgroundOpacity(
double opacity);
324 #endif // _STELGUIITEMS_HPP_
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.
Wrapper around an argumentless QObject slot or a bool Q_PROPERTY with WRITE method, allowing the slot to be called/property to be toggled using this action object.
void setFlagShowLocation(bool b)
Set whether location info must be displayed in the bottom bar.
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.
Maintain the state of a progress bar.