-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from ghutchis/update-render-options
Update render options
- Loading branch information
Showing
9 changed files
with
365 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
This source code is released under the 3-Clause BSD License, (see "LICENSE"). | ||
******************************************************************************/ | ||
|
||
// Adapted from Avogadro 1.0 by Geoffrey Hutchison | ||
// Contributed to Avogadro 2.0 by Geoffrey Hutchison | ||
|
||
#include "colorbutton.h" | ||
|
||
#include <QColorDialog> | ||
#include <QPainter> | ||
|
||
namespace Avogadro { | ||
namespace QtGui { | ||
|
||
ColorButton::ColorButton(QWidget* parent) | ||
: QAbstractButton(parent), m_color(Qt::white), m_title("") | ||
{ | ||
setMinimumSize(35, 20); | ||
|
||
connect(this, SIGNAL(clicked()), this, SLOT(changeColor())); | ||
} | ||
|
||
ColorButton::ColorButton(const QColor& initial, QWidget* parent) | ||
: QAbstractButton(parent), m_color(initial) | ||
{ | ||
setMinimumSize(35, 20); | ||
|
||
connect(this, SIGNAL(clicked()), this, SLOT(changeColor())); | ||
} | ||
|
||
void ColorButton::changeColor() | ||
{ | ||
// This could be an ifdef for KColorDialog if KDE is present | ||
if (m_title == "") | ||
m_color = QColorDialog::getColor(m_color, this); | ||
else | ||
m_color = QColorDialog::getColor(m_color, this, m_title); | ||
update(); | ||
|
||
emit colorChanged(m_color); | ||
} | ||
|
||
void ColorButton::setColor(const QColor& color) | ||
{ | ||
m_color = color; | ||
update(); | ||
|
||
emit colorChanged(m_color); | ||
} | ||
|
||
void ColorButton::setDialogTitle(const QString title) | ||
{ | ||
m_title = title; | ||
} | ||
|
||
QColor ColorButton::color() const | ||
{ | ||
return m_color; | ||
} | ||
|
||
void ColorButton::paintEvent(QPaintEvent*) | ||
{ | ||
// TODO: If we go to RGBA colors, we should really show two pieces | ||
// e.g. ----------- | ||
// | /| | ||
// | non / | | ||
// | alpha/ | | ||
// | / | | ||
// | /alpha | ||
// | / | | ||
// ----------- | ||
|
||
QPainter painter(this); | ||
|
||
// outer border | ||
painter.drawRect(0, 0, width(), height()); | ||
// inner color | ||
painter.setBrush(m_color); | ||
painter.drawRect(4, 4, width() - 8, height() - 8); | ||
} | ||
|
||
bool ColorButton::event(QEvent* e) | ||
{ | ||
return QAbstractButton::event(e); | ||
} | ||
|
||
} // namespace QtGui | ||
} // namespace Avogadro |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/****************************************************************************** | ||
This source file is part of the Avogadro project. | ||
This source code is released under the 3-Clause BSD License, (see "LICENSE"). | ||
******************************************************************************/ | ||
|
||
// Adapted from Avogadro 1.0 by Geoffrey Hutchison | ||
// Contributed to Avogadro 2.0 by Geoffrey Hutchison | ||
|
||
#ifndef AVOGADRO_QTGUI_COLORBUTTON_H | ||
#define AVOGADRO_QTGUI_COLORBUTTON_H | ||
|
||
#include "avogadroqtguiexport.h" | ||
|
||
#include <QAbstractButton> | ||
#include <QColor> | ||
|
||
namespace Avogadro { | ||
namespace QtGui { | ||
|
||
/** | ||
* @class ColorButton colorbutton.h <avogadro/colorbutton.h> | ||
* @author Geoffrey Hutchison | ||
* @brief A button to show the current color and bring up the QColorDialog. | ||
* | ||
* This class implements a QAbstractButton to display a colored rectangle. | ||
* When clicked by the user, it brings up a color picker to select a new | ||
* color. | ||
* | ||
* The widget has a default minimium size of 35x20 pixels. | ||
*/ | ||
|
||
class AVOGADROQTGUI_EXPORT ColorButton : public QAbstractButton | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ColorButton(QWidget* parent = 0); | ||
explicit ColorButton(const QColor& initial, QWidget* parent = 0); | ||
|
||
/** | ||
* Redraw the widget (i.e., refresh the colored rectange) | ||
*/ | ||
void paintEvent(QPaintEvent*); | ||
|
||
/** | ||
* @param color the new color to be used | ||
*/ | ||
void setColor(const QColor& color); | ||
|
||
/** | ||
* @param custom title for color choice dialog | ||
*/ | ||
void setDialogTitle(const QString title = ""); | ||
|
||
/** | ||
* @return the current color | ||
*/ | ||
QColor color() const; | ||
|
||
Q_SIGNALS: | ||
/** | ||
* emit any time the color is changed, either by a user or by setColor() | ||
*/ | ||
void colorChanged(const QColor &); | ||
|
||
public Q_SLOTS: | ||
/** | ||
* Call for a change in the current color | ||
*/ | ||
void changeColor(); | ||
|
||
protected: | ||
/** | ||
* Generic event handler, currently defaults to calling parent class | ||
* (included for future compatibility) | ||
*/ | ||
bool event(QEvent* e); | ||
|
||
QColor m_color; //!< The current color | ||
QString m_title; //!< The current dialog title | ||
}; | ||
|
||
} // namespace QtGui | ||
} // namespace Avogadro | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.