16using namespace MaxOS::common;
17using namespace MaxOS::gui;
18using namespace MaxOS::drivers::peripherals;
28 m_graphics_context(
gc),
29 colour(
Colour(0xA8, 0xA8, 0xA8)) {
42Desktop::~Desktop() =
default;
Stores the red, green, blue and alpha values of a colour. Can be parsed from a hex string,...
Draws pixels to the screen, and handles drawing lines, rectangles and circles.
void invert_pixel(uint32_t x, uint32_t y)
Inverts a pixel.
Stores the left, top, width and height of a rectangle.
Type height
The height of the rectangle.
Type top
The top coordinate of the rectangle.
bool intersects(const Rectangle< Type > &)
Type left
The left coordinate of the rectangle.
Vector< Rectangle< Type > > subtract(const Rectangle< Type > &)
Type width
The width of the rectangle.
Dynamically stores an array of elements.
virtual void on_key_up(KeyCode, const KeyboardState &)
Handle the key up event.
virtual void on_key_down(KeyCode, const KeyboardState &)
Handle the key down event.
Holds the state of the keyboard.
Handles events that are triggered by the mouse driver.
virtual void on_mouse_move_event(int8_t x, int8_t y)
Called when the mouse is moved.
void add_child(Widget *) final
Adds a child widget to the desktop.
void internal_invalidate(common::Rectangle< int32_t > &area, common::Vector< common::Rectangle< int32_t > >::iterator start, common::Vector< common::Rectangle< int32_t > >::iterator stop)
Goes through the passed areas and invalidates the areas that are covered by the given area.
void on_mouse_up_event(uint8_t button) final
When the mouse button is released pass the event to the widget that the mouse is over.
void draw_self(common::GraphicsContext *gc, common::Rectangle< int32_t > &area) final
Draws a certain area of the desktop.
void on_time(const common::Time &time)
Redraws the desktop when a time event occurs.
void on_mouse_move_event(int8_t x, int8_t y) final
When the mouse moves on the desktop update the m_position of the mouse and redraw the cursor....
void on_key_down(drivers::peripherals::KeyCode key_down_code, const drivers::peripherals::KeyboardState &key_down_state) final
When a key is pressed pass the event to the widget that is currently focussed.
common::Colour colour
The background colour of the desktop (.
void on_key_up(drivers::peripherals::KeyCode key_up_code, const drivers::peripherals::KeyboardState &key_up_state) final
When a key is pressed pass the event to the widget that is currently focussed.
Desktop(common::GraphicsContext *gc)
Creates a new desktop with the given graphics context.
void invert_mouse_cursor()
Draws the mouse cursor at the current mouse m_position by inverting the pixels (mouse is a plus sign)
drivers::peripherals::MouseEventHandler * m_dragged_widget
The widget that the mouse is currently dragging.
uint32_t m_mouse_y
The vertical position of the mouse cursor.
uint32_t m_mouse_x
The horizontal position of the mouse cursor.
Widget * m_focussed_widget
The widget that currently is receiving keyboard input and is at the front.
void set_focus(Widget *) final
Updates the currently focussed widget to be the given widget.
void on_mouse_down_event(uint8_t button) final
When the mouse button is pressed pass the event to the widget that the mouse is over.
common::GraphicsContext * m_graphics_context
Where to draw the desktop to.
common::Vector< common::Rectangle< int32_t > > m_invalid_areas
The areas of the desktop that need to be redrawn.
Defines a Desktop class for managing the GUI desktop, handling mouse and keyboard events,...
KeyCode
A mapping of key codes to their values.
Stores the year, month, day, hour, minute and second of a time.