Mercurial
diff third_party/raylib/custom.h @ 173:827c6ac504cd hg-web
Merged in default here.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 19 Jan 2026 18:59:10 -0800 |
| parents | 058de208e640 |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/third_party/raylib/custom.h Mon Jan 19 18:59:10 2026 -0800 @@ -0,0 +1,143 @@ +#ifndef CUSTOM_UI +#define CUSTOM_UI + +#include "dowa/dowa.h" +#include "third_party/raylib/include/raylib.h" + +// ============================================================================ +// COLOR SCHEME - Easily modifiable color palette +// ============================================================================ + +typedef struct { + Color primary; // Main accent color (Orange) + Color secondary; // Secondary background (Beige/Egg white) + Color background; // Main background (White) + Color text; // Text color (Black) + Color text_light; // Light text (White - for dark backgrounds) + Color border; // Border color + Color highlight; // Highlight/hover color + Color success; // Success indicator + Color error; // Error indicator + Color muted; // Muted/disabled elements +} ColorScheme; + +// Global color scheme - initialize with PostDog_InitColorScheme() +extern ColorScheme g_colors; + +void PostDog_InitColorScheme(void); +void PostDog_SetColorScheme(ColorScheme scheme); + +// Predefined color schemes +ColorScheme PostDog_DefaultColorScheme(void); +ColorScheme PostDog_DarkColorScheme(void); + +// ============================================================================ +// FUNCTIONALITY HELPERS +// ============================================================================ + +void DefaultBehaviours(void); +void IncreaseFontSize(void); +void DecreaseFontSize(void); + +// ============================================================================ +// LAYOUT HELPERS +// ============================================================================ + +Rectangle RightOf(Rectangle ref, float padding); +Rectangle Below(Rectangle ref, float padding); +Rectangle LeftColumn(Rectangle container, float ratio, float padding); +Rectangle RightColumn(Rectangle container, Rectangle leftCol, float padding); +Rectangle HorizontalSplit(Rectangle container, float ratio); +Rectangle VerticalSplit(Rectangle container, float ratio); +Rectangle AddPadding(Rectangle rect, float padding); +Rectangle AddPaddingAll(Rectangle rect, float top, float right, float down, float left); +Rectangle AddPaddingHorizontal(Rectangle rect, float padding); +Rectangle AddPaddingVertical(Rectangle rect, float padding); + +// ============================================================================ +// DRAWING HELPERS +// ============================================================================ + +void DrawRectangleSelectiveRounded(Rectangle rec, float radius, int segments, Color color, + boolean roundTL, boolean roundTR, boolean roundBR, boolean roundBL); +void DrawRectangleSelectiveRoundedLines(Rectangle rec, float radius, int segments, Color color, + boolean roundTL, boolean roundTR, boolean roundBR, boolean roundBL); + +// ============================================================================ +// CUSTOM TAB COMPONENT +// ============================================================================ + +// Tab configuration +typedef struct { + const char **labels; // Array of tab labels + int count; // Number of tabs + int *active_tab; // Pointer to active tab index + float padding; // Padding between tabs + float corner_radius; // Corner radius for rounded tabs + Color active_color; // Color for active tab + Color inactive_color; // Color for inactive tab + Color text_color; // Text color + Color active_text_color; // Text color for active tab +} TabConfig; + +// Draw tabs and return true if active tab changed +// Usage: PostDog_TabBar(bounds, config) where config contains all tab settings +boolean PostDog_TabBar(Rectangle bounds, TabConfig config); + +// Simplified tab bar - uses default styling from color scheme +// Returns true if tab changed +boolean PostDog_TabBarSimple(Rectangle bounds, const char **labels, int count, int *active_tab); + +// ============================================================================ +// COMBINED INPUT COMPONENTS +// ============================================================================ + +// Dropdown + TextBox combined component +// Draws a dropdown on the left, text input on the right, with shared rounded border +typedef struct { + // Dropdown settings + const char *dropdown_items; // Semicolon-separated items: "GET;POST;PUT;DELETE" + int *dropdown_active; // Pointer to active dropdown index + boolean *dropdown_edit_mode; // Pointer to dropdown edit mode state + float dropdown_width; // Width of dropdown (ratio 0.0-1.0 or absolute if > 1.0) + + // TextBox settings + char *text_buffer; // Text buffer for input + int text_buffer_size; // Size of text buffer + boolean *text_edit_mode; // Pointer to text edit mode state + + // Styling + float corner_radius; + Color background_color; + Color border_color; + Color text_color; + + // Optional: per-item colors for dropdown (NULL to use default text_color) + Color *item_colors; // Array of colors matching dropdown items count + int item_count; // Number of items (required if item_colors is set) +} DropdownTextBoxConfig; + +boolean PostDog_DropdownTextBox(Rectangle bounds, DropdownTextBoxConfig config); + +// ============================================================================ +// PANEL COMPONENTS +// ============================================================================ + +// Split panel - two panels side by side with shared rounded border +typedef struct { + float split_ratio; // 0.0-1.0, ratio of left panel + float corner_radius; + Color left_color; + Color right_color; + Color border_color; + float gap; // Gap between panels (0 for seamless) +} SplitPanelConfig; + +// Returns rectangles for left and right content areas +void PostDog_SplitPanel(Rectangle bounds, SplitPanelConfig config, + Rectangle *out_left, Rectangle *out_right); + +// Draw split panel background only (for custom content) +void PostDog_SplitPanelDraw(Rectangle bounds, SplitPanelConfig config); + +#endif // CUSTOM_UI