SayoriOS 0.3.3

widget_progress.c
1 #include "desktop/widget.h"
2 #include "desktop/widget_progress.h"
3 #include "gui/basics.h"
4 #include "mem/vmm.h"
5
6 void widget_progress_renderer(struct Widget* this, __attribute__((unused)) struct Window* container) {
7 // Widget_Progress_t* this_object = (Widget_Progress_t*)(this->custom_widget_data);
8
9 size_t cost = this->width / 100;
10
11 if(((Widget_Progress_t*)this->custom_widget_data)->current > 100) {
12 ((Widget_Progress_t*)this->custom_widget_data)->current = 100;
13 }
14
15 draw_rectangle(this->x, this->y, this->width, this->height, 0x000000);
16 draw_filled_rectangle(
17 this->x + 2,
18 this->y + 2,
19 (cost * ((Widget_Progress_t*)this->custom_widget_data)->current),
20 this->height - 4,
21 0xffffff);
22 }
23
24 Widget_t* new_widget_progress() {
25 Widget_t* wgt = new_bare_widget(
26 &widget_progress_renderer,
27 &destroy_widget_progress,
28 0, 0,
29 1, 1
30 );
31
32 wgt->custom_widget_data = kcalloc(sizeof(Widget_Progress_t), 1);
33
34 return wgt;
35 }
36
37 void destroy_widget_progress(Widget_t* widget) {
38 kfree(widget->custom_widget_data);
39 }
__attribute__
struct registers __attribute__((packed))
Структура данных пакета от мыши
Definition: psf.h:19
Widget_Progress
Definition: widget_progress.h:7
Widget
Definition: widget.h:12
Window
Definition: window.h:25