Base: Move App::Color to Base
Every basic data type is stored in Base module, color is standing out as one that does not. Moving it to Base opens possibilities to integrate it better with the rest of FreeCAD.
This commit is contained in:
@@ -467,13 +467,13 @@ bool Cell::getStyle(std::set<std::string>& _style) const
|
||||
*
|
||||
*/
|
||||
|
||||
void Cell::setForeground(const App::Color& color)
|
||||
void Cell::setForeground(const Base::Color& color)
|
||||
{
|
||||
if (color != foregroundColor) {
|
||||
PropertySheet::AtomicPropertyChange signaller(*owner);
|
||||
|
||||
foregroundColor = color;
|
||||
setUsed(FOREGROUND_COLOR_SET, foregroundColor != App::Color(0, 0, 0, 1));
|
||||
setUsed(FOREGROUND_COLOR_SET, foregroundColor != Base::Color(0, 0, 0, 1));
|
||||
setDirty();
|
||||
|
||||
signaller.tryInvoke();
|
||||
@@ -485,7 +485,7 @@ void Cell::setForeground(const App::Color& color)
|
||||
*
|
||||
*/
|
||||
|
||||
bool Cell::getForeground(App::Color& color) const
|
||||
bool Cell::getForeground(Base::Color& color) const
|
||||
{
|
||||
color = foregroundColor;
|
||||
return isUsed(FOREGROUND_COLOR_SET);
|
||||
@@ -496,13 +496,13 @@ bool Cell::getForeground(App::Color& color) const
|
||||
*
|
||||
*/
|
||||
|
||||
void Cell::setBackground(const App::Color& color)
|
||||
void Cell::setBackground(const Base::Color& color)
|
||||
{
|
||||
if (color != backgroundColor) {
|
||||
PropertySheet::AtomicPropertyChange signaller(*owner);
|
||||
|
||||
backgroundColor = color;
|
||||
setUsed(BACKGROUND_COLOR_SET, backgroundColor != App::Color(1, 1, 1, 0));
|
||||
setUsed(BACKGROUND_COLOR_SET, backgroundColor != Base::Color(1, 1, 1, 0));
|
||||
setDirty();
|
||||
|
||||
signaller.tryInvoke();
|
||||
@@ -516,7 +516,7 @@ void Cell::setBackground(const App::Color& color)
|
||||
*
|
||||
*/
|
||||
|
||||
bool Cell::getBackground(App::Color& color) const
|
||||
bool Cell::getBackground(Base::Color& color) const
|
||||
{
|
||||
color = backgroundColor;
|
||||
return isUsed(BACKGROUND_COLOR_SET);
|
||||
@@ -783,12 +783,12 @@ void Cell::restore(Base::XMLReader& reader, bool checkAlias)
|
||||
setAlignment(alignmentCode);
|
||||
}
|
||||
if (foregroundColor) {
|
||||
App::Color color = decodeColor(foregroundColor, App::Color(0, 0, 0, 1));
|
||||
Base::Color color = decodeColor(foregroundColor, Base::Color(0, 0, 0, 1));
|
||||
|
||||
setForeground(color);
|
||||
}
|
||||
if (backgroundColor) {
|
||||
App::Color color = decodeColor(backgroundColor, App::Color(1, 1, 1, 1));
|
||||
Base::Color color = decodeColor(backgroundColor, Base::Color(1, 1, 1, 1));
|
||||
|
||||
setBackground(color);
|
||||
}
|
||||
@@ -1016,7 +1016,7 @@ std::string Cell::encodeAlignment(int alignment)
|
||||
*
|
||||
*/
|
||||
|
||||
std::string Cell::encodeColor(const App::Color& color)
|
||||
std::string Cell::encodeColor(const Base::Color& color)
|
||||
{
|
||||
std::stringstream tmp;
|
||||
|
||||
@@ -1064,10 +1064,10 @@ std::string Cell::encodeStyle(const std::set<std::string>& style)
|
||||
*
|
||||
*/
|
||||
|
||||
App::Color Cell::decodeColor(const std::string& color, const App::Color& defaultColor)
|
||||
Base::Color Cell::decodeColor(const std::string& color, const Base::Color& defaultColor)
|
||||
{
|
||||
if (color.size() == 7 || color.size() == 9) {
|
||||
App::Color c;
|
||||
Base::Color c;
|
||||
|
||||
if (color[0] != '#') {
|
||||
return defaultColor;
|
||||
|
||||
@@ -72,11 +72,11 @@ public:
|
||||
void setStyle(const std::set<std::string>& _style);
|
||||
bool getStyle(std::set<std::string>& style) const;
|
||||
|
||||
void setForeground(const App::Color& color);
|
||||
bool getForeground(App::Color& color) const;
|
||||
void setForeground(const Base::Color& color);
|
||||
bool getForeground(Base::Color& color) const;
|
||||
|
||||
void setBackground(const App::Color& color);
|
||||
bool getBackground(App::Color& color) const;
|
||||
void setBackground(const Base::Color& color);
|
||||
bool getBackground(Base::Color& color) const;
|
||||
|
||||
void setDisplayUnit(const std::string& unit);
|
||||
bool getDisplayUnit(DisplayUnit& unit) const;
|
||||
@@ -161,8 +161,8 @@ public:
|
||||
|
||||
static std::string encodeStyle(const std::set<std::string>& style);
|
||||
|
||||
static std::string encodeColor(const App::Color& color);
|
||||
static App::Color decodeColor(const std::string& color, const App::Color& defaultColor);
|
||||
static std::string encodeColor(const Base::Color& color);
|
||||
static Base::Color decodeColor(const std::string& color, const Base::Color& defaultColor);
|
||||
|
||||
private:
|
||||
void setParseException(const std::string& e);
|
||||
@@ -199,8 +199,8 @@ private:
|
||||
mutable App::ExpressionPtr expression;
|
||||
int alignment;
|
||||
std::set<std::string> style;
|
||||
App::Color foregroundColor;
|
||||
App::Color backgroundColor;
|
||||
Base::Color foregroundColor;
|
||||
Base::Color backgroundColor;
|
||||
DisplayUnit displayUnit;
|
||||
std::string alias;
|
||||
Base::Unit computedUnit;
|
||||
|
||||
@@ -720,14 +720,14 @@ void PropertySheet::setStyle(CellAddress address, const std::set<std::string>& _
|
||||
cell->setStyle(_style);
|
||||
}
|
||||
|
||||
void PropertySheet::setForeground(CellAddress address, const App::Color& color)
|
||||
void PropertySheet::setForeground(CellAddress address, const Base::Color& color)
|
||||
{
|
||||
Cell* cell = nonNullCellAt(address);
|
||||
assert(cell);
|
||||
cell->setForeground(color);
|
||||
}
|
||||
|
||||
void PropertySheet::setBackground(CellAddress address, const App::Color& color)
|
||||
void PropertySheet::setBackground(CellAddress address, const Base::Color& color)
|
||||
{
|
||||
Cell* cell = nonNullCellAt(address);
|
||||
assert(cell);
|
||||
|
||||
@@ -98,9 +98,9 @@ public:
|
||||
|
||||
void setStyle(App::CellAddress address, const std::set<std::string>& _style);
|
||||
|
||||
void setForeground(App::CellAddress address, const App::Color& color);
|
||||
void setForeground(App::CellAddress address, const Base::Color& color);
|
||||
|
||||
void setBackground(App::CellAddress address, const App::Color& color);
|
||||
void setBackground(App::CellAddress address, const Base::Color& color);
|
||||
|
||||
void setDisplayUnit(App::CellAddress address, const std::string& unit);
|
||||
|
||||
|
||||
@@ -154,9 +154,9 @@ public:
|
||||
|
||||
void setStyle(App::CellAddress address, const std::set<std::string>& style);
|
||||
|
||||
void setForeground(App::CellAddress address, const App::Color& color);
|
||||
void setForeground(App::CellAddress address, const Base::Color& color);
|
||||
|
||||
void setBackground(App::CellAddress address, const App::Color& color);
|
||||
void setBackground(App::CellAddress address, const Base::Color& color);
|
||||
|
||||
void setDisplayUnit(App::CellAddress address, const std::string& unit);
|
||||
|
||||
|
||||
@@ -794,7 +794,7 @@ static float decodeFloat(const PyObject* obj)
|
||||
throw Base::TypeError("Float or integer expected");
|
||||
}
|
||||
|
||||
static void decodeColor(PyObject* value, Color& c)
|
||||
static void decodeColor(PyObject* value, Base::Color& c)
|
||||
{
|
||||
if (PyTuple_Check(value)) {
|
||||
if (PyTuple_Size(value) < 3 || PyTuple_Size(value) > 4) {
|
||||
@@ -822,7 +822,7 @@ PyObject* SheetPy::setForeground(PyObject* args)
|
||||
try {
|
||||
const char* range;
|
||||
PyObject* value;
|
||||
Color c;
|
||||
Base::Color c;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:setForeground", &range, &value)) {
|
||||
return nullptr;
|
||||
@@ -863,7 +863,7 @@ PyObject* SheetPy::getForeground(PyObject* args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Color c;
|
||||
Base::Color c;
|
||||
const Cell* cell = getSheetPtr()->getCell(address);
|
||||
if (cell && cell->getForeground(c)) {
|
||||
PyObject* t = PyTuple_New(4);
|
||||
@@ -886,7 +886,7 @@ PyObject* SheetPy::setBackground(PyObject* args)
|
||||
try {
|
||||
const char* strAddress;
|
||||
PyObject* value;
|
||||
Color c;
|
||||
Base::Color c;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO:setBackground", &strAddress, &value)) {
|
||||
return nullptr;
|
||||
@@ -927,7 +927,7 @@ PyObject* SheetPy::getBackground(PyObject* args)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Color c;
|
||||
Base::Color c;
|
||||
const Cell* cell = getSheetPtr()->getCell(address);
|
||||
if (cell && cell->getBackground(c)) {
|
||||
PyObject* t = PyTuple_New(4);
|
||||
|
||||
Reference in New Issue
Block a user