Make variation tree background colors themable.

This commit is contained in:
luyuju151 2018-07-08 23:46:23 +08:00
parent 264aa8c454
commit 8b2d5c9697
3 changed files with 21 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h" #include "FractoriumPch.h"
#include "Fractorium.h" #include "Fractorium.h"
#include "QssDialog.h" #include "QssDialog.h"
@ -90,6 +90,10 @@ Fractorium::Fractorium(QWidget* p)
m_XformComboIcons[i] = QIcon(pixmap); m_XformComboIcons[i] = QIcon(pixmap);
} }
//Set Default VariationTreeBgColor
m_VariationTreeBgColorNoneZero=QColor(200,200,200);
m_VariationTreeBgColorZero=QColor(255,255,255);
QPixmap pixmap(iconSize_, iconSize_); QPixmap pixmap(iconSize_, iconSize_);
pixmap.fill(m_FinalXformComboColor); pixmap.fill(m_FinalXformComboColor);
m_FinalXformComboIcon = QIcon(pixmap); m_FinalXformComboIcon = QIcon(pixmap);

View File

@ -1,4 +1,4 @@
#pragma once #pragma once
#include "ui_Fractorium.h" #include "ui_Fractorium.h"
#include "FractoriumCommon.h" #include "FractoriumCommon.h"
@ -63,6 +63,8 @@ template <typename T> class FinalRenderEmberController;
class Fractorium : public QMainWindow class Fractorium : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QColor VariationTreeBgColorNoneZero MEMBER m_VariationTreeBgColorNoneZero)
Q_PROPERTY(QColor VariationTreeBgColorZero MEMBER m_VariationTreeBgColorZero)
friend GLWidget; friend GLWidget;
friend QssDialog; friend QssDialog;
@ -559,6 +561,7 @@ private:
char m_CoordinateString[128]; char m_CoordinateString[128];
QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor; QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor;
QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon; QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon;
QColor m_VariationTreeBgColorNoneZero, m_VariationTreeBgColorZero;
vector<QDockWidget*> m_Docks; vector<QDockWidget*> m_Docks;
int m_FontSize; int m_FontSize;
@ -569,4 +572,7 @@ private:
shared_ptr<OpenCLInfo> m_Info; shared_ptr<OpenCLInfo> m_Info;
unique_ptr<FractoriumEmberControllerBase> m_Controller; unique_ptr<FractoriumEmberControllerBase> m_Controller;
Ui::FractoriumClass ui; Ui::FractoriumClass ui;
}; };

View File

@ -1,4 +1,4 @@
#include "FractoriumPch.h" #include "FractoriumPch.h"
#include "Fractorium.h" #include "Fractorium.h"
/// <summary> /// <summary>
@ -226,8 +226,8 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
if (xformVar) if (xformVar)
xform->DeleteVariationById(var->VariationId()); xform->DeleteVariationById(var->VariationId());
widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero. // widgetItem->setBackgroundColor(0, QColor(255, 255, 255));//Ensure background is always white if weight goes to zero.
} widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorZero); }
else else
{ {
if (xformVar)//The xform already contained this variation, which means they just went from a non-zero weight to another non-zero weight (the simple case). if (xformVar)//The xform already contained this variation, which means they just went from a non-zero weight to another non-zero weight (the simple case).
@ -241,8 +241,8 @@ void FractoriumEmberController<T>::VariationSpinBoxValueChanged(double d)//Would
auto newVar = var->Copy();//Create a new one with default values. auto newVar = var->Copy();//Create a new one with default values.
newVar->m_Weight = d; newVar->m_Weight = d;
xform->AddVariation(newVar); xform->AddVariation(newVar);
widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform. // widgetItem->setBackgroundColor(0, QColor(200, 200, 200));//Set background to gray when a variation has non-zero weight in this xform.
widgetItem->setBackgroundColor(0, m_Fractorium->m_VariationTreeBgColorNoneZero);
//If they've added a new parametric variation, then grab the values currently in the spinners //If they've added a new parametric variation, then grab the values currently in the spinners
//for the child parameters and assign them to the newly added variation. //for the child parameters and assign them to the newly added variation.
if (parVar) if (parVar)
@ -301,8 +301,8 @@ void FractoriumEmberController<T>::FillVariationTreeWithXform(Xform<T>* xform)
spinBox->SetValueStealth(var ? var->m_Weight : 0);//If the variation was present, set the spin box to its weight, else zero. spinBox->SetValueStealth(var ? var->m_Weight : 0);//If the variation was present, set the spin box to its weight, else zero.
// item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present. // item->setBackgroundColor(0, var ? Qt::darkGray : Qt::lightGray);//Ensure background is always white if the value goes to zero, else gray if var present.
item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present. // item->setBackgroundColor(0, var ? QColor(200, 200, 200) : QColor(255, 255, 255));//Ensure background is always white if the value goes to zero, else gray if var present.
item->setBackgroundColor(0, var ? m_Fractorium->m_VariationTreeBgColorNoneZero : m_Fractorium->m_VariationTreeBgColorZero);
for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params if it was a parametric variation. for (int j = 0; j < item->childCount(); j++)//Iterate through all of the children, which will be the params if it was a parametric variation.
{ {
T* param = nullptr; T* param = nullptr;