1 /* 2 * Stellarium 3 * Copyright (C) 2009 Fabien Chereau 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 18 */ 19 20 #ifndef SKYGUI_HPP 21 #define SKYGUI_HPP 22 23 #include "StelStyle.hpp" 24 #include "StelObject.hpp" 25 26 #include <QDebug> 27 #include <QGraphicsWidget> 28 #include <QGraphicsPixmapItem> 29 30 class QGraphicsSceneMouseEvent; 31 class QGraphicsTextItem; 32 class QTimeLine; 33 class StelButton; 34 class BottomStelBar; 35 class StelProgressController; 36 37 //! The informations about the currently selected object 38 class InfoPanel : public QGraphicsTextItem 39 { 40 public: 41 //! Reads "gui/selected_object_info", etc from the configuration file. 42 //! @todo Bad idea to read from the configuration file in a constructor? --BM 43 InfoPanel(QGraphicsItem* parent); 44 ~InfoPanel(); setInfoTextFilters(const StelObject::InfoStringGroup & aflags)45 void setInfoTextFilters(const StelObject::InfoStringGroup& aflags) {infoTextFilters=aflags;} getInfoTextFilters(void) const46 const StelObject::InfoStringGroup& getInfoTextFilters(void) const {return infoTextFilters;} 47 void setTextFromObjects(const QList<StelObjectP>&); 48 const QString getSelectedText(void) const; 49 50 private: 51 StelObject::InfoStringGroup infoTextFilters; 52 QGraphicsPixmapItem *infoPixmap; // Used when text rendering is buggy. Used when CLI option -t given. 53 }; 54 55 //! The class managing the layout for button bars, selected object info and loading bars. 56 class SkyGui: public QGraphicsWidget 57 { 58 Q_OBJECT 59 60 public: 61 friend class StelGui; 62 63 SkyGui(QGraphicsItem * parent=Q_NULLPTR); 64 //! Add a new progress bar in the lower right corner of the screen. 65 //! When the progress bar is deleted with removeProgressBar() the layout is automatically rearranged. 66 //! @return a pointer to the progress bar 67 void addProgressBar(StelProgressController*); 68 69 void init(class StelGui* stelGui); 70 71 virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget* = Q_NULLPTR) Q_DECL_OVERRIDE; 72 73 int getSkyGuiWidth() const; 74 int getSkyGuiHeight() const; 75 qreal getBottomBarHeight() const; //!< return height of bottom Bar when fully shown 76 qreal getLeftBarWidth() const; //!< return width of left Bar when fully shown 77 78 protected: 79 virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE; 80 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* event) Q_DECL_OVERRIDE; 81 virtual QVariant itemChange(GraphicsItemChange change, const QVariant & value) Q_DECL_OVERRIDE; 82 83 private slots: 84 //! Load color scheme from the given ini file and section name 85 void setStelStyle(const QString& style); 86 87 public slots: 88 //! Update the position of the button bars in the main window 89 //! GZ needed this public for interactive GUI scaling 90 void updateBarsPos(); 91 92 private: 93 class StelBarsPath* buttonBarPath; 94 QTimeLine* animLeftBarTimeLine; 95 QTimeLine* animBottomBarTimeLine; 96 int lastButtonbarWidth; 97 class LeftStelBar* winBar; 98 BottomStelBar* buttonBar; 99 class InfoPanel* infoPanel; 100 class StelProgressBarMgr* progressBarMgr; 101 102 // The 2 auto hide buttons in the lower left corner 103 StelButton* btHorizAutoHide; 104 StelButton* btVertAutoHide; 105 106 class CornerButtons* autoHidebts; 107 108 bool autoHideHorizontalButtonBar; 109 bool autoHideVerticalButtonBar; 110 111 StelGui* stelGui; 112 }; 113 114 #endif // _SKYGUI_HPP 115