Commit f2ca1461 authored by Jan Möbius's avatar Jan Möbius
Browse files

Use ColorChooserButton fromACG

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12507 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 27506fee
...@@ -81,7 +81,10 @@ void QtColorChooserButton::init() { ...@@ -81,7 +81,10 @@ void QtColorChooserButton::init() {
void QtColorChooserButton::onClick() { void QtColorChooserButton::onClick() {
QColor newColor = QColorDialog::getColor(color_, this, "Pick Color", QColorDialog::ShowAlphaChannel); QColor newColor = QColorDialog::getColor(color_, this, "Pick Color", QColorDialog::ShowAlphaChannel);
if (newColor.isValid()) color_ = newColor; if (newColor.isValid()) {
color_ = newColor;
emit colorChanged(color_);
}
} }
void QtColorChooserButton::paintEvent(QPaintEvent *ev) { void QtColorChooserButton::paintEvent(QPaintEvent *ev) {
......
...@@ -79,6 +79,9 @@ class QtColorChooserButton: public QPushButton { ...@@ -79,6 +79,9 @@ class QtColorChooserButton: public QPushButton {
public Q_SLOTS: public Q_SLOTS:
void onClick(); void onClick();
signals:
void colorChanged(QColor _newcolor );
private: private:
QColor color_; QColor color_;
}; };
......
...@@ -174,14 +174,14 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent, ...@@ -174,14 +174,14 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.colorMaterial, SIGNAL( pressed() ), this, SLOT( enableProperty() ) ); connect( ui_.colorMaterial, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.multiSampling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) ); connect( ui_.multiSampling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.baseColorButton, SIGNAL( clicked() ), connect( ui_.baseColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeBaseColor() ) ); this, SLOT( changeBaseColor(QColor) ) );
connect( ui_.ambientColorButton, SIGNAL( clicked() ), connect( ui_.ambientColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeAmbientColor() ) ); this, SLOT( changeAmbientColor(QColor) ) );
connect( ui_.diffuseColorButton, SIGNAL( clicked() ), connect( ui_.diffuseColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeDiffuseColor() ) ); this, SLOT( changeDiffuseColor(QColor) ) );
connect( ui_.specularColorButton, SIGNAL( clicked() ), connect( ui_.specularColorButton, SIGNAL( colorChanged(QColor) ),
this, SLOT( changeSpecularColor() ) ); this, SLOT( changeSpecularColor(QColor) ) );
connect( ui_.shininessSlider, SIGNAL( sliderMoved(int) ), connect( ui_.shininessSlider, SIGNAL( sliderMoved(int) ),
this, SLOT( changeShine(int) ) ); this, SLOT( changeShine(int) ) );
...@@ -271,12 +271,10 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent, ...@@ -271,12 +271,10 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
void void
QtMaterialDialog::setButtonColor( QPushButton * _button, QtMaterialDialog::setButtonColor( QtColorChooserButton* _button,
const Vec4f & _color ) const Vec4f& _color )
{ {
QPalette p( _button->palette() ); _button->setColor( convertColor( _color ) );
p.setColor( QPalette::Button, convertColor( _color ) );
_button->setPalette( p );
} }
...@@ -300,9 +298,9 @@ Vec4f ...@@ -300,9 +298,9 @@ Vec4f
QtMaterialDialog::convertColor( QColor _color) QtMaterialDialog::convertColor( QColor _color)
{ {
return Vec4f (_color.redF(), return Vec4f (_color.redF(),
_color.greenF(), _color.greenF(),
_color.blueF(), _color.blueF(),
_color.alphaF() ); _color.alphaF() );
} }
...@@ -457,70 +455,41 @@ void QtMaterialDialog::undoChanges() ...@@ -457,70 +455,41 @@ void QtMaterialDialog::undoChanges()
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void QtMaterialDialog::changeDiffuseColor() void QtMaterialDialog::changeDiffuseColor(QColor _newColor)
{ {
bool* ok = 0; diffuse_ = convertColor( _newColor );
applyChanges();
QColor newColor = QColor( QColorDialog::getRgba(convertColor(diffuse_).rgba(), ok, this));
if( newColor.isValid())
{
diffuse_ = convertColor( newColor );
applyChanges();
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void QtMaterialDialog::changeAmbientColor() void QtMaterialDialog::changeAmbientColor(QColor _newColor)
{ {
bool* ok = 0; ambient_ = convertColor( _newColor );
applyChanges();
QColor oldColor = convertColor(ambient_);
QColor newColor = QColorDialog::getColor(oldColor, this, "Ambient Color", QColorDialog::ShowAlphaChannel);
if( newColor.isValid())
{
ambient_ = convertColor( newColor );
applyChanges();
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void QtMaterialDialog::changeSpecularColor() void QtMaterialDialog::changeSpecularColor(QColor _newColor)
{ {
bool* ok = 0; specular_ = convertColor( _newColor );
applyChanges();
QColor newColor = QColor( QColorDialog::getRgba(convertColor(specular_).rgba(), ok, this));
if( newColor.isValid())
{
specular_ = convertColor( newColor );
applyChanges();
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void QtMaterialDialog::changeBaseColor() void QtMaterialDialog::changeBaseColor(QColor _newColor)
{ {
bool* ok = 0; color_ = convertColor( _newColor );
applyChanges();
QColor newColor = QColor( QColorDialog::getRgba(convertColor(color_).rgba(), ok, this));
if( newColor.isValid())
{
color_ = convertColor( newColor );
applyChanges();
}
} }
......
...@@ -107,15 +107,15 @@ private: ...@@ -107,15 +107,15 @@ private:
QColor convertColor( Vec4f _color); QColor convertColor( Vec4f _color);
Vec4f convertColor( QColor _color); Vec4f convertColor( QColor _color);
void setButtonColor( QPushButton * _button, void setButtonColor( QtColorChooserButton* _button,
const Vec4f & _color ); const Vec4f& _color );
private slots: private slots:
void changeBaseColor(); void changeBaseColor(QColor _newColor);
void changeAmbientColor(); void changeAmbientColor(QColor _newColor);
void changeDiffuseColor(); void changeDiffuseColor(QColor _newColor);
void changeSpecularColor(); void changeSpecularColor(QColor _newColor);
void changeShine(int _new); void changeShine(int _new);
void changePointSize(int _new); void changePointSize(int _new);
void changeLineWidth(int _new); void changeLineWidth(int _new);
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment