StelGuiItems.hpp   StelGuiItems.hpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#ifndef _STELGUIITEMS_HPP_ #ifndef _STELGUIITEMS_HPP_
#define _STELGUIITEMS_HPP_ #define _STELGUIITEMS_HPP_
#include <QGraphicsPixmapItem> #include <QGraphicsPixmapItem>
#include <QGraphicsWidget>
#include <QDebug> #include <QDebug>
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class QTimeLine; class QTimeLine;
class QAction; class QAction;
class QGraphicsTextItem; class QGraphicsTextItem;
class QTimer; class QTimer;
// Progess bars in the lower right corner // Progess bars in the lower right corner
class StelProgressBarMgr : public QObject, public QGraphicsItem class StelProgressBarMgr : public QGraphicsWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
StelProgressBarMgr(QGraphicsItem* parent); StelProgressBarMgr(QGraphicsItem* parent);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem
*option, QWidget *widget = 0);
virtual QRectF boundingRect() const;
class QProgressBar* addProgressBar(); class QProgressBar* addProgressBar();
private slots:
void oneDestroyed(QObject* obj);
private:
void updateBarsPositions();
}; };
// Buttons in the bottom left corner // Buttons in the bottom left corner
class CornerButtons : public QObject, public QGraphicsItem class CornerButtons : public QObject, public QGraphicsItem
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem);
public: public:
CornerButtons(QGraphicsItem* parent=NULL); CornerButtons(QGraphicsItem* parent=NULL);
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
void setOpacity(double opacity); void setOpacity(double opacity);
private: private:
mutable double lastOpacity; mutable double lastOpacity;
}; };
//! A Button Graphicsitem for use in Stellarium's graphic widgets //! A Button Graphicsitem for use in Stellarium's graphic widgets
skipping to change at line 74 skipping to change at line 70
friend class LeftStelBar; friend class LeftStelBar;
Q_OBJECT Q_OBJECT
public: public:
//! Constructor //! Constructor
//! @param parent the parent item //! @param parent the parent item
//! @param pixOn the pixmap to display when the button is toggled //! @param pixOn the pixmap to display when the button is toggled
//! @param pixOff the pixmap to display when the button is not toggl ed //! @param pixOff the pixmap to display when the button is not toggl ed
//! @param pixHover a pixmap slowly blended when mouse is over the b utton //! @param pixHover a pixmap slowly blended when mouse is over the b utton
//! @param action the associated action. Connections are automatical ly done with the signals if relevant. //! @param action the associated action. Connections are automatical ly done with the signals if relevant.
//! @param noBackground define whether the button background image h ave to be used //! @param noBackground define whether the button background image h ave to be used
StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixma StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixma
p& pixOff, const QPixmap& pixHover=QPixmap(), p& pixOff,
const QPixmap& pixHover=QPixmap(),
QAction* action=NULL, bool noBackground=false); QAction* action=NULL, bool noBackground=false);
//! Constructor
//! @param parent the parent item
//! @param pixOn the pixmap to display when the button is toggled
//! @param pixOff the pixmap to display when the button is not toggl
ed
//! @param pixNoChange the pixmap to display when the button state o
f a tristate is not changed
//! @param pixHover a pixmap slowly blended when mouse is over the b
utton
//! @param action the associated action. Connections are automatical
ly done with the signals if relevant.
//! @param noBackground define whether the button background image h
ave to be used
//! @param isTristate define whether the button is a tristate or an
on/off button
StelButton(QGraphicsItem* parent, const QPixmap& pixOn, const QPixma
p& pixOff, const QPixmap& pixNoChange,
const QPixmap& pixHover=QPixmap(),
QAction* action=NULL, bool noBackground=false, bo
ol isTristate=true);
//! Button states
enum {ButtonStateOff = 0, ButtonStateOn = 1, ButtonStateNoChange = 2
};
//! Get whether the button is checked //! Get whether the button is checked
bool isChecked() const {return checked;} int isChecked() const {return checked;}
//! Set the button opacity //! Set the button opacity
void setOpacity(double v) {opacity=v; updateIcon();} void setOpacity(double v) {opacity=v; updateIcon();}
//! Activate red mode for this button, i.e. will reduce the non red color component of the icon //! Activate red mode for this button, i.e. will reduce the non red color component of the icon
void setRedMode(bool b) {redMode=b; updateIcon();} void setRedMode(bool b) {redMode=b; updateIcon();}
//! Transform the pixmap so that it look red for night vision mode
static QPixmap makeRed(const QPixmap& p);
signals: signals:
//! Triggered when the button state changes //! Triggered when the button state changes
void toggled(bool); void toggled(bool);
//! Triggered when the button state changes //! Triggered when the button state changes
void triggered(); void triggered();
//! Emitted when the hover state change //! Emitted when the hover state change
//! @param b true if the mouse entered the button //! @param b true if the mouse entered the button
void hoverChanged(bool b); void hoverChanged(bool b);
public slots: public slots:
//! set whether the button is checked //! set whether the button is checked
void setChecked(bool b); void setChecked(int b);
void setChecked(bool b) { setChecked((int)b); }
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent* event); virtual void mousePressEvent(QGraphicsSceneMouseEvent* event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event); virtual void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event); virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private slots: private slots:
void animValueChanged(qreal value); void animValueChanged(qreal value);
private: private:
void updateIcon(); void updateIcon();
int toggleChecked(int);
QPixmap pixOn; QPixmap pixOn;
QPixmap pixOff; QPixmap pixOff;
QPixmap pixNoChange;
QPixmap pixHover; QPixmap pixHover;
QPixmap pixBackground; QPixmap pixBackground;
QPixmap pixOnRed; QPixmap pixOnRed;
QPixmap pixOffRed; QPixmap pixOffRed;
QPixmap pixNoChangeRed;
QPixmap pixHoverRed; QPixmap pixHoverRed;
QPixmap pixBackgroundRed; QPixmap pixBackgroundRed;
bool checked; int checked;
QTimeLine* timeLine; QTimeLine* timeLine;
QAction* action; QAction* action;
bool noBckground; bool noBckground;
bool isTristate_;
double opacity; double opacity;
double hoverOpacity; double hoverOpacity;
bool redMode; bool redMode;
}; };
// The button bar on the left containing windows toggle buttons // The button bar on the left containing windows toggle buttons
class LeftStelBar : public QObject, public QGraphicsItem class LeftStelBar : public QObject, public QGraphicsItem
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem);
public: public:
LeftStelBar(QGraphicsItem* parent); LeftStelBar(QGraphicsItem* parent);
~LeftStelBar(); ~LeftStelBar();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
void addButton(StelButton* button); void addButton(StelButton* button);
QRectF boundingRectNoHelpLabel() const; QRectF boundingRectNoHelpLabel() const;
//! Set the color for all the sub elements //! Set the color for all the sub elements
void setColor(const QColor& c); void setColor(const QColor& c);
//! Activate red mode for the buttons, i.e. will reduce the non red color component of the icon //! Activate red mode for the buttons, i.e. will reduce the non red color component of the icon
skipping to change at line 155 skipping to change at line 177
void buttonHoverChanged(bool b); void buttonHoverChanged(bool b);
private: private:
QTimeLine* hideTimeLine; QTimeLine* hideTimeLine;
QGraphicsSimpleTextItem* helpLabel; QGraphicsSimpleTextItem* helpLabel;
}; };
// The button bar on the bottom containing actions toggle buttons // The button bar on the bottom containing actions toggle buttons
class BottomStelBar : public QObject, public QGraphicsItem class BottomStelBar : public QObject, public QGraphicsItem
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(QGraphicsItem);
public: public:
BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft=QPixmap( ), const QPixmap& pixRight=QPixmap(), const QPixmap& pixMiddle=QPixmap(), c onst QPixmap& pixSingle=QPixmap()); BottomStelBar(QGraphicsItem* parent, const QPixmap& pixLeft=QPixmap( ), const QPixmap& pixRight=QPixmap(), const QPixmap& pixMiddle=QPixmap(), c onst QPixmap& pixSingle=QPixmap());
virtual ~BottomStelBar(); virtual ~BottomStelBar();
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;
QRectF boundingRectNoHelpLabel() const; QRectF boundingRectNoHelpLabel() const;
//! Add a button in a group in the button bar. Group are displayed i n alphabetic order. //! Add a button in a group in the button bar. Group are displayed i n alphabetic order.
//! @param b the button to add //! @param b the button to add
//! @param groupName the name of the button group to which the butto n belongs to. If the group doesn't exist yet, a new one is created. //! @param groupName the name of the button group to which the butto n belongs to. If the group doesn't exist yet, a new one is created.
//! @param beforeActionName insert the button before the button asso ciated to the given action. If the action doesn't exist, insert it at the e nd of the group. //! @param beforeActionName insert the button before the button asso ciated to the given action. If the action doesn't exist, insert it at the e nd of the group.
void addButton(StelButton* button, const QString& groupName="default Group", const QString& beforeActionName=""); void addButton(StelButton* button, const QString& groupName="default Group", const QString& beforeActionName="");
//! Hide the button associated with the action of the passed name //! Hide the button associated with the action of the passed name
StelButton* hideButton(const QString& actionName); StelButton* hideButton(const QString& actionName);
//! Set the margin at the left and right of a button group in pixels //! Set the margin at the left and right of a button group in pixels
void setGroupMargin(const QString& groupName, int left, int right); void setGroupMargin(const QString& groupName, int left, int right);
//! Set the background of a group
void setGroupBackground(const QString& groupName, const QPixmap& pix
Left=QPixmap(),
const QPixmap& pixRi
ght=QPixmap(), const QPixmap& pixMiddle=QPixmap(),
const QPixmap& pixSi
ngle=QPixmap());
//! Set the color for all the sub elements //! Set the color for all the sub elements
void setColor(const QColor& c); void setColor(const QColor& c);
//! Activate red mode for the buttons, i.e. will reduce the non red color component of the icon //! Activate red mode for the buttons, i.e. will reduce the non red color component of the icon
void setRedMode(bool b); void setRedMode(bool b);
//! Set whether time must be displayed in the bottom bar //! Set whether time must be displayed in the bottom bar
void setFlagShowTime(bool b) {flagShowTime=b;} void setFlagShowTime(bool b) {flagShowTime=b;}
//! Set whether location info must be displayed in the bottom bar //! Set whether location info must be displayed in the bottom bar
void setFlagShowLocation(bool b) {flagShowLocation=b;} void setFlagShowLocation(bool b) {flagShowLocation=b;}
private slots: private slots:
//! Update the help label when a button is hovered //! Update the help label when a button is hovered
void buttonHoverChanged(bool b); void buttonHoverChanged(bool b);
private: private:
void updateText(); void updateText(bool forceUpdatePos=false);
void updateButtonsGroups(); void updateButtonsGroups();
QRectF getButtonsBoundingRect() const; QRectF getButtonsBoundingRect() const;
QGraphicsSimpleTextItem* location; QGraphicsSimpleTextItem* location;
QGraphicsSimpleTextItem* datetime; QGraphicsSimpleTextItem* datetime;
QGraphicsSimpleTextItem* fov; QGraphicsSimpleTextItem* fov;
QGraphicsSimpleTextItem* fps; QGraphicsSimpleTextItem* fps;
struct ButtonGroup struct ButtonGroup
{ {
ButtonGroup() : leftMargin(0), rightMargin(0) {;} ButtonGroup() : leftMargin(0), rightMargin(0),
pixBackgroundLeft(NULL), pix
BackgroundRight(NULL),
pixBackgroundMiddle(NULL), p
ixBackgroundSingle(NULL) {;}
//! Elements of the group //! Elements of the group
QList<StelButton*> elems; QList<StelButton*> elems;
//! Left margin size in pixel //! Left margin size in pixel
int leftMargin; int leftMargin;
//! Right margin size in pixel //! Right margin size in pixel
int rightMargin; int rightMargin;
//! Background Images;
QPixmap* pixBackgroundLeft;
QPixmap* pixBackgroundRight;
QPixmap* pixBackgroundMiddle;
QPixmap* pixBackgroundSingle;
}; };
QMap<QString, ButtonGroup> buttonGroups; QMap<QString, ButtonGroup> buttonGroups;
QPixmap pixBackgroundLeft; QPixmap pixBackgroundLeft;
QPixmap pixBackgroundRight; QPixmap pixBackgroundRight;
QPixmap pixBackgroundMiddle; QPixmap pixBackgroundMiddle;
QPixmap pixBackgroundSingle; QPixmap pixBackgroundSingle;
bool flagShowTime; bool flagShowTime;
bool flagShowLocation; bool flagShowLocation;
 End of changes. 22 change blocks. 
16 lines changed or deleted 64 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/