Skip to content

Commit

Permalink
Support "Display zero as blank" option for OutputNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmiklos committed Jan 17, 2025
1 parent 9430daf commit 4e7322c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/OutputNumberComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ void OutputNumberComponent::paint(Graphics &g)
}
}

if (get_option(isobus::OutputNumber::Options::DisplayZeroAsBlank) && scaledValue == 0)
{
// When this option bit is set, a blank field is displayed if and only if the displayed value of the object is exactly zero.
return;
}

std::ostringstream valueText;
valueText << std::fixed << std::setprecision(get_number_of_decimals()) << scaledValue;
g.drawText(valueText.str(), 0, 0, get_width(), get_height(), convert_justification(get_horizontal_justification(), get_vertical_justification()), false);
Expand Down

0 comments on commit 4e7322c

Please sign in to comment.