openshot-audio
0.1.7
|
#include <juce_Button.h>
Classes | |
class | CallbackHelper |
class | Listener |
struct | LookAndFeelMethods |
Public Types | |
enum | ConnectedEdgeFlags { ConnectedOnLeft = 1, ConnectedOnRight = 2, ConnectedOnTop = 4, ConnectedOnBottom = 8 } |
enum | ButtonState { buttonNormal, buttonOver, buttonDown } |
![]() | |
enum | FocusChangeType { focusChangedByMouseClick, focusChangedByTabKey, focusChangedDirectly } |
Friends | |
class | CallbackHelper |
struct | ContainerDeletePolicy< CallbackHelper > |
Additional Inherited Members | |
![]() | |
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 |
A base class for buttons.
This contains all the logic for button behaviours such as enabling/disabling, responding to shortcut keystrokes, auto-repeating when held down, toggle-buttons and radio groups, etc.
enum Button::ButtonState |
Used by setState().
Enumerator | |
---|---|
buttonNormal | |
buttonOver | |
buttonDown |
A combination of these flags are used by setConnectedEdges().
Enumerator | |
---|---|
ConnectedOnLeft | |
ConnectedOnRight | |
ConnectedOnTop | |
ConnectedOnBottom |
Creates a button.
buttonName | the text to put in the button (the component's name is also initially set to this string, but these can be changed later using the setName() and setButtonText() methods) |
|
virtual |
Destructor.
void Button::addListener | ( | Listener * | newListener | ) |
Registers a listener to receive events when this button's state changes. If the listener is already registered, this will not register it again.
Assigns a shortcut key to trigger the button.
The button registers itself with its top-level parent component for keypresses.
Note that a different way of linking buttons to keypresses is by using the setCommandToTrigger() method to invoke a command.
|
protectedvirtual |
Called when the button's up/down/over state changes.
Subclasses can override this if they need to do something special when the button goes up or down.
Reimplemented in DrawableButton, and ToolbarButton.
void Button::clearShortcuts | ( | ) |
Removes all key shortcuts that had been set for this button.
|
protectedvirtual |
This method is called when the button has been clicked.
Subclasses can override this to perform whatever they actions they need to do.
Alternatively, a ButtonListener can be added to the button, and these listeners will be called when the click occurs.
Reimplemented in HyperlinkButton, KeyMappingEditorComponent::ChangeKeyButton, and ScrollBar::ScrollbarButton.
|
protectedvirtual |
This method is called when the button has been clicked.
By default it just calls clicked(), but you might want to override it to handle things like clicking when a modifier key is pressed, etc.
Reimplemented in TabBarButton.
|
overrideprotectedvirtual |
Callback to indicate that this component has been enabled or disabled.
This can be triggered by one of the component's parent components being enabled or disabled, as well as changes to the component itself.
The default implementation of this method does nothing; your class may wish to repaint itself or something when this happens.
Reimplemented from Component.
Reimplemented in DrawableButton, and ToolbarButton.
|
overrideprotectedvirtual |
Called to indicate that this component has just acquired the keyboard focus.
Reimplemented from Component.
|
overrideprotectedvirtual |
Called to indicate that this component has just lost the keyboard focus.
Reimplemented from Component.
Returns the text displayed in the button.
|
noexcept |
Returns true if this button is set to be an automatic toggle-button. This returns the last value that was passed to setClickingTogglesState().
|
inlinenoexcept |
Returns the command ID that was set by setCommandToTrigger().
|
inlinenoexcept |
Returns the set of flags passed into setConnectedEdges().
|
noexcept |
Returns the number of milliseconds since the last time the button went into the 'down' state.
|
inlinenoexcept |
Returns the ID of the group to which this button belongs. (See setRadioGroupId() for an explanation of this).
|
inlinenoexcept |
Returns the button's current over/down/up state.
|
inlinenoexcept |
Returns true if the button is 'on'.
By default buttons are 'off' and for simple buttons that you click to perform an action you won't change this. Toggle buttons, however will want to change their state when turned on or off.
|
inlinenoexcept |
Returns the Value object that represents the botton's toggle state. You can use this Value object to connect the button's state to external values or setters, either by taking a copy of the Value, or by using Value::referTo() to make it point to your own Value object.
|
overrideprotectedvirtual |
Called to handle a command that was sent by postCommandMessage().
This is called by the message thread when a command message arrives, and the component can override this method to process it in any way it needs to.
Reimplemented from Component.
|
protectedvirtual |
|
inlinenoexcept |
Indicates whether the button adjoins another one on its bottom edge.
|
inlinenoexcept |
Indicates whether the button adjoins another one on its left edge.
|
inlinenoexcept |
Indicates whether the button adjoins another one on its right edge.
|
inlinenoexcept |
Indicates whether the button adjoins another one on its top edge.
|
noexcept |
Returns true if the button is currently being held down.
|
noexcept |
Returns true if the mouse is currently over the button. This will be also be true if the button is being held down.
Returns true if the given keypress is a shortcut for this button.
Button::JUCE_DEPRECATED | ( | void | setToggleStatebool, bool | ) |
Called when a key is pressed.
When a key is pressed, the component that has the keyboard focus will have this method called. Remember that a component will only be given the focus if its setWantsKeyboardFocus() method has been used to enable this.
If your implementation returns true, the event will be consumed and not passed on to any other listeners. If it returns false, the key will be passed to any KeyListeners that have been registered with this component. As soon as one of these returns true, the process will stop, but if they all return false, the event will be passed upwards to this component's parent, and so on.
The default implementation of this method does nothing and returns false.
Reimplemented from Component.
|
overrideprotectedvirtual |
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.
event | details about the position and status of the mouse event, including the source component in which it occurred |
Reimplemented from Component.
|
overrideprotectedvirtual |
Called when the mouse is moved while a button is held down.
When a mouse button is pressed inside a component, that component receives mouseDrag callbacks each time the mouse moves, even if the mouse strays outside the component's bounds.
event | details about the position and status of the mouse event, including the source component in which it occurred |
Reimplemented from Component.
|
overrideprotectedvirtual |
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.
event | details about the position and status of the mouse event, including the source component in which it occurred |
Reimplemented from Component.
|
overrideprotectedvirtual |
Called when the mouse moves out of a component.
This will be called when the mouse moves off the edge of this component.
If the mouse button was pressed, and it was then dragged off the edge of the component and released, then this callback will happen when the button is released, after the mouseUp callback.
event | details about the position and status of the mouse event, including the source component in which it occurred |
Reimplemented from Component.
|
overrideprotectedvirtual |
Called when a mouse button is released.
A mouseUp callback is sent to the component in which a button was pressed even if the mouse is actually over a different component when the button is released.
The MouseEvent object passed in contains lots of methods for finding out which buttons were down just before they were released.
event | details about the position and status of the mouse event, including the source component in which it occurred |
Reimplemented from Component.
|
overrideprotectedvirtual |
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().
g | the graphics context that must be used to do the drawing operations. |
Reimplemented from Component.
Reimplemented in Toolbar::Spacer.
|
protectedpure virtual |
Subclasses should override this to actually paint the button's contents.
It's better to use this than the paint method, because it gives you information about the over/down state of the button.
g | the graphics context to use |
isMouseOverButton | true if the button is either in the 'over' or 'down' state |
isButtonDown | true if the button should be drawn in the 'down' position |
Implemented in LookAndFeel_V2::GlassWindowButton, LookAndFeel_V3_DocumentWindowButton, ToolbarItemComponent, DrawableButton, ImageButton, TabBarButton, HyperlinkButton, TextButton, ShapeButton, ToggleButton, ArrowButton, KeyMappingEditorComponent::ChangeKeyButton, and ScrollBar::ScrollbarButton.
|
overrideprotectedvirtual |
Called to indicate that the component's parents have changed.
When a component is added or removed from its parent, this method will be called on all of its children (recursively - so all children of its children will also be called as well).
Subclasses can override this if they need to react to this in some way.
Reimplemented from Component.
void Button::removeListener | ( | Listener * | listener | ) |
Removes a previously-registered button listener
Changes the button's text.
|
noexcept |
This tells the button to automatically flip the toggle state when the button is clicked.
If set to true, then before the clicked() callback occurs, the toggle-state of the button is flipped.
void Button::setCommandToTrigger | ( | ApplicationCommandManager * | commandManagerToUse, |
CommandID | commandID, | ||
bool | generateTooltip | ||
) |
Sets a command ID for this button to automatically invoke when it's clicked.
When the button is pressed, it will use the given manager to trigger the command ID.
Obviously be careful that the ApplicationCommandManager doesn't get deleted before this button is. To disable the command triggering, call this method and pass nullptr as the command manager.
If generateTooltip is true, then the button's tooltip will be automatically generated based on the name of this command and its current shortcut key.
void Button::setConnectedEdges | ( | int | connectedEdgeFlags | ) |
Hints about which edges of the button might be connected to adjoining buttons.
The value passed in is a bitwise combination of any of the values in the ConnectedEdgeFlags enum.
E.g. if you are placing two buttons adjacent to each other, you could use this to indicate which edges are touching, and the LookAndFeel might choose to drawn them without rounded corners on the edges that connect. It's only a hint, so the LookAndFeel can choose to ignore it if it's not relevent for this type of button.
void Button::setRadioGroupId | ( | int | newGroupId, |
NotificationType | notification = sendNotification |
||
) |
Enables the button to act as a member of a mutually-exclusive group of 'radio buttons'.
If the group ID is set to a non-zero number, then this button will act as part of a group of buttons with the same ID, only one of which can be 'on' at the same time. Note that when it's part of a group, clicking a toggle-button that's 'on' won't turn it off.
To find other buttons with the same ID, this button will search through its sibling components for ToggleButtons, so all the buttons for a particular group must be placed inside the same parent component.
Set the group ID back to zero if you want it to act as a normal toggle button again.
The notification argument lets you specify how other buttons should react to being turned on or off in response to this call.
|
noexcept |
Sets an auto-repeat speed for the button when it is held down.
(Auto-repeat is disabled by default).
initialDelayInMillisecs | how long to wait after the mouse is pressed before triggering the next click. If this is zero, auto-repeat is disabled |
repeatDelayInMillisecs | the frequently subsequent repeated clicks should be triggered |
minimumDelayInMillisecs | if this is greater than 0, the auto-repeat speed will get faster, the longer the button is held down, up to the minimum interval specified here |
void Button::setState | ( | ButtonState | newState | ) |
Can be used to force the button into a particular state.
This only changes the button's appearance, it won't trigger a click, or stop any mouse-clicks from happening.
The state that you set here will only last until it is automatically changed when the mouse enters or exits the button, or the mouse-button is pressed or released.
void Button::setToggleState | ( | bool | shouldBeOn, |
NotificationType | notification | ||
) |
A button has an on/off state associated with it, and this changes that.
By default buttons are 'off' and for simple buttons that you click to perform an action you won't change this. Toggle buttons, however will want to change their state when turned on or off.
shouldBeOn | whether to set the button's toggle state to be on or off. If it's a member of a button group, this will always try to turn it on, and to turn off any other buttons in the group |
notification | determines the behaviour if the value changes - this can invoke a synchronous call to clicked(), but sendNotificationAsync is not supported |
Sets the tooltip for this button.
Reimplemented from SettableTooltipClient.
|
noexcept |
Sets whether the button click should happen when the mouse is pressed or released.
By default the button is only considered to have been clicked when the mouse is released, but setting this to true will make it call the clicked() method as soon as the button is pressed.
This is useful if the button is being used to show a pop-up menu, as it allows the click to be used as a drag onto the menu.
|
virtual |
|
overrideprotectedvirtual |
Called when this component's visibility changes.
Reimplemented from Component.
|
friend |
|
friend |