26#include "guillaume/entities/floating_action_button_menu.hpp"
27#include "guillaume/entities/builder_base.hpp"
28#include "guillaume/entities/extended_floating_action_button.hpp"
29#include "guillaume/entities/floating_action_button.hpp"
30#include "guillaume/systems/floating_action_button_menu.hpp"
43 std::shared_ptr<FloatingActionButtonMenu>
54 _iconGlyphName.clear();
56 _accessibilityLabel.clear();
61 const std::string &iconGlyphName)
63 _iconGlyphName = iconGlyphName;
69 const std::string &iconGlyphName, std::function<
void(
void)> onClick)
71 _actions.push_back(
Action {
"", iconGlyphName, std::move(onClick) });
77 const std::string &iconGlyphName,
const std::string &label,
78 std::function<
void(
void)> onClick)
80 _actions.push_back(
Action { label, iconGlyphName, std::move(onClick) });
86 const std::string &accessibilityLabel)
88 _accessibilityLabel = accessibilityLabel;
92 std::shared_ptr<FloatingActionButtonMenu>
94 std::shared_ptr<Entity> parent,
const std::string &iconGlyphName)
96 return withIcon(iconGlyphName).registerEntity(parent);
99 FloatingActionButtonMenu::FloatingActionButtonMenu(
101 const std::vector<Action> &actions,
102 const std::string &accessibilityLabel)
109 .setIconGlyphName(iconGlyphName)
111 .setAccessibilityLabel(accessibilityLabel);
128 FloatingActionButtonMenu::state(
void)
const
157 std::function<
void(
bool)> onStateChange)
170 return state().getActionButtons().size();
176 return state().getTrigger();
182 const auto &buttons = state().getActionButtons();
184 return index < buttons.size() ? buttons[index]
188 void FloatingActionButtonMenu::build(
void)
193 const std::vector<Action> actions = state().
getActions();
197 const auto trigger = triggerBuilder.makeFloatingActionButton(
198 shared_from_this(), iconGlyphName, std::function<
void(
void)>(),
199 FloatingActionButton::Variant::Primary,
200 FloatingActionButton::Size::Medium);
204 std::vector<ecs::Entity::Identifier> identifiers;
206 for (
const auto &action: actions) {
207 std::shared_ptr<ButtonBase> button;
209 if (action.label.empty()) {
210 button = actionBuilder.makeFloatingActionButton(
211 shared_from_this(), action.iconGlyphName,
212 std::function<
void(
void)>(),
213 FloatingActionButton::Variant::Surface,
214 FloatingActionButton::Size::Small);
218 labelledBuilder.withIcon(action.iconGlyphName)
219 .withLabel(action.label)
221 ExtendedFloatingActionButton::Variant::Surface)
222 .withSize(ExtendedFloatingActionButton::Size::Small)
223 .withAccessibilityLabel(action.label)
224 .registerEntity(shared_from_this());
227 identifiers.push_back(button->getIdentifier());
231 .setTrigger(trigger->getIdentifier())
232 .setActionButtons(identifiers);
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
ComponentRegistry & getComponentRegistry(void)
Get the registry in which the builder creates components.
Owns entities and gives the systems the list of entities to visit.
Entity::Identifier getIdentifier(void) const noexcept
Get the identifier of the entity.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
ParentEntityFiller(ComponentRegistry &componentRegistry)
ComponentRegistry & getComponentRegistry(void)
EntityBuilderBase(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Widgets: the classes used to create entities with the right components and children.