Transiciones Suaves (Acabado Espectacular mejora #4): - Nuevo struct ColorTransition en animation.zig - Interpola colores en ~200ms usando lerp - Se inicializa automáticamente en primer uso - Exportado en zcatgui.zig junto con HoverTransition Uso: state.bg_transition.update(target_color, delta_ms) ctx.drawRect(..., state.bg_transition.current) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
269 lines
10 KiB
Zig
269 lines
10 KiB
Zig
//! zcatgui - Immediate Mode GUI Library for Zig
|
|
//!
|
|
//! A software-rendered, cross-platform GUI library with macro recording support.
|
|
//!
|
|
//! ## Features
|
|
//! - Immediate mode paradigm (no callbacks, explicit state)
|
|
//! - Software rendering (works everywhere, including SSH)
|
|
//! - Macro system for recording/replaying user actions
|
|
//! - SDL2 backend for cross-platform support
|
|
//!
|
|
//! ## Quick Start
|
|
//! ```zig
|
|
//! const zcatgui = @import("zcatgui");
|
|
//!
|
|
//! pub fn main() !void {
|
|
//! var app = try zcatgui.App.init(allocator, "My App", 800, 600);
|
|
//! defer app.deinit();
|
|
//!
|
|
//! while (app.running) {
|
|
//! app.beginFrame();
|
|
//!
|
|
//! if (app.button("Click me!")) {
|
|
//! // Handle click
|
|
//! }
|
|
//!
|
|
//! app.endFrame();
|
|
//! }
|
|
//! }
|
|
//! ```
|
|
|
|
const std = @import("std");
|
|
|
|
// =============================================================================
|
|
// Core modules
|
|
// =============================================================================
|
|
pub const Context = @import("core/context.zig").Context;
|
|
pub const Layout = @import("core/layout.zig");
|
|
pub const Style = @import("core/style.zig");
|
|
pub const Input = @import("core/input.zig");
|
|
pub const Command = @import("core/command.zig");
|
|
pub const clipboard = @import("core/clipboard.zig");
|
|
pub const mainloop = @import("core/mainloop.zig");
|
|
pub const MainLoop = mainloop.MainLoop;
|
|
pub const MainLoopConfig = mainloop.MainLoopConfig;
|
|
pub const dragdrop = @import("core/dragdrop.zig");
|
|
pub const DragDropManager = dragdrop.DragDropManager;
|
|
pub const DragData = dragdrop.DragData;
|
|
pub const DropZone = dragdrop.DropZone;
|
|
pub const DropResult = dragdrop.DropResult;
|
|
pub const shortcuts = @import("core/shortcuts.zig");
|
|
pub const ShortcutManager = shortcuts.ShortcutManager;
|
|
pub const Shortcut = shortcuts.Shortcut;
|
|
pub const focus = @import("core/focus.zig");
|
|
pub const FocusSystem = focus.FocusSystem;
|
|
pub const FocusGroup = focus.FocusGroup;
|
|
pub const accessibility = @import("core/accessibility.zig");
|
|
pub const A11yRole = accessibility.Role;
|
|
pub const A11yState = accessibility.State;
|
|
pub const A11yInfo = accessibility.Info;
|
|
pub const A11yManager = accessibility.Manager;
|
|
pub const gesture = @import("core/gesture.zig");
|
|
pub const GestureRecognizer = gesture.Recognizer;
|
|
pub const GestureType = gesture.GestureType;
|
|
pub const GesturePhase = gesture.GesturePhase;
|
|
pub const GestureResult = gesture.Result;
|
|
pub const GestureConfig = gesture.Config;
|
|
pub const SwipeDirection = gesture.SwipeDirection;
|
|
|
|
// =============================================================================
|
|
// Macro system
|
|
// =============================================================================
|
|
pub const macro = @import("macro/macro.zig");
|
|
pub const MacroRecorder = macro.MacroRecorder;
|
|
pub const MacroPlayer = macro.MacroPlayer;
|
|
pub const KeyEvent = macro.KeyEvent;
|
|
|
|
// =============================================================================
|
|
// Rendering
|
|
// =============================================================================
|
|
pub const render = struct {
|
|
pub const Framebuffer = @import("render/framebuffer.zig").Framebuffer;
|
|
pub const SoftwareRenderer = @import("render/software.zig").SoftwareRenderer;
|
|
const font_module = @import("render/font.zig");
|
|
pub const Font = font_module.Font;
|
|
pub const FontSize = font_module.FontSize;
|
|
pub const getFontForSize = font_module.getFontForSize;
|
|
pub const getFontForSizeAscii = font_module.getFontForSizeAscii;
|
|
// 8x8 fonts (compact)
|
|
pub const default_font = font_module.default_font;
|
|
pub const default_font_latin1 = font_module.default_font_latin1;
|
|
// 8x16 fonts (taller, VGA standard, better readability)
|
|
pub const font_8x16 = font_module.font_8x16;
|
|
pub const font_8x16_latin1 = font_module.font_8x16_latin1;
|
|
pub const font_data = font_module.font_data;
|
|
pub const ttf = @import("render/ttf.zig");
|
|
pub const TtfFont = ttf.TtfFont;
|
|
pub const FontRef = ttf.FontRef;
|
|
pub const embedded_font = @import("render/embedded_font.zig");
|
|
pub const animation = @import("render/animation.zig");
|
|
pub const effects = @import("render/effects.zig");
|
|
pub const antialiasing = @import("render/antialiasing.zig");
|
|
};
|
|
|
|
// Animation re-exports
|
|
pub const Animation = render.animation.Animation;
|
|
pub const AnimationManager = render.animation.AnimationManager;
|
|
pub const Easing = render.animation.Easing;
|
|
pub const lerp = render.animation.lerp;
|
|
pub const lerpInt = render.animation.lerpInt;
|
|
pub const Spring = render.animation.Spring;
|
|
pub const SpringConfig = render.animation.SpringConfig;
|
|
pub const HoverTransition = render.animation.HoverTransition;
|
|
pub const ColorTransition = render.animation.ColorTransition;
|
|
|
|
// Effects re-exports
|
|
pub const Shadow = render.effects.Shadow;
|
|
pub const Gradient = render.effects.Gradient;
|
|
pub const GradientDirection = render.effects.GradientDirection;
|
|
pub const applyShadow = render.effects.applyShadow;
|
|
pub const applyGradient = render.effects.applyGradient;
|
|
pub const applyBlur = render.effects.applyBlur;
|
|
pub const interpolateColor = render.effects.interpolateColor;
|
|
pub const applyOpacity = render.effects.applyOpacity;
|
|
pub const highlight = render.effects.highlight;
|
|
pub const lowlight = render.effects.lowlight;
|
|
|
|
// Anti-aliasing re-exports
|
|
pub const AAQuality = render.antialiasing.Quality;
|
|
pub const drawLineAA = render.antialiasing.drawLineAA;
|
|
pub const drawCircleAA = render.antialiasing.drawCircleAA;
|
|
pub const drawRoundedRectAA = render.antialiasing.drawRoundedRectAA;
|
|
pub const drawEllipseAA = render.antialiasing.drawEllipseAA;
|
|
pub const drawPolygonAA = render.antialiasing.drawPolygonAA;
|
|
|
|
// =============================================================================
|
|
// Backend
|
|
// =============================================================================
|
|
const builtin = @import("builtin");
|
|
|
|
pub const backend = struct {
|
|
pub const Backend = @import("backend/backend.zig").Backend;
|
|
|
|
// SDL2 backend (desktop only - not WASM, not Android)
|
|
pub const Sdl2Backend = if (builtin.cpu.arch == .wasm32 or builtin.cpu.arch == .wasm64 or builtin.os.tag == .linux and builtin.abi == .android)
|
|
void
|
|
else
|
|
@import("backend/sdl2.zig").Sdl2Backend;
|
|
|
|
// WASM backend
|
|
pub const wasm = if (builtin.cpu.arch == .wasm32 or builtin.cpu.arch == .wasm64)
|
|
@import("backend/wasm.zig")
|
|
else
|
|
struct {
|
|
pub const WasmBackend = void;
|
|
pub fn log(comptime fmt: []const u8, args: anytype) void {
|
|
_ = fmt;
|
|
_ = args;
|
|
}
|
|
};
|
|
|
|
// Android backend
|
|
pub const android = if (builtin.os.tag == .linux and builtin.abi == .android)
|
|
@import("backend/android.zig")
|
|
else
|
|
struct {
|
|
pub const AndroidBackend = void;
|
|
pub fn log(comptime fmt: []const u8, args: anytype) void {
|
|
_ = fmt;
|
|
_ = args;
|
|
}
|
|
pub fn getBackend() ?*AndroidBackend {
|
|
return null;
|
|
}
|
|
pub fn isRunning() bool {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
// iOS backend
|
|
pub const ios = if (builtin.os.tag == .ios)
|
|
@import("backend/ios.zig")
|
|
else
|
|
struct {
|
|
pub const IosBackend = void;
|
|
pub fn log(comptime fmt: []const u8, args: anytype) void {
|
|
_ = fmt;
|
|
_ = args;
|
|
}
|
|
pub fn getBackend() ?*IosBackend {
|
|
return null;
|
|
}
|
|
pub fn isRunning() bool {
|
|
return false;
|
|
}
|
|
};
|
|
};
|
|
|
|
// =============================================================================
|
|
// Utils (Performance utilities)
|
|
// =============================================================================
|
|
pub const utils = @import("utils/utils.zig");
|
|
pub const FrameArena = utils.FrameArena;
|
|
pub const ScopedArena = utils.ScopedArena;
|
|
pub const ObjectPool = utils.ObjectPool;
|
|
pub const CommandPool = utils.CommandPool;
|
|
pub const RingBuffer = utils.RingBuffer;
|
|
|
|
// Benchmarking
|
|
pub const Benchmark = utils.Benchmark;
|
|
pub const Timer = utils.Timer;
|
|
pub const FrameTimer = utils.FrameTimer;
|
|
pub const AllocationTracker = utils.AllocationTracker;
|
|
|
|
// =============================================================================
|
|
// Widgets
|
|
// =============================================================================
|
|
pub const widgets = @import("widgets/widgets.zig");
|
|
|
|
// =============================================================================
|
|
// Panels (Lego Panels architecture)
|
|
// =============================================================================
|
|
pub const panels = @import("panels/panels.zig");
|
|
|
|
// Re-export common widget types
|
|
pub const label = widgets.label.label;
|
|
pub const labelEx = widgets.label.labelEx;
|
|
pub const labelColored = widgets.label.labelColored;
|
|
pub const labelCentered = widgets.label.labelCentered;
|
|
|
|
pub const button = widgets.button.button;
|
|
pub const buttonEx = widgets.button.buttonEx;
|
|
pub const buttonPrimary = widgets.button.buttonPrimary;
|
|
pub const buttonDanger = widgets.button.buttonDanger;
|
|
|
|
pub const textInput = widgets.text_input.textInput;
|
|
pub const textInputEx = widgets.text_input.textInputEx;
|
|
pub const TextInputState = widgets.TextInputState;
|
|
|
|
pub const checkbox = widgets.checkbox.checkbox;
|
|
pub const checkboxEx = widgets.checkbox.checkboxEx;
|
|
|
|
pub const select = widgets.select.select;
|
|
pub const selectEx = widgets.select.selectEx;
|
|
pub const SelectState = widgets.SelectState;
|
|
|
|
pub const list = widgets.list.list;
|
|
pub const listEx = widgets.list.listEx;
|
|
pub const ListState = widgets.ListState;
|
|
|
|
|
|
// =============================================================================
|
|
// Re-exports for convenience
|
|
// =============================================================================
|
|
pub const Color = Style.Color;
|
|
pub const Rect = Layout.Rect;
|
|
pub const Constraint = Layout.Constraint;
|
|
|
|
// Theme system
|
|
pub const Theme = Style.Theme;
|
|
pub const ThemeManager = Style.ThemeManager;
|
|
pub const getThemeManager = Style.getThemeManager;
|
|
pub const currentTheme = Style.currentTheme;
|
|
|
|
// =============================================================================
|
|
// Tests
|
|
// =============================================================================
|
|
test {
|
|
std.testing.refAllDecls(@This());
|
|
}
|