From 59188f8ceb81f63c47bfa8124b97cf4889403108 Mon Sep 17 00:00:00 2001 From: Pablo Alvarez Lopez Date: Thu, 28 Nov 2024 12:00:29 +0100 Subject: [PATCH] Updated coloring of GNEAttributeRows. Refs #15776 --- src/netedit/frames/GNEAttributeRow.cpp | 36 ++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/netedit/frames/GNEAttributeRow.cpp b/src/netedit/frames/GNEAttributeRow.cpp index 3d0b4b530df..a253857a8e9 100644 --- a/src/netedit/frames/GNEAttributeRow.cpp +++ b/src/netedit/frames/GNEAttributeRow.cpp @@ -55,6 +55,16 @@ FXDEFMAP(GNEAttributeRow) GNEAttributeRowMap[] = { // Object implementation FXIMPLEMENT(GNEAttributeRow, FXHorizontalFrame, GNEAttributeRowMap, ARRAYNUMBER(GNEAttributeRowMap)) +// =========================================================================== +// defines +// =========================================================================== + +#define TEXTBLACK FXRGB(0, 0, 0) +#define TEXTBLUE FXRGB(0, 0, 255) +#define TEXTRED FXRGB(255, 0, 0) +#define BACKGROUND_RED FXRGBA(255, 213, 213, 255) +#define BACKGROUND_WHITE FXRGB(255, 255, 255) + // =========================================================================== // method definitions // =========================================================================== @@ -212,15 +222,13 @@ GNEAttributeRow::isAttributeRowShown() const { bool GNEAttributeRow::isCurrentValueValid() const { - const auto blackColor = FXRGB(0, 0, 0); - const auto blueColor = FXRGB(0, 0, 255); if (myValueCheckButton->shown()) { // check box have always a valid Value return true; } else if (myValueTextField->shown()) { - return ((myValueTextField->getTextColor() == blackColor) || (myValueTextField->getTextColor() == blueColor)); + return ((myValueTextField->getTextColor() == TEXTBLACK) || (myValueTextField->getTextColor() == TEXTBLUE)); } else if (myValueComboBox->shown()) { - return ((myValueComboBox->getTextColor() == blackColor) || (myValueComboBox->getTextColor() == blueColor)); + return ((myValueComboBox->getTextColor() == TEXTBLACK) || (myValueComboBox->getTextColor() == TEXTBLUE)); } else { return false; } @@ -305,12 +313,13 @@ GNEAttributeRow::onCmdSetAttribute(FXObject* obj, FXSelector, void*) { // check if the new comboBox value is valid if (editedAC->isValid(myAttribute, newValue)) { myAttributeTable->setAttribute(myAttribute, newValue); - myValueComboBox->setTextColor(FXRGB(0, 0, 0)); + myValueComboBox->setTextColor(TEXTBLACK); + myValueComboBox->setBackColor(BACKGROUND_WHITE); } else { // edit colors - myValueComboBox->setTextColor(FXRGB(255, 0, 0)); + myValueComboBox->setTextColor(TEXTRED); if (newValue.empty()) { - myValueComboBox->setBackColor(FXRGBA(255, 213, 213, 255)); + myValueComboBox->setBackColor(BACKGROUND_RED); } // Write Warning in console if we're in testing mode WRITE_DEBUG(TLF("ComboBox value '%' for attribute % of % isn't valid", newValue, attrProperties.getAttrStr(), attrProperties.getTagPropertyParent().getTagStr())); @@ -348,12 +357,12 @@ GNEAttributeRow::onCmdSetAttribute(FXObject* obj, FXSelector, void*) { // check if the new textField value is valid if (editedAC->isValid(myAttribute, newValue)) { myAttributeTable->setAttribute(myAttribute, newValue); - myValueTextField->setTextColor(FXRGB(0, 0, 0)); + myValueTextField->setTextColor(TEXTBLACK); } else { // edit colors - myValueTextField->setTextColor(FXRGB(255, 0, 0)); + myValueTextField->setTextColor(TEXTRED); if (newValue.empty()) { - myValueTextField->setBackColor(FXRGBA(255, 213, 213, 255)); + myValueTextField->setBackColor(BACKGROUND_RED); } // Write Warning in console if we're in testing mode WRITE_DEBUG(TLF("TextField value '%' for attribute % of % isn't valid", newValue, attrProperties.getAttrStr(), attrProperties.getTagPropertyParent().getTagStr())); @@ -556,7 +565,8 @@ GNEAttributeRow::showValueComboBox(const GNEAttributeProperties& attrProperty, c if (allValuesEqual) { // clear and enable comboBox myValueComboBox->clearItems(); - myValueComboBox->setTextColor(FXRGB(0, 0, 0)); + myValueComboBox->setTextColor(TEXTBLACK); + myValueComboBox->setBackColor(BACKGROUND_WHITE); if (enabled) { myValueComboBox->enable(); } else { @@ -643,9 +653,9 @@ GNEAttributeRow::showValueString(const GNEAttributeProperties& attrProperty, con // clear and enable comboBox myValueTextField->setText(value.c_str()); if (computed) { - myValueTextField->setTextColor(FXRGB(255, 0, 0)); + myValueTextField->setTextColor(TEXTBLUE); } else { - myValueTextField->setTextColor(FXRGB(0, 0, 0)); + myValueTextField->setTextColor(TEXTBLACK); } if (enabled) { myValueTextField->enable();