2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-12-08 18:50:23 +03:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-15 04:09:00 +03:00
|
|
|
#include <AK/OwnPtr.h>
|
2021-01-21 22:55:37 +03:00
|
|
|
#include <LibCore/MimeData.h>
|
2020-02-06 17:04:03 +03:00
|
|
|
#include <LibCore/Object.h>
|
2020-02-16 11:17:49 +03:00
|
|
|
#include <LibGUI/Forward.h>
|
2020-02-15 02:10:34 +03:00
|
|
|
#include <LibGfx/Forward.h>
|
2019-12-08 18:50:23 +03:00
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class DragOperation : public Core::Object {
|
|
|
|
C_OBJECT(DragOperation)
|
2019-12-08 18:50:23 +03:00
|
|
|
public:
|
|
|
|
enum class Outcome {
|
|
|
|
None,
|
|
|
|
Accepted,
|
|
|
|
Cancelled,
|
|
|
|
};
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
virtual ~DragOperation() override;
|
2019-12-08 18:50:23 +03:00
|
|
|
|
2020-11-07 22:44:21 +03:00
|
|
|
void set_mime_data(RefPtr<Core::MimeData> mime_data) { m_mime_data = move(mime_data); }
|
|
|
|
void set_text(const String& text);
|
|
|
|
void set_bitmap(const Gfx::Bitmap* bitmap);
|
|
|
|
void set_data(const String& data_type, const String& data);
|
2019-12-08 18:50:23 +03:00
|
|
|
|
|
|
|
Outcome exec();
|
|
|
|
Outcome outcome() const { return m_outcome; }
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
static void notify_accepted(Badge<WindowServerConnection>);
|
|
|
|
static void notify_cancelled(Badge<WindowServerConnection>);
|
2019-12-08 18:50:23 +03:00
|
|
|
|
|
|
|
protected:
|
2020-02-02 17:07:41 +03:00
|
|
|
explicit DragOperation(Core::Object* parent = nullptr);
|
2019-12-08 18:50:23 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
void done(Outcome);
|
|
|
|
|
2020-02-02 14:34:39 +03:00
|
|
|
OwnPtr<Core::EventLoop> m_event_loop;
|
2019-12-08 18:50:23 +03:00
|
|
|
Outcome m_outcome { Outcome::None };
|
2020-11-07 22:44:21 +03:00
|
|
|
RefPtr<Core::MimeData> m_mime_data;
|
2019-12-08 18:50:23 +03:00
|
|
|
};
|
2020-02-02 17:07:41 +03:00
|
|
|
|
|
|
|
}
|