From 0eec869661181ac8662b8f0cdf873b6403e98af1 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Wed, 20 Mar 2013 17:37:52 -0400 Subject: [PATCH] Converted Clock away from OpenGL --- Source/UI/ControlPanel.cpp | 38 +++++++++++++++++++------------------- Source/UI/ControlPanel.h | 15 +++++++-------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/Source/UI/ControlPanel.cpp b/Source/UI/ControlPanel.cpp index 518bf7570..3a7c0c182 100755 --- a/Source/UI/ControlPanel.cpp +++ b/Source/UI/ControlPanel.cpp @@ -159,10 +159,10 @@ void DiskSpaceMeter::paint(Graphics& g) Clock::Clock() : isRunning(false), isRecording(false) { - // const unsigned char* buffer = reinterpret_cast<const unsigned char*>(BinaryData::cpmono_light_otf); - // size_t bufferSize = BinaryData::cpmono_light_otfSize; - // font = new FTPixmapFont(buffer, bufferSize); + MemoryInputStream mis(BinaryData::cpmonolightserialized, BinaryData::cpmonolightserializedSize, false); + Typeface::Ptr typeface = new CustomTypeface(mis); + clockFont = Font(typeface); totalTime = 0; totalRecordTime = 0; @@ -172,20 +172,14 @@ Clock::~Clock() { } -void Clock::newOpenGLContextCreated() -{ - setUp2DCanvas(); - activateAntiAliasing(); - setClearColor(darkgrey); -} -void Clock::renderOpenGL() +void Clock::paint(Graphics& g) { - glClear(GL_COLOR_BUFFER_BIT); - drawTime(); + g.fillAll(Colour(58,58,58)); + drawTime(g); } -void Clock::drawTime() +void Clock::drawTime(Graphics& g) { if (isRunning) @@ -207,15 +201,17 @@ void Clock::drawTime() if (isRecording) { - glColor4f(1.0, 0.0, 0.0, 1.0); + g.setColour(Colours::red); m = floor(totalRecordTime/60000.0); s = floor((totalRecordTime - m*60000.0)/1000.0); } else { + if (isRunning) - glColor4f(1.0, 1.0, 0.0, 1.0); + g.setColour(Colours::yellow); else - glColor4f(1.0, 1.0, 1.0, 1.0); + g.setColour(Colours::white); + m = floor(totalTime/60000.0); s = floor((totalTime - m*60000.0)/1000.0); } @@ -231,10 +227,14 @@ void Clock::drawTime() timeString += s; timeString += " s"; - glRasterPos2f(8.0/getWidth(),0.75f); + g.setFont(clockFont); + g.setFont(30); + g.drawText(timeString, 0, 0, getWidth(), getHeight(), Justification::left, false); + + // glRasterPos2f(8.0/getWidth(),0.75f); - getFont(cpmono_light)->FaceSize(23); - getFont(cpmono_light)->Render(timeString); + // getFont(cpmono_light)->FaceSize(23); + // getFont(cpmono_light)->Render(timeString); } diff --git a/Source/UI/ControlPanel.h b/Source/UI/ControlPanel.h index a538530de..8b48a7cd0 100755 --- a/Source/UI/ControlPanel.h +++ b/Source/UI/ControlPanel.h @@ -175,18 +175,12 @@ private: */ -class Clock : public OpenGLCanvas +class Clock : public Component { public: Clock(); ~Clock(); - /** Initializes an OpenGL context in which drawing occurs.*/ - void newOpenGLContextCreated(); - - /** Draws the current time.*/ - void renderOpenGL(); - /** Starts the acquisition (yellow) clock.*/ void start(); @@ -202,10 +196,13 @@ class Clock : public OpenGLCanvas /** Sets the cumulative recording time to zero.*/ void resetRecordTime(); + /** Draws the current time.*/ + void paint(Graphics& g); + private: /** Draws the current time.*/ - void drawTime(); + void drawTime(Graphics& g); int64 lastTime; @@ -215,6 +212,8 @@ class Clock : public OpenGLCanvas bool isRunning; bool isRecording; + Font clockFont; + //FTPixmapFont* font; }; -- GitLab