2019-02-12 14:09:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/AKString.h>
|
|
|
|
#include <AK/Function.h>
|
2019-02-20 02:39:46 +01:00
|
|
|
#include <AK/Retainable.h>
|
|
|
|
#include <AK/RetainPtr.h>
|
|
|
|
#include <SharedGraphics/GraphicsBitmap.h>
|
2019-02-12 14:09:48 +01:00
|
|
|
|
2019-02-20 02:39:46 +01:00
|
|
|
class GAction : public Retainable<GAction> {
|
2019-02-12 14:09:48 +01:00
|
|
|
public:
|
2019-02-20 02:39:46 +01:00
|
|
|
static RetainPtr<GAction> create(const String& text, Function<void(const GAction&)> callback)
|
|
|
|
{
|
|
|
|
return adopt(*new GAction(text, move(callback)));
|
|
|
|
}
|
|
|
|
static RetainPtr<GAction> create(const String& text, const String& custom_data, Function<void(const GAction&)> callback)
|
|
|
|
{
|
|
|
|
return adopt(*new GAction(text, custom_data, move(callback)));
|
|
|
|
}
|
|
|
|
static RetainPtr<GAction> create(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> callback)
|
|
|
|
{
|
|
|
|
return adopt(*new GAction(text, move(icon), move(callback)));
|
|
|
|
}
|
2019-02-12 14:09:48 +01:00
|
|
|
~GAction();
|
|
|
|
|
|
|
|
String text() const { return m_text; }
|
|
|
|
String custom_data() const { return m_custom_data; }
|
2019-02-20 02:39:46 +01:00
|
|
|
const GraphicsBitmap* icon() const { return m_icon.ptr(); }
|
2019-02-12 14:09:48 +01:00
|
|
|
|
|
|
|
Function<void(GAction&)> on_activation;
|
|
|
|
|
|
|
|
void activate();
|
|
|
|
|
|
|
|
private:
|
2019-02-20 02:39:46 +01:00
|
|
|
GAction(const String& text, Function<void(const GAction&)> = nullptr);
|
|
|
|
GAction(const String& text, RetainPtr<GraphicsBitmap>&& icon, Function<void(const GAction&)> = nullptr);
|
|
|
|
GAction(const String& text, const String& custom_data = String(), Function<void(const GAction&)> = nullptr);
|
|
|
|
|
2019-02-12 14:09:48 +01:00
|
|
|
String m_text;
|
|
|
|
String m_custom_data;
|
2019-02-20 02:39:46 +01:00
|
|
|
RetainPtr<GraphicsBitmap> m_icon;
|
2019-02-12 14:09:48 +01:00
|
|
|
};
|
|
|
|
|