2019-01-16 16:03:50 +01:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-19 23:22:46 +01:00
|
|
|
#include <SharedGraphics/Rect.h>
|
|
|
|
#include <SharedGraphics/GraphicsBitmap.h>
|
2019-01-16 16:03:50 +01:00
|
|
|
#include <AK/AKString.h>
|
|
|
|
#include <AK/InlineLinkedList.h>
|
2019-01-26 05:28:02 +01:00
|
|
|
#include "WSMessageReceiver.h"
|
2019-02-12 11:53:45 +01:00
|
|
|
#include <WindowServer/WSWindowType.h>
|
2019-01-16 16:03:50 +01:00
|
|
|
|
2019-02-17 08:54:57 +01:00
|
|
|
class WSClientConnection;
|
2019-02-11 09:47:10 +01:00
|
|
|
class WSMenu;
|
2019-01-16 16:03:50 +01:00
|
|
|
|
2019-01-26 05:28:02 +01:00
|
|
|
class WSWindow final : public WSMessageReceiver, public InlineLinkedListNode<WSWindow> {
|
2019-01-16 16:03:50 +01:00
|
|
|
public:
|
2019-02-17 08:54:57 +01:00
|
|
|
WSWindow(WSClientConnection&, int window_id);
|
2019-02-11 09:47:10 +01:00
|
|
|
explicit WSWindow(WSMenu&);
|
2019-01-16 16:03:50 +01:00
|
|
|
virtual ~WSWindow() override;
|
|
|
|
|
2019-02-17 08:54:57 +01:00
|
|
|
WSClientConnection* client() { return m_client; }
|
|
|
|
const WSClientConnection* client() const { return m_client; }
|
2019-02-13 00:19:21 +01:00
|
|
|
|
2019-02-12 11:53:45 +01:00
|
|
|
WSWindowType type() const { return m_type; }
|
2019-01-16 16:03:50 +01:00
|
|
|
int window_id() const { return m_window_id; }
|
|
|
|
|
|
|
|
String title() const { return m_title; }
|
|
|
|
void set_title(String&&);
|
|
|
|
|
2019-02-19 01:42:53 +01:00
|
|
|
float opacity() const { return m_opacity; }
|
|
|
|
void set_opacity(float opacity) { m_opacity = opacity; }
|
|
|
|
|
2019-01-16 16:03:50 +01:00
|
|
|
int x() const { return m_rect.x(); }
|
|
|
|
int y() const { return m_rect.y(); }
|
|
|
|
int width() const { return m_rect.width(); }
|
|
|
|
int height() const { return m_rect.height(); }
|
|
|
|
|
2019-02-11 09:47:10 +01:00
|
|
|
bool is_visible() const { return m_visible; }
|
|
|
|
void set_visible(bool);
|
|
|
|
|
|
|
|
Rect rect() const { return m_rect; }
|
2019-01-16 16:03:50 +01:00
|
|
|
void set_rect(const Rect&);
|
2019-02-11 09:47:10 +01:00
|
|
|
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
2019-01-16 16:03:50 +01:00
|
|
|
void set_rect_without_repaint(const Rect& rect) { m_rect = rect; }
|
|
|
|
|
2019-02-11 09:47:10 +01:00
|
|
|
void move_to(const Point& position) { set_rect({ position, size() }); }
|
|
|
|
void move_to(int x, int y) { move_to({ x, y }); }
|
|
|
|
|
2019-01-16 16:03:50 +01:00
|
|
|
Point position() const { return m_rect.location(); }
|
|
|
|
void set_position(const Point& position) { set_rect({ position.x(), position.y(), width(), height() }); }
|
|
|
|
void set_position_without_repaint(const Point& position) { set_rect_without_repaint({ position.x(), position.y(), width(), height() }); }
|
|
|
|
|
2019-02-11 09:47:10 +01:00
|
|
|
Size size() const { return m_rect.size(); }
|
|
|
|
|
|
|
|
void invalidate();
|
|
|
|
|
2019-01-26 05:35:45 +01:00
|
|
|
virtual void on_message(WSMessage&) override;
|
2019-01-16 16:03:50 +01:00
|
|
|
|
|
|
|
bool is_being_dragged() const { return m_is_being_dragged; }
|
|
|
|
void set_is_being_dragged(bool b) { m_is_being_dragged = b; }
|
|
|
|
|
|
|
|
GraphicsBitmap* backing() { return m_backing.ptr(); }
|
|
|
|
|
2019-01-27 08:48:34 +01:00
|
|
|
void set_global_cursor_tracking_enabled(bool);
|
|
|
|
bool global_cursor_tracking() const { return m_global_cursor_tracking_enabled; }
|
|
|
|
|
2019-02-19 01:42:53 +01:00
|
|
|
bool has_alpha_channel() const { return m_has_alpha_channel; }
|
|
|
|
void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
|
|
|
|
|
2019-01-16 16:03:50 +01:00
|
|
|
// For InlineLinkedList.
|
|
|
|
// FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
|
|
|
|
WSWindow* m_next { nullptr };
|
|
|
|
WSWindow* m_prev { nullptr };
|
|
|
|
|
|
|
|
private:
|
2019-02-17 08:54:57 +01:00
|
|
|
WSClientConnection* m_client { nullptr };
|
2019-01-16 16:03:50 +01:00
|
|
|
String m_title;
|
|
|
|
Rect m_rect;
|
2019-02-12 11:53:45 +01:00
|
|
|
WSWindowType m_type { WSWindowType::Normal };
|
2019-01-16 16:03:50 +01:00
|
|
|
bool m_is_being_dragged { false };
|
2019-01-27 08:48:34 +01:00
|
|
|
bool m_global_cursor_tracking_enabled { false };
|
2019-02-11 09:47:10 +01:00
|
|
|
bool m_visible { true };
|
2019-02-19 01:42:53 +01:00
|
|
|
bool m_has_alpha_channel { false };
|
2019-02-11 09:47:10 +01:00
|
|
|
WSMenu* m_menu { nullptr };
|
2019-01-16 16:03:50 +01:00
|
|
|
RetainPtr<GraphicsBitmap> m_backing;
|
|
|
|
int m_window_id { -1 };
|
2019-02-19 01:42:53 +01:00
|
|
|
float m_opacity { 1 };
|
2019-01-16 16:03:50 +01:00
|
|
|
};
|