Max OS 0.3
Loading...
Searching...
No Matches
desktop.h
Go to the documentation of this file.
1
9#ifndef MaxOS_GUI_DESKTOP_H
10#define MaxOS_GUI_DESKTOP_H
11
12#include <cstdint>
15#include <gui/widget.h>
16#include <drivers/clock/clock.h>
17
18
19namespace MaxOS::gui {
20
28
29 protected:
30 uint32_t m_mouse_x;
31 uint32_t m_mouse_y;
32
34
37
38 void set_focus(Widget*) final;
39 void bring_to_front(Widget*) final;
41
45
46 public:
48
49 explicit Desktop(common::GraphicsContext* gc);
50 ~Desktop();
51
52 void add_child(Widget*) final;
53 void on_time(const common::Time& time);
54 void invalidate(common::Rectangle<int32_t>& area) final;
55
56 // Mouse Events
57 void on_mouse_move_event(int8_t x, int8_t y) final;
58 void on_mouse_down_event(uint8_t button) final;
59 void on_mouse_up_event(uint8_t button) final;
60
61 // Keyboard Events
62 void on_key_down(drivers::peripherals::KeyCode key_down_code, const drivers::peripherals::KeyboardState& key_down_state) final;
63 void on_key_up(drivers::peripherals::KeyCode key_up_code, const drivers::peripherals::KeyboardState& key_up_state) final;
64
65 };
66}
67
68
69#endif //MaxOS_GUI_DESKTOP_H
Stores the red, green, blue and alpha values of a colour. Can be parsed from a hex string,...
Definition colour.h:91
Draws pixels to the screen, and handles drawing lines, rectangles and circles.
Stores the left, top, width and height of a rectangle.
Definition rectangle.h:22
Dynamically stores an array of elements.
Definition vector.h:39
Holds the state of the keyboard.
Definition keyboard.h:216
Handles events that are triggered by the mouse driver.
Definition mouse.h:72
A widget that can contain other widgets.
Definition widget.h:88
The desktop that contains all the windows, handles the drawing of the screen and the mouse on every t...
Definition desktop.h:27
void add_child(Widget *) final
Adds a child widget to the desktop.
Definition desktop.cpp:154
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.
Definition desktop.cpp:97
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.
Definition desktop.cpp:265
void draw_self(common::GraphicsContext *gc, common::Rectangle< int32_t > &area) final
Draws a certain area of the desktop.
Definition desktop.cpp:137
void on_time(const common::Time &time)
Redraws the desktop when a time event occurs.
Definition desktop.cpp:176
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....
Definition desktop.cpp:219
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.
Definition desktop.cpp:279
common::Colour colour
The background colour of the desktop (.
Definition desktop.h:47
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.
Definition desktop.cpp:291
void invert_mouse_cursor()
Draws the mouse cursor at the current mouse m_position by inverting the pixels (mouse is a plus sign)
Definition desktop.cpp:77
drivers::peripherals::MouseEventHandler * m_dragged_widget
The widget that the mouse is currently dragging.
Definition desktop.h:36
uint32_t m_mouse_y
The vertical position of the mouse cursor.
Definition desktop.h:31
uint32_t m_mouse_x
The horizontal position of the mouse cursor.
Definition desktop.h:30
Widget * m_focussed_widget
The widget that currently is receiving keyboard input and is at the front.
Definition desktop.h:35
void set_focus(Widget *) final
Updates the currently focussed widget to be the given widget.
Definition desktop.cpp:49
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.
Definition desktop.cpp:254
common::GraphicsContext * m_graphics_context
Where to draw the desktop to.
Definition desktop.h:33
common::Vector< common::Rectangle< int32_t > > m_invalid_areas
The areas of the desktop that need to be redrawn.
Definition desktop.h:42
A graphical object that can be drawn on the screen.
Definition widget.h:29
void invalidate()
Invalidates the entire widget. This forces the widget to be redrawn on the next screen update.
Definition widget.cpp:55
void bring_to_front()
Brings this widget to the front of the screen.
Definition widget.cpp:230
Defines drivers for the Programmable Interval Timer (PIT) and APIC Clock.
Defines a GraphicsContext class for drawing pixels, lines, rectangles and circles to the screen.
KeyCode
A mapping of key codes to their values.
Definition keyboard.h:40
Defines a MouseDriver for handling PS/2 mouse input and generating mouse events.
Stores the year, month, day, hour, minute and second of a time.
Definition time.h:24
Defines a base Widget class and CompositeWidget class for creating graphical user interface elements.