Last Updated: 2025-11-16 Branch: dev Latest Commit: Merge macOS native rendering backend
GoFlow now has a working native macOS rendering backend using Core Graphics and Cocoa!
GoFlow/
├── pkg/ # Core packages (Go convention)
│ ├── core/
│ │ ├── framework/ # Framework core (renamed from goflow/)
│ │ ├── signals/ # Reactive state management
│ │ └── widgets/ # Base widgets
│ └── ui/
│ ├── adaptive/ # Platform-adaptive widgets
│ ├── material/ # Material Design
│ └── cupertino/ # iOS/macOS Cupertino
├── backends/ # ✨ NEW: Native rendering backends
│ └── macos/ # macOS Core Graphics backend
├── cmd/goflow/ # CLI tool
├── docs/ # Documentation
└── examples/ # Example applications
└── rendering-demo/ # ✨ NEW: Rendering demonstration
Total: ~1,321 lines of code
-
canvas_macos.go(197 lines) - Canvas interface implementation- DrawRect (filled and stroked)
- DrawCircle (filled and stroked)
- DrawLine
- DrawText with Core Text
- Canvas transformations (translate, scale, rotate)
- Save/restore state
- Clipping rectangles
-
window_macos.go(312 lines) - Window management- Window creation and destruction
- Event loop
- Resize callbacks
- Draw callbacks
- Thread-safe window registry
-
cgo_bridge.h/m(391 lines) - Core Graphics bridging- Graphics context creation
- Drawing primitives
- Text rendering with Core Text
- Color and transformation handling
-
window_bridge.h/m(421 lines) - Cocoa window bridging- NSWindow creation and management
- NSView for rendering
- Event handling infrastructure
- Display synchronization
-
Window Management
- Native macOS NSWindow creation
- Show/hide/destroy operations
- Resize event handling
- Clean event loop
-
Canvas Operations
- Rectangle drawing (filled/stroked)
- Circle drawing (filled/stroked)
- Line drawing
- Text rendering with fonts
- Full color support (RGBA)
- Stroke width control
-
Transformations
- Translate
- Scale
- Rotate
- Save/restore state
- Clipping rectangles
-
Text Rendering
- Core Text integration
- Font family support
- Font size control
- Font weight (bold)
- Color support
Complete working example demonstrating:
- Window creation
- Multiple shapes (rectangles, circles, lines)
- Text rendering with different styles
- Color palette display
- Animation placeholder
- Resize handling
Run it:
cd examples/rendering-demo
go run main.go- Widget, Element, RenderObject interfaces
- Canvas interface definition
- Layout system (constraints, sizing)
- Geometry primitives (Rect, Offset, Size)
- App entry point
- Signal - Reactive value containers
- Computed - Derived values
- Effect - Side effects
- Batch - Grouped updates
- Collections (SignalSlice, SignalMap)
- Text, Container, Column, Row
- Center, Align, Stack
- Flexible, Image, Icon
- ListView, GestureDetector
- Platform-adaptive widgets
- Auto-switches between Material/Cupertino
- Material Design widgets
- Scaffold, AppBar, Drawer
- Button, Card, Checkbox
- TextField, FAB, BottomNav
- iOS/macOS design widgets
- CupertinoScaffold, NavigationBar
- CupertinoButton, TextField
- iOS-style theming
Core Framework:
- ✅ Widget system
- ✅ Element lifecycle
- ✅ RenderObject tree
- ✅ Layout system (box protocol)
- ✅ Three-tree architecture
State Management:
- ✅ Signals (reactive values)
- ✅ Computed (derived values)
- ✅ Effects (side effects)
- ✅ Collections (SignalSlice, SignalMap)
- ✅ Batch updates
Rendering (macOS):
- ✅ Native window creation
- ✅ Core Graphics canvas
- ✅ Basic shapes (rect, circle, line)
- ✅ Text rendering (Core Text)
- ✅ Colors and transparency
- ✅ Stroke and fill
- ✅ Transformations
- ✅ Event loop
CLI Tool:
- ✅ Project scaffolding (
goflow create) - ✅ Multiple templates (default, minimal, material)
- ✅ Platform selection
- ✅ Embedded templates
Documentation:
- ✅ Complete architecture docs
- ✅ Getting started guide
- ✅ Rendering architecture
- ✅ CLI reference
- ✅ Workflow guide
- ✅ Flutter comparison
Rendering:
- ⏳ Mouse event handling
- ⏳ Keyboard event handling
- ⏳ More drawing primitives (paths, images)
- ⏳ Advanced text layout (multi-line, wrapping)
Platforms:
- ⏳ Windows backend (Direct2D)
- ⏳ Linux backend (Cairo)
- ⏳ WGPU cross-platform option
Widgets:
- ⏳ Input widgets (TextField, Button interactions)
- ⏳ Scrolling widgets implementation
- ⏳ More layout widgets
Core:
- Hot reload
- Animation system
- Advanced layout (Grid, Flow)
- Image loading and caching
- Asset management
Rendering:
- GPU acceleration
- Layer caching
- Dirty rectangles
- Paint culling
Platform:
- Native project files (Xcode, VS, CMake)
- Code signing
- Distribution tools
Widgets:
- Complete Material Design set
- Complete Cupertino set
- Custom widget toolkit
pkg/core/framework/ ~3,500 lines
pkg/core/signals/ ~2,000 lines
pkg/core/widgets/ ~5,000 lines
pkg/ui/adaptive/ ~1,500 lines
pkg/ui/material/ ~4,500 lines
pkg/ui/cupertino/ ~3,500 lines
backends/macos/ ~1,320 lines
cmd/goflow/ ~1,200 lines
examples/ ~2,500 lines
docs/ ~15,000 lines (markdown)
─────────────────────────────────
TOTAL (Go code): ~25,000 lines
Go files: ~66
Markdown files: ~15
Template files: ~12
Objective-C files: 4
Header files: 2
-
Complete macOS Backend
- Add mouse event handling
- Add keyboard event handling
- Implement image rendering
- Add path drawing
-
Widget Integration
- Connect widgets to rendering backend
- Implement widget-to-canvas pipeline
- Test basic widget rendering
-
Platform Runners Update
- Update platform templates to use backends
- Add rendering initialization code
- Test complete workflow
-
Windows Backend
- Implement Direct2D canvas
- DirectWrite text rendering
- Win32 window management
-
Linux Backend
- Implement Cairo canvas
- Pango text rendering
- X11/Wayland window management
-
Examples
- Widget rendering demo
- Interactive app demo
- Complete todo app with rendering
-
Production Ready
- Stable APIs
- Complete documentation
- Comprehensive tests
- Performance optimization
-
Platform Integration
- Native project templates (Xcode, VS)
- Build automation
- Code signing
- Distribution
-
Advanced Features
- Hot reload
- Animation system
- DevTools
- Plugin system
After reorganization:
import (
// Core framework
"github.com/base-go/GoFlow/pkg/core/framework"
"github.com/base-go/GoFlow/pkg/core/signals"
"github.com/base-go/GoFlow/pkg/core/widgets"
// UI packages
"github.com/base-go/GoFlow/pkg/ui/adaptive"
"github.com/base-go/GoFlow/pkg/ui/material"
"github.com/base-go/GoFlow/pkg/ui/cupertino"
// Backends
"github.com/base-go/GoFlow/backends/macos"
)- ✅ Working Native Rendering - First pixels on screen!
- ✅ Complete Core Framework - Widget/Element/RenderObject system
- ✅ Reactive State Management - Signals-based system
- ✅ CLI Tool - Project scaffolding
- ✅ Comprehensive Documentation - Complete guides
- ✅ Go Convention Structure - Professional organization
- ✅ Design Systems - Material + Cupertino + Adaptive
The Canvas interface successfully abstracts platform-specific rendering:
type Canvas interface {
Clear(color *Color)
DrawRect(rect *Rect, paint *Paint)
DrawCircle(center *Offset, radius float64, paint *Paint)
DrawText(text string, offset *Offset, style *TextStyle)
DrawLine(p1, p2 *Offset, paint *Paint)
Save()
Restore()
Translate(dx, dy float64)
Scale(sx, sy float64)
Rotate(radians float64)
ClipRect(rect *Rect)
}macOS Implementation: Core Graphics ✅ Windows Implementation: Direct2D (planned) Linux Implementation: Cairo (planned) WGPU Implementation: WebGPU (optional)
Clean separation between Go and Objective-C:
Go API (canvas_macos.go)
↓
CGo Bindings (import "C")
↓
C/Objective-C Bridge (cgo_bridge.h/m)
↓
Core Graphics / Cocoa APIs
This pattern will work for Windows (C++) and Linux (C) backends too.
Thread-safe window registry with callback system:
- Window creation/destruction
- Event loop integration
- Resize callbacks
- Draw callbacks
- Clean lifecycle management
# Navigate to rendering demo
cd examples/rendering-demo
# Run (macOS only for now)
go run main.goWhat you'll see:
- Native macOS window
- Title and subtitle text
- Filled and stroked rectangles
- Filled and stroked circles
- Colored lines
- Color palette swatches
- Smooth rendering
Close the window to exit.
package main
import (
"github.com/base-go/GoFlow/backends/macos"
"github.com/base-go/GoFlow/pkg/core/framework"
)
func main() {
macos.InitApp()
window := macos.NewWindow(800, 600, "My App")
defer window.Destroy()
window.SetDrawFunc(func(canvas *macos.CoreGraphicsCanvas) {
canvas.Clear(framework.ColorWhite)
paint := framework.NewPaint()
paint.Color = framework.ColorBlue
rect := framework.NewRect(
framework.NewOffset(100, 100),
framework.NewSize(200, 150),
)
canvas.DrawRect(rect, paint)
})
window.Show()
for !window.ShouldClose() {
window.PollEvents()
window.SetNeedsDisplay()
}
}All documentation is up-to-date with the latest changes:
- Getting Started - Complete tutorial
- Architecture - Framework design
- Rendering - Updated with macOS backend info
- Workflow - Complete technical flow
- CLI Reference - CLI documentation
- Project Structure - Organization guide
- Flutter Comparison - For Flutter devs
GoFlow v0.1.0+ is now a working GUI framework with:
✅ Complete core framework architecture ✅ Reactive state management ✅ Native macOS rendering (NEW!) ✅ CLI tool for project creation ✅ Comprehensive documentation ✅ Multiple design systems ✅ Professional code organization
Next milestone: Complete widget-to-renderer integration and add Windows/Linux backends!
Ready to build native desktop apps with Go! 🚀