Implemented simple GUI

This commit is contained in:
Alex 2023-01-04 06:46:13 +02:00
parent f91503d704
commit 4d8205a516
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
10 changed files with 675 additions and 287 deletions

View File

@ -101,6 +101,53 @@ namespace GraphicalUserInterface
{
}
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, long *CharCursorX, long *CharCursorY)
{
switch (font->GetInfo().Type)
{
case Video::FontType::PCScreenFont1:
{
uint32_t *PixelPtr = (uint32_t *)Bitmap->Data;
char *FontPtr = (char *)font->GetInfo().PSF1Font->GlyphBuffer + (c * font->GetInfo().PSF1Font->Header->charsize);
for (int64_t Y = *CharCursorY; Y < *CharCursorY + 16; Y++)
{
for (int64_t X = *CharCursorX; X < *CharCursorX + 8; X++)
if ((*FontPtr & (0b10000000 >> (X - *CharCursorX))) > 0)
InlineSetPixel(Bitmap, X, Y, Color);
FontPtr++;
}
*CharCursorX += 8;
break;
}
case Video::FontType::PCScreenFont2:
{
// if (font->PSF2Font->GlyphBuffer == (uint16_t *)0x01) // HAS UNICODE TABLE
// Char = font->PSF2Font->GlyphBuffer[Char];
int BytesPerLine = (font->GetInfo().PSF2Font->Header->width + 7) / 8;
char *FontPtr = (char *)font->GetInfo().StartAddress +
font->GetInfo().PSF2Font->Header->headersize +
(c > 0 && (unsigned char)c < font->GetInfo().PSF2Font->Header->length ? c : 0) *
font->GetInfo().PSF2Font->Header->charsize;
uint32_t fonthdrWidth = font->GetInfo().PSF2Font->Header->width;
uint32_t fonthdrHeight = font->GetInfo().PSF2Font->Header->height;
for (int64_t Y = *CharCursorY; Y < *CharCursorY + fonthdrHeight; Y++)
{
for (int64_t X = *CharCursorX; X < *CharCursorX + fonthdrWidth; X++)
if ((*FontPtr & (0b10000000 >> (X - *CharCursorX))) > 0)
InlineSetPixel(Bitmap, X, Y, Color);
FontPtr += BytesPerLine;
}
*CharCursorX += fonthdrWidth;
break;
}
default:
warn("Unsupported font type");
break;
}
}
void DrawString(ScreenBitmap *Bitmap, Rect rect, const char *Text, uint32_t Color)
{
}

View File

