1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 14:15:08 +00:00
serenity/Libraries/LibGUI/GDragOperation.h
Andreas Kling f5dfb29607 LibGUI+WindowServer: Allow specifying an optional drag bitmap
This bitmap is displayed alongside the dragged text underneath the
mouse cursor while dragging.

This will be a perfect fit for dragging e.g files around. :^)
2019-12-08 17:08:39 +01:00

39 lines
905 B
C++

#pragma once
#include <LibCore/CEventLoop.h>
#include <LibCore/CObject.h>
class GraphicsBitmap;
class GWindowServerConnection;
class GDragOperation : public CObject {
C_OBJECT(GDragOperation)
public:
enum class Outcome {
None,
Accepted,
Cancelled,
};
virtual ~GDragOperation() override;
void set_text(const String& text) { m_text = text; }
void set_bitmap(const GraphicsBitmap* bitmap) { m_bitmap = bitmap; }
Outcome exec();
Outcome outcome() const { return m_outcome; }
static void notify_accepted(Badge<GWindowServerConnection>);
static void notify_cancelled(Badge<GWindowServerConnection>);
protected:
explicit GDragOperation(CObject* parent = nullptr);
private:
void done(Outcome);
OwnPtr<CEventLoop> m_event_loop;
Outcome m_outcome { Outcome::None };
String m_text;
RefPtr<GraphicsBitmap> m_bitmap;
};