From 13ffbd4fa388dd5bd5dc6a6ddf40fa0bd28a6fc4 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 15 Aug 2019 09:27:04 -0400 Subject: [PATCH] Add README.md --- README.md | 36 ++++++++++++++++++++++++++++++++++++ main.go | 8 +++----- 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5133b12 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# GIOWrap + +An experimental wrapper package for the Gio immediate mode GUI, designed to reduce +boilerplate. + +The basic concept is to define a `Context` type that contains the Gio variables +required for layout and drawing. `Context` contains a pointer to `app.Window` and +`ui.Ops` so that, once layout is complete, you can call `Context.Draw()` to draw +your objects in your window. + +The following types and functions are defined in order to transform a `Context` +variable during layout: + +```go +type Layout func(Context) Context + +type Widget interface { + Layout(Context) Context +} + +func LayoutWithContext(ctx Context, ws ...Widget) Context { + for _, w := range ws { + ctx = w.Layout(ctx) + } + return ctx +} + +type WidgetCombinator func(...Widget) Widget + +type Enclosure interface { + Begin(Context) Context + End(Context) Context +} + +func Enclose(e Enclosure, w ...Widget) Widget { ... } +``` diff --git a/main.go b/main.go index 4af0bf0..3ebbd9e 100644 --- a/main.go +++ b/main.go @@ -51,11 +51,9 @@ func (ctx Context) Draw() { type Layout func(Context) Context -type LayoutCombinator func(...Layout) Layout - -func LayoutWithContext(ctx Context, ls ...Widget) Context { - for _, l := range ls { - ctx = l.Layout(ctx) +func LayoutWithContext(ctx Context, ws ...Widget) Context { + for _, w := range ws { + ctx = w.Layout(ctx) } return ctx }