Skip to content

Commit

Permalink
Updated coloring of GNEAttributeRows. Refs #15776
Browse files Browse the repository at this point in the history
  • Loading branch information
palvarezlopez committed Nov 28, 2024
1 parent 0abfbc5 commit 59188f8
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions src/netedit/frames/GNEAttributeRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ===========================================================================
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 59188f8

Please sign in to comment.