Showing the changes to interface/src/BandwidthMeter.cpp (1 of 1 file). Show all
Unified · Split
| @@ -13,7 +13,7 @@ · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | namespace { // .cpp-local | 14 | namespace { // .cpp-local |
| 15 | 15 | ||
| 16 | int const AREA_WIDTH = -400; // Width of the area used. Aligned to the right when negative. | 16 | int const AREA_WIDTH = -280; // Width of the area used. Aligned to the right when negative. |
| 17 | int const AREA_HEIGHT = 40; // Height of the area used. Aligned to the bottom when negative. | 17 | int const AREA_HEIGHT = 40; // Height of the area used. Aligned to the bottom when negative. |
| 18 | int const BORDER_DISTANCE_HORIZ = -20; // Distance to edge of screen (use negative value when width is negative). | 18 | int const BORDER_DISTANCE_HORIZ = -20; // Distance to edge of screen (use negative value when width is negative). |
| 19 | int const BORDER_DISTANCE_VERT = 40; // Distance to edge of screen (use negative value when height is negative). | 19 | int const BORDER_DISTANCE_VERT = 40; // Distance to edge of screen (use negative value when height is negative). |
| @@ -33,6 +33,8 @@ namespace { // .cpp-local · 13 unmodified lines | |||
| 33 | 33 | ||
| 34 | double const UNIT_SCALE = 8000.0 / (1024.0 * 1024.0); // Bytes/ms -> Mbps | 34 | double const UNIT_SCALE = 8000.0 / (1024.0 * 1024.0); // Bytes/ms -> Mbps |
| 35 | int const INITIAL_SCALE_MAXIMUM_INDEX = 250; // / 9: exponent, % 9: mantissa - 2, 0 o--o 2 * 10^-10 | 35 | int const INITIAL_SCALE_MAXIMUM_INDEX = 250; // / 9: exponent, % 9: mantissa - 2, 0 o--o 2 * 10^-10 |
| 36 | int const MIN_METER_SCALE = 10; // 10Mbps | ||
| 37 | int const NUMBER_OF_MARKERS = 10; | ||
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = { | 40 | BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = { |
| @@ -182,7 +184,7 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { · 143 unmodified lines | |||
| 182 | break; | 184 | break; |
| 183 | } | 185 | } |
| 184 | if (totalMax < scaleMax * 0.5) { | 186 | if (totalMax < scaleMax * 0.5) { |
| 185 | _scaleMaxIndex = glm::max(0, _scaleMaxIndex-1); | 187 | _scaleMaxIndex = glm::max(0, _scaleMaxIndex - 1); |
| 186 | commit = true; | 188 | commit = true; |
| 187 | } else if (totalMax > scaleMax) { | 189 | } else if (totalMax > scaleMax) { |
| 188 | _scaleMaxIndex += 1; | 190 | _scaleMaxIndex += 1; |
| @@ -190,10 +192,15 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { · 1 unmodified line | |||
| 190 | } | 192 | } |
| 191 | } while (commit); | 193 | } while (commit); |
| 192 | 194 | ||
| 195 | step = scaleMax / NUMBER_OF_MARKERS; | ||
| 196 | if (scaleMax < MIN_METER_SCALE) { | ||
| 197 | scaleMax = MIN_METER_SCALE; | ||
| 198 | } | ||
| 199 | |||
| 193 | // Render scale indicators | 200 | // Render scale indicators |
| 194 | setColorRGBA(COLOR_INDICATOR); | 201 | setColorRGBA(COLOR_INDICATOR); |
| 195 | for (int j = int((scaleMax + step - 0.000001) / step); --j > 0;) { | 202 | for (int j = NUMBER_OF_MARKERS; --j > 0;) { |
| 196 | renderVerticalLine(int(barWidth * j * step / scaleMax), 0, h); | 203 | renderVerticalLine(int(barWidth * j / NUMBER_OF_MARKERS), 0, h); |
| 197 | } | 204 | } |
| 198 | 205 | ||
| 199 | // Render bars | 206 | // Render bars |
| @@ -220,11 +227,11 @@ void BandwidthMeter::render(int screenWidth, int screenHeight) { · 20 unmodified lines | |||
| 220 | // Render numbers | 227 | // Render numbers |
| 221 | char fmtBuf[8]; | 228 | char fmtBuf[8]; |
| 222 | setColorRGBA(COLOR_TEXT); | 229 | setColorRGBA(COLOR_TEXT); |
| 223 | sprintf(fmtBuf, "%0.2f", totalIn); | 230 | sprintf(fmtBuf, "%0.1f", totalIn); |
| 224 | _textRenderer.draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, | 231 | _textRenderer.draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, |
| 225 | PADDING_HORIZ_VALUE), | 232 | PADDING_HORIZ_VALUE), |
| 226 | textYupperLine, fmtBuf); | 233 | textYupperLine, fmtBuf); |
| 227 | sprintf(fmtBuf, "%0.2f", totalOut); | 234 | sprintf(fmtBuf, "%0.1f", totalOut); |
| 228 | _textRenderer.draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, | 235 | _textRenderer.draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE, |
| 229 | PADDING_HORIZ_VALUE), | 236 | PADDING_HORIZ_VALUE), |
| 230 | textYlowerLine, fmtBuf); | 237 | textYlowerLine, fmtBuf); |