Krotos Modules 3
Loading...
Searching...
No Matches
krotos::DropComponent Class Reference

A component for dropping draggable juce objects onto. More...

#include <DropComponent.h>

Inheritance diagram for krotos::DropComponent:

Public Types

enum  RoundedCorner {
  TopLeft = 0 , TopRight , BottomLeft , BottomRight ,
  Top , Bottom , All , None
}
 Rounded corner state enum. More...
 

Public Member Functions

 DropComponent (const String &labelText, const String &kwidgetID="")
 
void resized () override
 
Label & getLabel ()
 
void setText (const String &labelText)
 
void setLabelValue (Value &labelValue)
 Assign a Value object to the DropComponent Label text. This will assign a Listener to the given value, which will update the label with the Value when it chanes.
 
void paintButton (Graphics &g, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
 
bool isInterestedInDragSource (const SourceDetails &) override
 
void itemDragEnter (const SourceDetails &) override
 
void itemDragMove (const SourceDetails &) override
 
void itemDragExit (const SourceDetails &) override
 
void itemDropped (const SourceDetails &dragSourceDetails) override
 
var getDescription ()
 
String & getConnectedKwidgetID ()
 Returns the ID of the kwidget this drop component is assigning modulation to.
 
void setRoundedCorner (RoundedCorner cornerToRound, float cornerSize=4.0f)
 Sets which corners to draw as rounded and their size as a radius.
 
void setArmed (bool isArmed)
 Sets the component to draw with a visual indication that it has active modulation assigned to it.
 

Public Attributes

std::function< void(var desc)> onDropped
 

Static Public Attributes

static const Identifier DragSource {"DropComponent"}
 Set this identifier in your drag source component properties so DropComponent will be interested in it as a drag source.
 

Private Member Functions

void valueChanged (Value &value) override
 

Private Attributes

Label m_label
 
String m_connectedKwidgetID {""}
 
bool m_somethingIsBeingDraggedOver = false
 
var m_lastDesc
 
Value m_labelValue
 
RoundedCorner m_cornerToRound {RoundedCorner::All}
 
float m_cornerSize {4.0f}
 
const float m_defaultOpacity {0.5f}
 
const float m_hoverOpacity {1.0f}
 
const float m_hoverBrightnessAmount {0.055f}
 
const float m_armedHoverBrightnessAmount {0.15f}
 
bool m_armed {false}
 

Detailed Description

A component for dropping draggable juce objects onto.

Picks up a drag and drop event from within a DragAndDropContainer

Member Enumeration Documentation

◆ RoundedCorner

Rounded corner state enum.

Enumerator
TopLeft 
TopRight 
BottomLeft 
BottomRight 
Top 
Bottom 
All 
None 

Constructor & Destructor Documentation

◆ DropComponent()

krotos::krotos::DropComponent::DropComponent ( const String & labelText,
const String & kwidgetID = "" )

Constructs a new DropComponent with specified text for the label.

Member Function Documentation

◆ getConnectedKwidgetID()

String & krotos::DropComponent::getConnectedKwidgetID ( )
inline

Returns the ID of the kwidget this drop component is assigning modulation to.

◆ getDescription()

var krotos::DropComponent::getDescription ( )

◆ getLabel()

Label & krotos::krotos::DropComponent::getLabel ( )

Returns reference to the label displaying the button name.

◆ isInterestedInDragSource()

bool krotos::DropComponent::isInterestedInDragSource ( const SourceDetails & dragSourceDetails)
override

Here is where we can determine if we are interested in whatever is being dragged over.

◆ itemDragEnter()

void krotos::krotos::DropComponent::itemDragEnter ( const SourceDetails & )
override

◆ itemDragExit()

void krotos::DropComponent::itemDragExit ( const SourceDetails & )
override

◆ itemDragMove()

void krotos::DropComponent::itemDragMove ( const SourceDetails & )
override

◆ itemDropped()

void krotos::DropComponent::itemDropped ( const SourceDetails & dragSourceDetails)
override

◆ paintButton()

void krotos::DropComponent::paintButton ( Graphics & g,
bool shouldDrawButtonAsHighlighted,
bool shouldDrawButtonAsDown )
override

◆ resized()

void krotos::DropComponent::resized ( )
override

◆ setArmed()

void krotos::DropComponent::setArmed ( bool isArmed)

Sets the component to draw with a visual indication that it has active modulation assigned to it.

Parameters
isArmedDraw the component in the armed visual state.

◆ setLabelValue()

void krotos::DropComponent::setLabelValue ( Value & labelValue)

Assign a Value object to the DropComponent Label text. This will assign a Listener to the given value, which will update the label with the Value when it chanes.

◆ setRoundedCorner()

void krotos::DropComponent::setRoundedCorner ( RoundedCorner cornerToRound,
float cornerSize = 4.0f )
inline

Sets which corners to draw as rounded and their size as a radius.

◆ setText()

void krotos::DropComponent::setText ( const String & labelText)

Set the label text from string. Note: If A Value has been assigned to the label with setLabelValue(), the label will be overwritten when that Value object changes.

◆ valueChanged()

void krotos::DropComponent::valueChanged ( Value & value)
overrideprivate

Member Data Documentation

◆ DragSource

const Identifier krotos::DropComponent::DragSource {"DropComponent"}
static

Set this identifier in your drag source component properties so DropComponent will be interested in it as a drag source.

e.g. In the constructor of your component that you want DropComponent to be interested in as a drag source, call getProperties().set(DropComponent::DragSource, "MyComponentID")

See also
juce::DragAndDropTarget::isInterestedInDragSource, juce::Component::getProperties

◆ m_armed

bool krotos::DropComponent::m_armed {false}
private

◆ m_armedHoverBrightnessAmount

const float krotos::DropComponent::m_armedHoverBrightnessAmount {0.15f}
private

◆ m_connectedKwidgetID

String krotos::DropComponent::m_connectedKwidgetID {""}
private

◆ m_cornerSize

float krotos::DropComponent::m_cornerSize {4.0f}
private

◆ m_cornerToRound

RoundedCorner krotos::DropComponent::m_cornerToRound {RoundedCorner::All}
private

◆ m_defaultOpacity

const float krotos::DropComponent::m_defaultOpacity {0.5f}
private

◆ m_hoverBrightnessAmount

const float krotos::DropComponent::m_hoverBrightnessAmount {0.055f}
private

◆ m_hoverOpacity

const float krotos::DropComponent::m_hoverOpacity {1.0f}
private

◆ m_label

Label krotos::DropComponent::m_label
private

◆ m_labelValue

Value krotos::DropComponent::m_labelValue
private

◆ m_lastDesc

var krotos::DropComponent::m_lastDesc
private

◆ m_somethingIsBeingDraggedOver

bool krotos::DropComponent::m_somethingIsBeingDraggedOver = false
private

◆ onDropped

std::function<void(var desc)> krotos::DropComponent::onDropped

Callback lambda for itemDropped, passing the dragSource description.


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