@@ -461,29 +461,3 @@ bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::I | |||||
return false; | return false; | ||||
} | } | ||||
//============================================================================== | |||||
class CallOutBoxCallback : public ModalComponentManager::Callback | |||||
{ | |||||
public: | |||||
CallOutBoxCallback (Component& attachTo, Component* content_) | |||||
: content (content_), | |||||
callout (*content_, attachTo, nullptr) | |||||
{ | |||||
callout.setVisible (true); | |||||
callout.enterModalState (true, this); | |||||
} | |||||
void modalStateFinished (int) {} | |||||
private: | |||||
ScopedPointer<Component> content; | |||||
CallOutBox callout; | |||||
JUCE_DECLARE_NON_COPYABLE (CallOutBoxCallback); | |||||
}; | |||||
void launchAsyncCallOutBox (Component& attachTo, Component* content) | |||||
{ | |||||
new CallOutBoxCallback (attachTo, content); | |||||
} |
@@ -51,9 +51,6 @@ void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize); | |||||
void showUTF8ToolWindow(); | void showUTF8ToolWindow(); | ||||
// Start a callout modally, which will delete the content comp when it's dismissed. | |||||
void launchAsyncCallOutBox (Component& attachTo, Component* content); | |||||
bool cancelAnyModalComponents(); | bool cancelAnyModalComponents(); | ||||
bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&); | bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&); | ||||
@@ -335,7 +332,9 @@ public: | |||||
if (undoManager != nullptr) | if (undoManager != nullptr) | ||||
undoManager->beginNewTransaction(); | undoManager->beginNewTransaction(); | ||||
launchAsyncCallOutBox (*this, new PopupColourSelector (colourValue, defaultColour, canResetToDefault)); | |||||
CallOutBox::launchAsynchronously (*this, new PopupColourSelector (colourValue, | |||||
defaultColour, | |||||
canResetToDefault), nullptr); | |||||
} | } | ||||
void valueChanged (Value&) | void valueChanged (Value&) | ||||
@@ -446,6 +446,11 @@ void Graphics::drawBevel (const int x, const int y, const int width, const int h | |||||
} | } | ||||
//============================================================================== | //============================================================================== | ||||
void Graphics::fillEllipse (const Rectangle<float>& area) const | |||||
{ | |||||
fillEllipse (area.getX(), area.getY(), area.getWidth(), area.getHeight()); | |||||
} | |||||
void Graphics::fillEllipse (const float x, const float y, const float width, const float height) const | void Graphics::fillEllipse (const float x, const float y, const float width, const float height) const | ||||
{ | { | ||||
// passing in a silly number can cause maths problems in rendering! | // passing in a silly number can cause maths problems in rendering! | ||||
@@ -332,13 +332,17 @@ public: | |||||
//============================================================================== | //============================================================================== | ||||
/** Fills an ellipse with the current colour or brush. | /** Fills an ellipse with the current colour or brush. | ||||
The ellipse is drawn to fit inside the given rectangle. | The ellipse is drawn to fit inside the given rectangle. | ||||
@see drawEllipse, Path::addEllipse | @see drawEllipse, Path::addEllipse | ||||
*/ | */ | ||||
void fillEllipse (float x, float y, float width, float height) const; | void fillEllipse (float x, float y, float width, float height) const; | ||||
/** Fills an ellipse with the current colour or brush. | |||||
The ellipse is drawn to fit inside the given rectangle. | |||||
@see drawEllipse, Path::addEllipse | |||||
*/ | |||||
void fillEllipse (const Rectangle<float>& area) const; | |||||
/** Draws an elliptical stroke using the current colour or brush. | /** Draws an elliptical stroke using the current colour or brush. | ||||
@see fillEllipse, Path::addEllipse | @see fillEllipse, Path::addEllipse | ||||
@@ -55,6 +55,35 @@ CallOutBox::~CallOutBox() | |||||
{ | { | ||||
} | } | ||||
//============================================================================== | |||||
class CallOutBoxCallback : public ModalComponentManager::Callback | |||||
{ | |||||
public: | |||||
CallOutBoxCallback (Component& attachTo, Component* content_, Component* parentComponent) | |||||
: content (content_), callout (*content_, attachTo, parentComponent) | |||||
{ | |||||
callout.setVisible (true); | |||||
callout.enterModalState (true, this); | |||||
} | |||||
void modalStateFinished (int) {} | |||||
private: | |||||
ScopedPointer<Component> content; | |||||
CallOutBox callout; | |||||
JUCE_DECLARE_NON_COPYABLE (CallOutBoxCallback); | |||||
}; | |||||
void CallOutBox::launchAsynchronously (Component& componentToPointTo, | |||||
Component* contentComponent, | |||||
Component* parentComponent) | |||||
{ | |||||
jassert (contentComponent != nullptr); // must be a valid content component! | |||||
new CallOutBoxCallback (componentToPointTo, contentComponent, parentComponent); | |||||
} | |||||
//============================================================================== | //============================================================================== | ||||
void CallOutBox::setArrowSize (const float newSize) | void CallOutBox::setArrowSize (const float newSize) | ||||
{ | { | ||||
@@ -90,6 +90,24 @@ public: | |||||
void updatePosition (const Rectangle<int>& newAreaToPointTo, | void updatePosition (const Rectangle<int>& newAreaToPointTo, | ||||
const Rectangle<int>& newAreaToFitIn); | const Rectangle<int>& newAreaToFitIn); | ||||
/** This will launch a callout box containing the given content, pointing to the | |||||
specified target component. | |||||
This method will create and display a callout, returning immediately, after which | |||||
the box will continue to run modally until the user clicks on some other component, at | |||||
which point it will be dismissed automatically. | |||||
The content component that is passed-in will be owned by the callout, which will | |||||
delete it when it is dismissed. | |||||
The parentComponent parameter can be a nullptr if you want the window to appear on | |||||
the desktop. | |||||
*/ | |||||
static void launchAsynchronously (Component& componentToPointTo, | |||||
Component* contentComponent, | |||||
Component* parentComponent); | |||||
//============================================================================== | //============================================================================== | ||||
/** @internal */ | /** @internal */ | ||||
void paint (Graphics& g); | void paint (Graphics& g); | ||||