Showing the changes to interface/src/ui/Stats.cpp (1 of 3 files). Show all
Unified · Split
| @@ -2,6 +2,7 @@ · 1 unmodified line | ||
| 2 | 2 | // Stats.cpp |
| 3 | 3 | // interface |
| 4 | 4 | // |
| 5 | +// Created by Lucas Crisman on 22/03/14. | |
| 5 | 6 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved |
| 6 | 7 | // |
| 7 | 8 | |
| @@ -38,9 +39,11 @@ Stats::Stats(): · 30 unmodified lines | ||
| 38 | 39 | _generalStatsWidth(STATS_GENERAL_MIN_WIDTH), |
| 39 | 40 | _pingStatsWidth(STATS_PING_MIN_WIDTH), |
| 40 | 41 | _geoStatsWidth(STATS_GEO_MIN_WIDTH), |
| 41 | − _voxelStatsWidth(STATS_VOXEL_MIN_WIDTH) | |
| 42 | + _voxelStatsWidth(STATS_VOXEL_MIN_WIDTH), | |
| 43 | + _lastHorizontalOffset(0) | |
| 42 | 44 | { |
| 43 | − // no constructor behavior yet, only members initialization | |
| 45 | + QGLWidget* glWidget = Application::getInstance()->getGLWidget(); | |
| 46 | + resetWidth(glWidget->width(), 0); | |
| 44 | 47 | } |
| 45 | 48 | |
| 46 | 49 | void Stats::toggleExpanded() { |
| @@ -75,15 +78,17 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD · 28 unmodified lines | ||
| 75 | 78 | statsX += _generalStatsWidth; |
| 76 | 79 | |
| 77 | 80 | // ping stats click |
| 78 | − lines = _expanded ? 4 : 3; | |
| 79 | − statsHeight = lines * STATS_PELS_PER_LINE + 10; | |
| 80 | − if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { | |
| 81 | − toggleExpanded(); | |
| 82 | − return; | |
| 81 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { | |
| 82 | + lines = _expanded ? 4 : 3; | |
| 83 | + statsHeight = lines * STATS_PELS_PER_LINE + 10; | |
| 84 | + if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { | |
| 85 | + toggleExpanded(); | |
| 86 | + return; | |
| 87 | + } | |
| 88 | + statsX += _pingStatsWidth; | |
| 83 | 89 | } |
| 84 | − statsX += _pingStatsWidth; | |
| 85 | 90 | |
| 86 | − // top-center stats panel click | |
| 91 | + // geo stats panel click | |
| 87 | 92 | lines = _expanded ? 4 : 3; |
| 88 | 93 | statsHeight = lines * STATS_PELS_PER_LINE + 10; |
| 89 | 94 | if (mouseX > statsX && mouseX < statsX + _geoStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { |
| @@ -102,24 +107,32 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD · 12 unmodified lines | ||
| 102 | 107 | } |
| 103 | 108 | } |
| 104 | 109 | |
| 105 | −void Stats::resetWidthOnResizeGL(int width) { | |
| 110 | +void Stats::resetWidth(int width, int horizontalOffset) { | |
| 106 | 111 | QGLWidget* glWidget = Application::getInstance()->getGLWidget(); |
| 107 | − int extraSpace = glWidget->width() | |
| 112 | + int extraSpace = glWidget->width() - horizontalOffset -2 | |
| 108 | 113 | - STATS_GENERAL_MIN_WIDTH |
| 109 | − - STATS_PING_MIN_WIDTH | |
| 114 | + - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0) | |
| 110 | 115 | - STATS_GEO_MIN_WIDTH |
| 111 | − - STATS_VOXEL_MIN_WIDTH | |
| 112 | − - 3; | |
| 116 | + - STATS_VOXEL_MIN_WIDTH; | |
| 117 | + | |
| 118 | + int panels = 4; | |
| 113 | 119 | |
| 114 | 120 | _generalStatsWidth = STATS_GENERAL_MIN_WIDTH; |
| 115 | − _pingStatsWidth = STATS_PING_MIN_WIDTH; | |
| 121 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { | |
| 122 | + _pingStatsWidth = STATS_PING_MIN_WIDTH; | |
| 123 | + } else { | |
| 124 | + _pingStatsWidth = 0; | |
| 125 | + panels = 3; | |
| 126 | + } | |
| 116 | 127 | _geoStatsWidth = STATS_GEO_MIN_WIDTH; |
| 117 | 128 | _voxelStatsWidth = STATS_VOXEL_MIN_WIDTH; |
| 118 | 129 | |
| 119 | − if (extraSpace > 4) { | |
| 120 | − _generalStatsWidth += (int) extraSpace / 4; | |
| 121 | − _pingStatsWidth += (int) extraSpace / 4; | |
| 122 | − _geoStatsWidth += (int) extraSpace / 4; | |
| 130 | + if (extraSpace > panels) { | |
| 131 | + _generalStatsWidth += (int) extraSpace / panels; | |
| 132 | + if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { | |
| 133 | + _pingStatsWidth += (int) extraSpace / panels; | |
| 134 | + } | |
| 135 | + _geoStatsWidth += (int) extraSpace / panels; | |
| 123 | 136 | _voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3); |
| 124 | 137 | } |
| 125 | 138 | } |
| @@ -157,6 +170,11 @@ void Stats::display( · 31 unmodified lines | ||
| 157 | 170 | QLocale locale(QLocale::English); |
| 158 | 171 | std::stringstream voxelStats; |
| 159 | 172 | |
| 173 | + if (_lastHorizontalOffset != horizontalOffset) { | |
| 174 | + resetWidth(glWidget->width(), horizontalOffset); | |
| 175 | + _lastHorizontalOffset = horizontalOffset; | |
| 176 | + } | |
| 177 | + | |
| 160 | 178 | glPointSize(1.0f); |
| 161 | 179 | |
| 162 | 180 | // we need to take one avatar out so we don't include ourselves |
| @@ -307,7 +325,7 @@ void Stats::display( · 144 unmodified lines | ||
| 307 | 325 | |
| 308 | 326 | VoxelSystem* voxels = Application::getInstance()->getVoxels(); |
| 309 | 327 | |
| 310 | − lines = _expanded ? 11 : 3; | |
| 328 | + lines = _expanded ? 12 : 3; | |
| 311 | 329 | drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); |
| 312 | 330 | horizontalOffset += 5; |
| 313 | 331 | |