@ -3,248 +3,18 @@
#include <task.hpp>
#include <debug.h>
#include "icons.hpp"
#include "../kernel.h"
#include "../DAPI.hpp"
#include "../Fex.hpp"
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn7x14r_psf_start;
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn7x14r_psf_end;
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn7x14r_psf_size;
namespace GraphicalUserInterface
{
char CursorArrow[] = {
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 12x19
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, //
1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, //
1, 2, 2, 2, 1, 2, 2, 1, 0, 0, 0, 0, //
1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 0, 0, //
1, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 0, //
1, 1, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, //
1, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, //
};
char CursorHand[] = {
0, 0, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
};
O1 void GUI::FetchInputs()
void GUI::FetchInputs()
{
KernelCallback callback;
MouseData Mouse;
@ -318,8 +88,11 @@ namespace GraphicalUserInterface
wnd->OnMouseUp(&eTemplate);
}
static int Idle = 0;
if (likely(Mouse.X != MouseArray[1].X || Mouse.Y != MouseArray[1].Y))
{
Idle = 0;
Rect TopBarPos = wnd->GetPosition();
TopBarPos.Top -= 20;
TopBarPos.Height = 20;
@ -406,10 +179,19 @@ namespace GraphicalUserInterface
eTemplate.MouseMove.Middle = Mouse.Middle;
wnd->OnMouseMove(&eTemplate);
}
else
{
if (unlikely(Idle > 1000))
CPU::Halt();
else
Idle++;
}
}
foreach (auto wdg in this->Widgets)
{
// TODO: Implement mouse events for widgets
UNUSED(wdg);
}
memmove(MouseArray + 1, MouseArray, sizeof(MouseArray) - sizeof(MouseArray[1]));
@ -418,7 +200,7 @@ namespace GraphicalUserInterface
LastCursor = Cursor;
}
Ofast void GUI::PaintDesktop()
void GUI::PaintDesktop()
{
if (DesktopBufferRepaint)
{
@ -429,7 +211,7 @@ namespace GraphicalUserInterface
memcpy(this->BackBuffer->Data, this->DesktopBuffer->Data, this->DesktopBuffer->Size);
}
Ofast void GUI::PaintWidgets()
void GUI::PaintWidgets()
{
Event eTemplate;
memset(&eTemplate, 0, sizeof(Event));
@ -437,7 +219,7 @@ namespace GraphicalUserInterface
wdg->OnPaint(nullptr);
}
O0 void GUI::PaintWindows()
void GUI::PaintWindows()
{
foreach (auto wnd in this->Windows)
{
@ -514,7 +296,7 @@ namespace GraphicalUserInterface
MouseArray[0].Y >= CloseButtonPos.Top &&
MouseArray[0].Y <= CloseButtonPos.Top + CloseButtonPos.Height)
{
PutRect(this->OverlayBuffer, CloseButtonPos, 0xFF0000);
PutRect(this->OverlayBuffer, CloseButtonPos, MouseArray[0].Left ? 0xFF5500 : 0xFF0000);
RepaintNeeded = true;
}
else
@ -527,7 +309,7 @@ namespace GraphicalUserInterface
MouseArray[0].Y >= MaximizeButtonPos.Top &&
MouseArray[0].Y <= MaximizeButtonPos.Top + MaximizeButtonPos.Height)
{
PutRect(this->OverlayBuffer, MaximizeButtonPos, 0x404040);
PutRect(this->OverlayBuffer, MaximizeButtonPos, MouseArray[0].Left ? 0x454545 : 0x404040);
RepaintNeeded = true;
}
else
@ -540,7 +322,7 @@ namespace GraphicalUserInterface
MouseArray[0].Y >= MinimizeButtonPos.Top &&
MouseArray[0].Y <= MinimizeButtonPos.Top + MinimizeButtonPos.Height)
{
PutRect(this->OverlayBuffer, MinimizeButtonPos, 0x404040);
PutRect(this->OverlayBuffer, MinimizeButtonPos, MouseArray[0].Left ? 0x454545 : 0x404040);
RepaintNeeded = true;
}
else
@ -592,11 +374,14 @@ namespace GraphicalUserInterface
PutBorder(this->OverlayBuffer, wndPos, 0xFF000000);
Rect TopBarTextPos = TopBarPos;
TopBarTextPos.Left += 5;
TopBarTextPos.Top += 5;
TopBarTextPos.Left += 4;
TopBarTextPos.Top += 4;
// Title bar text
DrawString(this->OverlayBuffer, TopBarTextPos, wnd->GetTitle(), 0xFFFFFFFF);
long CharCursorX = TopBarTextPos.Left;
long CharCursorY = TopBarTextPos.Top;
for (uint64_t i = 0; i < strlen(wnd->GetTitle()); i++)
PaintChar(this->CurrentFont, this->OverlayBuffer, wnd->GetTitle()[i], 0xFFFFFF, &CharCursorX, &CharCursorY);
if (!RepaintNeeded)
{
@ -615,7 +400,7 @@ namespace GraphicalUserInterface
*/
#define ICON_SIZE
Ofast void GUI::PaintCursor()
void GUI::PaintCursor()
{
uint32_t CursorColorInner = 0xFFFFFFFF;
uint32_t CursorColorOuter = 0xFF000000;
@ -745,7 +530,7 @@ namespace GraphicalUserInterface
DrawOverBitmap(this->BackBuffer, this->CursorBuffer, MouseArray[0].Y, MouseArray[0].X);
}
Ofast void GUI::Loop()
void GUI::Loop()
{
/*
Because we do not use a gpu to do the rendering, we need to do it manually.
@ -776,6 +561,7 @@ namespace GraphicalUserInterface
GUI::GUI()
{
Display->CreateBuffer(0, 0, 200);
this->CurrentFont = new Video::Font(&_binary_Files_tamsyn_font_1_11_Tamsyn7x14r_psf_start, &_binary_Files_tamsyn_font_1_11_Tamsyn7x14r_psf_end, Video::FontType::PCScreenFont2);
this->mem = new Memory::MemMgr;
this->Desktop.Top = 0;
this->Desktop.Left = 0;

236
GUI/Icons.cpp Normal file
View File

@ -0,0 +1,236 @@
#include "icons.hpp"
char CursorArrow[] = {
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 12x19
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, //
1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, //
1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, //
1, 2, 2, 2, 1, 2, 2, 1, 0, 0, 0, 0, //
1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 0, 0, //
1, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 0, //
1, 1, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, //
1, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, //
};
char C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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //
};

View File

@ -11,7 +11,129 @@
namespace GraphicalUserInterface
{
void WidgetCollection::OnPaint(Event *e)
void WidgetCollection::OnPaintBackground(Event *e)
{
}
void WidgetCollection::OnPaintForeground(Event *e)
{
foreach (auto Panel in this->Panels)
{
PutRect(this->Buffer, Panel->rect, Panel->Color);
}
foreach (auto Label in this->Labels)
{
Label->CharCursorX = Label->rect.Left;
Label->CharCursorY = Label->rect.Top;
for (uint64_t i = 0; i < strlen(Label->Text); i++)
PaintChar(this->CurrentFont, this->Buffer, Label->Text[i], 0xFFFFFF, &Label->CharCursorX, &Label->CharCursorY);
}
foreach (auto Button in this->Buttons)
{
if (Button->Pressed)
PutRect(this->Buffer, Button->rect, Button->PressedColor);
else if (Button->Hover)
PutRect(this->Buffer, Button->rect, Button->HoverColor);
else
PutRect(this->Buffer, Button->rect, Button->Color);
Button->CharCursorX = Button->rect.Left + (((Button->rect.Width / 2) - (this->CurrentFont->GetInfo().Width * strlen(Button->Text) / 2)));
Button->CharCursorY = Button->rect.Top + (((Button->rect.Height / 2) - (this->CurrentFont->GetInfo().Height / 2)));
for (uint64_t i = 0; i < strlen(Button->Text); i++)
PaintChar(this->CurrentFont, this->Buffer, Button->Text[i], 0xFFFFFF, &Button->CharCursorX, &Button->CharCursorY);
}
}
void WidgetCollection::OnPaint(Event *e)
{
static long LastWidth = 0;
static long LastHeight = 0;
if (LastWidth != ((Window *)this->ParentWindow)->GetPosition().Width ||
LastHeight != ((Window *)this->ParentWindow)->GetPosition().Height)
{
LastWidth = ((Window *)this->ParentWindow)->GetPosition().Width;
LastHeight = ((Window *)this->ParentWindow)->GetPosition().Height;
this->mem->FreePages(this->Buffer->Data, TO_PAGES(this->Buffer->Size));
delete this->Buffer;
this->Buffer = new ScreenBitmap;
this->Buffer->Width = LastWidth;
this->Buffer->Height = LastHeight;
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
this->Buffer->Pitch = Display->GetPitch();
this->Buffer->Size = this->Buffer->Pitch * LastHeight;
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size));
memset(this->Buffer->Data, 0, this->Buffer->Size);
NeedRedraw = true;
}
if (NeedRedraw)
{
memset(this->Buffer->Data, 0, this->Buffer->Size);
this->OnPaintBackground(e);
this->OnPaintForeground(e);
NeedRedraw = false;
}
DrawOverBitmap(((Window *)this->ParentWindow)->GetBuffer(), this->Buffer, 0, 0);
}
void WidgetCollection::OnMouseDown(Event *e)
{
foreach (auto Button in this->Buttons)
{
if (Button->rect.Contains(e->MouseDown.X, e->MouseDown.Y))
{
if (e->MouseDown.Left)
{
debug("Button Hold");
Button->Pressed = true;
NeedRedraw = true;
}
}
}
}
void WidgetCollection::OnMouseUp(Event *e)
{
foreach (auto Button in this->Buttons)
{
if (Button->rect.Contains(e->MouseUp.X, e->MouseUp.Y))
{
if (e->MouseUp.Left)
{
debug("Button Release");
if (Button->Pressed)
{
debug("Button Clicked");
if (Button->OnClick != (uintptr_t) nullptr)
((void (*)(void))Button->OnClick)();
Button->Pressed = false;
NeedRedraw = true;
}
}
}
}
}
void WidgetCollection::OnMouseMove(Event *e)
{
foreach (auto Button in this->Buttons)
{
if (Button->rect.Contains(e->MouseMove.X, e->MouseMove.Y))
{
Button->Hover = true;
NeedRedraw = true;
}
else
{
Button->Hover = false;
NeedRedraw = true;
}
}
}
}

View File

@ -9,20 +9,105 @@
#include "../DAPI.hpp"
#include "../Fex.hpp"
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn10x20r_psf_start;
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn10x20r_psf_end;
extern uintptr_t _binary_Files_tamsyn_font_1_11_Tamsyn10x20r_psf_size;
namespace GraphicalUserInterface
{
Handle WidgetCollection::CreatePanel(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height)
Handle WidgetCollection::CreatePanel(Rect rect, uint32_t Color)
{
return 0;
PanelObject *panel = (PanelObject *)mem->RequestPages(TO_PAGES(sizeof(PanelObject)));
panel->Handle.Type[0] = 'P';
panel->Handle.Type[1] = 'N';
panel->Handle.Type[2] = 'L';
panel->Handle.Type[3] = '\0';
panel->rect = rect;
panel->Color = Color;
panel->BorderColor = 0xFF000000;
panel->ShadowColor = 0xFF000000;
panel->Shadow = false;
Panels.push_back(panel);
NeedRedraw = true;
return (Handle)panel;
}
Handle WidgetCollection::CreateLabel(Rect rect, const char *Text)
{
LabelObject *label = (LabelObject *)mem->RequestPages(TO_PAGES(sizeof(LabelObject)));
label->Handle.Type[0] = 'L';
label->Handle.Type[1] = 'B';
label->Handle.Type[2] = 'L';
label->Handle.Type[3] = '\0';
label->rect = rect;
strcpy(label->Text, Text);
label->Color = 0xFFFFFF;
label->CharCursorX = rect.Left;
label->CharCursorY = rect.Top;
Labels.push_back(label);
NeedRedraw = true;
return (Handle)label;
}
Handle WidgetCollection::CreateButton(Rect rect, const char *Text, uintptr_t OnClick)
{
ButtonObject *button = (ButtonObject *)mem->RequestPages(TO_PAGES(sizeof(ButtonObject)));
button->Handle.Type[0] = 'B';
button->Handle.Type[1] = 'T';
button->Handle.Type[2] = 'N';
button->Handle.Type[3] = '\0';
button->rect = rect;
strcpy(button->Text, Text);
button->Color = 0x252525;
button->HoverColor = 0x353535;
button->PressedColor = 0x555555;
button->BorderColor = 0xFF000000;
button->ShadowColor = 0xFF000000;
button->Shadow = false;
button->Hover = false;
button->Pressed = false;
button->OnClick = OnClick;
Buttons.push_back(button);
NeedRedraw = true;
return (Handle)button;
}
WidgetCollection::WidgetCollection(void *ParentWindow)
{
if (!ParentWindow)
{
error("ParentWindow is null");
return;
}
this->ParentWindow = ParentWindow;
this->mem = new Memory::MemMgr;
this->Buffer = new ScreenBitmap;
this->Buffer->Width = ((Window *)this->ParentWindow)->GetPosition().Width;
this->Buffer->Height = ((Window *)this->ParentWindow)->GetPosition().Height;
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
this->Buffer->Pitch = Display->GetPitch();
this->Buffer->Size = this->Buffer->Pitch * ((Window *)this->ParentWindow)->GetPosition().Height;
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size));
memset(this->Buffer->Data, 0, this->Buffer->Size);
this->CurrentFont = new Video::Font(&_binary_Files_tamsyn_font_1_11_Tamsyn10x20r_psf_start, &_binary_Files_tamsyn_font_1_11_Tamsyn10x20r_psf_end, Video::FontType::PCScreenFont2);
}
WidgetCollection::~WidgetCollection()
{
delete this->mem;
delete this->Buffer;
delete this->CurrentFont;
}
}

View File

@ -14,27 +14,26 @@ namespace GraphicalUserInterface
#define TASKBAR_HEIGHT 25
// if (!Maximized)
// {
// this->LastPosition.Left = this->Position.Left;
// this->LastPosition.Top = this->Position.Top;
// this->LastPosition.Width = this->Position.Width;
// this->LastPosition.Height = this->Position.Height;
// this->Position.Left = 0;
// this->Position.Top = 0;
// this->Position.Width = Display->GetBuffer(200)->Width;
// this->Position.Height = Display->GetBuffer(200)->Height - 20 - TASKBAR_HEIGHT;
// Maximized = true;
// }
// else
// {
// this->Position.Left = this->LastPosition.Left;
// this->Position.Top = this->LastPosition.Top;
// this->Position.Width = this->LastPosition.Width;
// this->Position.Height = this->LastPosition.Height;
// Maximized = false;
// }
// if (!Maximized)
// {
// this->LastPosition.Left = this->Position.Left;
// this->LastPosition.Top = this->Position.Top;
// this->LastPosition.Width = this->Position.Width;
// this->LastPosition.Height = this->Position.Height;
// this->Position.Left = 0;
// this->Position.Top = 0;
// this->Position.Width = Display->GetBuffer(200)->Width;
// this->Position.Height = Display->GetBuffer(200)->Height - 20 - TASKBAR_HEIGHT;
// Maximized = true;
// }
// else
// {
// this->Position.Left = this->LastPosition.Left;
// this->Position.Top = this->LastPosition.Top;
// this->Position.Width = this->LastPosition.Width;
// this->Position.Height = this->LastPosition.Height;
// Maximized = false;
// }
void Window::AddWidget(WidgetCollection *widget)
{
@ -50,7 +49,7 @@ namespace GraphicalUserInterface
this->Buffer->BitsPerPixel = Display->GetBitsPerPixel();
this->Buffer->Pitch = Display->GetPitch();
this->Buffer->Size = this->Buffer->Pitch * rect.Height;
this->Buffer->Data = (uint8_t*)this->mem->RequestPages(TO_PAGES(this->Buffer->Size));
this->Buffer->Data = (uint8_t *)this->mem->RequestPages(TO_PAGES(this->Buffer->Size));
memset(this->Buffer->Data, 0, this->Buffer->Size);
this->ParentGUI = ParentGUI;
this->Position = rect;

View File

@ -48,7 +48,7 @@ namespace GraphicalUserInterface
Rect PaintPosition = this->Position;
PaintPosition.Left = 0;
PaintPosition.Top = 0;
PutRect(this->Buffer, PaintPosition, /*0x121212*/ 0xFF00FF);
PutRect(this->Buffer, PaintPosition, 0x121212);
}
void Window::OnPaintForeground(Event *e)
@ -69,19 +69,47 @@ namespace GraphicalUserInterface
void Window::OnPaint(Event *e)
{
memset(this->Buffer->Data, 0, this->Buffer->Size);
this->OnPaintBackground(e);
this->OnPaintForeground(e);
}
void Window::OnMouseDown(Event *e)
{
Event WindowPos = *e;
WindowPos.MouseDown.X -= this->Position.Left;
WindowPos.MouseDown.Y -= this->Position.Top;
foreach (auto var in this->Widgets)
{
var->OnMouseDown(&WindowPos);
}
}
void Window::OnMouseUp(Event *e)
{
Event WindowPos = *e;
WindowPos.MouseUp.X -= this->Position.Left;
WindowPos.MouseUp.Y -= this->Position.Top;
foreach (auto var in this->Widgets)
{
var->OnMouseUp(&WindowPos);
}
}
void Window::OnMouseMove(Event *e)
{
Event WindowPos = *e;
WindowPos.MouseMove.X -= this->Position.Left;
WindowPos.MouseMove.Y -= this->Position.Top;
foreach (auto var in this->Widgets)
{
var->OnMouseMove(&WindowPos);
}
}
}

