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 | // Stats.cpp | 2 | // Stats.cpp |
| 3 | // interface | 3 | // interface |
| 4 | // | 4 | // |
| 5 | // Created by Lucas Crisman on 22/03/14. | ||
| 5 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved | 6 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved |
| 6 | // | 7 | // |
| 7 | 8 | ||
| @@ -38,9 +39,11 @@ Stats::Stats(): · 30 unmodified lines | |||
| 38 | _generalStatsWidth(STATS_GENERAL_MIN_WIDTH), | 39 | _generalStatsWidth(STATS_GENERAL_MIN_WIDTH), |
| 39 | _pingStatsWidth(STATS_PING_MIN_WIDTH), | 40 | _pingStatsWidth(STATS_PING_MIN_WIDTH), |
| 40 | _geoStatsWidth(STATS_GEO_MIN_WIDTH), | 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 | void Stats::toggleExpanded() { | 49 | void Stats::toggleExpanded() { |
| @@ -75,15 +78,17 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD · 28 unmodified lines | |||
| 75 | statsX += _generalStatsWidth; | 78 | statsX += _generalStatsWidth; |
| 76 | 79 | ||
| 77 | // ping stats click | 80 | // ping stats click |
| 78 | lines = _expanded ? 4 : 3; | 81 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 79 | statsHeight = lines * STATS_PELS_PER_LINE + 10; | 82 | lines = _expanded ? 4 : 3; |
| 80 | if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { | 83 | statsHeight = lines * STATS_PELS_PER_LINE + 10; |
| 81 | toggleExpanded(); | 84 | if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { |
| 82 | return; | 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 | lines = _expanded ? 4 : 3; | 92 | lines = _expanded ? 4 : 3; |
| 88 | statsHeight = lines * STATS_PELS_PER_LINE + 10; | 93 | statsHeight = lines * STATS_PELS_PER_LINE + 10; |
| 89 | if (mouseX > statsX && mouseX < statsX + _geoStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) { | 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 | QGLWidget* glWidget = Application::getInstance()->getGLWidget(); | 111 | QGLWidget* glWidget = Application::getInstance()->getGLWidget(); |
| 107 | int extraSpace = glWidget->width() | 112 | int extraSpace = glWidget->width() - horizontalOffset -2 |
| 108 | - STATS_GENERAL_MIN_WIDTH | 113 | - STATS_GENERAL_MIN_WIDTH |
| 109 | - STATS_PING_MIN_WIDTH | 114 | - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0) |
| 110 | - STATS_GEO_MIN_WIDTH | 115 | - STATS_GEO_MIN_WIDTH |
| 111 | - STATS_VOXEL_MIN_WIDTH | 116 | - STATS_VOXEL_MIN_WIDTH; |
| 112 | - 3; | 117 | |
| 118 | int panels = 4; | ||
| 113 | 119 | ||
| 114 | _generalStatsWidth = STATS_GENERAL_MIN_WIDTH; | 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 | _geoStatsWidth = STATS_GEO_MIN_WIDTH; | 127 | _geoStatsWidth = STATS_GEO_MIN_WIDTH; |
| 117 | _voxelStatsWidth = STATS_VOXEL_MIN_WIDTH; | 128 | _voxelStatsWidth = STATS_VOXEL_MIN_WIDTH; |
| 118 | 129 | ||
| 119 | if (extraSpace > 4) { | 130 | if (extraSpace > panels) { |
| 120 | _generalStatsWidth += (int) extraSpace / 4; | 131 | _generalStatsWidth += (int) extraSpace / panels; |
| 121 | _pingStatsWidth += (int) extraSpace / 4; | 132 | if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) { |
| 122 | _geoStatsWidth += (int) extraSpace / 4; | 133 | _pingStatsWidth += (int) extraSpace / panels; |
| 134 | } | ||
| 135 | _geoStatsWidth += (int) extraSpace / panels; | ||
| 123 | _voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3); | 136 | _voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3); |
| 124 | } | 137 | } |
| 125 | } | 138 | } |
| @@ -157,6 +170,11 @@ void Stats::display( · 31 unmodified lines | |||
| 157 | QLocale locale(QLocale::English); | 170 | QLocale locale(QLocale::English); |
| 158 | std::stringstream voxelStats; | 171 | std::stringstream voxelStats; |
| 159 | 172 | ||
| 173 | if (_lastHorizontalOffset != horizontalOffset) { | ||
| 174 | resetWidth(glWidget->width(), horizontalOffset); | ||
| 175 | _lastHorizontalOffset = horizontalOffset; | ||
| 176 | } | ||
| 177 | |||
| 160 | glPointSize(1.0f); | 178 | glPointSize(1.0f); |
| 161 | 179 | ||
| 162 | // we need to take one avatar out so we don't include ourselves | 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 | VoxelSystem* voxels = Application::getInstance()->getVoxels(); | 326 | VoxelSystem* voxels = Application::getInstance()->getVoxels(); |
| 309 | 327 | ||
| 310 | lines = _expanded ? 11 : 3; | 328 | lines = _expanded ? 12 : 3; |
| 311 | drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); | 329 | drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10); |
| 312 | horizontalOffset += 5; | 330 | horizontalOffset += 5; |
| 313 | 331 | ||