Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions include/FontSettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef FONT_SETTINGS_H
#define FONT_SETTINGS_H

struct FontDimensions {
int height;
int width;

constexpr FontDimensions(int h, int w) : height(h), width(w) {}
};

inline constexpr FontDimensions getFontDimensions(int fontSetting) {
switch (fontSetting) {
case 0: return {10, 6};
case 1: return {12, 8};
case 2: return {20, 11};
default: return {10, 2};
}
}

#endif
2 changes: 1 addition & 1 deletion include/ced_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
#define CED_BGCOLOR_OPTION1_NAME "Gainsboro"
#define CED_BGCOLOR_OPTION1_COLORCODE 0.862745,0.862745,0.862745,0

#define CED_BGCOLOR_OPTION2_NAME "Lightgrey"
#define CED_BGCOLOR_OPTION2_NAME "Lightgray"
#define CED_BGCOLOR_OPTION2_COLORCODE 0.827451,0.827451,0.827451,0

#define CED_BGCOLOR_OPTION3_NAME "Darkgray"
Expand Down
92 changes: 19 additions & 73 deletions include/ced_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ USED BY:
****************************************************************/
#ifndef __CED_MENU
#define __CED_MENU

#include <FontSettings.h>

using namespace std;
extern CEDsettings setting;
extern GLfloat window_width;
Expand Down Expand Up @@ -85,21 +88,10 @@ class CED_SubSubMenu{
title=new_title;
}
void draw(){
int height=10;
int width=2;
if(setting.font==0){
height=10;
width=6;
}
if(setting.font==1){
height=12;
width=8;
}
if(setting.font==2){
height=20;
width=11;
}

FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;
int width = dim.width;

if(isExtend || isMouseOver){
isAktive=true;
Expand Down Expand Up @@ -274,20 +266,8 @@ class CED_SubSubMenu{


void addItem(CED_SubSubMenu *subsub){
int height=10;
// int width=6;
if(setting.font==0){
height=10;
// width=6;
}
if(setting.font==1){
height=12;
// width=8;
}
if(setting.font==2){
height=20;
// width=11;
}
FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;

subsub->x_start=x_start;
subsub->x_end =x_start+50; //TODO
Expand Down Expand Up @@ -340,21 +320,10 @@ class CED_SubMenu{
title=new_title;
}
void draw(){
int height=10;
int width=6;
if(setting.font==0){
height=10;
width=6;
}
if(setting.font==1){
height=12;
width=8;
}
if(setting.font==2){
height=20;
width=11;
}

FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;
int width = dim.width;

if(isExtend || isMouseOver){
glColor4f(0.662745,0.662745,0.662745,1);
Expand Down Expand Up @@ -537,17 +506,8 @@ class CED_Menu{

glColor4f(0.827451,0.827451,0.827451,1);

int height=10;
if(setting.font==0){
height=10;
}
if(setting.font==1){
height=12;
}
if(setting.font==2){
height=20;
}

FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;


glBegin(GL_QUADS);
Expand Down Expand Up @@ -613,21 +573,19 @@ class CED_Menu{
}

void addSubMenu(CED_SubMenu *sub){
FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;

double length=10;
int height=10;
if(setting.font==0){
length=4.8;
height=10;
}
if(setting.font==1){
length=5.2;
height=12;
}
if(setting.font==2){
length=10.0;
height=20;
}
//cout << "length: " << length << endl;

sub->x_start=x_offset;
sub->y_start=1;
Expand Down Expand Up @@ -658,21 +616,9 @@ class CED_PopUpMenu{
title=new_title;
}
void draw(){
int height=10;
int width=6;
if(setting.font==0){
height=10;
width=6;
}
if(setting.font==1){
height=12;
width=8;
}
if(setting.font==2){
height=20;
width=11;
}

FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;
int width = dim.width;

unsigned maxlength=title.length();
for(unsigned i=0u; i<subsubMenus.size();i++){
Expand Down
27 changes: 9 additions & 18 deletions src/server/glced.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@
#include <sstream>
#include <iomanip>

#include <FontSettings.h>

static GLfloat window_width=0.;
static GLfloat window_height=0.;

Expand Down Expand Up @@ -564,20 +566,10 @@ void printShortcuts(void){
const unsigned int MAX_STR_LEN=30;
int i;

int height=10;
int width=2;
if(setting.font==0){
height=10+2;
width=6;
}
if(setting.font==1){
height=12+2;
width=8;
}
if(setting.font==2){
height=20+2;
width=11;
}
FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;
int width = dim.width;
height += 2;


//float line = 12; //height of one line
Expand Down Expand Up @@ -3627,18 +3619,17 @@ void buildPopUpMenu(int x, int y){

}

int height=10;
FontDimensions dim = getFontDimensions(setting.font);
int height = dim.height;

int width=200;
if(setting.font==0){
height=10;
width=150;
}
if(setting.font==1){
height=12;
width=200;
}
if(setting.font==2){
height=20;
width=300;
}

Expand Down