mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-05 18:52:56 +00:00
Use this to implement incremental resizing for Terminal so that we only ever resize to fit a perfect number of rows and columns. This is very nice. :^)
100 lines
3.7 KiB
C++
100 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include <SharedGraphics/Rect.h>
|
|
#include <SharedGraphics/GraphicsBitmap.h>
|
|
#include <AK/AKString.h>
|
|
#include <AK/InlineLinkedList.h>
|
|
#include "WSMessageReceiver.h"
|
|
#include <WindowServer/WSWindowType.h>
|
|
|
|
class WSClientConnection;
|
|
class WSMenu;
|
|
|
|
class WSWindow final : public WSMessageReceiver, public InlineLinkedListNode<WSWindow> {
|
|
public:
|
|
WSWindow(WSClientConnection&, int window_id);
|
|
explicit WSWindow(WSMenu&);
|
|
virtual ~WSWindow() override;
|
|
|
|
WSClientConnection* client() { return m_client; }
|
|
const WSClientConnection* client() const { return m_client; }
|
|
|
|
WSWindowType type() const { return m_type; }
|
|
int window_id() const { return m_window_id; }
|
|
|
|
String title() const { return m_title; }
|
|
void set_title(String&&);
|
|
|
|
float opacity() const { return m_opacity; }
|
|
void set_opacity(float opacity) { m_opacity = opacity; }
|
|
|
|
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(); }
|
|
|
|
bool is_visible() const { return m_visible; }
|
|
void set_visible(bool);
|
|
|
|
Rect rect() const { return m_rect; }
|
|
void set_rect(const Rect&);
|
|
void set_rect(int x, int y, int width, int height) { set_rect({ x, y, width, height }); }
|
|
void set_rect_without_repaint(const Rect& rect) { m_rect = rect; }
|
|
void set_rect_from_window_manager_resize(const Rect&);
|
|
|
|
void move_to(const Point& position) { set_rect({ position, size() }); }
|
|
void move_to(int x, int y) { move_to({ x, y }); }
|
|
|
|
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() }); }
|
|
|
|
Size size() const { return m_rect.size(); }
|
|
|
|
void invalidate();
|
|
|
|
virtual void on_message(WSMessage&) override;
|
|
|
|
GraphicsBitmap* backing_store() { return m_backing_store.ptr(); }
|
|
void set_backing_store(RetainPtr<GraphicsBitmap>&& backing_store) { m_backing_store = move(backing_store); }
|
|
|
|
void set_global_cursor_tracking_enabled(bool);
|
|
bool global_cursor_tracking() const { return m_global_cursor_tracking_enabled; }
|
|
|
|
bool has_alpha_channel() const { return m_has_alpha_channel; }
|
|
void set_has_alpha_channel(bool value) { m_has_alpha_channel = value; }
|
|
|
|
void set_last_lazy_resize_rect(const Rect& rect) { m_last_lazy_resize_rect = rect; }
|
|
Rect last_lazy_resize_rect() const { return m_last_lazy_resize_rect; }
|
|
|
|
bool has_painted_since_last_resize() const { return m_has_painted_since_last_resize; }
|
|
void set_has_painted_since_last_resize(bool b) { m_has_painted_since_last_resize = b; }
|
|
|
|
Size size_increment() const { return m_size_increment; }
|
|
void set_size_increment(const Size& increment) { m_size_increment = increment; }
|
|
|
|
Size base_size() const { return m_base_size; }
|
|
void set_base_size(const Size& size) { m_base_size = size; }
|
|
|
|
// For InlineLinkedList.
|
|
// FIXME: Maybe make a ListHashSet and then WSWindowManager can just use that.
|
|
WSWindow* m_next { nullptr };
|
|
WSWindow* m_prev { nullptr };
|
|
|
|
private:
|
|
WSClientConnection* m_client { nullptr };
|
|
String m_title;
|
|
Rect m_rect;
|
|
WSWindowType m_type { WSWindowType::Normal };
|
|
bool m_global_cursor_tracking_enabled { false };
|
|
bool m_visible { true };
|
|
bool m_has_alpha_channel { false };
|
|
bool m_has_painted_since_last_resize { false };
|
|
WSMenu* m_menu { nullptr };
|
|
RetainPtr<GraphicsBitmap> m_backing_store;
|
|
int m_window_id { -1 };
|
|
float m_opacity { 1 };
|
|
Rect m_last_lazy_resize_rect;
|
|
Size m_size_increment;
|
|
Size m_base_size;
|
|
};
|