Stats tweaks: fonts adjustments

This commit is contained in:
Lucas Crisman 2014-03-24 14:57:40 -03:00
parent 5fe59acb87
commit e545c2ac65
3 changed files with 49 additions and 24 deletions

View file

@ -591,7 +591,13 @@ void Application::resizeGL(int width, int height) {
updateProjectionMatrix();
glLoadIdentity();
Stats::getInstance()->resetWidthOnResizeGL(width);
// update Stats width
int horizontalOffset = 0;
if (Menu::getInstance()->isOptionChecked(MenuOption::Mirror)) {
// mirror is enabled, let's set horizontal offset to give stats some margin
horizontalOffset += MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
}
Stats::getInstance()->resetWidth(width, horizontalOffset);
}
void Application::updateProjectionMatrix() {

View file

@ -2,6 +2,7 @@
// Stats.cpp
// interface
//
// Created by Lucas Crisman on 22/03/14.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved
//
@ -38,9 +39,11 @@ Stats::Stats():
_generalStatsWidth(STATS_GENERAL_MIN_WIDTH),
_pingStatsWidth(STATS_PING_MIN_WIDTH),
_geoStatsWidth(STATS_GEO_MIN_WIDTH),
_voxelStatsWidth(STATS_VOXEL_MIN_WIDTH)
_voxelStatsWidth(STATS_VOXEL_MIN_WIDTH),
_lastHorizontalOffset(0)
{
// no constructor behavior yet, only members initialization
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
resetWidth(glWidget->width(), 0);
}
void Stats::toggleExpanded() {
@ -75,15 +78,17 @@ void Stats::checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseD
statsX += _generalStatsWidth;
// ping stats click
lines = _expanded ? 4 : 3;
statsHeight = lines * STATS_PELS_PER_LINE + 10;
if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
toggleExpanded();
return;
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
lines = _expanded ? 4 : 3;
statsHeight = lines * STATS_PELS_PER_LINE + 10;
if (mouseX > statsX && mouseX < statsX + _pingStatsWidth && mouseY > statsY && mouseY < statsY + statsHeight) {
toggleExpanded();
return;
}
statsX += _pingStatsWidth;
}
statsX += _pingStatsWidth;
// top-center stats panel click
// geo stats panel click
lines = _expanded ? 4 : 3;
statsHeight = lines * STATS_PELS_PER_LINE + 10;
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
}
}
void Stats::resetWidthOnResizeGL(int width) {
void Stats::resetWidth(int width, int horizontalOffset) {
QGLWidget* glWidget = Application::getInstance()->getGLWidget();
int extraSpace = glWidget->width()
int extraSpace = glWidget->width() - horizontalOffset -2
- STATS_GENERAL_MIN_WIDTH
- STATS_PING_MIN_WIDTH
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
- STATS_GEO_MIN_WIDTH
- STATS_VOXEL_MIN_WIDTH
- 3;
- STATS_VOXEL_MIN_WIDTH;
int panels = 4;
_generalStatsWidth = STATS_GENERAL_MIN_WIDTH;
_pingStatsWidth = STATS_PING_MIN_WIDTH;
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
_pingStatsWidth = STATS_PING_MIN_WIDTH;
} else {
_pingStatsWidth = 0;
panels = 3;
}
_geoStatsWidth = STATS_GEO_MIN_WIDTH;
_voxelStatsWidth = STATS_VOXEL_MIN_WIDTH;
if (extraSpace > 4) {
_generalStatsWidth += (int) extraSpace / 4;
_pingStatsWidth += (int) extraSpace / 4;
_geoStatsWidth += (int) extraSpace / 4;
if (extraSpace > panels) {
_generalStatsWidth += (int) extraSpace / panels;
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
_pingStatsWidth += (int) extraSpace / panels;
}
_geoStatsWidth += (int) extraSpace / panels;
_voxelStatsWidth += glWidget->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
}
}
@ -157,6 +170,11 @@ void Stats::display(
QLocale locale(QLocale::English);
std::stringstream voxelStats;
if (_lastHorizontalOffset != horizontalOffset) {
resetWidth(glWidget->width(), horizontalOffset);
_lastHorizontalOffset = horizontalOffset;
}
glPointSize(1.0f);
// we need to take one avatar out so we don't include ourselves
@ -307,7 +325,7 @@ void Stats::display(
VoxelSystem* voxels = Application::getInstance()->getVoxels();
lines = _expanded ? 11 : 3;
lines = _expanded ? 12 : 3;
drawBackground(backgroundColor, horizontalOffset, 0, glWidget->width() - horizontalOffset, lines * STATS_PELS_PER_LINE + 10);
horizontalOffset += 5;

View file

@ -2,6 +2,7 @@
// Stats.h
// interface
//
// Created by Lucas Crisman on 22/03/14.
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
//
@ -9,8 +10,6 @@
#include <NodeList.h>
//#include "Menu.h"
class Stats: public QObject {
Q_OBJECT
@ -23,7 +22,7 @@ public:
void toggleExpanded();
void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset);
void resetWidthOnResizeGL(int width);
void resetWidth(int width, int horizontalOffset);
void display(const float* color, int horizontalOffset, float fps, int packetsPerSecond, int bytesPerSecond, int voxelPacketsToProcess);
private:
static Stats* _sharedInstance;
@ -37,4 +36,6 @@ private:
int _pingStatsWidth;
int _geoStatsWidth;
int _voxelStatsWidth;
int _lastHorizontalOffset;
};