History

Stats tweaks: fonts adjustments

Lucas Crisman committed 12 years ago

Commit e545c2a1 parent 5fe59ac3 files · +49 −24Browse files

Showing the changes to interface/src/ui/Stats.cpp (1 of 3 files). Show all

Unified · Split

interface/src/ui/Stats.cpp+38−20
@@ -2,6 +2,7 @@ · 1 unmodified line
2// Stats.cpp2// Stats.cpp
3// interface3// interface
4//4//
5// Created by Lucas Crisman on 22/03/14.
5// Copyright (c) 2013 High Fidelity, Inc. All rights reserved6// 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 initialization45 QGLWidget* glWidget = Application::getInstance()->getGLWidget();
46 resetWidth(glWidget->width(), 0);
44}47}
45 48
46void Stats::toggleExpanded() {49void 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 click80 // 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 click91 // 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
105void Stats::resetWidthOnResizeGL(int width) {110void 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_WIDTH113 - STATS_GENERAL_MIN_WIDTH
109 - STATS_PING_MIN_WIDTH114 - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
110 - STATS_GEO_MIN_WIDTH115 - STATS_GEO_MIN_WIDTH
111 - STATS_VOXEL_MIN_WIDTH116 - 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 ourselves180 // 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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t