Loading...
Searching...
No Matches
ml::ToolbarWidget Struct Referenceabstract

Interface for components that register a button+action in a toolbar. More...

#include <Malena/Traits/Communication/ToolbarWidget.h>

Public Types

enum class  Hook { REGISTER }

Public Member Functions

virtual ~ToolbarWidget ()=default
virtual std::function< void()> getToolbarAction ()=0
virtual std::string getToolbarLabel ()=0

Detailed Description

Interface for components that register a button+action in a toolbar.

Inherit ToolbarWidget alongside Hookable and call sendHook(ml::ToolbarWidget::Hook::REGISTER) to add a labelled action button to whatever shell is listening.

Usage

class MyAction : public ml::ToolbarWidget, public ml::Hookable {
std::string getToolbarLabel() override { return "Export"; }
std::function<void()> getToolbarAction() override { return [this]{ doExport(); }; }
};
// In shell registerHooks():
onHook(ml::ToolbarWidget::Hook::REGISTER, [this](ml::ToolbarWidget& w) {
_toolbar.addButton(w.getToolbarLabel(), w.getToolbarAction());
});
Trait that layers a hook system on top of ml::Messenger.
Definition Hookable.h:43
Interface for components that register a button+action in a toolbar.
virtual std::string getToolbarLabel()=0
virtual std::function< void()> getToolbarAction()=0
See also
SplitPaneWidget, OverlayWidget

Definition at line 38 of file ToolbarWidget.h.

Member Enumeration Documentation

◆ Hook

enum class ml::ToolbarWidget::Hook
strong
Enumerator
REGISTER 

Definition at line 40 of file ToolbarWidget.h.

Constructor & Destructor Documentation

◆ ~ToolbarWidget()

virtual ml::ToolbarWidget::~ToolbarWidget ( )
virtualdefault

Member Function Documentation

◆ getToolbarAction()

virtual std::function< void()> ml::ToolbarWidget::getToolbarAction ( )
pure virtual

◆ getToolbarLabel()

virtual std::string ml::ToolbarWidget::getToolbarLabel ( )
pure virtual

The documentation for this struct was generated from the following file: