mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 20:44:14 +02:00
#19171 Code Review changes
This commit is contained in:
parent
eb646ade84
commit
4dbff46234
9 changed files with 221 additions and 227 deletions
|
@ -1,137 +1,133 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include "MenuRow.h"
|
||||
#include "MenuColumn.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
int lineHeight = 30;
|
||||
int menuHeight = 30;
|
||||
int yOffset = 8; // under windows we have 8 vertical pixels offset. In 2D an object with y=8, the object is displayed at y=0
|
||||
// change the value in the other platforms (if required).
|
||||
const int lineHeight = 30;
|
||||
const int menuHeight = 30;
|
||||
const int yOffset = 8; // under windows we have 8 vertical pixels offset. In 2D an object with y=8, the object is displayed at y=0
|
||||
// change the value in the other platforms (if required).
|
||||
|
||||
|
||||
Menu::Menu(){
|
||||
iCurrentColumn = -1;
|
||||
xLeftMouseOver = 0;
|
||||
xRightMouseOver = 0;
|
||||
yTopMouseOver = 0;
|
||||
yBottomMouseOver = 0;
|
||||
Menu::Menu() {
|
||||
currentColumn = -1;
|
||||
leftMouseOver = 0;
|
||||
rightMouseOver = 0;
|
||||
topMouseOver = 0;
|
||||
bottomMouseOver = 0;
|
||||
}
|
||||
|
||||
|
||||
Menu::~Menu(){
|
||||
Menu::~Menu() {
|
||||
columns.clear();
|
||||
}
|
||||
|
||||
void Menu::mouseClickColumn(int iColumnIndex) {
|
||||
if (iCurrentColumn == iColumnIndex) {
|
||||
iCurrentColumn = -1;
|
||||
if (currentColumn == iColumnIndex) {
|
||||
currentColumn = -1;
|
||||
} else {
|
||||
iCurrentColumn = iColumnIndex;
|
||||
currentColumn = iColumnIndex;
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::setMouseOver(int xLeft, int xRight, int yTop, int yBottom) {
|
||||
xLeftMouseOver = xLeft;
|
||||
xRightMouseOver = xRight;
|
||||
yTopMouseOver = yTop;
|
||||
yBottomMouseOver = yBottom;
|
||||
void Menu::setMouseOver(int leftPosition, int rightPosition, int yTop, int yBottom) {
|
||||
leftMouseOver = leftPosition;
|
||||
rightMouseOver = rightPosition;
|
||||
topMouseOver = yTop;
|
||||
bottomMouseOver = yBottom;
|
||||
}
|
||||
|
||||
void Menu::renderMouseOver() {
|
||||
if (xLeftMouseOver != 0 || yTopMouseOver != 0 || xRightMouseOver != 0 ||& yBottomMouseOver != 0){
|
||||
glColor4f(0,0,0,0.1);
|
||||
if (leftMouseOver != 0 || topMouseOver != 0 || rightMouseOver != 0 ||& bottomMouseOver != 0) {
|
||||
glColor4f(0, 0, 0, 0.1);
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(xLeftMouseOver, yOffset + yTopMouseOver);
|
||||
glVertex2f(xRightMouseOver, yOffset + yTopMouseOver);
|
||||
glVertex2f(xRightMouseOver, yOffset + yBottomMouseOver);
|
||||
glVertex2f(xLeftMouseOver , yOffset + yBottomMouseOver);
|
||||
glVertex2f(leftMouseOver, yOffset + topMouseOver);
|
||||
glVertex2f(rightMouseOver, yOffset + topMouseOver);
|
||||
glVertex2f(rightMouseOver, yOffset + bottomMouseOver);
|
||||
glVertex2f(leftMouseOver, yOffset + bottomMouseOver);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
bool Menu::mouseClick(int x, int y) {
|
||||
int xLeft = 0.5 * SPACE_BETWEEN_COLUMNS;
|
||||
int xRight;
|
||||
int columnWidth;
|
||||
bool bRet = false;
|
||||
for (unsigned int i = 0; i < columns.size(); ++i)
|
||||
{
|
||||
int leftPosition = 0.5 * SPACE_BETWEEN_COLUMNS;
|
||||
int rightPosition = 0;
|
||||
int columnWidth = 0;
|
||||
bool menuFound = false;
|
||||
for (unsigned int i = 0; i < columns.size(); ++i) {
|
||||
columnWidth = columns[i].getWidth();
|
||||
xRight = xLeft + columnWidth + 1.5 * SPACE_BETWEEN_COLUMNS;
|
||||
if (x > xLeft && x < xRight && y > 0 && y < menuHeight){
|
||||
rightPosition = leftPosition + columnWidth + 1.5 * SPACE_BETWEEN_COLUMNS;
|
||||
if (x > leftPosition && x < rightPosition && y > 0 && y < menuHeight) {
|
||||
mouseClickColumn(i);
|
||||
bRet = true;
|
||||
menuFound = true;
|
||||
break;
|
||||
}
|
||||
if (iCurrentColumn == i) {
|
||||
bRet = columns[i].mouseClick(x, y, xLeft, menuHeight, lineHeight);
|
||||
if (bRet) {
|
||||
iCurrentColumn = -1;
|
||||
} else if (currentColumn == i) {
|
||||
menuFound = columns[i].mouseClick(x, y, leftPosition, menuHeight, lineHeight);
|
||||
if (menuFound) {
|
||||
currentColumn = -1;
|
||||
}
|
||||
}
|
||||
xLeft = xRight;
|
||||
leftPosition = rightPosition;
|
||||
}
|
||||
return bRet;
|
||||
return menuFound;
|
||||
}
|
||||
|
||||
bool Menu::mouseOver(int x, int y) {
|
||||
int xLeft = 0.5 * SPACE_BETWEEN_COLUMNS;
|
||||
int xRight;
|
||||
int leftPosition = 0.5 * SPACE_BETWEEN_COLUMNS;
|
||||
int rightPosition;
|
||||
int columnWidth;
|
||||
bool bRet = false;
|
||||
for (unsigned int i = 0; i < columns.size(); ++i)
|
||||
{
|
||||
bool overMenu = false;
|
||||
for (unsigned int i = 0; i < columns.size(); ++i) {
|
||||
columnWidth = columns[i].getWidth();
|
||||
xRight = xLeft + columnWidth + SPACE_BETWEEN_COLUMNS;
|
||||
if (x > xLeft && x < xRight && y > 0 && y < menuHeight){
|
||||
printf("Mouse Over: %d %d", x, y);
|
||||
|
||||
setMouseOver(xLeft, xRight, 0, menuHeight);
|
||||
bRet = true;
|
||||
if (iCurrentColumn >= 0) {
|
||||
columns[iCurrentColumn].setMouseOver(0, 0, 0, 0);
|
||||
iCurrentColumn = i;
|
||||
rightPosition = leftPosition + columnWidth + SPACE_BETWEEN_COLUMNS;
|
||||
if (x > leftPosition && x < rightPosition && y > 0 && y < menuHeight) {
|
||||
setMouseOver(leftPosition, rightPosition, 0, menuHeight);
|
||||
overMenu = true;
|
||||
if (currentColumn >= 0) {
|
||||
columns[currentColumn].setMouseOver(0, 0, 0, 0);
|
||||
currentColumn = i;
|
||||
}
|
||||
break;
|
||||
} else if (iCurrentColumn == i) {
|
||||
columns[i].mouseOver(x, y, xLeft, menuHeight, lineHeight);
|
||||
} else if (currentColumn == i) {
|
||||
columns[i].mouseOver(x, y, leftPosition, menuHeight, lineHeight);
|
||||
}
|
||||
xLeft = xRight;
|
||||
leftPosition = rightPosition;
|
||||
}
|
||||
if (!bRet) {
|
||||
if (!overMenu) {
|
||||
setMouseOver(0, 0, 0, 0);
|
||||
}
|
||||
return bRet;
|
||||
return overMenu;
|
||||
}
|
||||
|
||||
void Menu::render(int screenwidth, int screenheight) {
|
||||
void Menu::render(int screenWidth, int screenHeight) {
|
||||
float scale = 0.10;
|
||||
int mono = 0;
|
||||
glColor3f(0.9,0.9,0.9);
|
||||
int width = screenwidth;
|
||||
int height = screenheight;
|
||||
glColor3f(0.9, 0.9, 0.9);
|
||||
int width = screenWidth;
|
||||
int height = screenHeight;
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(0, yOffset);
|
||||
glVertex2f(width, yOffset);
|
||||
glVertex2f( width, menuHeight + yOffset);
|
||||
glVertex2f(width, menuHeight + yOffset);
|
||||
glVertex2f(0 , menuHeight + yOffset);
|
||||
}
|
||||
glEnd();
|
||||
int x = SPACE_BETWEEN_COLUMNS;
|
||||
char * columnName;
|
||||
int xPosition = SPACE_BETWEEN_COLUMNS;
|
||||
char* columnName;
|
||||
int columnWidth;
|
||||
for (unsigned int i = 0; i < columns.size(); ++i)
|
||||
{
|
||||
for (unsigned int i = 0; i < columns.size(); ++i) {
|
||||
columnName = columns[i].getName();
|
||||
columnWidth = columns[i].getWidth(scale, mono, x- 0.5 * SPACE_BETWEEN_COLUMNS);
|
||||
drawtext(x,18 + yOffset, scale, 0, 1.0, mono, columnName, 0, 0, 0);
|
||||
x += columnWidth + SPACE_BETWEEN_COLUMNS;
|
||||
if (iCurrentColumn == i) {
|
||||
columnWidth = columns[i].getWidth(scale, mono, xPosition - 0.5 * SPACE_BETWEEN_COLUMNS);
|
||||
drawtext(xPosition, 18 + yOffset, scale, 0, 1.0, mono, columnName, 0, 0, 0);
|
||||
xPosition += columnWidth + SPACE_BETWEEN_COLUMNS;
|
||||
if (currentColumn == i) {
|
||||
columns[i].render(yOffset, menuHeight, lineHeight);
|
||||
}
|
||||
}
|
||||
|
@ -140,9 +136,9 @@ void Menu::render(int screenwidth, int screenheight) {
|
|||
|
||||
|
||||
MenuColumn* Menu::addColumn(char *columnName) {
|
||||
MenuColumn * pColumn;
|
||||
MenuColumn* pColumn;
|
||||
pColumn = new MenuColumn(columnName);
|
||||
columns.push_back(*pColumn);
|
||||
delete pColumn;
|
||||
return &columns[columns.size()-1];
|
||||
return &columns[columns.size() - 1];
|
||||
}
|
|
@ -1,30 +1,31 @@
|
|||
#ifndef __hifi__Menu__
|
||||
#define __hifi__Menu__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#define MAX_COLUMN_NAME 50
|
||||
#define SPACE_BETWEEN_COLUMNS 20
|
||||
#define SPACE_BEFORE_ROW_NAME 10
|
||||
typedef int(CALLBACK * PFNRowCallback)(int);
|
||||
|
||||
|
||||
|
||||
class Menu {
|
||||
public:
|
||||
Menu();
|
||||
~Menu();
|
||||
void mouseClickColumn(int iColumnIndex);
|
||||
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
|
||||
void renderMouseOver();
|
||||
bool mouseClick(int x, int y);
|
||||
bool mouseOver(int x, int y);
|
||||
void render(int screenwidth, int screenheight);
|
||||
void renderColumn(int i);
|
||||
MenuColumn* addColumn(char *columnName);
|
||||
public:
|
||||
Menu();
|
||||
~Menu();
|
||||
void mouseClickColumn(int iColumnIndex);
|
||||
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
|
||||
void renderMouseOver();
|
||||
bool mouseClick(int x, int y);
|
||||
bool mouseOver(int x, int y);
|
||||
void render(int screenwidth, int screenheight);
|
||||
void renderColumn(int i);
|
||||
MenuColumn* addColumn(char *columnName);
|
||||
private:
|
||||
std::vector<MenuColumn> columns;
|
||||
int iCurrentColumn;
|
||||
int xLeftMouseOver;
|
||||
int xRightMouseOver;
|
||||
int yTopMouseOver;
|
||||
int yBottomMouseOver;
|
||||
};
|
||||
int currentColumn;
|
||||
int leftMouseOver;
|
||||
int rightMouseOver;
|
||||
int topMouseOver;
|
||||
int bottomMouseOver;
|
||||
};
|
||||
#endif /* defined(__hifi__Menu__) */
|
||||
|
|
|
@ -1,78 +1,79 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include "MenuRow.h"
|
||||
#include "MenuColumn.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
|
||||
MenuColumn::MenuColumn()
|
||||
{
|
||||
MenuColumn::MenuColumn() {
|
||||
}
|
||||
MenuColumn::MenuColumn(char * columnName)
|
||||
{
|
||||
|
||||
MenuColumn::MenuColumn(char * columnName) {
|
||||
int length = std::min(MAX_COLUMN_NAME - 1,(int) strlen(columnName));
|
||||
strncpy(this->columnName, columnName, length);
|
||||
this->columnName[length] = '\0';
|
||||
columnWidth = 0;
|
||||
leftPosition = 0;
|
||||
xLeftMouseOver = 0;
|
||||
xRightMouseOver = 0;
|
||||
yTopMouseOver = 0;
|
||||
yBottomMouseOver = 0;
|
||||
leftMouseOver = 0;
|
||||
rightMouseOver = 0;
|
||||
topMouseOver = 0;
|
||||
bottomMouseOver = 0;
|
||||
}
|
||||
|
||||
MenuColumn::~MenuColumn()
|
||||
{
|
||||
MenuColumn::~MenuColumn() {
|
||||
rows.clear();
|
||||
}
|
||||
|
||||
void MenuColumn::mouseClickRow(int iRowIndex) {
|
||||
rows[iRowIndex].call();
|
||||
void MenuColumn::mouseClickRow(int numberOfRowsIndex) {
|
||||
rows[numberOfRowsIndex].call();
|
||||
}
|
||||
|
||||
bool MenuColumn::mouseClick(int x, int y, int xLeft, int menuHeight, int lineHeight) {
|
||||
int xRight = xLeft + 200;
|
||||
int yTop = menuHeight;
|
||||
int yBottom = menuHeight;
|
||||
int columnWidth;
|
||||
bool MenuColumn::mouseClick(int x, int y, int leftPosition, int menuHeight, int lineHeight) {
|
||||
int rightPosition = leftPosition + 200;
|
||||
int topPosition = menuHeight;
|
||||
int bottomPosition = menuHeight;
|
||||
int columnWidth = 0;
|
||||
bool bRet = false;
|
||||
for (unsigned int i = 0; i < rows.size(); ++i) {
|
||||
columnWidth = rows[i].getWidth();
|
||||
yTop = yBottom + lineHeight;
|
||||
if (x > xLeft && x < xRight && y > yBottom && y < yTop) {
|
||||
topPosition = bottomPosition + lineHeight;
|
||||
if (x > leftPosition && x < rightPosition && y > bottomPosition && y < topPosition) {
|
||||
mouseClickRow(i);
|
||||
bRet = true;
|
||||
break;
|
||||
}
|
||||
yBottom = yTop;
|
||||
bottomPosition = topPosition;
|
||||
}
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void MenuColumn::setMouseOver(int xLeft, int xRight, int yTop, int yBottom) {
|
||||
xLeftMouseOver = xLeft;
|
||||
xRightMouseOver = xRight;
|
||||
yTopMouseOver = yTop;
|
||||
yBottomMouseOver = yBottom;
|
||||
void MenuColumn::setMouseOver(int leftPosition, int rightPosition, int topPosition, int bottomPosition) {
|
||||
leftMouseOver = leftPosition;
|
||||
rightMouseOver = rightPosition;
|
||||
topMouseOver = topPosition;
|
||||
bottomMouseOver = bottomPosition;
|
||||
}
|
||||
|
||||
bool MenuColumn::mouseOver(int x, int y, int xLeft, int menuHeight, int lineHeight) {
|
||||
int xRight = xLeft + 100;
|
||||
int yTop = menuHeight;
|
||||
int yBottom = menuHeight;
|
||||
int columnWidth;
|
||||
bool MenuColumn::mouseOver(int x, int y, int leftPosition, int menuHeight, int lineHeight) {
|
||||
int rightPosition = leftPosition + 100;
|
||||
int topPosition = menuHeight;
|
||||
int bottomPosition = menuHeight;
|
||||
int columnWidth = 0;
|
||||
bool bRet = false;
|
||||
for (unsigned int i = 0; i < rows.size(); ++i) {
|
||||
columnWidth = rows[i].getWidth();
|
||||
yTop = yBottom + lineHeight ;
|
||||
if (x > xLeft && x < xRight && y > yBottom && y < yTop) {
|
||||
setMouseOver(xLeft, xRight, yBottom, yTop);
|
||||
topPosition = bottomPosition + lineHeight ;
|
||||
if (x > leftPosition && x < rightPosition && y > bottomPosition && y < topPosition) {
|
||||
setMouseOver(leftPosition, rightPosition, bottomPosition, topPosition);
|
||||
bRet = true;
|
||||
break;
|
||||
}
|
||||
yBottom = yTop;
|
||||
bottomPosition = topPosition;
|
||||
}
|
||||
if (!bRet) {
|
||||
setMouseOver(0, 0, 0, 0);
|
||||
|
@ -80,54 +81,52 @@ bool MenuColumn::mouseOver(int x, int y, int xLeft, int menuHeight, int lineHeig
|
|||
return bRet;
|
||||
}
|
||||
|
||||
char * MenuColumn::getName() {
|
||||
char* MenuColumn::getName() {
|
||||
return this->columnName;
|
||||
}
|
||||
|
||||
int MenuColumn::getWidth(float scale, int mono, int leftPosition){
|
||||
int MenuColumn::getWidth(float scale, int mono, int leftPosition) {
|
||||
if (columnWidth == 0) {
|
||||
columnWidth = widthText( scale, mono, this->columnName);
|
||||
columnWidth = widthText(scale, mono, this->columnName);
|
||||
this->leftPosition = leftPosition;
|
||||
}
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
int MenuColumn::getWidth(){
|
||||
int MenuColumn::getWidth() {
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
int MenuColumn::getLeftPosition(){
|
||||
int MenuColumn::getLeftPosition() {
|
||||
return leftPosition;
|
||||
}
|
||||
|
||||
int MenuColumn::addRow(char * rowName, PFNRowCallback callback){
|
||||
MenuRow * pRow;
|
||||
int MenuColumn::addRow(char * rowName, PFNRowCallback callback) {
|
||||
MenuRow* pRow;
|
||||
pRow = new MenuRow(rowName, callback);
|
||||
rows.push_back(*pRow);
|
||||
delete pRow;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void MenuColumn::render(int yOffset, int menuHeight, int lineHeight) {
|
||||
int iRow = rows.size();
|
||||
if (iRow > 0) {
|
||||
int numberOfRows = rows.size();
|
||||
if (numberOfRows > 0) {
|
||||
glColor3f(0.9,0.9,0.9);
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(leftPosition, yOffset + menuHeight);
|
||||
glVertex2f(leftPosition+100, yOffset + menuHeight);
|
||||
glVertex2f(leftPosition+100, yOffset + menuHeight + iRow*lineHeight);
|
||||
glVertex2f(leftPosition , yOffset + menuHeight + iRow* lineHeight);
|
||||
glVertex2f(leftPosition+100, yOffset + menuHeight + numberOfRows*lineHeight);
|
||||
glVertex2f(leftPosition , yOffset + menuHeight + numberOfRows* lineHeight);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
float scale = 0.10;
|
||||
int mono = 0;
|
||||
int y = menuHeight + lineHeight / 2 ;
|
||||
char * rowName;
|
||||
int columnWidth;
|
||||
for (unsigned int i = 0; i < rows.size(); ++i)
|
||||
{
|
||||
char* rowName;
|
||||
int columnWidth = 0;
|
||||
for (unsigned int i = 0; i < rows.size(); ++i) {
|
||||
rowName = rows[i].getName();
|
||||
columnWidth = rows[i].getWidth(scale, mono, 0);
|
||||
drawtext(leftPosition + SPACE_BEFORE_ROW_NAME, y+5 + yOffset, scale, 0, 1.0, mono, rowName, 0, 0, 0);
|
||||
|
@ -137,13 +136,13 @@ void MenuColumn::render(int yOffset, int menuHeight, int lineHeight) {
|
|||
}
|
||||
|
||||
void MenuColumn::renderMouseOver(int yOffset) {
|
||||
if (xLeftMouseOver != 0 || yTopMouseOver != 0 || xRightMouseOver != 0 ||& yBottomMouseOver != 0){
|
||||
if (leftMouseOver != 0 || topMouseOver != 0 || rightMouseOver != 0 ||& bottomMouseOver != 0) {
|
||||
glColor4f(0,0,0,0.1);
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(xLeftMouseOver, yOffset + yTopMouseOver);
|
||||
glVertex2f(xRightMouseOver, yOffset + yTopMouseOver);
|
||||
glVertex2f(xRightMouseOver, yOffset + yBottomMouseOver);
|
||||
glVertex2f(xLeftMouseOver , yOffset + yBottomMouseOver);
|
||||
glVertex2f(leftMouseOver, yOffset + topMouseOver);
|
||||
glVertex2f(rightMouseOver, yOffset + topMouseOver);
|
||||
glVertex2f(rightMouseOver, yOffset + bottomMouseOver);
|
||||
glVertex2f(leftMouseOver , yOffset + bottomMouseOver);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
|
|
@ -1,28 +1,33 @@
|
|||
#ifndef __hifi__MenuColumn__
|
||||
#define __hifi__MenuColumn__
|
||||
#include <vector>
|
||||
|
||||
class MenuColumn {
|
||||
public:
|
||||
MenuColumn();
|
||||
MenuColumn(char * columnName);
|
||||
~MenuColumn();
|
||||
void mouseClickRow(int iColumnIndex);
|
||||
bool mouseClick(int x, int y, int xLeft, int menuHeight, int lineHeight);
|
||||
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
|
||||
bool mouseOver(int x, int y, int xLeft, int menuHeight, int lineHeight);
|
||||
char * getName();
|
||||
int getWidth(float scale, int mono, int leftPosition);
|
||||
int getWidth();
|
||||
int getLeftPosition();
|
||||
void render(int yOffset, int menuHeight, int lineHeight);
|
||||
void MenuColumn::renderMouseOver(int yOffset);
|
||||
int addRow(char * rowName, PFNRowCallback callback);
|
||||
public:
|
||||
MenuColumn();
|
||||
MenuColumn(char * columnName);
|
||||
~MenuColumn();
|
||||
void mouseClickRow(int iColumnIndex);
|
||||
bool mouseClick(int x, int y, int xLeft, int menuHeight, int lineHeight);
|
||||
void setMouseOver(int xLeft, int xRight, int yTop, int yBottom);
|
||||
bool mouseOver(int x, int y, int xLeft, int menuHeight, int lineHeight);
|
||||
char * getName();
|
||||
int getWidth(float scale, int mono, int leftPosition);
|
||||
int getWidth();
|
||||
int getLeftPosition();
|
||||
void render(int yOffset, int menuHeight, int lineHeight);
|
||||
void MenuColumn::renderMouseOver(int yOffset);
|
||||
int addRow(char * rowName, PFNRowCallback callback);
|
||||
private:
|
||||
char columnName[MAX_COLUMN_NAME];
|
||||
int columnWidth;
|
||||
int leftPosition;
|
||||
std::vector<MenuRow> rows;
|
||||
int xLeftMouseOver;
|
||||
int xRightMouseOver;
|
||||
int yTopMouseOver;
|
||||
int yBottomMouseOver;
|
||||
int leftMouseOver;
|
||||
int rightMouseOver;
|
||||
int topMouseOver;
|
||||
int bottomMouseOver;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MenuColumn__) */
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include "InterfaceConfig.h"
|
||||
#include "Util.h"
|
||||
|
||||
#include "MenuRow.h"
|
||||
#include "MenuColumn.h"
|
||||
#include "Menu.h"
|
||||
#include "Util.h"
|
||||
|
||||
|
||||
MenuRow::MenuRow()
|
||||
{
|
||||
MenuRow::MenuRow() {
|
||||
}
|
||||
MenuRow::MenuRow(char * columnName, PFNRowCallback callback)
|
||||
{
|
||||
MenuRow::MenuRow(char * columnName, PFNRowCallback callback) {
|
||||
int length = std::min(MAX_COLUMN_NAME - 5,(int) strlen(columnName));
|
||||
strncpy(this->rowName, columnName, length);
|
||||
memcpy(this->rowName + length, " \0", 5);
|
||||
|
@ -19,15 +19,14 @@ MenuRow::MenuRow(char * columnName, PFNRowCallback callback)
|
|||
rowWidth = 0;
|
||||
}
|
||||
|
||||
MenuRow::~MenuRow()
|
||||
{
|
||||
MenuRow::~MenuRow() {
|
||||
}
|
||||
|
||||
void MenuRow::call() {
|
||||
callback(-2);
|
||||
}
|
||||
|
||||
char * MenuRow::getName() {
|
||||
char* MenuRow::getName() {
|
||||
int length = (int) strlen(this->rowName) - 4;
|
||||
int currentValue = callback(-1);
|
||||
if (currentValue == 0) {
|
||||
|
@ -40,14 +39,14 @@ char * MenuRow::getName() {
|
|||
return this->rowName;
|
||||
}
|
||||
|
||||
int MenuRow::getWidth(float scale, int mono, int leftPosition){
|
||||
int MenuRow::getWidth(float scale, int mono, int leftPosition) {
|
||||
if (rowWidth == 0) {
|
||||
rowWidth = widthText( scale, mono, this->rowName);
|
||||
}
|
||||
return rowWidth;
|
||||
}
|
||||
|
||||
int MenuRow::getWidth(){
|
||||
int MenuRow::getWidth() {
|
||||
return rowWidth;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,27 @@
|
|||
#ifndef __hifi__MenuRow__
|
||||
#define __hifi__MenuRow__
|
||||
|
||||
#include <vector>
|
||||
const int MAX_COLUMN_NAME = 50;
|
||||
const int SPACE_BETWEEN_COLUMNS = 20;
|
||||
const int SPACE_BEFORE_ROW_NAME = 10;
|
||||
|
||||
#define MAX_COLUMN_NAME 50
|
||||
#define SPACE_BETWEEN_COLUMNS 20
|
||||
#define SPACE_BEFORE_ROW_NAME 10
|
||||
typedef int(CALLBACK * PFNRowCallback)(int);
|
||||
#define MenuCallBack CALLBACK
|
||||
|
||||
typedef int(MenuCallBack * PFNRowCallback)(int);
|
||||
|
||||
class MenuRow {
|
||||
public:
|
||||
MenuRow();
|
||||
MenuRow(char * rowName, PFNRowCallback);
|
||||
~MenuRow();
|
||||
void call();
|
||||
char * getName();
|
||||
int getWidth(float scale, int mono, int leftPosition);
|
||||
int getWidth();
|
||||
public:
|
||||
MenuRow();
|
||||
MenuRow(char * rowName, PFNRowCallback);
|
||||
~MenuRow();
|
||||
void call();
|
||||
char * getName();
|
||||
int getWidth(float scale, int mono, int leftPosition);
|
||||
int getWidth();
|
||||
private:
|
||||
char rowName[MAX_COLUMN_NAME];
|
||||
int rowWidth;
|
||||
PFNRowCallback callback;
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__MenuRow__) */
|
||||
|
|
|
@ -93,10 +93,9 @@ double diffclock(timeval *clock1,timeval *clock2)
|
|||
int widthText(float scale, int mono, char *string) {
|
||||
int width = 0;
|
||||
if (!mono) {
|
||||
width =scale * glutStrokeLength(GLUT_STROKE_ROMAN, (const unsigned char *) string);
|
||||
}
|
||||
else {
|
||||
width =scale * glutStrokeLength(GLUT_STROKE_MONO_ROMAN, (const unsigned char *) string);
|
||||
width = scale * glutStrokeLength(GLUT_STROKE_ROMAN, (const unsigned char *) string);
|
||||
} else {
|
||||
width = scale * glutStrokeLength(GLUT_STROKE_MONO_ROMAN, (const unsigned char *) string);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ void Timer(int extra)
|
|||
void displayStats(void)
|
||||
{
|
||||
int statsVerticalOffset = 50;
|
||||
if (menuOn == 0) {
|
||||
if (::menuOn == 0) {
|
||||
statsVerticalOffset = 8;
|
||||
}
|
||||
// bitmap chars are about 10 pels high
|
||||
|
@ -840,7 +840,7 @@ void display(void)
|
|||
}
|
||||
|
||||
// Show menu
|
||||
if (menuOn) {
|
||||
if (::menuOn) {
|
||||
glLineWidth(1.0f);
|
||||
glPointSize(1.0f);
|
||||
menu.render(WIDTH,HEIGHT);
|
||||
|
@ -868,7 +868,7 @@ void display(void)
|
|||
frameCount++;
|
||||
}
|
||||
|
||||
int CALLBACK setValue(int state, int *value) {
|
||||
int MenuCallBack setValue(int state, int *value) {
|
||||
if (state == -2) {
|
||||
*value = !(*value);
|
||||
} else if (state == -1) {
|
||||
|
@ -879,36 +879,33 @@ int CALLBACK setValue(int state, int *value) {
|
|||
return *value;
|
||||
}
|
||||
|
||||
int CALLBACK setHead(int state) {
|
||||
int MenuCallBack setHead(int state) {
|
||||
return setValue(state, &displayHead);
|
||||
}
|
||||
|
||||
int CALLBACK setField(int state) {
|
||||
int MenuCallBack setField(int state) {
|
||||
return setValue(state, &displayField);
|
||||
}
|
||||
|
||||
int CALLBACK setNoise(int state) {
|
||||
int MenuCallBack setNoise(int state) {
|
||||
int iRet = setValue(state, &noiseOn);
|
||||
if (noiseOn)
|
||||
{
|
||||
if (noiseOn) {
|
||||
myHead.setNoise(noise);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
myHead.setNoise(0);
|
||||
}
|
||||
return iRet;
|
||||
}
|
||||
|
||||
int CALLBACK setStats(int state) {
|
||||
int MenuCallBack setStats(int state) {
|
||||
return setValue(state, &statsOn);
|
||||
}
|
||||
|
||||
int CALLBACK setMenu(int state) {
|
||||
return setValue(state, &menuOn);
|
||||
int MenuCallBack setMenu(int state) {
|
||||
return setValue(state, &::menuOn);
|
||||
}
|
||||
|
||||
int CALLBACK setMirror(int state) {
|
||||
int MenuCallBack setMirror(int state) {
|
||||
return setValue(state, &headMirror);
|
||||
}
|
||||
|
||||
|
@ -1240,20 +1237,19 @@ void mouseFunc( int button, int state, int x, int y )
|
|||
{
|
||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN )
|
||||
{
|
||||
if (menu.mouseClick(x, y) == false) {
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
mousePressed = 1;
|
||||
lattice.mouseClick((float)x/(float)WIDTH,(float)y/(float)HEIGHT);
|
||||
if (!menu.mouseClick(x, y)) {
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
mousePressed = 1;
|
||||
lattice.mouseClick((float)x/(float)WIDTH, (float)y/(float)HEIGHT);
|
||||
mouseStartX = x;
|
||||
mouseStartY = y;
|
||||
}
|
||||
}
|
||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP )
|
||||
{
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
mousePressed = 0;
|
||||
if( button == GLUT_LEFT_BUTTON && state == GLUT_UP ) {
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
mousePressed = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,11 +19,6 @@
|
|||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#endif
|
||||
|
||||
|
||||
double usecTimestamp(timeval *time) {
|
||||
return (time->tv_sec * 1000000.0 + time->tv_usec);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue