openshot-audio  0.1.6
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
Label Class Reference

#include <juce_Label.h>

Inheritance diagram for Label:
Value::Listener LookAndFeel_V2::SliderLabelComp

Classes

class  Listener
 
struct  LookAndFeelMethods
 

Public Types

enum  ColourIds {
  backgroundColourId = 0x1000280, textColourId = 0x1000281, outlineColourId = 0x1000282, backgroundWhenEditingColourId = 0x1000283,
  textWhenEditingColourId = 0x1000284, outlineWhenEditingColourId = 0x1000285
}
 

Public Member Functions

 Label (const String &componentName=String::empty, const String &labelText=String::empty)
 
 ~Label ()
 
void setText (const String &newText, NotificationType notification)
 
String getText (bool returnActiveEditorContents=false) const
 
ValuegetTextValue () noexcept
 
void setFont (const Font &newFont)
 
Font getFont () const noexcept
 
void setJustificationType (Justification justification)
 
Justification getJustificationType () const noexcept
 
void setBorderSize (BorderSize< int > newBorderSize)
 
BorderSize< intgetBorderSize () const noexcept
 
void attachToComponent (Component *owner, bool onLeft)
 
ComponentgetAttachedComponent () const
 
bool isAttachedOnLeft () const noexcept
 
void setMinimumHorizontalScale (float newScale)
 
float getMinimumHorizontalScale () const noexcept
 
void setKeyboardType (TextInputTarget::VirtualKeyboardType type) noexcept
 
void addListener (Listener *listener)
 
void removeListener (Listener *listener)
 
void setEditable (bool editOnSingleClick, bool editOnDoubleClick=false, bool lossOfFocusDiscardsChanges=false)
 
bool isEditableOnSingleClick () const noexcept
 
bool isEditableOnDoubleClick () const noexcept
 
bool doesLossOfFocusDiscardChanges () const noexcept
 
bool isEditable () const noexcept
 
void showEditor ()
 
void hideEditor (bool discardCurrentEditorContents)
 
bool isBeingEdited () const noexcept
 
TextEditorgetCurrentTextEditor () const noexcept
 

Protected Member Functions

virtual TextEditorcreateEditorComponent ()
 
virtual void textWasEdited ()
 
virtual void textWasChanged ()
 
virtual void editorShown (TextEditor *)
 
virtual void editorAboutToBeHidden (TextEditor *)
 
void paint (Graphics &) override
 
void resized () override
 
void mouseUp (const MouseEvent &) override
 
void mouseDoubleClick (const MouseEvent &) override
 
void componentMovedOrResized (Component &, bool wasMoved, bool wasResized) override
 
void componentParentHierarchyChanged (Component &) override
 
void componentVisibilityChanged (Component &) override
 
void inputAttemptWhenModal () override
 
void focusGained (FocusChangeType) override
 
void enablementChanged () override
 
KeyboardFocusTraversercreateFocusTraverser () override
 
void textEditorTextChanged (TextEditor &) override
 
void textEditorReturnKeyPressed (TextEditor &) override
 
void textEditorEscapeKeyPressed (TextEditor &) override
 
void textEditorFocusLost (TextEditor &) override
 
void colourChanged () override
 
void valueChanged (Value &) override
 
void callChangeListeners ()
 

Detailed Description

A component that displays a text string, and can optionally become a text editor when clicked.

Member Enumeration Documentation

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

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

Note that you can also use the constants from TextEditor::ColourIds to change the colour of the text editor that is opened when a label is editable.

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

The background colour to fill the label with.

textColourId 

The colour for the text.

outlineColourId 

An optional colour to use to draw a border around the label. Leave this transparent to not have an outline.

backgroundWhenEditingColourId 

The background colour when the label is being edited.

textWhenEditingColourId 

The colour for the text when the label is being edited.

outlineWhenEditingColourId 

An optional border colour when the label is being edited.

Constructor & Destructor Documentation

Label::Label ( const String componentName = String::empty,
const String labelText = String::empty 
)

Creates a Label.

Parameters
componentNamethe name to give the component
labelTextthe text to show in the label
Label::~Label ( )

Destructor.

Member Function Documentation

void Label::addListener ( Listener listener)

Registers a listener that will be called when the label's text changes.

void Label::attachToComponent ( Component owner,
bool  onLeft 
)

Makes this label "stick to" another component.

This will cause the label to follow another component around, staying either to its left or above it.

Parameters
ownerthe component to follow
onLeftif true, the label will stay on the left of its component; if false, it will stay above it.
void Label::callChangeListeners ( )
protected
void Label::colourChanged ( )
overrideprotected
void Label::componentMovedOrResized ( Component component,
bool  wasMoved,
bool  wasResized 
)
overrideprotected
void Label::componentParentHierarchyChanged ( Component component)
overrideprotected
void Label::componentVisibilityChanged ( Component component)
overrideprotected
TextEditor * Label::createEditorComponent ( )
protectedvirtual

Creates the TextEditor component that will be used when the user has clicked on the label. Subclasses can override this if they need to customise this component in some way.

KeyboardFocusTraverser * Label::createFocusTraverser ( )
overrideprotected
bool Label::doesLossOfFocusDiscardChanges ( ) const
inlinenoexcept

Returns true if this option has been set in a call to setEditable().

void Label::editorAboutToBeHidden ( TextEditor textEditor)
protectedvirtual

Called when the text editor is going to be deleted, after editing has finished.

void Label::editorShown ( TextEditor textEditor)
protectedvirtual

