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
22 // Stats.cpp
33 // interface
44 //
5+// Created by Lucas Crisman on 22/03/14.
56 // Copyright (c) 2013 High Fidelity, Inc. All rights reserved
67 //
78
@@ -38,9 +39,11 @@ Stats::Stats(): · 30 unmodified lines
3839 _generalStatsWidth(STATS_GENERAL_MIN_WIDTH),
3940 _pingStatsWidth(STATS_PING_MIN_WIDTH),
4041 _geoStatsWidth(STATS_GEO_MIN_WIDTH),
41− _voxelStatsWidth(STATS_VOXEL_MIN_WIDTH)
42+ _voxelStatsWidth(STATS_VOXEL_MIN_WIDTH),
43+ _lastHorizontalOffset(0)
4244 {
43− // no constructor behavior yet, only members initialization
45+ QGLWidget* glWidget = Application::getInstance()->getGLWidget();
46+ resetWidth(glWidget->width(), 0);
4447 }
4548
4649 void Stats::toggleExpanded() {
@@ -75,15 +78,17 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD · 28 unmodified lines
7578 statsX += _generalStatsWidth;
7679
7780 // 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;
8389 }
84− statsX += _pingStatsWidth;
8590
86− // top-center stats panel click
91+ // geo stats panel click
8792 lines = _expanded ? 4 : 3;
8893 statsHeight = lines * STATS_PELS_PER_LINE + 10;
8994 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
102107 }
103108 }
104109
105−void Stats::resetWidthOnResizeGL(int width) {
110+void Stats::resetWidth(int width, int horizontalOffset) {
106111 QGLWidget* glWidget = Application::getInstance()->getGLWidget();
107− int extraSpace = glWidget->width()
112+ int extraSpace = glWidget->width() - horizontalOffset -2
108113 - STATS_GENERAL_MIN_WIDTH
109− - STATS_PING_MIN_WIDTH
114+ - (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
110115 - STATS_GEO_MIN_WIDTH
111− - STATS_VOXEL_MIN_WIDTH
112− - 3;
116+ - STATS_VOXEL_MIN_WIDTH;
117+
118+ int panels = 4;
113119
114120 _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+ }
116127 _geoStatsWidth = STATS_GEO_MIN_WIDTH;
117128 _voxelStatsWidth = STATS_VOXEL_MIN_WIDTH;
118129
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;
123136 _voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
124137 }
125138 }
@@ -157,6 +170,11 @@ void Stats::display( · 31 unmodified lines
157170 QLocale locale(QLocale::English);
158171 std::stringstream voxelStats;
159172
173+ if (_lastHorizontalOffset != horizontalOffset) {
174+ resetWidth(glWidget->width(), horizontalOffset);
175+ _lastHorizontalOffset = horizontalOffset;
176+ }
177+
160178 glPointSize(1.0f);
161179
162180 // we need to take one avatar out so we don't include ourselves
@@ -307,7 +325,7 @@ void Stats::display( · 144 unmodified lines
307325
308326 VoxelSystem* voxels = Application::getInstance()->getVoxels();
309327
310− lines = _expanded ? 11 : 3;
328+ lines = _expanded ? 12 : 3;
311329 drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
312330 horizontalOffset += 5;
313331

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