Files
mpsk_rx_gui/Source/IQPoint.cpp
T
2014-07-19 08:20:53 +00:00

161 lines
4.0 KiB
C++

/*
==============================================================================
This is an automatically generated GUI class created by the Introjucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Introjucer version: 3.1.0
------------------------------------------------------------------------------
The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-13 by Raw Material Software Ltd.
==============================================================================
*/
//[Headers] You can add your own extra header files here...
//[/Headers]
#include "IQPoint.h"
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
//==============================================================================
IQPoint::IQPoint (uint32 id)
: m_id(id)
{
//[UserPreSize]
//[/UserPreSize]
setSize (10, 10);
//[Constructor] You can add your own custom stuff here..
m_alpha = 1.0f;
setVisible(false);
//[/Constructor]
}
IQPoint::~IQPoint()
{
//[Destructor_pre]. You can add your own custom destruction code here..
//[/Destructor_pre]
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]
}
//==============================================================================
void IQPoint::paint (Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
//[UserPaint] Add your own custom painting code here..
g.setColour (m_color.withMultipliedAlpha(m_alpha));
drawCross(g);
//[/UserPaint]
}
void IQPoint::resized()
{
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
void IQPoint::drawPoint(Graphics& g)
{
g.fillEllipse (getLocalBounds().toFloat());
}
void IQPoint::drawCross(Graphics& g)
{
Rectangle<float> coord;
coord = getLocalBounds().toFloat();
g.drawLine(coord.getTopLeft().getX(), coord.getTopLeft().getY(), coord.getBottomRight().getX(), coord.getBottomRight().getY(), 1.f);
g.drawLine(coord.getTopRight().getX(), coord.getTopRight().getY(), coord.getBottomLeft().getX(), coord.getBottomLeft().getY(), 1.f);
}
void IQPoint::drawPlusSign(Graphics& g)
{
(void)g;
}
void IQPoint::start()
{
m_alpha = 1.0f;
startTimer (1000 / 20);
setVisible(true);
repaint();
}
void IQPoint::stop()
{
stopTimer ();
setVisible(false);
m_alpha = 1.0f;
repaint();
}
void IQPoint::setColor(Colour color)
{
m_color = color;
repaint();
}
void IQPoint::timerCallback()
{
// Reduce the alpha level of the flash slightly so it fades out
m_alpha -= 0.06f*m_alpha;
if (m_alpha < 0.05f)
{
stop();
sendChangeMessage();
// Once we've finsihed flashing send a change message to trigger the next component to flash
}
repaint();
}
//[/MiscUserCode]
//==============================================================================
#if 0
/* -- Introjucer information section --
This is where the Introjucer stores the metadata that describe this GUI layout, so
make changes in here at your peril!
BEGIN_JUCER_METADATA
<JUCER_COMPONENT documentType="Component" className="IQPoint" componentName=""
parentClasses="public Component, public ChangeBroadcaster, public Timer"
constructorParams="uint32 id" variableInitialisers="m_id(id)"
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="0" initialWidth="10" initialHeight="10">
<BACKGROUND backgroundColour="ffffff"/>
</JUCER_COMPONENT>
END_JUCER_METADATA
*/
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]