Skip to content
Snippets Groups Projects
Commit 0eec8696 authored by jsiegle's avatar jsiegle
Browse files

Converted Clock away from OpenGL

parent 13185897
Branches
Tags
No related merge requests found
......@@ -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);
}
......
......@@ -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;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment