A pop-up column of pressable items, shown on demand next to an anchor entity (Paper Menu and Menu.Item).
More...
|
|
| ~Menu (void) override=default |
| | Default destructor.
|
| Menu & | setVariant (Variant variant) |
| | Change the variant stored in components::Menu.
|
| Variant | getVariant (void) const |
| | Get the variant.
|
| Menu & | setMode (Mode mode) |
| | Change the surface mode (Paper mode). Restyles at once.
|
| Mode | getMode (void) const |
| | Get the surface mode.
|
| Menu & | setItems (const std::vector< Item > &items) |
| | Replace the items.
|
| std::size_t | getItemCount (void) const |
| | Get the number of items.
|
| ecs::Entity::Identifier | getItemIdentifier (std::size_t index) const |
| | Get the row entity of an item: the pressable container of its icons and label.
|
| Menu & | setItemDisabled (std::size_t index, bool disabled) |
| | Enable or disable an item. Restyles at once.
|
| Menu & | setAnchor (ecs::Entity::Identifier anchor) |
| | Anchor the menu to another entity.
|
| ecs::Entity::Identifier | getAnchor (void) const |
| | Get the anchor entity.
|
| Menu & | setAnchorPosition (AnchorPosition position) |
| | Choose on which side of its anchor the menu opens. Moves the menu at once.
|
| AnchorPosition | getAnchorPosition (void) const |
| | Get the side of the anchor the menu opens on.
|
| Menu & | setOnDismiss (std::function< void(void)> onDismiss) |
| | Set the handler called when the menu is dismissed (Paper onDismiss).
|
| Menu & | dismiss (void) |
| | Close the menu as the user would: hide it, then call the dismiss handler.
|
| Menu & | open (void) |
| | Open the menu. Same as show().
|
| Menu & | close (void) |
| | Close the menu without calling the dismiss handler. Same as hide().
|
| bool | isOpen (void) const |
| | Whether the menu is open. Same as isVisible().
|
| Menu & | show (void) |
| | Move the menu next to its anchor, then show it.
|
| Menu & | hide (void) |
| | Hide the menu without calling the dismiss handler.
|
| bool | isVisible (void) const |
| | Whether the menu is shown.
|
|
| ~SurfaceBase (void) override=default |
| | Default destructor.
|
| SurfaceBase & | setPose (const utility::graphic::PoseF &pose) |
| | Move the surface.
|
| SurfaceBase & | setColor (const utility::graphic::Color32Bit &color) |
| | Set the fill color (Color component).
|
| SurfaceBase & | setBorderRadius (float radius) |
| | Set the radius of the four corners (Borders component).
|
| SurfaceBase & | setSurfaceConfig (const SurfaceConfig &config) |
| | Apply every field of a configuration at once.
|
| SurfaceConfig | getSurfaceConfig (void) const |
| | Read the current configuration back from the components.
|
| SurfaceBase & | setChildren (const Children &children) |
| | Choose the children this surface arranges, in order.
|
| std::vector< ecs::Entity::Identifier > | getChildren (void) const |
| | Get the children this surface arranges.
|
| | ParentEntityFiller (ComponentRegistry &componentRegistry) |
| | Create the entity, its listed components and its components::Hierarchy. It owns no child yet.
|
|
virtual | ~ParentEntityFiller (void)=default |
| | Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity).
|
| | Entity (void) |
| | Create an entity with a fresh identifier, an empty signature, no parent and no component.
|
| virtual | ~Entity (void)=default |
| | Destroy the entity object.
|
| Entity::Identifier | getIdentifier (void) const noexcept |
| | Get the identifier of the entity.
|
| Entity::Signature | getSignature (void) const noexcept |
| | Get the set of component types the entity declares.
|
| void | setSignature (const Signature &signature) |
| | Replace the signature of the entity.
|
| std::int32_t | getLayer (void) const noexcept |
| | Get the depth of the entity in the tree.
|
| Entity & | setParent (std::shared_ptr< Entity > parent) |
| | Attach the entity under another one, or detach it.
|
| std::vector< Identifier > | releaseComponents (void) |
| | Drop the entity's place in the tree and all its components.
|
| std::shared_ptr< Entity > | getParent (void) const noexcept |
| | Get the parent entity.
|
|
| EntityRegistry (void)=default |
| | Create a registry.
|
| virtual | ~EntityRegistry (void)=default |
| | Virtual destructor.
|
| void | addEntity (std::shared_ptr< Entity > entity) |
| | Make this registry own an entity, so that it stays alive and systems visit it.
|
| bool | removeEntity (Entity::Identifier identifier) |
| | Remove an entity, with its children and all their components.
|
| void | clearEntities (void) |
| | Remove every entity owned by this registry, with everything they own and all their components.
|
| const std::vector< std::shared_ptr< Entity > > & | getEntities (void) const |
| | Get the entities this registry owns directly.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) |
| | List every entity of this registry and of the registries nested in it, level by level.
|
| std::vector< std::shared_ptr< Entity > > | getEntitiesBreadthFirst (void) const |
| | List every entity of this registry and of the registries nested in it, level by level (const overload).
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< EntityType > | getEntity (Entity::Identifier identifier) |
| | Find an entity owned directly by this registry, by identifier.
|
| template<InheritFromEntity EntityType> |
| std::shared_ptr< const EntityType > | getEntity (Entity::Identifier identifier) const |
| | Find an entity owned directly by this registry, by identifier (const overload).
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature) const |
| | List the entities that have every component type of a signature, from the root down.
|
| std::vector< Entity::Identifier > | getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const |
| | List the entities that have every component type of a signature, in the order chosen by a traveler.
|
A pop-up column of pressable items, shown on demand next to an anchor entity (Paper Menu and Menu.Item).
Its state lives in components::Menu (variant, mode, items, row identifiers, anchor); whether it is shown and its dismiss handler live in components::Overlay. systems::Menu styles the menu, sizes its rows and moves it next to its anchor each frame, in the Layout phase. The class itself holds no field: it builds the row entities, and its setters write the component and restyle at once.
};
auto menu = builder.addItem("Rename", "edit")
.addItem(remove)
.makeMenu(parent, Menu::Variant::Dropdown, {});
menu->setAnchor(button->getIdentifier());
menu->open();
ComponentRegistry & getComponentRegistry(void)
Menu::create(registry, config, variant, items) builds the same widget without registering it in an entity registry.
Things to know:
- The menu is closed at creation: call open().
- Pressing an item calls its press handler and leaves the menu open; close it from the handler when needed.
- close() and hide() do not call the dismiss handler themselves; dismiss() and Escape do.
- Each row holds an optional leading icon, a label and an optional trailing icon. A row is 48 dp high, or 32 dp when the item is dense. The width follows the widest row, kept between MinWidth (112 dp) and MaxWidth (280 dp); it is overwritten each frame, like the menu's layout, color, corners, elevation and overlay flags.
- With an anchor, the pose is overwritten each frame: the menu takes the position of the anchor and sits 4 dp below or above it. Without one, the menu stays at the pose it was given.
- The variant is stored but systems::Menu does not read it: the three variants look and behave the same.
- The menu is the entity registry that owns its rows. setItems() removes every row and builds new ones: identifiers returned before by getItemIdentifier() are then invalid.
- See also
- components::Menu, systems::Menu, components::Overlay
Definition at line 103 of file menu.hpp.