17
GUI/icons.hpp Normal file
View File

@ -0,0 +1,17 @@
#ifndef __FENNIX_KERNEL_ICONS_AND_FONTS_H__
#define __FENNIX_KERNEL_ICONS_AND_FONTS_H__
#include <types.h>
extern char CursorArrow[];
extern char CursorHand[];
extern char CursorWait[];
extern char CursorIBeam[];
extern char CursorResizeAll[];
extern char CloseButton[];
extern char MinimizeButton[];
extern char MaximizeButtonNormal[];
extern char MaximizeButtonMaximized[];
extern char ResizeHint[];
#endif // !__FENNIX_KERNEL_ICONS_AND_FONTS_H__

View File

@ -21,6 +21,8 @@ namespace Recovery
}
void RecoveryThreadWrapper() { RecoveryScreen->RecoveryThread(); }
void RebootCommandWrapper() { PowerManager->Reboot(); }
void ShutdownCommandWrapper() { PowerManager->Shutdown(); }
GraphicalUserInterface::GUI *gui = nullptr;
void GUIWrapper() { gui->Loop(); }
@ -37,10 +39,21 @@ namespace Recovery
TCB *guiThread = TaskManager->CreateThread(TaskManager->GetCurrentProcess(), (IP)GUIWrapper, nullptr, nullptr, auxv);
guiThread->Rename("GUI Thread");
guiThread->SetPriority(100);
Window *win = new Window(gui, {50, 50, 400, 250}, "Recovery");
WidgetCollection *wdg = new WidgetCollection(nullptr);
wdg->CreatePanel(0, Display->GetBuffer(0)->Height - 25, Display->GetBuffer(0)->Width, 25);
Rect RecoveryModeWindow;
RecoveryModeWindow.Width = 460;
RecoveryModeWindow.Height = 100;
RecoveryModeWindow.Left = Display->GetBuffer(200)->Width / 2 - RecoveryModeWindow.Width / 2;
RecoveryModeWindow.Top = Display->GetBuffer(200)->Height / 2 - RecoveryModeWindow.Height / 2;
Window *win = new Window(gui, RecoveryModeWindow, "Recovery Mode");
gui->AddWindow(win);
WidgetCollection *wdg = new WidgetCollection(win);
wdg->CreateLabel({10, 10, 0, 0}, "This is not fully implemented.");
wdg->CreateLabel({10, 25, 0, 0}, "All you can do is shutdown/reboot the system.");
wdg->CreateButton({10, 50, 90, 20}, "Reboot", (uintptr_t)RebootCommandWrapper);
wdg->CreateButton({110, 50, 90, 20}, "Shutdown", (uintptr_t)ShutdownCommandWrapper);
win->AddWidget(wdg);
}

