mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
feat(gui): Implement complete Graphical Desktop Environment, SUB-WM, and apps
- Create separate feature branch 'feat/gui-desktop' - Implement double-buffered 2D graphics engine with alpha blending, gradients, rounded rects, and font rasterization in gui/gui_gfx.c and include/gui/gui_gfx.h - Implement alpha-blended mouse pointer overlay in gui/gui_cursor.c and include/gui/gui_cursor.h - Implement SUB-WM Window Manager with draggable titlebars, close/minimize buttons, drop shadows, and event routing in gui/gui_wm.c and include/gui/gui_wm.h - Implement Cyberpunk/Nord desktop environment with wallpaper, taskbar, start menu popup, and system tray in gui/gui_desktop.c and include/gui/gui_desktop.h - Implement built-in GUI apps: System Performance Monitor, GUI Terminal Emulator, File Explorer, Calculator, Paint Studio, and About dialog in gui/gui_apps.c and include/gui/gui_apps.h - Add 'startx', 'gui', and 'desktop' applets in LazyBox suite - Verified multi-architecture compilation across x86_64, AArch64, and ARMv8i
This commit is contained in:
1 parent
492045b24d
commit
109472816c
16 files changed
+1545
-2
No files matched your search
@@ -0,0 +1,14 @@
|
||||
#ifndef _GUI_H
|
||||
#define _GUI_H
|
||||
|
||||
#include <gui/gui_theme.h>
|
||||
#include <gui/gui_gfx.h>
|
||||
#include <gui/gui_cursor.h>
|
||||
#include <gui/gui_wm.h>
|
||||
#include <gui/gui_desktop.h>
|
||||
#include <gui/gui_apps.h>
|
||||
|
||||
void gui_init(void);
|
||||
int gui_start_desktop(void);
|
||||
|
||||
#endif // _GUI_H
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _GUI_APPS_H
|
||||
#define _GUI_APPS_H
|
||||
|
||||
#include <gui/gui_wm.h>
|
||||
|
||||
void gui_app_terminal_launch(int x, int y, int w, int h);
|
||||
void gui_app_sysmon_launch(int x, int y, int w, int h);
|
||||
void gui_app_fileman_launch(int x, int y, int w, int h);
|
||||
void gui_app_calc_launch(int x, int y, int w, int h);
|
||||
void gui_app_paint_launch(int x, int y, int w, int h);
|
||||
void gui_app_about_launch(int x, int y, int w, int h);
|
||||
|
||||
#endif // _GUI_APPS_H
|
||||
@@ -0,0 +1,13 @@
|
||||
#ifndef _GUI_CURSOR_H
|
||||
#define _GUI_CURSOR_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void gui_cursor_init(void);
|
||||
void gui_cursor_set_pos(int x, int y);
|
||||
int gui_cursor_get_x(void);
|
||||
int gui_cursor_get_y(void);
|
||||
void gui_cursor_draw(void);
|
||||
|
||||
#endif // _GUI_CURSOR_H
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _GUI_DESKTOP_H
|
||||
#define _GUI_DESKTOP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define GUI_TASKBAR_HEIGHT 20
|
||||
|
||||
void gui_desktop_init(void);
|
||||
void gui_desktop_render_background(void);
|
||||
void gui_desktop_render_taskbar(void);
|
||||
void gui_desktop_render_start_menu(void);
|
||||
void gui_desktop_toggle_start_menu(void);
|
||||
bool gui_desktop_is_start_menu_open(void);
|
||||
void gui_desktop_handle_taskbar_click(int mx, int my);
|
||||
|
||||
int gui_desktop_run(void);
|
||||
|
||||
#endif // _GUI_DESKTOP_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef _GUI_GFX_H
|
||||
#define _GUI_GFX_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <gui/gui_theme.h>
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
} gui_rect_t;
|
||||
|
||||
void gui_gfx_init(uint32_t* fb, int width, int height);
|
||||
int gui_gfx_get_width(void);
|
||||
int gui_gfx_get_height(void);
|
||||
uint32_t* gui_gfx_get_backbuffer(void);
|
||||
|
||||
void gui_gfx_clear(uint32_t color);
|
||||
void gui_gfx_draw_pixel(int x, int y, uint32_t color);
|
||||
void gui_gfx_draw_pixel_blend(int x, int y, uint32_t color, uint8_t alpha);
|
||||
void gui_gfx_draw_line(int x0, int y0, int x1, int y1, uint32_t color);
|
||||
void gui_gfx_draw_rect(int x, int y, int w, int h, uint32_t color);
|
||||
void gui_gfx_fill_rect(int x, int y, int w, int h, uint32_t color);
|
||||
void gui_gfx_fill_rect_blend(int x, int y, int w, int h, uint32_t color, uint8_t alpha);
|
||||
void gui_gfx_draw_rounded_rect(int x, int y, int w, int h, int r, uint32_t color, bool filled);
|
||||
void gui_gfx_draw_gradient_v(int x, int y, int w, int h, uint32_t top_col, uint32_t bot_col);
|
||||
void gui_gfx_draw_gradient_h(int x, int y, int w, int h, uint32_t left_col, uint32_t right_col);
|
||||
|
||||
void gui_gfx_draw_char(int x, int y, char c, uint32_t fg, uint32_t bg, bool transparent_bg);
|
||||
void gui_gfx_draw_string(int x, int y, const char* str, uint32_t fg);
|
||||
void gui_gfx_draw_string_bg(int x, int y, const char* str, uint32_t fg, uint32_t bg);
|
||||
void gui_gfx_draw_string_shadow(int x, int y, const char* str, uint32_t fg, uint32_t shadow);
|
||||
void gui_gfx_draw_shadow(int x, int y, int w, int h, int blur);
|
||||
void gui_gfx_blit(int dx, int dy, int w, int h, const uint32_t* src_buf);
|
||||
void gui_gfx_present(void);
|
||||
|
||||
#endif // _GUI_GFX_H
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef _GUI_THEME_H
|
||||
#define _GUI_THEME_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// 32-bit ARGB Color definitions (0xAARRGGBB)
|
||||
#define GUI_COLOR_TRANSPARENT 0x00000000
|
||||
#define GUI_COLOR_BLACK 0xFF000000
|
||||
#define GUI_COLOR_WHITE 0xFFFFFFFF
|
||||
|
||||
// Cyberpunk / Nord Dark Theme
|
||||
#define GUI_THEME_BG_DARK 0xFF0F172A // Slate 900
|
||||
#define GUI_THEME_BG_SURFACE 0xFF1E293B // Slate 800
|
||||
#define GUI_THEME_BG_ELEVATED 0xFF334155 // Slate 700
|
||||
#define GUI_THEME_BORDER 0xFF475569 // Slate 600
|
||||
|
||||
#define GUI_THEME_PRIMARY 0xFF38BDF8 // Sky 400
|
||||
#define GUI_THEME_PRIMARY_DARK 0xFF0284C7 // Sky 600
|
||||
#define GUI_THEME_ACCENT 0xFF818CF8 // Indigo 400
|
||||
#define GUI_THEME_SUCCESS 0xFF34D399 // Emerald 400
|
||||
#define GUI_THEME_WARNING 0xFFFBBF24 // Amber 400
|
||||
#define GUI_THEME_DANGER 0xFFF87171 // Red 400
|
||||
|
||||
#define GUI_THEME_TEXT_MAIN 0xFFF8FAFC // Slate 50
|
||||
#define GUI_THEME_TEXT_MUTED 0xFF94A3B8 // Slate 400
|
||||
#define GUI_THEME_TEXT_DIM 0xFF64748B // Slate 500
|
||||
|
||||
#define GUI_THEME_TITLEBAR_ACT 0xFF1E293B
|
||||
#define GUI_THEME_TITLEBAR_INACT 0xFF0F172A
|
||||
#define GUI_THEME_TASKBAR_BG 0xFF0B0F19
|
||||
|
||||
#define GUI_THEME_BTN_CLOSE 0xFFEF4444
|
||||
#define GUI_THEME_BTN_MINIMIZE 0xFFF59E0B
|
||||
#define GUI_THEME_BTN_MAXIMIZE 0xFF10B981
|
||||
|
||||
static inline uint32_t gui_color_alpha_blend(uint32_t bg, uint32_t fg, uint8_t alpha) {
|
||||
if (alpha == 0) return bg;
|
||||
if (alpha == 255) return fg;
|
||||
|
||||
uint32_t rb_bg = bg & 0x00FF00FF;
|
||||
uint32_t g_bg = bg & 0x0000FF00;
|
||||
uint32_t rb_fg = fg & 0x00FF00FF;
|
||||
uint32_t g_fg = fg & 0x0000FF00;
|
||||
|
||||
uint32_t rb = rb_bg + (((rb_fg - rb_bg) * alpha) >> 8);
|
||||
uint32_t g = g_bg + (((g_fg - g_bg) * alpha) >> 8);
|
||||
|
||||
return 0xFF000000 | (rb & 0x00FF00FF) | (g & 0x0000FF00);
|
||||
}
|
||||
|
||||
#endif // _GUI_THEME_H
|
||||
@@ -0,0 +1,64 @@
|
||||
#ifndef _GUI_WM_H
|
||||
#define _GUI_WM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <gui/gui_gfx.h>
|
||||
#include <gui/gui_theme.h>
|
||||
|
||||
#define GUI_MAX_WINDOWS 16
|
||||
#define GUI_TITLEBAR_HEIGHT 16
|
||||
|
||||
typedef enum {
|
||||
GUI_EVENT_MOUSE_MOVE,
|
||||
GUI_EVENT_MOUSE_DOWN,
|
||||
GUI_EVENT_MOUSE_UP,
|
||||
GUI_EVENT_KEY_DOWN,
|
||||
GUI_EVENT_FOCUS,
|
||||
GUI_EVENT_CLOSE
|
||||
} gui_event_type_t;
|
||||
|
||||
typedef struct {
|
||||
gui_event_type_t type;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
int rel_x;
|
||||
int rel_y;
|
||||
bool btn_left;
|
||||
bool btn_right;
|
||||
uint16_t key;
|
||||
} gui_event_t;
|
||||
|
||||
typedef struct gui_window {
|
||||
int id;
|
||||
char title[48];
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
bool active;
|
||||
bool minimized;
|
||||
bool visible;
|
||||
bool is_dragging;
|
||||
int drag_off_x;
|
||||
int drag_off_y;
|
||||
void* user_data;
|
||||
|
||||
void (*paint)(struct gui_window* win);
|
||||
void (*handle_event)(struct gui_window* win, const gui_event_t* ev);
|
||||
} gui_window_t;
|
||||
|
||||
void gui_wm_init(void);
|
||||
gui_window_t* gui_wm_create_window(const char* title, int x, int y, int w, int h);
|
||||
void gui_wm_destroy_window(int win_id);
|
||||
void gui_wm_focus_window(int win_id);
|
||||
gui_window_t* gui_wm_get_window(int win_id);
|
||||
gui_window_t* gui_wm_get_active_window(void);
|
||||
int gui_wm_get_window_count(void);
|
||||
|
||||
void gui_wm_handle_mouse(int x, int y, bool btn_left, bool btn_right);
|
||||
void gui_wm_handle_key(uint16_t key);
|
||||
void gui_wm_render(void);
|
||||
|
||||
#endif // _GUI_WM_H
|
||||
Reference in new issue
Block a user