LibGUI: Implement attributes for windows

Windows can now change whether they have title bar, rounded corners,
alpha channel and whether they are movable. Also windows can also change
their own position
This commit is contained in:
2024-10-18 03:32:12 +03:00
parent d7e5c56e94
commit d266c7f93b
10 changed files with 184 additions and 27 deletions

View File

@@ -160,6 +160,8 @@ namespace LibGUI
WindowCreate,
WindowCreateResponse,
WindowInvalidate,
WindowSetPosition,
WindowSetAttributes,
DestroyWindowEvent,
CloseWindowEvent,
@@ -179,6 +181,8 @@ namespace LibGUI
);
DEFINE_PACKET(WindowCreateResponse,
uint32_t, width,
uint32_t, height,
long, smo_key
);
@@ -189,6 +193,18 @@ namespace LibGUI
uint32_t, height
);
DEFINE_PACKET(WindowSetPosition,
int32_t, x,
int32_t, y
);
DEFINE_PACKET(WindowSetAttributes,
bool, title_bar,
bool, rounded_corners,
bool, movable,
bool, alpha_channel
);
}
namespace EventPacket

View File

@@ -13,6 +13,15 @@ namespace LibGUI
class Window
{
public:
struct Attributes
{
bool title_bar { true };
bool movable { true };
bool rounded_corners { true };
bool alpha_channel { false };
};
public:
~Window();
@@ -49,6 +58,11 @@ namespace LibGUI
bool invalidate(int32_t x, int32_t y, uint32_t width, uint32_t height);
bool invalidate() { return invalidate(0, 0, width(), height()); }
bool set_position(int32_t x, int32_t y);
Attributes get_attributes() const { return m_attributes; }
bool set_attributes(Attributes attributes);
uint32_t width() const { return m_width; }
uint32_t height() const { return m_height; }
@@ -75,6 +89,8 @@ namespace LibGUI
private:
int m_server_fd;
Attributes m_attributes;
BAN::Vector<uint32_t> m_framebuffer;
uint32_t* m_framebuffer_smo;
uint32_t m_width;