View File

@ -2,6 +2,7 @@
#define __FENNIX_KERNEL_GUI_H__
#include <types.h>
#include <display.hpp>
#include <memory.hpp>
#include <vector.hpp>
#include <debug.h>
@ -171,24 +172,74 @@ namespace GraphicalUserInterface
uint32_t BlendColors(uint32_t c1, uint32_t c2, float t);
void PutBorderWithShadow(ScreenBitmap *Bitmap, Rect rect, uint32_t Color);
void DrawShadow(ScreenBitmap *Bitmap, Rect rect);
void PaintChar(Video::Font *font, ScreenBitmap *Bitmap, char c, uint32_t Color, long *CharCursorX, long *CharCursorY);
void DrawString(ScreenBitmap *Bitmap, Rect rect, const char *Text, uint32_t Color);
class WidgetCollection
{
private:
Memory::MemMgr *mem;
ScreenBitmap *Buffer;
Video::Font *CurrentFont;
void *ParentWindow;
bool NeedRedraw;
struct HandleMeta
{
char Type[4];
};
struct LabelObject
{
HandleMeta Handle;
Rect rect;
char Text[512];
uint32_t Color;
long CharCursorX, CharCursorY;
};
struct PanelObject
{
HandleMeta Handle;
Rect rect;
uint32_t Color;
uint32_t BorderColor;
uint32_t ShadowColor;
bool Shadow;
};
struct ButtonObject
{
HandleMeta Handle;
Rect rect;
char Text[512];
uint32_t Color;
uint32_t HoverColor;
uint32_t PressedColor;
uint32_t BorderColor;
uint32_t ShadowColor;
long CharCursorX, CharCursorY;
bool Shadow;
bool Hover;
bool Pressed;
uintptr_t OnClick;
};
Vector<LabelObject *> Labels;
Vector<PanelObject *> Panels;
Vector<ButtonObject *> Buttons;
public:
Handle CreatePanel(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height);
Handle CreateButton(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateLabel(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateTextBox(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateCheckBox(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateRadioButton(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateComboBox(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateListBox(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateProgressBar(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreateContextMenu(uint32_t Left, uint32_t Top, uint32_t Width, uint32_t Height, const char *Text);
Handle CreatePanel(Rect rect, uint32_t Color);
Handle CreateButton(Rect rect, const char *Text, uintptr_t OnClick = (uintptr_t) nullptr);
Handle CreateLabel(Rect rect, const char *Text);
Handle CreateTextBox(Rect rect, const char *Text);
Handle CreateCheckBox(Rect rect, const char *Text);
Handle CreateRadioButton(Rect rect, const char *Text);
Handle CreateComboBox(Rect rect, const char *Text);
Handle CreateListBox(Rect rect, const char *Text);
Handle CreateProgressBar(Rect rect, const char *Text);
Handle CreateContextMenu(Rect rect, const char *Text);
WidgetCollection(void /* Window */ *ParentWindow);
~WidgetCollection();
@ -215,6 +266,8 @@ namespace GraphicalUserInterface
void OnDestroy(Event *e);
void OnPaint(Event *e);
void OnPaintBackground(Event *e);
void OnPaintForeground(Event *e);
};
class Window
@ -292,6 +345,7 @@ namespace GraphicalUserInterface
private:
MouseData MouseArray[256];
Memory::MemMgr *mem;
Video::Font *CurrentFont;
Rect Desktop;
ScreenBitmap *BackBuffer;
ScreenBitmap *DesktopBuffer;
@ -305,7 +359,8 @@ namespace GraphicalUserInterface
bool IsRunning = false;
bool DesktopBufferRepaint = true;
bool OverlayBufferRepaint = true; bool OverlayFullRepaint = true;
bool OverlayBufferRepaint = true;
bool OverlayFullRepaint = true;
bool CursorBufferRepaint = true;
void FetchInputs();