Phase 4: SkyKit library + Rigel file manager; fix text centering

SkyKit (skykit/):
- Shared palette constants, font setup, and Xlib/Xft drawing utilities
- sk_fill, sk_rect, sk_line, sk_text, sk_text_clip, sk_textw, sk_baseline
- Builds as libskykit.a, consumed by Rigel and future shell components

Rigel (rigel/):
- Native C/Xlib file manager with SkyKit
- Sidebar with 8 bookmarks (Home, Desktop, Documents, Downloads, etc.)
- Editable path bar (Ctrl+L or '/' to activate, Enter to navigate)
- Sortable columns: Name / Size / Modified (click header to sort/reverse)
- Colored type badges: DIR, IMG, SND, VID, ZIP, SRC, PDF, TXT, EXE
- Double-click to open dirs or files (xdg-open)
- Keyboard: ↑↓ select, Enter open, Backspace back, Ctrl+H toggle hidden
- Right-click menu updated: "File Manager" now launches rigel

Text centering fix (deskbar + wm):
- Root cause: draw_str added glyph-specific ext.height/ext.y offset, and
  all callers used hardcoded (H-10)/2 magic numbers instead of font metrics
- Fix: draw_str now takes y as a direct baseline; str_baseline() computes
  (strip_y + strip_h + ascent - descent) / 2 for consistent centering
- WM titlebar: same fix using font_title->ascent/descent
- Affects: "Orion ▾" button, clock, date, app list, flyout menu items,
  letter icons, and all window titlebars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-07-23 15:40:03 -04:00
1 parent e3bc761f25
commit 1340bf012c
11 files changed
+1113 -18

No files matched your search

+91
View File
@@ -0,0 +1,91 @@
/* skykit.h — OrionOS native UI toolkit
* Shared palette, drawing utilities, and app boilerplate used by all OrionOS
* shell components (Rigel, Nebula, OrionPkg, installer, etc.).
*/
#pragma once
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
#include <fontconfig/fontconfig.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/* ── Palette ─────────────────────────────────────────────────────── */
#define SK_BG 0x0E1220UL
#define SK_SURFACE 0x141828UL
#define SK_SIDEBAR 0x090D1AUL
#define SK_PANEL 0x111828UL
#define SK_BORDER 0x1A2840UL
#define SK_SEP 0x162030UL
#define SK_ACCENT 0x1E58A8UL
#define SK_ACCENT_HOV 0x2A70CCUL
#define SK_BTN 0x182848UL
#define SK_BTN_HOV 0x1E3860UL
#define SK_SEL 0x1A3058UL
#define SK_ROW_ALT 0x0C1520UL
#define SK_ROW_HOV 0x132030UL
#define SK_TEXT 0xC8D4E8UL
#define SK_TEXT_HDR 0xE8F4FFUL
#define SK_TEXT_DIM 0x5A6880UL
#define SK_TEXT_HOV 0xF0F8FFUL
#define SK_TEXT_OK 0x44BB77UL
#define SK_TEXT_ERR 0xFF5555UL
#define SK_TEXT_WARN 0xFFCC44UL
/* ── Standard fonts ──────────────────────────────────────────────── */
#define SK_FONT_UI "Sans:size=9"
#define SK_FONT_SM "Sans:size=8"
#define SK_FONT_HDR "Sans:size=10:weight=bold"
#define SK_FONT_MONO "DejaVu Sans Mono:size=8"
/* ── App context (one per process) ──────────────────────────────── */
typedef struct {
Display *dpy;
int screen;
Window root;
Visual *vis;
Colormap cmap;
int depth;
XftFont *font_ui;
XftFont *font_sm;
XftFont *font_hdr;
XftFont *font_mono;
} SKApp;
/* ── Painter (per-window drawing context) ────────────────────────── */
typedef struct {
SKApp *app;
Drawable drw;
GC gc;
} SKPainter;
/* ── Simple button descriptor ────────────────────────────────────── */
typedef struct {
int x, y, w, h;
const char *label;
int id;
} SKBtn;
/* ── API ─────────────────────────────────────────────────────────── */
void sk_app_init (SKApp *app);
void sk_app_free (SKApp *app);
unsigned long sk_color (SKApp *app, unsigned long rgb);
void sk_xft_color (SKApp *app, unsigned long rgb, XftColor *out);
void sk_fill (SKPainter *p, unsigned long rgb, int x, int y, int w, int h);
void sk_rect (SKPainter *p, unsigned long rgb, int x, int y, int w, int h);
void sk_line (SKPainter *p, unsigned long rgb, int x1, int y1, int x2, int y2);
void sk_text (SKPainter *p, XftFont *font, unsigned long rgb, int x, int y, const char *s);
void sk_text_clip (SKPainter *p, XftFont *font, unsigned long rgb, int x, int y,
const char *s, int cx, int cy, int cw, int ch);
int sk_textw (SKApp *app, XftFont *font, const char *s);
int sk_baseline (XftFont *font, int y, int h);
int sk_in_rect (int mx, int my, int x, int y, int w, int h);
void sk_draw_btn (SKPainter *p, SKApp *app, XftFont *font, const SKBtn *b,
int hovered, unsigned long bg, unsigned long bghov);