From 8b2d5c96976af5df97d288612888ae9991c083f1 Mon Sep 17 00:00:00 2001 From: luyuju151 Date: Sun, 8 Jul 2018 23:46:23 +0800 Subject: [PATCH] Make variation tree background colors themable. --- Source/Fractorium/Fractorium.cpp | 6 +++++- Source/Fractorium/Fractorium.h | 10 ++++++++-- Source/Fractorium/FractoriumXformsVariations.cpp | 16 ++++++++-------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Source/Fractorium/Fractorium.cpp b/Source/Fractorium/Fractorium.cpp index e32d3e5..efb7282 100644 --- a/Source/Fractorium/Fractorium.cpp +++ b/Source/Fractorium/Fractorium.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "Fractorium.h" #include "QssDialog.h" @@ -89,6 +89,10 @@ Fractorium::Fractorium(QWidget* p) pixmap.fill(m_XformComboColors[i]); m_XformComboIcons[i] = QIcon(pixmap); } + + //Set Default VariationTreeBgColor + m_VariationTreeBgColorNoneZero=QColor(200,200,200); + m_VariationTreeBgColorZero=QColor(255,255,255); QPixmap pixmap(iconSize_, iconSize_); pixmap.fill(m_FinalXformComboColor); diff --git a/Source/Fractorium/Fractorium.h b/Source/Fractorium/Fractorium.h index 8874628..ad92d21 100644 --- a/Source/Fractorium/Fractorium.h +++ b/Source/Fractorium/Fractorium.h @@ -1,4 +1,4 @@ -#pragma once +#pragma once #include "ui_Fractorium.h" #include "FractoriumCommon.h" @@ -63,7 +63,9 @@ template class FinalRenderEmberController; class Fractorium : public QMainWindow { Q_OBJECT - + Q_PROPERTY(QColor VariationTreeBgColorNoneZero MEMBER m_VariationTreeBgColorNoneZero) + Q_PROPERTY(QColor VariationTreeBgColorZero MEMBER m_VariationTreeBgColorZero) + friend GLWidget; friend QssDialog; friend LibraryTreeWidget; @@ -559,6 +561,7 @@ private: char m_CoordinateString[128]; QColor m_XformComboColors[XFORM_COLOR_COUNT], m_FinalXformComboColor; QIcon m_XformComboIcons[XFORM_COLOR_COUNT], m_FinalXformComboIcon; + QColor m_VariationTreeBgColorNoneZero, m_VariationTreeBgColorZero; vector m_Docks; int m_FontSize; @@ -569,4 +572,7 @@ private: shared_ptr m_Info; unique_ptr m_Controller; Ui::FractoriumClass ui; + + + }; diff --git a/Source/Fractorium/FractoriumXformsVariations.cpp b/Source/Fractorium/FractoriumXformsVariations.cpp index bcc9621..77b609e 100644 --- a/Source/Fractorium/FractoriumXformsVariations.cpp +++ b/Source/Fractorium/FractoriumXformsVariations.cpp @@ -1,4 +1,4 @@ -#include "FractoriumPch.h" +#include "FractoriumPch.h" #include "Fractorium.h" /// @@ -226,8 +226,8 @@ void FractoriumEmberController::VariationSpinBoxValueChanged(double d)//Would if (xformVar) 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 { 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::VariationSpinBoxValueChanged(double d)//Would auto newVar = var->Copy();//Create a new one with default values. newVar->m_Weight = d; 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 //for the child parameters and assign them to the newly added variation. if (parVar) @@ -300,9 +300,9 @@ void FractoriumEmberController::FillVariationTreeWithXform(Xform* xform) item->setHidden(false); 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 ? 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 ? 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 ? 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. { T* param = nullptr;