Skip to content

Commit

Permalink
fixes to logger and file lister for font size, flag for removing from…
Browse files Browse the repository at this point in the history
… horizontal arrangement (lets elements span two columns), fix for button slider
  • Loading branch information
ofTheo committed Apr 2, 2010
1 parent ec2627b commit bdfe742
Show file tree
Hide file tree
Showing 38 changed files with 220 additions and 63 deletions.
Binary file added bin/data/images/of_logos/DSC09302.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09305.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09307.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09310.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09311.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09315.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09316.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09318.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09320.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09322.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09324.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09326.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09327.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09329.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09330.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09334.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09336.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09337.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09341.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09343.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09344.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/data/images/of_logos/DSC09347.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified currentScreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/ofxControlPanel/guiBaseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ guiColor gOutlineColor;
bool initialColorsLoaded = false;

guiBaseObject::guiBaseObject(){
readOnly = false;
bShowText = true;
locked = false;
dataType = SG_TYPE_FLOAT;
readOnly = false;
bShowText = true;
locked = false;
bRemoveFromLayout = false;
dataType = SG_TYPE_FLOAT;

numDecimalPlaces = 2;
storedTextWidth = 0;
Expand Down
1 change: 1 addition & 0 deletions src/ofxControlPanel/guiBaseObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ class guiBaseObject{

//bool isRelative;
bool locked;
bool bRemoveFromLayout;

float storedTextWidth;
float titleSpacing;
Expand Down
3 changes: 3 additions & 0 deletions src/ofxControlPanel/guiIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,8 @@
#include "guiTypeVideo.h"
#include "guiTypeVairableLister.h"
#include "guiTypeChartPlotter.h"
#include "guiTypeLogger.h"
#include "guiTypeFileLister.h"



16 changes: 8 additions & 8 deletions src/ofxControlPanel/guiTypeButtonSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,23 @@ void guiTypeButtonSlider::update(){
//-----------------------------------------------.
void guiTypeButtonSlider::updateGui(float x, float y, bool firstHit, bool isRelative){


if(state != SG_STATE_SELECTED)return;

if(this->readOnly) return;

if( isInsideRect(x, y, slider->hitArea))
{
if( firstHit ){
if( isInsideRect(x, y, slider->hitArea) ){
slider->state = SG_STATE_SELECTED;
slider->setSelected();
slider->updateGui(x,y,firstHit,isRelative);
prevMouse.set(x, y);
}
}else{
slider->state = SG_STATE_SELECTED;
slider->setSelected();
slider->updateGui(x,y,firstHit,isRelative);
prevMouse.set(x, y);
}
else
if ((slider->state == SG_STATE_SELECTED) && (!firstHit&&isRelative))
{
slider->updateGui(x,y,firstHit,isRelative);
}

if( isInsideRect(x, y, leftButton->hitArea) ){
if(!firstHit) return;
Expand Down
48 changes: 27 additions & 21 deletions src/ofxControlPanel/guiTypeFileLister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@


//TODO: fix this!
static int lineSpacing = 18;
static int dblClickTime = 500;


//TODO: fix bitmap type specific code

//------------------------------------------------
guiTypeFileLister::guiTypeFileLister(){
lister = NULL;
pct = 0;
sliderWidth = 20;
selectPct = -1;
selection = -1;
selectionTmp = -1;
startPos = 0;
endPos = 0;
usingSlider = false;
lister = NULL;
pct = 0;
sliderWidth = 20;
selectPct = -1;
selection = -1;
selectionTmp = -1;
startPos = 0;
endPos = 0;
usingSlider = false;

lineSpacing = 12;
dblClickTime = 500;
}

//------------------------------------------------
Expand All @@ -33,7 +35,7 @@ void guiTypeFileLister::setup(string listerName, simpleFileLister * listerPtr ,
//-----------------------------------------------
void guiTypeFileLister::notify(){
guiCallbackData cbVal;
cbVal.setup(xmlName);
cbVal.setup(name);
cbVal.addString(lister->getSelectedPath());
cbVal.addString(lister->getSelectedName());
ofNotifyEvent(guiEvent,cbVal,this);
Expand Down Expand Up @@ -80,43 +82,47 @@ void guiTypeFileLister::release(){
void guiTypeFileLister::drawRecords(float x, float y, float width, float height){
if( lister == NULL)return;
if( lister->entries.size() == 0)return;


float textW = MAX(5, displayText.stringWidth("abcdefg")/7.0);
float textH = MAX(lineSpacing, displayText.getTextSingleLineHeight() + 2);
lineSpacing = textH;

ofPushStyle();
float yPos = lineSpacing;
float yPos = textH;
startPos = (float)(lister->entries.size()-1) * (pct);
endPos = 0;

int numCanFit = (height / lineSpacing)- 1;
int numCanFit = (height / textH)- 1;
endPos = startPos + numCanFit;
endPos = MIN(lister->entries.size(), endPos);

for(int i = startPos; i < endPos; i++){

string str = lister->entries[i].filename;
if( str.length() * 8 > width ){
int newLen = (float)width / 8;
//newLen = ofClamp(newLen, 1, 999999);
if( str.length() * textW > width ){
int newLen = (float)width / textW;

str = str.substr(0, newLen);
}

if( i == selection ){
ofPushStyle();
ofFill();
glColor4fv( fgColor.getSelectedColorF() );
ofRect(x, y+yPos+4, width-5, -lineSpacing);
ofRect(x, y+yPos+4, width-5, -textH);
ofPopStyle();
}else if( i == selectionTmp){
ofPushStyle();
ofNoFill();
glColor4fv(outlineColor.getColorF());
ofRect(x, y+yPos+4, width-2, -lineSpacing);
ofRect(x, y+yPos+4, width-2, -textH);
ofPopStyle();
}

glColor4fv(textColor.getColorF());

displayText.renderString(str, x, y + yPos);
yPos += lineSpacing;
yPos += textH;
//if(yPos+lineSpacing >= height)break;
}
ofPopStyle();
Expand Down
3 changes: 3 additions & 0 deletions src/ofxControlPanel/guiTypeFileLister.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class guiTypeFileLister : public guiBaseObject{
void render();

void notify();

int lineSpacing;
int dblClickTime;

int selection;
int selectionTmp;
Expand Down
53 changes: 45 additions & 8 deletions src/ofxControlPanel/guiTypeLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ void guiTypeLogger::setup(string loggerName, simpleLogger * logger, float logger
log = logger;
name = loggerName;
updateText();

toggle = 2;

setDimensions(loggerWidth, loggerHeight);
hitArea.width = 20;
Expand All @@ -22,28 +24,44 @@ void guiTypeLogger::updateGui(float x, float y, bool firstHit, bool isRelative){
pct = ( y - ( hitArea.y ) ) / hitArea.height;
pct = ofClamp(pct, 0, 1);
}

if( firstHit && x >= boundingBox.x + boundingBox.width-20 && y > boundingBox.y && y<= boundingBox.y + 20 ){
toggle++;
if( toggle > 3 ){
toggle = 0;
}
}
}

//-----------------------------------------------.
void guiTypeLogger::drawRecords(float x, float y, float width, float height){
if( log == NULL)return;
if( log->logs.size() == 0)return;


float textH = MAX(8, displayText.getTextSingleLineHeight() + 2);
float charW = MAX(4, displayText.stringWidth("abcdefg")/7.0);

ofPushStyle();
float yPos = 13;
float yPos = textH;
int startPos = (float)(log->logs.size()-1) * (1.0-pct);
for(int i = startPos; i >= 0; i--){
string str = log->logs[i].logStr;
if( str.length() * 8> width ){
int newLen = (float)width / 8;
//newLen = ofClamp(newLen, 1, 999999);

string str;

if( toggle == 0 ) str = log->logs[i].logStr;
else if( toggle == 1 ) str = log->logs[i].timeStr + log->logs[i].levelStr + log->logs[i].msg;
else if( toggle == 2 ) str = log->logs[i].levelStr + log->logs[i].msg;
else if( toggle == 3 ) str = log->logs[i].msg;

if( str.length() * charW > width ){
int newLen = (float)width / charW;
str = str.substr(0, newLen);
}

displayText.renderString(str, x, y + yPos);

yPos += 13.6;
if(yPos +14 >= height)break;
yPos += textH;
if(yPos+textH >= height)break;
}
ofPopStyle();
}
Expand All @@ -57,6 +75,25 @@ void guiTypeLogger::render(){
ofFill();
glColor4fv(bgColor.getColorF());
ofRect(boundingBox.x, boundingBox.y, boundingBox.width, boundingBox.height);

float xx = boundingBox.x + boundingBox.width - 20;
float yy = boundingBox.y;

ofFill();
for(int i = 0; i < 4; i++){

if( toggle == 0 || i >= toggle ){
glColor4fv(fgColor.getSelectedColorF());
ofFill();
ofRect(xx, yy, 5, 10);
}

glColor4fv(outlineColor.getColorF());
ofNoFill();
ofRect(xx, yy, 5, 10);

xx += 5;
}

glColor4fv(textColor.getColorF());
guiBaseObject::renderText();
Expand Down
1 change: 1 addition & 0 deletions src/ofxControlPanel/guiTypeLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class guiTypeLogger : public guiBaseObject{
void drawRecords(float x, float y, float width, float height);
void render();

int toggle;
float pct;
simpleLogger * log;
};
7 changes: 4 additions & 3 deletions src/ofxControlPanel/guiTypePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void guiTypePanel::update(){
if( children[i]->boundingBox.x != columns[whichColumn[i]].x ){
float amntToShiftX = columns[whichColumn[i]].x - children[i]->boundingBox.x;

children[i]->hitArea.x += amntToShiftX;
children[i]->hitArea.x += amntToShiftX;
children[i]->boundingBox.x += amntToShiftX;
}
}
Expand All @@ -136,18 +136,19 @@ void guiTypePanel::addElement( guiBaseObject * element ){
columns[col].y += element->getHeight() + spacingAmntY;

float checkWidth = element->getWidth();
if(checkWidth >= columns[col].width ){

if(checkWidth >= columns[col].width && !element->bRemoveFromLayout ){
float amnt = checkWidth - columns[col].width;
columns[col].width += amnt;

for(unsigned int i = col+1; i < columns.size(); i++){
columns[i].x += amnt;
}

}

//see if we need to resize!
//checkResize(element);

}

//-----------------------------------------------.
Expand Down
Loading

0 comments on commit bdfe742

Please sign in to comment.