From e427b8d2f46829cc78781f8a3503a5c5fb2a12b1 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Mon, 20 Feb 2012 19:02:28 -0500 Subject: [PATCH] InfoLabel now uses an FTSimpleLayout to draw its text To simplify text alignment, the InfoLabel now uses an FTSimpleLayout object to automatically wrap text within the bounds of the OpenGLCanvas. This will allow a welcome message and simple instructions to be displayed. --- Source/Main.cpp | 2 +- Source/UI/InfoLabel.cpp | 101 ++++++++++++++++++++++++++-------------- Source/UI/InfoLabel.h | 6 ++- 3 files changed, 72 insertions(+), 37 deletions(-) diff --git a/Source/Main.cpp b/Source/Main.cpp index ebe7a1b52..f70d622a9 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -68,7 +68,7 @@ public: {quit();} //============================================================================== - const String getApplicationName() { return "Open Ephys Data Acquisition Software";} + const String getApplicationName() { return "Open Ephys GUI";} const String getApplicationVersion() {return ProjectInfo::versionString;} bool moreThanOneInstanceAllowed() {return true;} void anotherInstanceStarted (const String& commandLine) diff --git a/Source/UI/InfoLabel.cpp b/Source/UI/InfoLabel.cpp index c5721fdf7..776fff649 100644 --- a/Source/UI/InfoLabel.cpp +++ b/Source/UI/InfoLabel.cpp @@ -25,7 +25,12 @@ InfoLabel::InfoLabel() : xBuffer(10), yBuffer(10) { + layout.SetAlignment(FTGL::ALIGN_LEFT); + layout.SetFont(getFont(String("miso-regular"))); + infoString = "Welcome to the Open Ephys GUI!\n \n" + "The GUI is still in the early stages of development, so we expect there to be a lot of bugs.\n \n" + ; } InfoLabel::~InfoLabel() @@ -64,51 +69,76 @@ void InfoLabel::drawLabel() { glViewport(xBuffer, - yBuffer-getScrollAmount(), + getHeight()-getTotalHeight()-yBuffer + getScrollAmount(), getWidth()-2*xBuffer, - jmax(getHeight(),getTotalHeight())-2*yBuffer); + getTotalHeight()); + //jmax(getHeight(),getTotalHeight())-2*yBuffer); - float mult = 1/float(getWidth()); + // float mult = 1/float(getWidth()); - glColor4f(0.5,0.5,0.5,0.6); + // glColor4f(0.5,0.5,0.5,0.6); - glBegin(GL_LINE_STRIP); - glVertex2f(0.1,0); - glVertex2f(0.1,1.0); - glEnd(); + // glBegin(GL_LINE_STRIP); + // glVertex2f(0.1,0); + // glVertex2f(0.1,1.0); + // glEnd(); - glBegin(GL_LINE_STRIP); - glVertex2f(0,0.1); - glVertex2f(1.0,0.1); - glEnd(); + // glBegin(GL_LINE_STRIP); + // glVertex2f(0,0.1); + // glVertex2f(1.0,0.1); + // glEnd(); - glBegin(GL_LINE_STRIP); - glVertex2f(0.9,0); - glVertex2f(0.9,1.0); - glEnd(); + // glBegin(GL_LINE_STRIP); + // glVertex2f(0.9,0); + // glVertex2f(0.9,1.0); + // glEnd(); - glBegin(GL_LINE_STRIP); - glVertex2f(0,0.9); - glVertex2f(1.0,0.9); - glEnd(); + // glBegin(GL_LINE_STRIP); + // glVertex2f(0,0.9); + // glVertex2f(1.0,0.9); + // glEnd(); - glColor4f(0.5,0.5,0.5,0.8); + - getFont(String("miso-regular"))->FaceSize(12.0f); + // getFont(String("miso-regular"))->FaceSize(12.0f); - for (float x = 0.1f; x < 1.0f; x += 0.8f) - { - for (float y = 0.1f; y < 1.0f; y += 0.8f) - { - glRasterPos2f(x+0.005f,y+0.025f); - String s = String("(0."); - s += int(x*10); - s += String(", 0."); - s += int(y*10); - s += String(")"); - getFont(String("miso-regular"))->Render(s); - } - } + // for (float x = 0.1f; x < 1.0f; x += 0.8f) + // { + // for (float y = 0.1f; y < 1.0f; y += 0.8f) + // { + // glRasterPos2f(x+0.005f,y+0.025f); + // String s = String("(0."); + // s += int(x*10); + // s += String(", 0."); + // s += int(y*10); + // s += String(")"); + // getFont(String("miso-regular"))->Render(s); + // } + // } + + // glColor4f(0.9,0.9,0.9,1.0); + + // glRasterPos2f(7.0/float(getWidth()),0.099f); + // getFont(String("miso-bold"))->FaceSize(40.0f); + // getFont(String("miso-bold"))->Render("open ephys gui"); + + // glColor4f(0.3,0.3,0.3,1.0); + + // glRasterPos2f(5.0/float(getWidth()),0.1f); + // getFont(String("miso-bold"))->FaceSize(40.0f); + // getFont(String("miso-bold"))->Render("open ephys gui"); + + glColor4f(0.3,0.3,0.3,1.0); + + glRasterPos2f(15.0/float(getWidth()),0.1f); + getFont(String("miso-regular"))->FaceSize(18.0f); + layout.Render(infoString, -1, FTPoint(), FTGL::RENDER_FRONT); + + // + // + //getFont(String("miso-regular"))->Render("Open Ephys GUI"); + + } void InfoLabel::resized() @@ -116,6 +146,7 @@ void InfoLabel::resized() //std::cout << getWidth() << " " << getHeight() // << std::endl; + layout.SetLineLength(getWidth()-45); canvasWasResized(); diff --git a/Source/UI/InfoLabel.h b/Source/UI/InfoLabel.h index 0069858e5..eab0b3fdb 100644 --- a/Source/UI/InfoLabel.h +++ b/Source/UI/InfoLabel.h @@ -61,8 +61,12 @@ private: void mouseUp(const MouseEvent& e); void mouseWheelMove(const MouseEvent&, float, float); + FTSimpleLayout layout; + String infoString; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (InfoLabel); - + + }; -- GitLab