Skip to content
Snippets Groups Projects
Commit 9ae142aa authored by jsiegle's avatar jsiegle
Browse files

Simplify MessageCenter animation code

parent b3247944
No related branches found
No related tags found
No related merge requests found
...@@ -59,85 +59,27 @@ void MessageCenterEditor::buttonClicked(Button* button) ...@@ -59,85 +59,27 @@ void MessageCenterEditor::buttonClicked(Button* button)
void MessageCenterEditor::labelTextChanged(Label* label) void MessageCenterEditor::labelTextChanged(Label* label)
{ {
if (label == incomingMessageDisplayArea)
{
incomingBackground = Colours::orange;
startTimer(20);
}
} }
void MessageCenterEditor::timerCallback() void MessageCenterEditor::timerCallback()
{ {
uint8 defaultValue = 100;
uint8 inRed = incomingBackground.getRed();
uint8 inGreen = incomingBackground.getGreen();
uint8 inBlue = incomingBackground.getBlue();
uint8 outRed = outgoingBackground.getRed();
uint8 outGreen = outgoingBackground.getGreen();
uint8 outBlue = outgoingBackground.getBlue();
bool shouldRepaint = false; bool shouldRepaint = false;
if (inGreen > defaultValue) float incomingAlpha = incomingBackground.getFloatAlpha();
{
inGreen -= 1; shouldRepaint = true;
}
else if (inGreen < defaultValue)
{
inGreen += 1; shouldRepaint = true;
}
if (inRed > defaultValue) if (incomingAlpha > 0)
{ {
inRed -= 1; shouldRepaint = true; incomingAlpha -= 0.05;
}
else if (inRed < defaultValue)
{
inRed += 1; shouldRepaint = true;
}
if (inBlue > defaultValue) if (incomingAlpha < 0)
{ incomingAlpha = 0;
inBlue -= 1; shouldRepaint = true;
}
else if (inBlue < defaultValue)
{
inBlue += 1; shouldRepaint = true;
}
if (outGreen > defaultValue) incomingBackground = incomingBackground.withAlpha(incomingAlpha);
{
outGreen -= 1; shouldRepaint = true;
}
else if (outGreen < defaultValue)
{
outGreen += 1; shouldRepaint = true;
}
if (outRed > defaultValue)
{
outRed -= 1; shouldRepaint = true;
}
else if (outRed < defaultValue)
{
outRed += 1; shouldRepaint = true;
}
if (outBlue > defaultValue) shouldRepaint = true;
{
outBlue -= 1; shouldRepaint = true;
}
else if (outBlue < defaultValue)
{
outBlue += 1; shouldRepaint = true;
} }
incomingBackground = Colour(inRed, inGreen, inBlue);
outgoingBackground = Colour(outRed, outGreen, outBlue);
if (shouldRepaint) if (shouldRepaint)
repaint(); repaint();
else else
...@@ -177,7 +119,7 @@ void MessageCenterEditor::messageReceived(bool state) ...@@ -177,7 +119,7 @@ void MessageCenterEditor::messageReceived(bool state)
incomingBackground = Colours::green; incomingBackground = Colours::green;
} }
startTimer(20); startTimer(75);
} }
void MessageCenterEditor::paint(Graphics& g) void MessageCenterEditor::paint(Graphics& g)
...@@ -187,6 +129,11 @@ void MessageCenterEditor::paint(Graphics& g) ...@@ -187,6 +129,11 @@ void MessageCenterEditor::paint(Graphics& g)
g.fillRect(0, 0, getWidth(), getHeight()); g.fillRect(0, 0, getWidth(), getHeight());
g.setColour(Colour(100,100,100));
g.fillRect(5, 5, getWidth()/2-5, getHeight()-10);
g.fillRect(getWidth()/2+5, 5, getWidth()/2-60, getHeight()-10);
g.setColour(incomingBackground); g.setColour(incomingBackground);
g.fillRect(5, 5, getWidth()/2-5, getHeight()-10); g.fillRect(5, 5, getWidth()/2-5, getHeight()-10);
...@@ -215,7 +162,7 @@ void MessageCenterEditor::actionListenerCallback(const String& message) ...@@ -215,7 +162,7 @@ void MessageCenterEditor::actionListenerCallback(const String& message)
incomingMessageDisplayArea->setText(message, sendNotification); incomingMessageDisplayArea->setText(message, sendNotification);
incomingBackground = Colours::orange; incomingBackground = Colours::orange;
startTimer(20); startTimer(75);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment