Browse Source

New methods for Graphics, CallOutBox.

tags/2021-05-28
jules 13 years ago
parent
commit
1e9e6cbf79
6 changed files with 61 additions and 32 deletions
  1. +0
    -26
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp
  2. +3
    -4
      extras/Introjucer/Source/Utility/jucer_MiscUtilities.h
  3. +5
    -0
      modules/juce_graphics/contexts/juce_GraphicsContext.cpp
  4. +6
    -2
      modules/juce_graphics/contexts/juce_GraphicsContext.h
  5. +29
    -0
      modules/juce_gui_basics/windows/juce_CallOutBox.cpp
  6. +18
    -0
      modules/juce_gui_basics/windows/juce_CallOutBox.h

+ 0
- 26
extras/Introjucer/Source/Utility/jucer_MiscUtilities.cpp View File

@@ -461,29 +461,3 @@ bool reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::I
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);
}

+ 3
- 4
extras/Introjucer/Source/Utility/jucer_MiscUtilities.h View File

@@ -51,9 +51,6 @@ void drawRecessedShadows (Graphics& g, int w, int h, int shadowSize);
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 reinvokeCommandAfterCancellingModalComps (const ApplicationCommandTarget::InvocationInfo&);
@@ -335,7 +332,9 @@ public:
if (undoManager != nullptr)
undoManager->beginNewTransaction();
launchAsyncCallOutBox (*this, new PopupColourSelector (colourValue, defaultColour, canResetToDefault));
CallOutBox::launchAsynchronously (*this, new PopupColourSelector (colourValue,
defaultColour,
canResetToDefault), nullptr);
}
void valueChanged (Value&)


+ 5
- 0
modules/juce_graphics/contexts/juce_GraphicsContext.cpp View File

@@ -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
{
// passing in a silly number can cause maths problems in rendering!


+ 6
- 2
modules/juce_graphics/contexts/juce_GraphicsContext.h View File

@@ -332,13 +332,17 @@ public:
//==============================================================================
/** 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 (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.
@see fillEllipse, Path::addEllipse


+ 29
- 0
modules/juce_gui_basics/windows/juce_CallOutBox.cpp View File

@@ -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)
{


+ 18
- 0
modules/juce_gui_basics/windows/juce_CallOutBox.h View File

@@ -90,6 +90,24 @@ public:
void updatePosition (const Rectangle<int>& newAreaToPointTo,
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 */
void paint (Graphics& g);


Loading…
Cancel
Save