Skip to content
Open
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
34 changes: 34 additions & 0 deletions Box.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "Box.h"

Box::Box()
{
isOpen = false;
}

void Box::setName(string _name)
{
name = _name;
}

void Box::setOpen(bool _val)
{
isOpen = _val;
}

void Box::loadFont(const string &filename, int fontsize)
{
int offset = fontsize / 2;
label.loadFont(filename, fontsize);
}


void Box::drawBox()
{
ofSetColor(color);
ofDrawRectangle(shape);
ofSetColor(ofColor(255, 255, 0));
/*Set Label*/
float xCenter = (shape.width - label.stringWidth(name)) / 2; //offset by leftover spaces
float yOffset = (shape.height / 5) + 3;
label.drawString(name, shape.x + xCenter, shape.y + yOffset);
}
21 changes: 21 additions & 0 deletions Box.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "ofMain.h"
#include <string>

class Box
{
public:
Box();
void drawBox();
void setName(string _name);
void setOpen(bool _val);
void loadFont(const string &filename, int fontsize);

protected:
ofRectangle shape;
ofColor color;
string name;
bool isOpen;
ofTrueTypeFont label;
};

17 changes: 17 additions & 0 deletions ButtonBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "ButtonBox.h"



ButtonBox::ButtonBox()
{
}


ButtonBox::~ButtonBox()
{
}

void ButtonBox::clicked(int x, int y)
{

}
16 changes: 16 additions & 0 deletions ButtonBox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "Box.h"

class ButtonBox
{
public:
ButtonBox();
~ButtonBox();

void clicked(int x, int y);

protected:


};

54 changes: 54 additions & 0 deletions DataBox.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include "DataBox.h"

const float DNULL = 0.01021; //custom null
DataBox::DataBox()
{
isOpen = false;
}

DataBox::~DataBox()
{
}

void DataBox::set(float _x, float _y, float _px, float _py, double data)
{
shape.set(_px, _py, _x, _y);
this->data = data;
color = ofColor(150, 150, 150);
}

double DataBox::getData() {
return data;
}

void DataBox::loadFont(const string &filename, int fontsize)
{
int offset = fontsize / 2;
label.loadFont(filename, fontsize);
dataLabel.loadFont(filename, offset);

}

void DataBox::setData(double data)
{
this->data = data;
}


void DataBox::draw()
{
drawBox();
float xCenter = (shape.width - label.stringWidth(name)) / 2; //offset by leftover spaces
float yOffset = (shape.height / 5) + 3;
/*Set Data Label
Positions are partially hardcoded
FIX!!! */
float newHeight = yOffset;
if (data != DNULL)
{
xCenter = (shape.width - dataLabel.stringWidth(to_string(data))) / 2; //offset by leftover spaces
yOffset = newHeight*2 + (newHeight - label.stringHeight(to_string(data))) / 4;
dataLabel.drawString(to_string(data), shape.x + xCenter, shape.y + yOffset);
}

}
22 changes: 22 additions & 0 deletions DataBox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once
#include "Box.h"


class DataBox: public Box
{
public:
DataBox();
virtual ~DataBox();

void draw();
void set(float _x, float _y, float _px, float _py, double data);
void setData(double data);
double getData();
void loadFont(const string &filename, int fontsize);


private:
double data;
ofTrueTypeFont dataLabel;
};

Binary file added Exo-Light.otf
Binary file not shown.
14 changes: 14 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "ofMain.h"
#include "ofApp.h"


//========================================================================
int main( ){
ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp(new ofApp());

}
Loading