2018-10-12 01:03:22 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
#include "GObject.h"
|
2019-01-19 23:49:56 +01:00
|
|
|
#include <SharedGraphics/Rect.h>
|
|
|
|
|
#include <SharedGraphics/GraphicsBitmap.h>
|
2018-12-21 02:18:16 +01:00
|
|
|
#include <AK/AKString.h>
|
2019-01-27 08:48:34 +01:00
|
|
|
#include <AK/WeakPtr.h>
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2019-01-20 05:48:43 +01:00
|
|
|
class GWidget;
|
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
class GWindow final : public GObject {
|
2018-10-12 01:03:22 +02:00
|
|
|
public:
|
2019-01-20 05:48:43 +01:00
|
|
|
GWindow(GObject* parent = nullptr);
|
2019-01-20 04:49:48 +01:00
|
|
|
virtual ~GWindow() override;
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2019-01-20 05:48:43 +01:00
|
|
|
static GWindow* from_window_id(int);
|
|
|
|
|
|
2019-02-19 01:42:53 +01:00
|
|
|
void set_has_alpha_channel(bool);
|
|
|
|
|
void set_opacity(float);
|
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
int window_id() const { return m_window_id; }
|
|
|
|
|
|
2019-01-26 05:20:32 +01:00
|
|
|
String title() const;
|
2019-01-16 13:49:44 +01:00
|
|
|
void set_title(String&&);
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2019-01-24 23:40:12 +01:00
|
|
|
int x() const { return rect().x(); }
|
|
|
|
|
int y() const { return rect().y(); }
|
|
|
|
|
int width() const { return rect().width(); }
|
|
|
|
|
int height() const { return rect().height(); }
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2019-01-24 23:40:12 +01:00
|
|
|
Rect rect() const;
|
2019-02-10 14:28:39 +01:00
|
|
|
Size size() const { return rect().size(); }
|
2019-01-16 13:49:44 +01:00
|
|
|
void set_rect(const Rect&);
|
2019-02-08 00:14:37 +01:00
|
|
|
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
2018-10-12 01:03:22 +02:00
|
|
|
|
2019-01-24 23:40:12 +01:00
|
|
|
Point position() const { return rect().location(); }
|
2018-10-12 02:24:05 +02:00
|
|
|
|
2019-02-11 06:09:54 +01:00
|
|
|
void move_to(int x, int y) { move_to({ x, y }); }
|
|
|
|
|
void move_to(const Point& point) { set_rect({ point, size() }); }
|
|
|
|
|
|
2019-01-20 04:49:48 +01:00
|
|
|
virtual void event(GEvent&) override;
|
2018-10-12 01:26:20 +02:00
|
|
|
|
2019-01-16 13:49:44 +01:00
|
|
|
bool is_visible() const;
|
2019-01-26 21:58:43 +01:00
|
|
|
bool is_active() const { return m_is_active; }
|
2018-10-14 01:23:01 +02:00
|
|
|
|
2019-01-30 20:03:52 +01:00
|
|
|
void show();
|
|
|
|
|
void hide();
|
2018-10-14 00:21:42 +02:00
|
|
|
void close();
|
|
|
|
|
|
2019-01-20 07:56:48 +01:00
|
|
|
GWidget* main_widget() { return m_main_widget; }
|
|
|
|
|
const GWidget* main_widget() const { return m_main_widget; }
|
2019-01-20 05:48:43 +01:00
|
|
|
void set_main_widget(GWidget*);
|
2019-01-26 11:24:16 +01:00
|
|
|
|
|
|
|
|
GWidget* focused_widget() { return m_focused_widget; }
|
|
|
|
|
const GWidget* focused_widget() const { return m_focused_widget; }
|
2019-01-26 06:39:13 +01:00
|
|
|
void set_focused_widget(GWidget*);
|
2019-01-20 05:48:43 +01:00
|
|
|
|
2019-01-26 05:20:32 +01:00
|
|
|
void update(const Rect& = Rect());
|
2019-01-20 05:48:43 +01:00
|
|
|
|
2019-01-27 08:48:34 +01:00
|
|
|
void set_global_cursor_tracking_widget(GWidget*);
|
|
|
|
|
GWidget* global_cursor_tracking_widget() { return m_global_cursor_tracking_widget.ptr(); }
|
|
|
|
|
const GWidget* global_cursor_tracking_widget() const { return m_global_cursor_tracking_widget.ptr(); }
|
|
|
|
|
|
2019-02-05 10:31:37 +01:00
|
|
|
bool should_exit_app_on_close() const { return m_should_exit_app_on_close; }
|
|
|
|
|
void set_should_exit_app_on_close(bool b) { m_should_exit_app_on_close = b; }
|
|
|
|
|
|
2018-10-12 01:03:22 +02:00
|
|
|
private:
|
2019-02-10 14:28:39 +01:00
|
|
|
virtual const char* class_name() const override { return "GWindow"; }
|
|
|
|
|
|
2019-01-09 02:06:04 +01:00
|
|
|
RetainPtr<GraphicsBitmap> m_backing;
|
2019-01-30 20:03:52 +01:00
|
|
|
int m_window_id { 0 };
|
2019-02-19 01:42:53 +01:00
|
|
|
float m_opacity_when_windowless { 1.0f };
|
2019-01-20 05:48:43 +01:00
|
|
|
GWidget* m_main_widget { nullptr };
|
2019-01-26 06:39:13 +01:00
|
|
|
GWidget* m_focused_widget { nullptr };
|
2019-01-27 08:48:34 +01:00
|
|
|
WeakPtr<GWidget> m_global_cursor_tracking_widget;
|
2019-01-30 20:03:52 +01:00
|
|
|
Rect m_rect_when_windowless;
|
|
|
|
|
String m_title_when_windowless;
|
2019-02-10 14:46:43 +01:00
|
|
|
Vector<Rect> m_pending_paint_event_rects;
|
2019-02-19 01:42:53 +01:00
|
|
|
bool m_is_active { false };
|
2019-02-05 10:31:37 +01:00
|
|
|
bool m_should_exit_app_on_close { false };
|
2019-02-19 01:42:53 +01:00
|
|
|
bool m_has_alpha_channel { false };
|
2018-10-12 01:03:22 +02:00
|
|
|
};
|
|
|
|
|
|