|
MT Showcase SDK
|
This is a base class for components that provide UI functionality. More...
#include <UIComponent.hpp>
Public Member Functions | |
| UIComponent (CachedGraphPtr uiGraph=nullptr) | |
| Create a new UIComponent. More... | |
| std::vector< std::shared_ptr < UIComponent > > | assignments (const QByteArray &slot) const |
| List of components assigned to slot. More... | |
| const Slots & | componentSlots () const |
| Slots of this component. More... | |
| const std::unordered_set < QByteArray > & | roles () const |
| Roles that this component will implement. More... | |
| QByteArray | subtype () const |
| The subtype of this component. More... | |
| UIComponentInstancePtr | createInstance (const QByteArray &role) |
| Create a new instance of this component with the given role. More... | |
| void | assignToSlot (const QByteArray &slotName, std::shared_ptr< UIComponent > comp) |
| Add the given component to this component's slot. More... | |
| void | componentAddedToSlot (const QByteArray &slotName, std::shared_ptr< UIComponent > comp) |
| Callback, that is called when one of the child components has finished. More... | |
| void | componentRemovedFromSlot (const QByteArray &slotName, std::shared_ptr< UIComponent > comp) |
| Callback, that is called when one of the child components has been removed. More... | |
| bool | slotsFulfilled (const std::unique_lock< std::mutex > &lock=std::unique_lock< std::mutex >()) const |
| Checks if the component is ready to be instanced (it has all the slots in place) More... | |
| void | setOnSlotsFulfilled (std::function< void(void)> &&f) |
| Set component to execute lambda when slots are fulfilled. More... | |
| void | setOnSlotsUnfulfilled (std::function< void(void)> &&f) |
| Set component to execute lambda when slots were previously fulfilled and become unfulfilled. More... | |
| void | removeFromSlots (const NodeId &id) |
| Remove all instances of the given node id from this component's slots. More... | |
| void | initializeContentSlot (const Slot &slot, const Property &property) |
| Initialize a new content slot. More... | |
| void | removeContentSlot (const Slot &slot) |
| Remove content from given slot. More... | |
| bool | enabled () const |
| Components are enabled by default, but they can be disabled in certain circumstances. More... | |
| void | setEnabled (bool enabled) |
| Set component enabled or disabled. More... | |
Public Member Functions inherited from Showcase::Component | |
| Component (CachedGraphPtr uiGraph=nullptr) | |
| Create a new component. More... | |
| void | setCachedGraph (CachedGraphPtr uiGraph) |
| Showcase nodes are stored in cached graphs. More... | |
| void | init (const GraphNode &confNode) |
| Initializes the component and links it to the given graph node. More... | |
| const QString & | name () const |
| Each component has a unique name that identifies it. More... | |
| void | setComponentName (const QString &name) |
| Set a new name for this coomponent. More... | |
| void | setSchema (const Schema &schema) |
| Schema holds the definition of the component. More... | |
| const Schema & | schema () const |
| Get the schema of this component. More... | |
| ComponentInstancePtr | createInstance () |
| A single component can have multiple instances, each instance behaves independently from one another, but is tied to the creator component. More... | |
| void | instanceDestroyed (ComponentInstanceKey key) |
| Component keeps track of its instances, and must be notified when an instance is destroyed. More... | |
| size_t | numInstances () const |
| Returns the current number of alive instances created from this component. More... | |
| CachedGraphPtr | cachedGraph () const |
| Returns the cached graph that this component is part of. More... | |
| CachedNodePtr | cachedNode () const |
| Returns the cached graph node that links to this component. More... | |
| const NodeId & | nodeId () const |
| Returns the node id of this component's cached node. More... | |
| const std::list < ComponentInstancePtr > & | instances () const |
| Returns all current instances of this component. More... | |
Protected Member Functions | |
| bool | acceptContentProperty (const PropertyKey &key) const |
| Filters non relevant content properties away. | |
| virtual void | placeholderStatusChanged (const NodeId &id) override |
| virtual void | propertyReceived (const Property &property) override |
| Need to override because some 'slots' (content), may hide in attributes. More... | |
| virtual void | contentNodeReceivedProperty (std::shared_ptr< ContentNode > node, const Property &prop, bool eventWasPending=false) |
| These just passes the correspongind callbacks to instances. More... | |
| virtual void | contentNodeLostProperty (std::shared_ptr< ContentNode > node, const Property &prop, bool eventWasPending=false) |
| virtual void | contentNodeFound (std::shared_ptr< ContentNode > node, std::shared_ptr< ContentNode > parent=nullptr, bool eventWasPending=false) |
| These just passes the correspongind callbacks to instances, When this is called, it must be that found node is 'complete'. More... | |
| virtual void | contentNodeLost (std::shared_ptr< ContentNode > node, std::shared_ptr< ContentNode > parent=nullptr, bool eventWasPending=false) |
Protected Member Functions inherited from Showcase::Component | |
| void | applyForInstances (std::function< void(ComponentInstancePtr)> &&f) |
| Calls f for each instance. | |
This is a base class for components that provide UI functionality.
| Showcase::UIComponent::UIComponent | ( | CachedGraphPtr | uiGraph = nullptr | ) |
Create a new UIComponent.
| uiGraph | the cached graph for the component |
| std::vector< UIComponentPtr > Showcase::UIComponent::assignments | ( | const QByteArray & | slot | ) | const |
List of components assigned to slot.
| slot | name of the slot |
| void Showcase::UIComponent::assignToSlot | ( | const QByteArray & | slotName, |
| std::shared_ptr< UIComponent > | comp | ||
| ) |
Add the given component to this component's slot.
| slotName | name of the slot |
| comp | component to add |
Error! what to do?
| void Showcase::UIComponent::componentAddedToSlot | ( | const QByteArray & | slotName, |
| std::shared_ptr< UIComponent > | comp | ||
| ) |
Callback, that is called when one of the child components has finished.
By default just propagates event to instances
| slotName | name of the slot |
| comp | component that was added |
| void Showcase::UIComponent::componentRemovedFromSlot | ( | const QByteArray & | slotName, |
| std::shared_ptr< UIComponent > | comp | ||
| ) |
Callback, that is called when one of the child components has been removed.
By default just propagates event to instances
| slotName | name of the slot |
| comp | component that was removed |
| const Slots & Showcase::UIComponent::componentSlots | ( | ) | const |
Slots of this component.
This will specify what roles this component will accept.
|
protectedvirtual |
These just passes the correspongind callbacks to instances, When this is called, it must be that found node is 'complete'.
If we're currently setting content to an instance, don't handle new events yet, queue them and handle later
|
protectedvirtual |
If we're currently setting content to an instance, don't handle new events yet, queue them and handle later
|
protectedvirtual |
If we're currently setting content to an instance, don't handle new events yet, queue them and handle later
|
protectedvirtual |
These just passes the correspongind callbacks to instances.
If we're currently setting content to an instance, don't handle new events yet, queue them and handle later
| UIComponentInstancePtr Showcase::UIComponent::createInstance | ( | const QByteArray & | role | ) |
Create a new instance of this component with the given role.
| which | role the component is created into |
| bool Showcase::UIComponent::enabled | ( | ) | const |
Components are enabled by default, but they can be disabled in certain circumstances.
| void Showcase::UIComponent::initializeContentSlot | ( | const Slot & | slot, |
| const Property & | property | ||
| ) |
Initialize a new content slot.
below content stuff
| slot | slot the content set is assigned to |
| property | property that holds the data for creating content root node |
|
overrideprotectedvirtual |
Not ready or no placeholder, either way destroy the subcomponent
Implements Showcase::Component.
|
overrideprotectedvirtual |
Need to override because some 'slots' (content), may hide in attributes.
If any children were already attached to this slot, remove them first. Make sure that LOST events are sent before FOUND event.
Reimplemented from Showcase::Component.
| void Showcase::UIComponent::removeContentSlot | ( | const Slot & | slot | ) |
Remove content from given slot.
| slot | slot the content set is removed from |
| void Showcase::UIComponent::removeFromSlots | ( | const NodeId & | id | ) |
Remove all instances of the given node id from this component's slots.
| id | node id to remove |
A somewhat unefficient way
| const std::unordered_set< QByteArray > & Showcase::UIComponent::roles | ( | ) | const |
Roles that this component will implement.
This determines the slots this component can be added to
| void Showcase::UIComponent::setEnabled | ( | bool | enabled | ) |
Set component enabled or disabled.
If component is disabled, all its instances are removed
| void Showcase::UIComponent::setOnSlotsFulfilled | ( | std::function< void(void)> && | f | ) |
Set component to execute lambda when slots are fulfilled.
This is needed to propagate 'slots fulfilled' -event in the ui component hierarchy
| f | lambda to execute |
| void Showcase::UIComponent::setOnSlotsUnfulfilled | ( | std::function< void(void)> && | f | ) |
Set component to execute lambda when slots were previously fulfilled and become unfulfilled.
| f | lambda to execute |
| bool Showcase::UIComponent::slotsFulfilled | ( | const std::unique_lock< std::mutex > & | lock = std::unique_lock<std::mutex>() | ) | const |
Checks if the component is ready to be instanced (it has all the slots in place)
| lock | mutex used to lock the component tree while checking |
| QByteArray Showcase::UIComponent::subtype | ( | ) | const |
The subtype of this component.
Will be empty if component has no subtype