Called when the text editor has just appeared, due to a user click or other focus change.

void Label::enablementChanged ( )
overrideprotected
void Label::focusGained ( FocusChangeType  cause)
overrideprotected
Component * Label::getAttachedComponent ( ) const

If this label has been attached to another component using attachToComponent, this returns the other component.

Returns nullptr if the label is not attached.

BorderSize<int> Label::getBorderSize ( ) const
inlinenoexcept

Returns the size of the border to be left around the text.

TextEditor * Label::getCurrentTextEditor ( ) const
noexcept

Returns the currently-visible text editor, or nullptr if none is open.

Font Label::getFont ( ) const
noexcept

Returns the font currently being used. This may be the one set by setFont(), unless it has been overridden by the current LookAndFeel

See also
setFont
Justification Label::getJustificationType ( ) const
inlinenoexcept

Returns the type of justification, as set in setJustificationType().

float Label::getMinimumHorizontalScale ( ) const
inlinenoexcept

Specifies the amount that the font can be squashed horizontally.

String Label::getText ( bool  returnActiveEditorContents = false) const

Returns the label's current text.

Parameters
returnActiveEditorContentsif this is true and the label is currently being edited, then this method will return the text as it's being shown in the editor. If false, then the value returned here won't be updated until the user has finished typing and pressed the return key.
Value& Label::getTextValue ( )
inlinenoexcept

Returns the text content as a Value object. You can call Value::referTo() on this object to make the label read and control a Value object that you supply.

void Label::hideEditor ( bool  discardCurrentEditorContents)

Hides the editor if it was being shown.

Parameters
discardCurrentEditorContentsif true, the label's text will be reset to whatever it was before the editor was shown; if false, the current contents of the editor will be used to set the label's text before it is hidden.
void Label::inputAttemptWhenModal ( )
overrideprotected
bool Label::isAttachedOnLeft ( ) const
inlinenoexcept

If the label is attached to the left of another component, this returns true.

Returns false if the label is above the other component. This is only relevent if attachToComponent() has been called.

bool Label::isBeingEdited ( ) const
noexcept

Returns true if the editor is currently focused and active.

bool Label::isEditable ( ) const
inlinenoexcept

Returns true if the user can edit this label's text.

bool Label::isEditableOnDoubleClick ( ) const
inlinenoexcept

Returns true if this option was set using setEditable().

bool Label::isEditableOnSingleClick ( ) const
inlinenoexcept

Returns true if this option was set using setEditable().

void Label::mouseDoubleClick ( const MouseEvent e)
overrideprotected
void Label::mouseUp ( const MouseEvent e)
overrideprotected
void Label::paint ( Graphics g)
overrideprotected
void Label::removeListener ( Listener listener)

Deregisters a previously-registered listener.

void Label::resized ( )
overrideprotected
void Label::setBorderSize ( BorderSize< int newBorderSize)

Changes the border that is left between the edge of the component and the text. By default there's a small gap left at the sides of the component to allow for the drawing of the border, but you can change this if necessary.

void Label::setEditable ( bool  editOnSingleClick,
bool  editOnDoubleClick = false,
bool  lossOfFocusDiscardsChanges = false 
)

Makes the label turn into a TextEditor when clicked.

By default this is turned off.

If turned on, then single- or double-clicking will turn the label into an editor. If the user then changes the text, then the ChangeBroadcaster base class will be used to send change messages to any listeners that have registered.

If the user changes the text, the textWasEdited() method will be called afterwards, and subclasses can override this if they need to do anything special.

Parameters
editOnSingleClickif true, just clicking once on the label will start editing the text
editOnDoubleClickif true, a double-click is needed to start editing
lossOfFocusDiscardsChangesif true, clicking somewhere else while the text is being edited will discard any changes; if false, then this will commit the changes.
See also
showEditor, setEditorColours, TextEditor
void Label::setFont ( const Font newFont)

Changes the font to use to draw the text.

See also
getFont
void Label::setJustificationType ( Justification  justification)

Sets the style of justification to be used for positioning the text. (The default is Justification::centredLeft)

void Label::setKeyboardType ( TextInputTarget::VirtualKeyboardType  type)
inlinenoexcept

Set a keyboard type for use when the text editor is shown.

void Label::setMinimumHorizontalScale ( float  newScale)

Specifies the minimum amount that the font can be squashed horizontally before it starts using ellipsis. Use a value of 0 for a default value.

See also
Graphics::drawFittedText
void Label::setText ( const String newText,
NotificationType  notification 
)

Changes the label text.

The NotificationType parameter indicates whether to send a change message to any Label::Listener objects if the new text is different.

void Label::showEditor ( )

Makes the editor appear as if the label had been clicked by the user.

See also
textWasEdited, setEditable
void Label::textEditorEscapeKeyPressed ( TextEditor ed)
overrideprotected
void Label::textEditorFocusLost ( TextEditor ed)
overrideprotected
void Label::textEditorReturnKeyPressed ( TextEditor ed)
overrideprotected
void Label::textEditorTextChanged ( TextEditor ed)
overrideprotected
void Label::textWasChanged ( )
protectedvirtual

Called when the text has been altered.

void Label::textWasEdited ( )
protectedvirtual

Called after the user changes the text.

void Label::valueChanged ( Value value)
overrideprotectedvirtual

Called when a Value object is changed.

Note that the Value object passed as a parameter may not be exactly the same object that you registered the listener with - it might be a copy that refers to the same underlying ValueSource. To find out, you can call Value::refersToSameSourceAs().

Implements Value::Listener.


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