Text fields added

- With UI sliders to adjust various visual elements
- Text is hardcoded currently
This commit is contained in:
James Alliban
2014-01-08 17:31:33 +00:00
parent 33298f7bcb
commit e2523e0b72
23 changed files with 307 additions and 12 deletions
+24 -1
View File
@@ -21,6 +21,7 @@ void GUI::setup()
addBarGraphDesignGUI();
addGraphSimulationGUI();
addBackgroundGUI();
addHUDTextGUI();
addVariousGUI();
setGUIColour();
@@ -106,7 +107,7 @@ void GUI::addBackgroundGUI()
gui->addSlider("Blue", 0, 2, &app->scene.blue, length, dim);
gui->addSlider("Alpha", 0, 2, &app->scene.alpha, length, dim);
gui->addSpacer(length, 1);
gui->addLabel("HUD SETTINGS");
gui->addLabel("HUD BACKGROUND SETTINGS");
gui->addSlider("Red .", 0, 255, &app->scene.hudColour[0], length, dim);
gui->addSlider("Green .", 0, 255, &app->scene.hudColour[1], length, dim);
gui->addSlider("Blue .", 0, 255, &app->scene.hudColour[2], length, dim);
@@ -120,6 +121,28 @@ void GUI::addBackgroundGUI()
}
void GUI::addHUDTextGUI()
{
string title = "HUD TEXT";
ofxUICanvas* gui = getNewGUI(title);
gui->addSlider("X Margin", 0, 500, &app->scene.xMargin, length, dim);
gui->addSlider("Y Margin", 0, 500, &app->scene.yMargin, length, dim);
gui->addSlider("Y Margin Bottom Offset", 0, 300, &app->scene.yMarginBottomOffset, length, dim);
gui->addSlider("Line Length", 50, 500, &app->scene.lineLength, length, dim);
gui->addSlider("Line Spacing", 0, 10, &app->scene.lineSpacing, length, dim);
gui->addSlider("Text Size", 10, 100, &app->scene.textSize, length, dim);
gui->addSpacer(length, 1);
gui->addSlider("Red", 0, 255, &app->scene.textColour[0], length, dim);
gui->addSlider("Green", 0, 255, &app->scene.textColour[1], length, dim);
gui->addSlider("Blue", 0, 255, &app->scene.textColour[2], length, dim);
gui->addSlider("Alpha", 0, 255, &app->scene.textColour[3], length, dim);
ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent);
finaliseCanvas(gui, true);
}
void GUI::addVariousGUI()
{
string title = "VARIOUS";
+1
View File
@@ -24,6 +24,7 @@ public:
void addBarGraphDesignGUI();
void addGraphSimulationGUI();
void addBackgroundGUI();
void addHUDTextGUI();
void addVariousGUI();
void variousGUIEvent(ofxUIEventArgs &e);
+3
View File
@@ -32,6 +32,7 @@ void testApp::setup()
ofSetWindowPosition(0, 100);
ofEnableSmoothing();
ofSeedRandom(ofRandom(23243));
ofSetFullscreen(true);
dataManager.setup();
scene.setup();
@@ -70,6 +71,8 @@ void testApp::keyPressed(int key)
isPaused = !isPaused;
else if (key == 'f')
ofToggleFullscreen();
scene.keyPressed(key);
}
+70 -2
View File
@@ -14,12 +14,26 @@ void Scene::setup()
bgImg.loadImage("images/tanks.jpg");
rgbShader.load("shaders/RGBShader");
barGraph.setup();
text.loadFont("fonts/mplus-1c-regular.ttf", 8);
//text.setLineLength(ofGetWidth() - margin * 2);
xMargin = 500;
yMargin = 400;
lineLength = 200;
}
void Scene::update()
{
barGraph.update();
text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing);
text.setSize(textSize);
}
@@ -27,7 +41,8 @@ void Scene::draw()
{
drawVideo();
barGraph.draw();
drawHUD();
drawHUDBG();
drawHUDCopy();
}
void Scene::drawVideo()
@@ -47,7 +62,7 @@ void Scene::drawVideo()
rgbShader.end();
}
void Scene::drawHUD()
void Scene::drawHUDBG()
{
ofPushStyle();
ofSetColor(hudColour[0], hudColour[1], hudColour[2], hudColour[3]);
@@ -71,4 +86,57 @@ void Scene::drawHUD()
ofPopStyle();
ofFill();
}
void Scene::drawHUDCopy()
{
string tlStr = "TOP LEFT\nThis is some text\nthis is some more text\na little more";
drawTextBox(tlStr, "TOP LEFT");
string trStr = "TOP RIGHT\nThis is some text\nthis is some more text\na little more\none more line";
drawTextBox(trStr, "TOP RIGHT");
string blStr = "BOTTOM LEFT\nThis is some text\nthis is some more text";
drawTextBox(blStr, "BOTTOM LEFT");
string brStr = "BOTTOM RIGHT\nThis is some text\nthis is some more text\na little more";
drawTextBox(brStr, "BOTTOM RIGHT");
}
void Scene::drawTextBox(string copy, string align)
{
ofPushStyle();
ofSetColor(textColour[0], textColour[1], textColour[2], textColour[3]);
ofPushMatrix();
if (align == "TOP LEFT")
{
ofTranslate(xMargin, yMargin);
text.setAlignment(FTGL_ALIGN_LEFT);
}
else if (align == "TOP RIGHT")
{
text.setAlignment(FTGL_ALIGN_RIGHT);
ofTranslate(ofGetWidth() - xMargin - lineLength, yMargin);
}
else if (align == "BOTTOM LEFT")
{
ofTranslate(xMargin, ofGetHeight() - yMargin - yMarginBottomOffset);
text.setAlignment(FTGL_ALIGN_LEFT);
}
if (align == "BOTTOM RIGHT")
{
text.setAlignment(FTGL_ALIGN_RIGHT);
ofTranslate(ofGetWidth() - xMargin - lineLength, ofGetHeight() - yMargin - yMarginBottomOffset);
}
text.drawString(copy, 0, 0);
ofPopMatrix();
ofPopStyle();
}
void Scene::keyPressed(int key)
{
}
+27 -3
View File
@@ -10,6 +10,7 @@
#include "ofMain.h"
#include "BarGraph.h"
#include "ofxFTGL.h"
class testApp;
@@ -20,16 +21,39 @@ public:
void update();
void draw();
void drawVideo();
void drawHUD();
void drawHUDBG();
void drawHUDCopy();
void drawTextBox(string copy, string align);
void keyPressed(int key);
BarGraph barGraph;
ofShader rgbShader;
ofImage bgImg;
ofxFTGLSimpleLayout text;
// video image vars
float brightness;
float contrast;
float saturation;
float red;
float green;
float blue;
float alpha;
float brightness, contrast, saturation, red, green, blue, alpha;
// HUD background vars
float hudColour[4];
float circlePointSize;
float radiusW;
float radiusH;
// text vars
float xMargin;
float yMargin;
float yMarginBottomOffset;
float lineLength;
float lineSpacing;
float textSize;
float textColour[4];
};