LMMS
Loading...
Searching...
No Matches
juce::TooltipWindow Class Reference

#include <juce_TooltipWindow.h>

Inheritance diagram for juce::TooltipWindow:
juce::Component juce::Timer juce::MouseListener

Classes

struct  LookAndFeelMethods

Public Types

enum  ColourIds { backgroundColourId = 0x1001b00 , textColourId = 0x1001c00 , outlineColourId = 0x1001c10 }
Public Types inherited from juce::Component
enum class  FocusContainerType { none , focusContainer , keyboardFocusContainer }
enum  FocusChangeType { focusChangedByMouseClick , focusChangedByTabKey , focusChangedDirectly }

Public Member Functions

 TooltipWindow (Component *parentComponent=nullptr, int millisecondsBeforeTipAppears=700)
 ~TooltipWindow () override
void setMillisecondsBeforeTipAppears (int newTimeMs=700) noexcept
void displayTip (Point< int > screenPosition, const String &text)
void hideTip ()
virtual String getTipFor (Component &)
float getDesktopScaleFactor () const override
Public Member Functions inherited from juce::Component
 Component () noexcept
 ~Component () override
 Component (const String &componentName) noexcept
String getName () const noexcept
virtual void setName (const String &newName)
String getComponentID () const noexcept
void setComponentID (const String &newID)
virtual void setVisible (bool shouldBeVisible)
bool isVisible () const noexcept
virtual void visibilityChanged ()
bool isShowing () const
virtual void addToDesktop (int windowStyleFlags, void *nativeWindowToAttachTo=nullptr)
void removeFromDesktop ()
bool isOnDesktop () const noexcept
ComponentPeergetPeer () const
virtual void userTriedToCloseWindow ()
virtual void minimisationStateChanged (bool isNowMinimised)
void toFront (bool shouldAlsoGainKeyboardFocus)
void toBack ()
void toBehind (Component *other)
void setAlwaysOnTop (bool shouldStayOnTop)
bool isAlwaysOnTop () const noexcept
int getX () const noexcept
int getY () const noexcept
int getWidth () const noexcept
int getHeight () const noexcept
int getRight () const noexcept
Point< intgetPosition () const noexcept
int getBottom () const noexcept
Rectangle< intgetBounds () const noexcept
Rectangle< intgetLocalBounds () const noexcept
Rectangle< intgetBoundsInParent () const noexcept
int getScreenX () const
int getScreenY () const
Point< intgetScreenPosition () const
Rectangle< intgetScreenBounds () const
Point< intgetLocalPoint (const Component *sourceComponent, Point< int > pointRelativeToSourceComponent) const
Point< float > getLocalPoint (const Component *sourceComponent, Point< float > pointRelativeToSourceComponent) const
Rectangle< intgetLocalArea (const Component *sourceComponent, Rectangle< int > areaRelativeToSourceComponent) const
Rectangle< float > getLocalArea (const Component *sourceComponent, Rectangle< float > areaRelativeToSourceComponent) const
Point< intlocalPointToGlobal (Point< int > localPoint) const
Point< float > localPointToGlobal (Point< float > localPoint) const
Rectangle< intlocalAreaToGlobal (Rectangle< int > localArea) const
Rectangle< float > localAreaToGlobal (Rectangle< float > localArea) const
void setTopLeftPosition (int x, int y)
void setTopLeftPosition (Point< int > newTopLeftPosition)
void setTopRightPosition (int x, int y)
void setSize (int newWidth, int newHeight)
void setBounds (int x, int y, int width, int height)
void setBounds (Rectangle< int > newBounds)
void setBoundsRelative (float proportionalX, float proportionalY, float proportionalWidth, float proportionalHeight)
void setBoundsRelative (Rectangle< float > proportionalArea)
void setBoundsInset (BorderSize< int > borders)
void setBoundsToFit (Rectangle< int > targetArea, Justification justification, bool onlyReduceInSize)
void setCentrePosition (int x, int y)
void setCentrePosition (Point< int > newCentrePosition)
void setCentreRelative (float x, float y)
void centreWithSize (int width, int height)
void setTransform (const AffineTransform &transform)
AffineTransform getTransform () const
bool isTransformed () const noexcept
int proportionOfWidth (float proportion) const noexcept
int proportionOfHeight (float proportion) const noexcept
int getParentWidth () const noexcept
int getParentHeight () const noexcept
Rectangle< intgetParentMonitorArea () const
int getNumChildComponents () const noexcept
ComponentgetChildComponent (int index) const noexcept
int getIndexOfChildComponent (const Component *child) const noexcept
const Array< Component * > & getChildren () const noexcept
ComponentfindChildWithID (StringRef componentID) const noexcept
void addChildComponent (Component *child, int zOrder=-1)
void addChildComponent (Component &child, int zOrder=-1)
void addAndMakeVisible (Component *child, int zOrder=-1)
void addAndMakeVisible (Component &child, int zOrder=-1)
void addChildAndSetID (Component *child, const String &componentID)
void removeChildComponent (Component *childToRemove)
ComponentremoveChildComponent (int childIndexToRemove)
void removeAllChildren ()
void deleteAllChildren ()
ComponentgetParentComponent () const noexcept
template<class TargetClass>
TargetClass * findParentComponentOfClass () const
ComponentgetTopLevelComponent () const noexcept
bool isParentOf (const Component *possibleChild) const noexcept
virtual void parentHierarchyChanged ()
virtual void childrenChanged ()
virtual bool hitTest (int x, int y)
void setInterceptsMouseClicks (bool allowClicksOnThisComponent, bool allowClicksOnChildComponents) noexcept
void getInterceptsMouseClicks (bool &allowsClicksOnThisComponent, bool &allowsClicksOnChildComponents) const noexcept
bool contains (Point< int > localPoint)
bool contains (Point< float > localPoint)
bool reallyContains (Point< int > localPoint, bool returnTrueIfWithinAChild)
bool reallyContains (Point< float > localPoint, bool returnTrueIfWithinAChild)
ComponentgetComponentAt (int x, int y)
ComponentgetComponentAt (Point< int > position)
ComponentgetComponentAt (Point< float > position)
void repaint ()
void repaint (int x, int y, int width, int height)
void repaint (Rectangle< int > area)
void setBufferedToImage (bool shouldBeBuffered)
Image createComponentSnapshot (Rectangle< int > areaToGrab, bool clipImageToComponentBounds=true, float scaleFactor=1.0f)
void paintEntireComponent (Graphics &context, bool ignoreAlphaLevel)
void setPaintingIsUnclipped (bool shouldPaintWithoutClipping) noexcept
bool isPaintingUnclipped () const noexcept
void setComponentEffect (ImageEffectFilter *newEffect)
ImageEffectFiltergetComponentEffect () const noexcept
LookAndFeelgetLookAndFeel () const noexcept
void setLookAndFeel (LookAndFeel *newLookAndFeel)
virtual void lookAndFeelChanged ()
void sendLookAndFeelChange ()
void setOpaque (bool shouldBeOpaque)
bool isOpaque () const noexcept
void setBroughtToFrontOnMouseClick (bool shouldBeBroughtToFront) noexcept
bool isBroughtToFrontOnMouseClick () const noexcept
void setExplicitFocusOrder (int newFocusOrderIndex)
int getExplicitFocusOrder () const
void setFocusContainerType (FocusContainerType containerType) noexcept
bool isFocusContainer () const noexcept
bool isKeyboardFocusContainer () const noexcept
ComponentfindFocusContainer () const
ComponentfindKeyboardFocusContainer () const
void setWantsKeyboardFocus (bool wantsFocus) noexcept
bool getWantsKeyboardFocus () const noexcept
void setMouseClickGrabsKeyboardFocus (bool shouldGrabFocus)
bool getMouseClickGrabsKeyboardFocus () const noexcept
void grabKeyboardFocus ()
void giveAwayKeyboardFocus ()
bool hasKeyboardFocus (bool trueIfChildIsFocused) const
void moveKeyboardFocusToSibling (bool moveToNext)
virtual std::unique_ptr< ComponentTraversercreateFocusTraverser ()
virtual std::unique_ptr< ComponentTraversercreateKeyboardFocusTraverser ()
void setHasFocusOutline (bool hasFocusOutline) noexcept
bool hasFocusOutline () const noexcept
bool isEnabled () const noexcept
void setEnabled (bool shouldBeEnabled)
virtual void enablementChanged ()
float getAlpha () const noexcept
void setAlpha (float newAlpha)
virtual void alphaChanged ()
void setMouseCursor (const MouseCursor &cursorType)
virtual MouseCursor getMouseCursor ()
void updateMouseCursor () const
virtual void paintOverChildren (Graphics &g)
void mouseMove (const MouseEvent &event) override
void mouseExit (const MouseEvent &event) override
void mouseDrag (const MouseEvent &event) override
void mouseUp (const MouseEvent &event) override
void mouseDoubleClick (const MouseEvent &event) override
void mouseMagnify (const MouseEvent &event, float scaleFactor) override
void setRepaintsOnMouseActivity (bool shouldRepaint) noexcept
void addMouseListener (MouseListener *newListener, bool wantsEventsForAllNestedChildComponents)
void removeMouseListener (MouseListener *listenerToRemove)
void addKeyListener (KeyListener *newListener)
void removeKeyListener (KeyListener *listenerToRemove)
virtual bool keyPressed (const KeyPress &key)
virtual bool keyStateChanged (bool isKeyDown)
virtual void modifierKeysChanged (const ModifierKeys &modifiers)
virtual void focusGained (FocusChangeType cause)
virtual void focusLost (FocusChangeType cause)
virtual void focusOfChildComponentChanged (FocusChangeType cause)
bool isMouseOver (bool includeChildren=false) const
bool isMouseButtonDown (bool includeChildren=false) const
bool isMouseOverOrDragging (bool includeChildren=false) const
Point< intgetMouseXYRelative () const
virtual void resized ()
virtual void moved ()
virtual void childBoundsChanged (Component *child)
virtual void parentSizeChanged ()
virtual void broughtToFront ()
void addComponentListener (ComponentListener *newListener)
void removeComponentListener (ComponentListener *listenerToRemove)
void postCommandMessage (int commandId)
virtual void handleCommandMessage (int commandId)
void enterModalState (bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
void exitModalState (int returnValue)
bool isCurrentlyModal (bool onlyConsiderForemostModalComponent=true) const noexcept
bool isCurrentlyBlockedByAnotherModalComponent () const
virtual bool canModalEventBeSentToComponent (const Component *targetComponent)
virtual void inputAttemptWhenModal ()
NamedValueSetgetProperties () noexcept
const NamedValueSetgetProperties () const noexcept
Colour findColour (int colourID, bool inheritFromParent=false) const
void setColour (int colourID, Colour newColour)
void removeColour (int colourID)
bool isColourSpecified (int colourID) const
void copyAllExplicitColoursTo (Component &target) const
virtual void colourChanged ()
voidgetWindowHandle () const
PositionergetPositioner () const noexcept
void setPositioner (Positioner *newPositioner)
void setCachedComponentImage (CachedComponentImage *newCachedImage)
CachedComponentImagegetCachedComponentImage () const noexcept
void setViewportIgnoreDragFlag (bool ignoreDrag) noexcept
bool getViewportIgnoreDragFlag () const noexcept
String getTitle () const noexcept
void setTitle (const String &newTitle)
String getDescription () const noexcept
void setDescription (const String &newDescription)
String getHelpText () const noexcept
void setHelpText (const String &newHelpText)
void setAccessible (bool shouldBeAccessible)
bool isAccessible () const noexcept
AccessibilityHandlergetAccessibilityHandler ()
void invalidateAccessibilityHandler ()
void setFocusContainer (bool shouldBeFocusContainer) noexcept
void contains (int, int)=delete
Public Member Functions inherited from juce::MouseListener
virtual ~MouseListener ()=default

Private Types

enum  ShownManually { yes , no }

Private Member Functions

void displayTipInternal (Point< int >, const String &, ShownManually)
std::unique_ptr< AccessibilityHandlercreateAccessibilityHandler () override
void paint (Graphics &) override
void mouseEnter (const MouseEvent &) override
void mouseDown (const MouseEvent &) override
void mouseWheelMove (const MouseEvent &, const MouseWheelDetails &) override
void timerCallback () override
void updatePosition (const String &, Point< int >, Rectangle< int >)
Private Member Functions inherited from juce::Timer
virtual ~Timer ()
void startTimer (int intervalInMilliseconds) noexcept
void startTimerHz (int timerFrequencyHz) noexcept
void stopTimer () noexcept
bool isTimerRunning () const noexcept
int getTimerInterval () const noexcept
 Timer () noexcept
 Timer (const Timer &) noexcept

Private Attributes

Point< float > lastMousePos
SafePointer< ComponentlastComponentUnderMouse
String tipShowing
String lastTipUnderMouse
String manuallyShownTip
int millisecondsBeforeTipAppears
unsigned int lastCompChangeTime = 0
unsigned int lastHideTime = 0
bool reentrant = false
bool dismissalMouseEventOccurred = false

Additional Inherited Members

Static Public Member Functions inherited from juce::Component
static float JUCE_CALLTYPE getApproximateScaleFactorForComponent (const Component *targetComponent)
static Component *JUCE_CALLTYPE getCurrentlyFocusedComponent () noexcept
static void JUCE_CALLTYPE unfocusAllComponents ()
static void JUCE_CALLTYPE beginDragAutoRepeat (int millisecondsBetweenCallbacks)
static bool JUCE_CALLTYPE isMouseButtonDownAnywhere () noexcept
static int JUCE_CALLTYPE getNumCurrentlyModalComponents () noexcept
static Component *JUCE_CALLTYPE getCurrentlyModalComponent (int index=0) noexcept
Protected Member Functions inherited from juce::Component
virtual ComponentPeercreateNewPeer (int styleFlags, void *nativeWindowToAttachTo)
Static Protected Member Functions inherited from juce::Component
static std::unique_ptr< AccessibilityHandlercreateIgnoredAccessibilityHandler (Component &)
Static Private Member Functions inherited from juce::Timer
static void JUCE_CALLTYPE callAfterDelay (int milliseconds, std::function< void()> functionToCall)
static void JUCE_CALLTYPE callPendingTimersSynchronously ()

Detailed Description

A window that displays a pop-up tooltip when the mouse hovers over another component.

To enable tooltips in your app, just create a single instance of a TooltipWindow object. Note that if you instantiate more than one instance of this class with the same parentComponent (even if both TooltipWindow's parentComponent is nil), you'll end up with multiple tooltips being shown! To avoid this use a SharedResourcePointer to instantiate the TooltipWindow only once.

For audio plug-ins (which should not be opening native windows) it is better to add a TooltipWindow as a member variable to the editor and ensure that the editor is the parentComponent of your TooltipWindow. This will ensure that your TooltipWindow is scaled according to your editor and the DAWs scaling setting.

The TooltipWindow object will then stay invisible, waiting until the mouse hovers for the specified length of time - it will then see if it's currently over a component which implements the TooltipClient interface, and if so, it will make itself visible to show the tooltip in the appropriate place.

See also
TooltipClient, SettableTooltipClient, SharedResourcePointer

@tags{GUI}

Member Enumeration Documentation

◆ ColourIds

enum juce::TooltipWindow::ColourIds

A set of colour IDs to use to change the colour of various aspects of the tooltip.

These constants can be used either via the Component::setColour(), or LookAndFeel::setColour() methods.

See also
Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
Enumerator
backgroundColourId 

The colour to fill the background with.

textColourId 

The colour to use for the text.

outlineColourId 

The colour to use to draw an outline around the tooltip.

◆ ShownManually

enum juce::TooltipWindow::ShownManually
private
Enumerator
yes 
no 

Constructor & Destructor Documentation

◆ TooltipWindow()

juce::TooltipWindow::TooltipWindow ( Component * parentComponent = nullptr,
int millisecondsBeforeTipAppears = 700 )
explicit

Creates a tooltip window.

Make sure your app only creates one instance of this class, otherwise you'll get multiple overlaid tooltips appearing. The window will initially be invisible and will make itself visible when it needs to display a tip.

To change the style of tooltips, see the LookAndFeel class for its tooltip methods.

Parameters
parentComponentif set to nullptr, the TooltipWindow will appear on the desktop, otherwise the tooltip will be added to the given parent component.
millisecondsBeforeTipAppearsthe time for which the mouse has to stay still before a tooltip will be shown
See also
TooltipClient, LookAndFeel::drawTooltip, LookAndFeel::getTooltipBounds

◆ ~TooltipWindow()

juce::TooltipWindow::~TooltipWindow ( )
override

Destructor.

Member Function Documentation

◆ createAccessibilityHandler()

std::unique_ptr< AccessibilityHandler > juce::TooltipWindow::createAccessibilityHandler ( )
overrideprivatevirtual

Override this method to return a custom AccessibilityHandler for this component.

The default implementation creates and returns a AccessibilityHandler object with an unspecified role, meaning that it will be visible to accessibility clients but without a specific role, action callbacks or interfaces. To control how accessibility clients see and interact with your component subclass AccessibilityHandler, implement the desired behaviours, and return an instance of it from this method in your component subclass.

The accessibility handler you return here is guaranteed to be destroyed before its Component, so it's safe to store and use a reference back to the Component inside the AccessibilityHandler if necessary.

See also
getAccessibilityHandler

Reimplemented from juce::Component.

◆ displayTip()

void juce::TooltipWindow::displayTip ( Point< int > screenPosition,
const String & text )

Can be called to manually force a tip to be shown at a particular location.

The tip will be shown until hideTip() is called, or a dismissal mouse event occurs.

See also
hideTip

◆ displayTipInternal()

void juce::TooltipWindow::displayTipInternal ( Point< int > screenPos,
const String & tip,
ShownManually shownManually )
private

◆ getDesktopScaleFactor()

float juce::TooltipWindow::getDesktopScaleFactor ( ) const
overridevirtual

Returns the default scale factor to use for this component when it is placed on the desktop. The default implementation of this method just returns the value from Desktop::getGlobalScaleFactor(), but it can be overridden if a particular component has different requirements. The method only used if this component is added to the desktop - it has no effect for child components.

Reimplemented from juce::Component.

◆ getTipFor()

String juce::TooltipWindow::getTipFor ( Component & c)
virtual

Asks a component for its tooltip. This can be overridden if you need custom lookup behaviour or to modify the strings.

◆ hideTip()

void juce::TooltipWindow::hideTip ( )

Can be called to manually hide the tip if it's showing.

◆ mouseDown()

void juce::TooltipWindow::mouseDown ( const MouseEvent & event)
overrideprivatevirtual

Called when a mouse button is pressed.

The MouseEvent object passed in contains lots of methods for finding out which button was pressed, as well as which modifier keys (e.g. shift, ctrl) were held down at the time.

Once a button is held down, the mouseDrag method will be called when the mouse moves, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseUp, mouseDrag, mouseDoubleClick, contains

Reimplemented from juce::Component.

◆ mouseEnter()

void juce::TooltipWindow::mouseEnter ( const MouseEvent & event)
overrideprivatevirtual

Called when the mouse first enters a component.

If the mouse button isn't pressed and the mouse moves into a component, this will be called to let the component react to this.

When the mouse button is pressed and held down while being moved in or out of a component, no mouseEnter or mouseExit callbacks are made - only mouseDrag messages are sent to the component that the mouse was originally clicked on, until the button is released.

Parameters
Eventdetails about the position and status of the mouse event, including the source component in which it occurred
See also
mouseExit, mouseDrag, mouseMove, contains

Reimplemented from juce::Component.

◆ mouseWheelMove()

void juce::TooltipWindow::mouseWheelMove ( const MouseEvent & event,
const MouseWheelDetails & wheel )
overrideprivatevirtual

Called when the mouse-wheel is moved.

This callback is sent to the component that the mouse is over when the wheel is moved.

If not overridden, a component will forward this message to its parent, so that parent components can collect mouse-wheel messages that happen to child components which aren't interested in them. (Bear in mind that if you attach a component as a mouse-listener to other components, then those wheel moves will also end up calling this method and being passed up to the parents, which may not be what you intended to happen).

Parameters
Eventdetails about the mouse event
wheeldetails about the mouse wheel movement

Reimplemented from juce::Component.

◆ paint()

void juce::TooltipWindow::paint ( Graphics & g)
overrideprivatevirtual

Components can override this method to draw their content.

The paint() method gets called when a region of a component needs redrawing, either because the component's repaint() method has been called, or because something has happened on the screen that means a section of a window needs to be redrawn.

Any child components will draw themselves over whatever this method draws. If you need to paint over the top of your child components, you can also implement the paintOverChildren() method to do this.

If you want to cause a component to redraw itself, this is done asynchronously - calling the repaint() method marks a region of the component as "dirty", and the paint() method will automatically be called sometime later, by the message thread, to paint any bits that need refreshing. In JUCE (and almost all modern UI frameworks), you never redraw something synchronously.

You should never need to call this method directly - to take a snapshot of the component you could use createComponentSnapshot() or paintEntireComponent().

Parameters
gthe graphics context that must be used to do the drawing operations.
See also
repaint, paintOverChildren, Graphics

Reimplemented from juce::Component.

◆ setMillisecondsBeforeTipAppears()

void juce::TooltipWindow::setMillisecondsBeforeTipAppears ( int newTimeMs = 700)
noexcept

Changes the time before the tip appears. This lets you change the value that was set in the constructor.

◆ timerCallback()

void juce::TooltipWindow::timerCallback ( )
overrideprivatevirtual

The user-defined callback routine that actually gets called periodically.

It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.

Implements juce::Timer.

◆ updatePosition()

void juce::TooltipWindow::updatePosition ( const String & tip,
Point< int > pos,
Rectangle< int > parentArea )
private

Member Data Documentation

◆ dismissalMouseEventOccurred

bool juce::TooltipWindow::dismissalMouseEventOccurred = false
private

◆ lastCompChangeTime

unsigned int juce::TooltipWindow::lastCompChangeTime = 0
private

◆ lastComponentUnderMouse

SafePointer<Component> juce::TooltipWindow::lastComponentUnderMouse
private

◆ lastHideTime

unsigned int juce::TooltipWindow::lastHideTime = 0
private

◆ lastMousePos

Point<float> juce::TooltipWindow::lastMousePos
private

◆ lastTipUnderMouse

String juce::TooltipWindow::lastTipUnderMouse
private

◆ manuallyShownTip

String juce::TooltipWindow::manuallyShownTip
private

◆ millisecondsBeforeTipAppears

int juce::TooltipWindow::millisecondsBeforeTipAppears
private

◆ reentrant

bool juce::TooltipWindow::reentrant = false
private

◆ tipShowing

String juce::TooltipWindow::tipShowing
private

The documentation for this class was generated from the following files: