Skip to content

Instantly share code, notes, and snippets.

@adamski
Created January 22, 2015 07:21
Show Gist options
  • Save adamski/9fac24ed90de412396a1 to your computer and use it in GitHub Desktop.
Save adamski/9fac24ed90de412396a1 to your computer and use it in GitHub Desktop.
Custom class derived from CallOutBox for removing arrow (JUCE)
#include "CustomCallOutBox.h"
CustomCallOutBox::CustomCallOutBox (Component &contentComponent,
const Rectangle< int > &areaToPointTo,
Component *parentComponent,
bool drawArrow)
: CallOutBox (contentComponent, areaToPointTo, parentComponent), drawArrow (drawArrow)
{
}
class CustomCallOutBoxCallback : public ModalComponentManager::Callback,
private Timer
{
public:
CustomCallOutBoxCallback (Component* c, const Rectangle<int>& area, Component* parent, bool arrow)
: content (c), callout (*c, area, parent, arrow)
{
callout.setVisible (true);
callout.enterModalState (true, this);
startTimer (200);
}
void modalStateFinished (int) override {}
void timerCallback() override
{
if (! Process::isForegroundProcess())
callout.dismiss();
}
ScopedPointer<Component> content;
CustomCallOutBox callout;
JUCE_DECLARE_NON_COPYABLE (CustomCallOutBoxCallback)
};
CustomCallOutBox& CustomCallOutBox::launchAsynchronously (Component* content, const Rectangle<int>& area, Component* parent, bool arrow)
{
jassert (content != nullptr); // must be a valid content component!
return (new CustomCallOutBoxCallback (content, area, parent, arrow))->callout;
}
#ifndef CUSTOMCALLOUTBOX_H_INCLUDED
#define CUSTOMCALLOUTBOX_H_INCLUDED
#include "JuceHeader.h"
class CustomCallOutBox : public CallOutBox
{
public:
CustomCallOutBox (Component &contentComponent, const Rectangle< int > &areaToPointTo, Component *parentComponent, bool drawArrow);
static CustomCallOutBox& launchAsynchronously (Component* content, const Rectangle<int>& area, Component* parent, bool drawArrow);
private:
bool drawArrow;
};
#endif // CUSTOMCALLOUTBOX_H_INCLUDED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment