From ad697d550868a8e141ac9bcac31f0bd28034a43e Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 22 Sep 2018 16:23:26 +0200 Subject: [PATCH] Renamed repository to opslag.de/schobers/zntg. Renamed allegro5 package to allg5 --- {allegro5 => allg5}/bitmap.go | 2 +- {allegro5 => allg5}/c.go | 2 +- {allegro5 => allg5}/c_windows.go | 2 +- {allegro5 => allg5}/c_windows_static.go | 2 +- {allegro5 => allg5}/color.go | 2 +- {allegro5 => allg5}/display.go | 2 +- {allegro5 => allg5}/event.go | 2 +- {allegro5 => allg5}/flagmut.go | 2 +- {allegro5 => allg5}/font.go | 2 +- {allegro5 => allg5}/graphics.go | 2 +- {allegro5 => allg5}/keyboard.go | 2 +- {allegro5 => allg5}/monitor.go | 2 +- {allegro5 => allg5}/mouse.go | 2 +- {allegro5 => allg5}/newbitmapflag.go | 2 +- {allegro5 => allg5}/platform_windows.go | 2 +- {allegro5 => allg5}/primitives.go | 2 +- {allegro5 => allg5}/system.go | 2 +- ui/button.go | 20 ++++----- ui/checkbox.go | 20 ++++----- ui/container.go | 4 +- ui/contentscrollbar.go | 12 ++--- ui/context.go | 20 ++++----- ui/control.go | 18 ++++---- ui/draw.go | 8 ++-- ui/fonts.go | 12 ++--- ui/label.go | 4 +- ui/loop.go | 32 ++++++------- ui/palette.go | 60 ++++++++++++------------- ui/scroll.go | 10 ++--- ui/scrollbar.go | 26 +++++------ ui/shadow.go | 24 +++++----- ui/spinner.go | 12 ++--- ui/state.go | 6 +-- ui/statusbar.go | 8 ++-- ui/wrapper.go | 4 +- 35 files changed, 167 insertions(+), 167 deletions(-) rename {allegro5 => allg5}/bitmap.go (99%) rename {allegro5 => allg5}/c.go (88%) rename {allegro5 => allg5}/c_windows.go (88%) rename {allegro5 => allg5}/c_windows_static.go (94%) rename {allegro5 => allg5}/color.go (97%) rename {allegro5 => allg5}/display.go (99%) rename {allegro5 => allg5}/event.go (99%) rename {allegro5 => allg5}/flagmut.go (94%) rename {allegro5 => allg5}/font.go (99%) rename {allegro5 => allg5}/graphics.go (98%) rename {allegro5 => allg5}/keyboard.go (99%) rename {allegro5 => allg5}/monitor.go (97%) rename {allegro5 => allg5}/mouse.go (97%) rename {allegro5 => allg5}/newbitmapflag.go (97%) rename {allegro5 => allg5}/platform_windows.go (93%) rename {allegro5 => allg5}/primitives.go (98%) rename {allegro5 => allg5}/system.go (98%) diff --git a/allegro5/bitmap.go b/allg5/bitmap.go similarity index 99% rename from allegro5/bitmap.go rename to allg5/bitmap.go index 2e3f41d..0e56704 100644 --- a/allegro5/bitmap.go +++ b/allg5/bitmap.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include // #include diff --git a/allegro5/c.go b/allg5/c.go similarity index 88% rename from allegro5/c.go rename to allg5/c.go index 090dbe7..1b5f2b1 100644 --- a/allegro5/c.go +++ b/allg5/c.go @@ -1,6 +1,6 @@ // +build !windows -package allegro5 +package allg5 // #cgo pkg-config: allegro-5 allegro_font-5 allegro_image-5 allegro_primitives-5 allegro_ttf-5 import "C" diff --git a/allegro5/c_windows.go b/allg5/c_windows.go similarity index 88% rename from allegro5/c_windows.go rename to allg5/c_windows.go index 0ca62d4..3646de5 100644 --- a/allegro5/c_windows.go +++ b/allg5/c_windows.go @@ -1,6 +1,6 @@ // +build windows,!static -package allegro5 +package allg5 // #cgo LDFLAGS: -lallegro -lallegro_font -lallegro_image -lallegro_primitives -lallegro_ttf import "C" diff --git a/allegro5/c_windows_static.go b/allg5/c_windows_static.go similarity index 94% rename from allegro5/c_windows_static.go rename to allg5/c_windows_static.go index cfca8fd..2655561 100644 --- a/allegro5/c_windows_static.go +++ b/allg5/c_windows_static.go @@ -1,6 +1,6 @@ // +build windows,static -package allegro5 +package allg5 // #cgo LDFLAGS: -lallegro_monolith-static -static -ljpeg -ldumb -lFLAC -lfreetype -lvorbisfile -lvorbis -logg -lphysfs -lpng16 -lzlib -luuid -lkernel32 -lwinmm -lpsapi -lopengl32 -lglu32 -luser32 -lcomdlg32 -lgdi32 -lshell32 -lole32 -ladvapi32 -lws2_32 -lshlwapi -lstdc++ import "C" diff --git a/allegro5/color.go b/allg5/color.go similarity index 97% rename from allegro5/color.go rename to allg5/color.go index c861cbc..ae30853 100644 --- a/allegro5/color.go +++ b/allg5/color.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/display.go b/allg5/display.go similarity index 99% rename from allegro5/display.go rename to allg5/display.go index 0f8b1ec..23e5d98 100644 --- a/allegro5/display.go +++ b/allg5/display.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/event.go b/allg5/event.go similarity index 99% rename from allegro5/event.go rename to allg5/event.go index 59572bf..64df75d 100644 --- a/allegro5/event.go +++ b/allg5/event.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/flagmut.go b/allg5/flagmut.go similarity index 94% rename from allegro5/flagmut.go rename to allg5/flagmut.go index f4547d0..43684b4 100644 --- a/allegro5/flagmut.go +++ b/allg5/flagmut.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/font.go b/allg5/font.go similarity index 99% rename from allegro5/font.go rename to allg5/font.go index 4937860..0aeef9f 100644 --- a/allegro5/font.go +++ b/allg5/font.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include // #include diff --git a/allegro5/graphics.go b/allg5/graphics.go similarity index 98% rename from allegro5/graphics.go rename to allg5/graphics.go index 1411b2c..ef018cb 100644 --- a/allegro5/graphics.go +++ b/allg5/graphics.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/keyboard.go b/allg5/keyboard.go similarity index 99% rename from allegro5/keyboard.go rename to allg5/keyboard.go index a12a6ec..2961a8c 100644 --- a/allegro5/keyboard.go +++ b/allg5/keyboard.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/monitor.go b/allg5/monitor.go similarity index 97% rename from allegro5/monitor.go rename to allg5/monitor.go index be681de..f6b1852 100644 --- a/allegro5/monitor.go +++ b/allg5/monitor.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/mouse.go b/allg5/mouse.go similarity index 97% rename from allegro5/mouse.go rename to allg5/mouse.go index 5598b8e..8ad9f6d 100644 --- a/allegro5/mouse.go +++ b/allg5/mouse.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/newbitmapflag.go b/allg5/newbitmapflag.go similarity index 97% rename from allegro5/newbitmapflag.go rename to allg5/newbitmapflag.go index 645b135..d978066 100644 --- a/allegro5/newbitmapflag.go +++ b/allg5/newbitmapflag.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include import "C" diff --git a/allegro5/platform_windows.go b/allg5/platform_windows.go similarity index 93% rename from allegro5/platform_windows.go rename to allg5/platform_windows.go index 4400bed..3908d18 100644 --- a/allegro5/platform_windows.go +++ b/allg5/platform_windows.go @@ -1,6 +1,6 @@ // +build windows -package allegro5 +package allg5 // #include // #include diff --git a/allegro5/primitives.go b/allg5/primitives.go similarity index 98% rename from allegro5/primitives.go rename to allg5/primitives.go index 72205e0..114e3f5 100644 --- a/allegro5/primitives.go +++ b/allg5/primitives.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include // #include diff --git a/allegro5/system.go b/allg5/system.go similarity index 98% rename from allegro5/system.go rename to allg5/system.go index 6fd40fe..aa3d1bb 100644 --- a/allegro5/system.go +++ b/allg5/system.go @@ -1,4 +1,4 @@ -package allegro5 +package allg5 // #include // #include diff --git a/ui/button.go b/ui/button.go index de2043f..8e75d4b 100644 --- a/ui/button.go +++ b/ui/button.go @@ -1,21 +1,21 @@ package ui import ( - "opslag.de/schobers/galleg/allegro5" "opslag.de/schobers/geom" + "opslag.de/schobers/zntg/allg5" ) type Button struct { ControlBase Text string - HorizontalAlignment allegro5.HorizontalAlignment + HorizontalAlignment allg5.HorizontalAlignment } func NewButton(text string, click MouseClickFn) *Button { return &Button{ControlBase: ControlBase{OnClick: click}, Text: text} } -func NewButtonAlign(text string, click MouseClickFn, align allegro5.HorizontalAlignment) *Button { +func NewButtonAlign(text string, click MouseClickFn, align allg5.HorizontalAlignment) *Button { return &Button{ControlBase: ControlBase{OnClick: click}, Text: text, HorizontalAlignment: align} } @@ -40,14 +40,14 @@ func (b *Button) Render(ctx Context) { if b.IsOver && !b.IsPressed { back = ctx.Palette().PrimaryHighlight() } - allegro5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, back) + allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, back) switch b.HorizontalAlignment { - case allegro5.AlignLeft: - fnt.Draw(min.X+.5*fntH, min.Y+.5*fntH, ctx.Palette().Lightest(), allegro5.AlignLeft, b.Text) - case allegro5.AlignCenter: - fnt.Draw(.5*(min.X+max.X), min.Y+.5*fntH, ctx.Palette().Lightest(), allegro5.AlignCenter, b.Text) - case allegro5.AlignRight: - fnt.Draw(min.X-.5*fntH, min.Y+.5*fntH, ctx.Palette().Lightest(), allegro5.AlignRight, b.Text) + case allg5.AlignLeft: + fnt.Draw(min.X+.5*fntH, min.Y+.5*fntH, ctx.Palette().Lightest(), allg5.AlignLeft, b.Text) + case allg5.AlignCenter: + fnt.Draw(.5*(min.X+max.X), min.Y+.5*fntH, ctx.Palette().Lightest(), allg5.AlignCenter, b.Text) + case allg5.AlignRight: + fnt.Draw(min.X-.5*fntH, min.Y+.5*fntH, ctx.Palette().Lightest(), allg5.AlignRight, b.Text) } b.ControlBase.Render(ctx) diff --git a/ui/checkbox.go b/ui/checkbox.go index dab8fd0..9679200 100644 --- a/ui/checkbox.go +++ b/ui/checkbox.go @@ -6,13 +6,13 @@ import ( "github.com/llgcode/draw2d/draw2dimg" "github.com/llgcode/draw2d/draw2dkit" - "opslag.de/schobers/galleg/allegro5" "opslag.de/schobers/geom" + "opslag.de/schobers/zntg/allg5" ) type CheckboxValueChangedFn func(bool) -func drawCheckedBitmap(fill, stroke color.Color) *allegro5.Bitmap { +func drawCheckedBitmap(fill, stroke color.Color) *allg5.Bitmap { return drawBitmap(checkboxSize, checkboxSize, func(gc *draw2dimg.GraphicContext) { var size = float64(checkboxSize) var margin = float64(checkboxMargin) @@ -30,7 +30,7 @@ func drawCheckedBitmap(fill, stroke color.Color) *allegro5.Bitmap { }) } -func drawUncheckedBitmap(fill, stroke color.Color) *allegro5.Bitmap { +func drawUncheckedBitmap(fill, stroke color.Color) *allg5.Bitmap { return drawBitmap(checkboxSize, checkboxSize, func(gc *draw2dimg.GraphicContext) { var size = float64(checkboxSize) var margin = float64(checkboxMargin) @@ -47,8 +47,8 @@ type Checkbox struct { Value bool Text string OnChanged CheckboxValueChangedFn - checked *allegro5.Bitmap - unchecked *allegro5.Bitmap + checked *allg5.Bitmap + unchecked *allg5.Bitmap } func (c *Checkbox) Created(ctx Context, p Container) error { @@ -65,11 +65,11 @@ func (c *Checkbox) Created(ctx Context, p Container) error { return nil } -func (c *Checkbox) Handle(ctx Context, ev allegro5.Event) { +func (c *Checkbox) Handle(ctx Context, ev allg5.Event) { var pressed = c.IsPressed c.ControlBase.Handle(ctx, ev) switch ev.(type) { - case *allegro5.MouseButtonUpEvent: + case *allg5.MouseButtonUpEvent: if !c.Disabled && pressed && c.IsOver { c.Value = !c.Value var onChanged = c.OnChanged @@ -87,7 +87,7 @@ func (c *Checkbox) DesiredSize(ctx Context) geom.PointF { return geom.PtF(float64(w+checkboxSize), checkboxSize) } -func (c *Checkbox) box() *allegro5.Bitmap { +func (c *Checkbox) box() *allg5.Bitmap { if c.Value { return c.checked } @@ -100,10 +100,10 @@ func (c *Checkbox) Render(ctx Context) { var min = c.Bounds.Min.To32() var fnt = fonts.Get("default") - fnt.Draw(min.X+checkboxSize, min.Y-.67*fnt.Ascent()+.5*checkboxSize, ctx.Palette().Darkest(), allegro5.AlignLeft, c.Text) + fnt.Draw(min.X+checkboxSize, min.Y-.67*fnt.Ascent()+.5*checkboxSize, ctx.Palette().Darkest(), allg5.AlignLeft, c.Text) if c.Disabled { var disabled = ctx.Palette().Disabled() - c.box().DrawOptions(min.X, min.Y, allegro5.DrawOptions{Tint: &disabled}) + c.box().DrawOptions(min.X, min.Y, allg5.DrawOptions{Tint: &disabled}) } else { c.box().Draw(min.X, min.Y) } diff --git a/ui/container.go b/ui/container.go index 156d241..8fe477d 100644 --- a/ui/container.go +++ b/ui/container.go @@ -3,8 +3,8 @@ package ui import ( "time" - "opslag.de/schobers/galleg/allegro5" "opslag.de/schobers/geom" + "opslag.de/schobers/zntg/allg5" ) type Container interface { @@ -92,7 +92,7 @@ func (c *ContainerBase) Update(ctx Context, dt time.Duration) { } } -func (c *ContainerBase) Handle(ctx Context, ev allegro5.Event) { +func (c *ContainerBase) Handle(ctx Context, ev allg5.Event) { for _, child := range c.children { child.Handle(ctx, ev) } diff --git a/ui/contentscrollbar.go b/ui/contentscrollbar.go index 6269834..82a85f7 100644 --- a/ui/contentscrollbar.go +++ b/ui/contentscrollbar.go @@ -3,8 +3,8 @@ package ui import ( "math" - "opslag.de/schobers/galleg/allegro5" "opslag.de/schobers/geom" + "opslag.de/schobers/zntg/allg5" ) var _ Control = &ContentScrollbar{} @@ -35,7 +35,7 @@ func (h *contentScrollbarHandle) Render(ctx Context) { } var min = h.Bounds.Min.To32() var max = h.Bounds.Max.To32() - allegro5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, c) + allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, c) } func (s *ContentScrollbar) Created(ctx Context, p Container) error { @@ -138,22 +138,22 @@ func (s *ContentScrollbar) increment(d int) { s.change(val) } -func (s *ContentScrollbar) Handle(ctx Context, ev allegro5.Event) { +func (s *ContentScrollbar) Handle(ctx Context, ev allg5.Event) { s.ControlBase.Handle(ctx, ev) s.handle.Handle(ctx, ev) switch e := ev.(type) { - case *allegro5.MouseMoveEvent: + case *allg5.MouseMoveEvent: if s.handle.IsPressed { s.snapTo(e.X, e.Y) } if 0 != e.DeltaZ && s.IsOver { var d = e.DeltaZ - if allegro5.IsAnyKeyDown(allegro5.KeyLShift, allegro5.KeyRShift) { + if allg5.IsAnyKeyDown(allg5.KeyLShift, allg5.KeyRShift) { d *= 10 } s.increment(d) } - case *allegro5.MouseButtonDownEvent: + case *allg5.MouseButtonDownEvent: if !s.handle.IsPressed && s.IsOver { s.snapTo(e.X, e.Y) } diff --git a/ui/context.go b/ui/context.go index 6bf0d1e..2faae97 100644 --- a/ui/context.go +++ b/ui/context.go @@ -1,9 +1,9 @@ package ui -import "opslag.de/schobers/galleg/allegro5" +import "opslag.de/schobers/zntg/allg5" type Context interface { - Display() *allegro5.Display + Display() *allg5.Display Fonts() Fonts Palette() Palette Debug() Debug @@ -11,13 +11,13 @@ type Context interface { type Debug interface { IsEnabled() bool - Rainbow() allegro5.Color + Rainbow() allg5.Color } var _ Context = &context{} type context struct { - disp *allegro5.Display + disp *allg5.Display fts Fonts pal Palette dbg *debug @@ -25,23 +25,23 @@ type context struct { type debug struct { enbl bool - rainb []allegro5.Color + rainb []allg5.Color col int } -func rainbow() []allegro5.Color { - var colors = make([]allegro5.Color, len(Colors500)) +func rainbow() []allg5.Color { + var colors = make([]allg5.Color, len(Colors500)) for i, c := range Colors500 { colors[i] = NewColorAlpha(c, 0x7f) } return colors } -func newContext(disp *allegro5.Display, f Fonts) *context { +func newContext(disp *allg5.Display, f Fonts) *context { return &context{disp, f, DefaultPalette(), &debug{rainb: rainbow()}} } -func (c *context) Display() *allegro5.Display { +func (c *context) Display() *allg5.Display { return c.disp } @@ -65,7 +65,7 @@ func (d *debug) resetRainbow() { d.col = 0 } -func (d *debug) Rainbow() allegro5.Color { +func (d *debug) Rainbow() allg5.Color { var col = d.col d.col = (col + 1) % len(d.rainb) return d.rainb[col] diff --git a/ui/control.go b/ui/control.go index 6e6bdcc..7ff090a 100644 --- a/ui/control.go +++ b/ui/control.go @@ -3,7 +3,7 @@ package ui import ( "time" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -12,7 +12,7 @@ type Control interface { Destroyed(Context) Update(Context, time.Duration) - Handle(Context, allegro5.Event) + Handle(Context, allg5.Event) DesiredSize(Context) geom.PointF Rect() geom.RectangleF SetRect(geom.RectangleF) @@ -31,7 +31,7 @@ type ControlBase struct { IsPressed bool OnClick MouseClickFn MinSize geom.PointF - Background *allegro5.Color + Background *allg5.Color } func (c *ControlBase) Created(_ Context, p Container) error { @@ -43,15 +43,15 @@ func (c *ControlBase) Destroyed(Context) {} func (c *ControlBase) Update(Context, time.Duration) {} -func (c *ControlBase) Handle(ctx Context, ev allegro5.Event) { +func (c *ControlBase) Handle(ctx Context, ev allg5.Event) { switch e := ev.(type) { - case *allegro5.MouseMoveEvent: + case *allg5.MouseMoveEvent: c.IsOver = c.IsInRect(float64(e.X), float64(e.Y)) - case *allegro5.MouseButtonDownEvent: + case *allg5.MouseButtonDownEvent: if c.IsOver { c.IsPressed = true } - case *allegro5.MouseButtonUpEvent: + case *allg5.MouseButtonUpEvent: if c.IsPressed && c.IsOver { var onClick = c.OnClick if nil != onClick { @@ -74,10 +74,10 @@ func (c *ControlBase) Render(ctx Context) { var min = c.Bounds.Min.To32() var max = c.Bounds.Max.To32() if nil != c.Background { - allegro5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, *c.Background) + allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, *c.Background) } if ctx.Debug().IsEnabled() { - allegro5.DrawRectangle(min.X, min.Y, max.X, max.Y, ctx.Debug().Rainbow(), 5) + allg5.DrawRectangle(min.X, min.Y, max.X, max.Y, ctx.Debug().Rainbow(), 5) } } diff --git a/ui/draw.go b/ui/draw.go index c022d29..94ba64b 100644 --- a/ui/draw.go +++ b/ui/draw.go @@ -6,23 +6,23 @@ import ( "math" "github.com/llgcode/draw2d/draw2dimg" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) -func drawBitmap(w, h int, draw func(*draw2dimg.GraphicContext)) *allegro5.Bitmap { +func drawBitmap(w, h int, draw func(*draw2dimg.GraphicContext)) *allg5.Bitmap { dest := image.NewRGBA(image.Rect(0, 0, w, h)) gc := draw2dimg.NewGraphicContext(dest) gc.SetFillColor(color.Transparent) gc.Clear() draw(gc) - bmp, err := allegro5.NewBitmapFromImage(dest, false) + bmp, err := allg5.NewBitmapFromImage(dest, false) if nil != err { return nil } return bmp } -func drawCircle(r, w int, startAngle, a float64, c color.Color) *allegro5.Bitmap { +func drawCircle(r, w int, startAngle, a float64, c color.Color) *allg5.Bitmap { var width = 2*r + w return drawBitmap(width, width, func(gc *draw2dimg.GraphicContext) { gc.SetFillColor(c) diff --git a/ui/fonts.go b/ui/fonts.go index 38a9790..d1bedc0 100644 --- a/ui/fonts.go +++ b/ui/fonts.go @@ -3,22 +3,22 @@ package ui import ( "github.com/spf13/afero" "opslag.de/schobers/fs/vfs" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) type Fonts interface { Register(name, path string, size int) error - Get(name string) *allegro5.Font + Get(name string) *allg5.Font Destroy() } type fonts struct { - fts map[string]*allegro5.Font + fts map[string]*allg5.Font dir vfs.CopyDir } func newFonts(dir vfs.CopyDir) *fonts { - return &fonts{make(map[string]*allegro5.Font), dir} + return &fonts{make(map[string]*allg5.Font), dir} } func NewFonts(fs afero.Fs) (Fonts, error) { @@ -30,7 +30,7 @@ func NewFonts(fs afero.Fs) (Fonts, error) { } func (fts *fonts) load(name, path string, size int) error { - f, err := allegro5.LoadTTFFont(path, size) + f, err := allg5.LoadTTFFont(path, size) if nil != err { return err } @@ -53,7 +53,7 @@ func (fts *fonts) Register(name, path string, size int) error { return fts.load(name, path, size) } -func (fts *fonts) Get(name string) *allegro5.Font { +func (fts *fonts) Get(name string) *allg5.Font { return fts.fts[name] } diff --git a/ui/label.go b/ui/label.go index c6773d7..e7fe97e 100644 --- a/ui/label.go +++ b/ui/label.go @@ -1,14 +1,14 @@ package ui import ( - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) type Label struct { ControlBase Text string - HorizontalAlignment allegro5.HorizontalAlignment + HorizontalAlignment allg5.HorizontalAlignment } func (l *Label) DesiredSize(ctx Context) geom.PointF { diff --git a/ui/loop.go b/ui/loop.go index 298800a..b22a721 100644 --- a/ui/loop.go +++ b/ui/loop.go @@ -3,32 +3,32 @@ package ui import ( "time" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) -func shouldClose(ev allegro5.Event) bool { +func shouldClose(ev allg5.Event) bool { switch e := ev.(type) { - case *allegro5.KeyCharEvent: + case *allg5.KeyCharEvent: switch e.KeyCode { - case allegro5.KeyEscape: + case allg5.KeyEscape: return true - case allegro5.KeyF4: - if e.Modifiers&allegro5.KeyModAlt == allegro5.KeyModAlt { + case allg5.KeyF4: + if e.Modifiers&allg5.KeyModAlt == allg5.KeyModAlt { return true } } - case *allegro5.DisplayCloseEvent: + case *allg5.DisplayCloseEvent: return true } return false } -func shouldToggleDebug(ev allegro5.Event) bool { +func shouldToggleDebug(ev allg5.Event) bool { switch e := ev.(type) { - case *allegro5.KeyCharEvent: + case *allg5.KeyCharEvent: switch e.KeyCode { - case allegro5.KeyD: - return e.Modifiers&allegro5.KeyModAlt == allegro5.KeyModAlt + case allg5.KeyD: + return e.Modifiers&allg5.KeyModAlt == allg5.KeyModAlt } } return false @@ -44,21 +44,21 @@ func switchState(ctx Context, curr State, s State) error { } func Init() error { - return allegro5.Init(allegro5.InitAll) + return allg5.Init(allg5.InitAll) } -func Run(w, h int, title string, s State, f Fonts, opts *allegro5.NewDisplayOptions) error { +func Run(w, h int, title string, s State, f Fonts, opts *allg5.NewDisplayOptions) error { if nil == opts { - opts = &allegro5.NewDisplayOptions{} + opts = &allg5.NewDisplayOptions{} } - disp, err := allegro5.NewDisplay(w, h, *opts) + disp, err := allg5.NewDisplay(w, h, *opts) if nil != err { return err } disp.SetWindowTitle(title) defer disp.Destroy() - evq, err := allegro5.NewEventQueue() + evq, err := allg5.NewEventQueue() if nil != err { return err } diff --git a/ui/palette.go b/ui/palette.go index 668a6ea..19149d7 100644 --- a/ui/palette.go +++ b/ui/palette.go @@ -3,63 +3,63 @@ package ui import ( "image/color" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) type Palette interface { - Primary() allegro5.Color - PrimaryHighlight() allegro5.Color - PrimaryTransparent() allegro5.Color - Lightest() allegro5.Color - Darker() allegro5.Color - Darkest() allegro5.Color - Disabled() allegro5.Color + Primary() allg5.Color + PrimaryHighlight() allg5.Color + PrimaryTransparent() allg5.Color + Lightest() allg5.Color + Darker() allg5.Color + Darkest() allg5.Color + Disabled() allg5.Color } type palette struct { - primary allegro5.Color - primaryH allegro5.Color - primaryT allegro5.Color - lightest allegro5.Color - darker allegro5.Color - darkest allegro5.Color - disabled allegro5.Color + primary allg5.Color + primaryH allg5.Color + primaryT allg5.Color + lightest allg5.Color + darker allg5.Color + darkest allg5.Color + disabled allg5.Color } -func (p *palette) Primary() allegro5.Color { +func (p *palette) Primary() allg5.Color { return p.primary } -func (p *palette) PrimaryHighlight() allegro5.Color { +func (p *palette) PrimaryHighlight() allg5.Color { return p.primaryH } -func (p *palette) PrimaryTransparent() allegro5.Color { +func (p *palette) PrimaryTransparent() allg5.Color { return p.primaryT } -func (p *palette) Lightest() allegro5.Color { +func (p *palette) Lightest() allg5.Color { return p.lightest } -func (p *palette) Darker() allegro5.Color { +func (p *palette) Darker() allg5.Color { return p.darker } -func (p *palette) Darkest() allegro5.Color { +func (p *palette) Darkest() allg5.Color { return p.darkest } -func (p *palette) Disabled() allegro5.Color { +func (p *palette) Disabled() allg5.Color { return p.disabled } -func NewColor(c *color.RGBA) allegro5.Color { - return allegro5.NewColorAlpha(c.R, c.G, c.B, c.A) +func NewColor(c *color.RGBA) allg5.Color { + return allg5.NewColorAlpha(c.R, c.G, c.B, c.A) } -func NewColorAlpha(c *color.RGBA, a uint8) allegro5.Color { - return allegro5.NewColorAlpha(c.R, c.G, c.B, a) +func NewColorAlpha(c *color.RGBA, a uint8) allg5.Color { + return allg5.NewColorAlpha(c.R, c.G, c.B, a) } func DefaultPalette() Palette { @@ -68,9 +68,9 @@ func DefaultPalette() Palette { primary: NewColor(primary), primaryH: NewColor(Blue400), primaryT: NewColorAlpha(primary, 96), - lightest: allegro5.NewColor(0xff, 0xff, 0xff), - darker: allegro5.NewColorAlpha(0, 0, 0, 188), - darkest: allegro5.NewColorAlpha(0, 0, 0, 222), - disabled: allegro5.NewColorAlpha(0x1f, 0x1f, 0x1f, 0x1f), + lightest: allg5.NewColor(0xff, 0xff, 0xff), + darker: allg5.NewColorAlpha(0, 0, 0, 188), + darkest: allg5.NewColorAlpha(0, 0, 0, 222), + disabled: allg5.NewColorAlpha(0x1f, 0x1f, 0x1f, 0x1f), } } diff --git a/ui/scroll.go b/ui/scroll.go index 8f07c30..36714ec 100644 --- a/ui/scroll.go +++ b/ui/scroll.go @@ -1,7 +1,7 @@ package ui import ( - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -29,13 +29,13 @@ func Scroll(c Control, o Orientation) Control { return s } -func (s *scroll) Handle(ctx Context, ev allegro5.Event) { +func (s *scroll) Handle(ctx Context, ev allg5.Event) { s.Wrapper.Handle(ctx, ev) switch e := ev.(type) { - case *allegro5.MouseMoveEvent: + case *allg5.MouseMoveEvent: if 0 != e.DeltaZ && !s.Bar.IsOver && geom.PtF(float64(e.X), float64(e.Y)).In(s.Bounds) { var d = e.DeltaZ - if allegro5.IsAnyKeyDown(allegro5.KeyLShift, allegro5.KeyRShift) { + if allg5.IsAnyKeyDown(allg5.KeyLShift, allg5.KeyRShift) { d *= 10 } s.Bar.increment(d) @@ -46,7 +46,7 @@ func (s *scroll) Handle(ctx Context, ev allegro5.Event) { func (s *scroll) Render(ctx Context) { var bounds = s.Content.Rect() var w, h = bounds.Dx(), bounds.Dy() - var bmp, err = allegro5.NewVideoBitmap(int(w), int(h)) + var bmp, err = allg5.NewVideoBitmap(int(w), int(h)) if nil != err { return } diff --git a/ui/scrollbar.go b/ui/scrollbar.go index 8170939..3e7903a 100644 --- a/ui/scrollbar.go +++ b/ui/scrollbar.go @@ -5,7 +5,7 @@ import ( "github.com/llgcode/draw2d/draw2dimg" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -25,9 +25,9 @@ type Scrollbar struct { Orientation Orientation OnChanged ScrollbarValueChangedFn handle *ControlBase - normal *allegro5.Bitmap - hover *allegro5.Bitmap - pressed *allegro5.Bitmap + normal *allg5.Bitmap + hover *allg5.Bitmap + pressed *allg5.Bitmap } func (s *Scrollbar) Created(ctx Context, p Container) error { @@ -68,7 +68,7 @@ func (s *Scrollbar) Created(ctx Context, p Container) error { } func (s *Scrollbar) Destroyed(ctx Context) { - var d = func(b *allegro5.Bitmap) { + var d = func(b *allg5.Bitmap) { if nil != b { b.Destroy() } @@ -152,22 +152,22 @@ func (s *Scrollbar) increment(d int) { s.change(val) } -func (s *Scrollbar) Handle(ctx Context, ev allegro5.Event) { +func (s *Scrollbar) Handle(ctx Context, ev allg5.Event) { s.ControlBase.Handle(ctx, ev) s.handle.Handle(ctx, ev) switch e := ev.(type) { - case *allegro5.MouseMoveEvent: + case *allg5.MouseMoveEvent: if s.handle.IsPressed { s.snapTo(e.X, e.Y) } if 0 != e.DeltaZ && s.IsOver { var d = e.DeltaZ - if allegro5.IsAnyKeyDown(allegro5.KeyLShift, allegro5.KeyRShift) { + if allg5.IsAnyKeyDown(allg5.KeyLShift, allg5.KeyRShift) { d *= 10 } s.increment(d) } - case *allegro5.MouseButtonDownEvent: + case *allg5.MouseButtonDownEvent: if !s.handle.IsPressed && s.IsOver { s.snapTo(e.X, e.Y) } @@ -221,11 +221,11 @@ func (s *Scrollbar) Render(ctx Context) { switch s.Orientation { case OrientationHorizontal: // Left line - allegro5.DrawLine(min, center, centerH.X, center, ctx.Palette().Primary(), 2) - allegro5.DrawLine(centerH.X, center, max, center, ctx.Palette().PrimaryTransparent(), 2) + allg5.DrawLine(min, center, centerH.X, center, ctx.Palette().Primary(), 2) + allg5.DrawLine(centerH.X, center, max, center, ctx.Palette().PrimaryTransparent(), 2) default: - allegro5.DrawLine(center, max, center, centerH.Y, ctx.Palette().PrimaryTransparent(), 2) - allegro5.DrawLine(center, centerH.Y, center, min, ctx.Palette().Primary(), 2) + allg5.DrawLine(center, max, center, centerH.Y, ctx.Palette().PrimaryTransparent(), 2) + allg5.DrawLine(center, centerH.Y, center, min, ctx.Palette().Primary(), 2) } var minH = s.handle.Bounds.Min.To32() diff --git a/ui/shadow.go b/ui/shadow.go index 56955dc..cde3b01 100644 --- a/ui/shadow.go +++ b/ui/shadow.go @@ -1,29 +1,29 @@ package ui import ( - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) -var dropShadowPalette []allegro5.Color +var dropShadowPalette []allg5.Color func initDropShadowPalette() { if nil != dropShadowPalette { return } - dropShadowPalette = []allegro5.Color{ - allegro5.NewColorAlpha(0, 0, 0, 0x0f), - allegro5.NewColorAlpha(0, 0, 0, 0x07), - allegro5.NewColorAlpha(0, 0, 0, 0x03), + dropShadowPalette = []allg5.Color{ + allg5.NewColorAlpha(0, 0, 0, 0x0f), + allg5.NewColorAlpha(0, 0, 0, 0x07), + allg5.NewColorAlpha(0, 0, 0, 0x03), } } func DropShadow(x1, y1, x2, y2 float32) { initDropShadowPalette() - allegro5.DrawLine(x1, y2+1, x2+1, y2+1, dropShadowPalette[0], 1) - allegro5.DrawLine(x2+1, y1, x2+1, y2, dropShadowPalette[0], 1) - allegro5.DrawLine(x1, y2+2, x2+2, y2+2, dropShadowPalette[1], 1) - allegro5.DrawLine(x2+2, y1, x2+2, y2+1, dropShadowPalette[1], 1) - allegro5.DrawLine(x1+1, y2+3, x2+2, y2+3, dropShadowPalette[2], 1) - allegro5.DrawLine(x2+3, y1+1, x2+3, y2+2, dropShadowPalette[2], 1) + allg5.DrawLine(x1, y2+1, x2+1, y2+1, dropShadowPalette[0], 1) + allg5.DrawLine(x2+1, y1, x2+1, y2, dropShadowPalette[0], 1) + allg5.DrawLine(x1, y2+2, x2+2, y2+2, dropShadowPalette[1], 1) + allg5.DrawLine(x2+2, y1, x2+2, y2+1, dropShadowPalette[1], 1) + allg5.DrawLine(x1+1, y2+3, x2+2, y2+3, dropShadowPalette[2], 1) + allg5.DrawLine(x2+3, y1+1, x2+3, y2+2, dropShadowPalette[2], 1) } diff --git a/ui/spinner.go b/ui/spinner.go index 486e3cf..12cf4be 100644 --- a/ui/spinner.go +++ b/ui/spinner.go @@ -6,7 +6,7 @@ import ( "github.com/llgcode/draw2d/draw2dimg" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" ) var _ Control = &Spinner{} @@ -15,7 +15,7 @@ type Spinner struct { ControlBase Text string spin float32 - circs *allegro5.Bitmap + circs *allg5.Bitmap } func (s *Spinner) Created(ctx Context, p Container) error { @@ -81,19 +81,19 @@ func (s *Spinner) Render(ctx Context) { var fnt = fonts.Get("default") var textW = fnt.TextWidth(s.Text) - allegro5.DrawFilledRectangle(0, 0, width, height, ctx.Palette().Disabled()) + allg5.DrawFilledRectangle(0, 0, width, height, ctx.Palette().Disabled()) const marginH, marginV float32 = 64, 16 const textH float32 = 12 var rectW, rectH float32 = textW + 2*marginH, 3*marginV + textH + 32 var rectX, rectY = (width - rectW) * .5, (height - rectH) * .5 - allegro5.DrawFilledRectangle(rectX, rectY, rectX+rectW, rectY+rectH, ctx.Palette().Lightest()) + allg5.DrawFilledRectangle(rectX, rectY, rectX+rectW, rectY+rectH, ctx.Palette().Lightest()) DropShadow(rectX, rectY, rectX+rectW, rectY+rectH) - fnt.Draw(rectX+marginH, rectY+marginV, ctx.Palette().Darkest(), allegro5.AlignLeft, s.Text) + fnt.Draw(rectX+marginH, rectY+marginV, ctx.Palette().Darkest(), allg5.AlignLeft, s.Text) const numCircs = 36 var i = int(math.Floor(float64(s.spin) * numCircs)) - s.circs.Subs()[i].DrawOptions(width*.5, rectY+2*marginV+2*textH, allegro5.DrawOptions{Center: true}) + s.circs.Subs()[i].DrawOptions(width*.5, rectY+2*marginV+2*textH, allg5.DrawOptions{Center: true}) s.ControlBase.Render(ctx) } diff --git a/ui/state.go b/ui/state.go index 9fe4104..fcf2109 100644 --- a/ui/state.go +++ b/ui/state.go @@ -4,7 +4,7 @@ import ( "log" "time" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -12,7 +12,7 @@ type State interface { Enter(Context) error Leave(Context) error Update(Context, time.Duration) (State, error) - Handle(Context, allegro5.Event) error + Handle(Context, allg5.Event) error Render(Context) error } @@ -46,7 +46,7 @@ func (s *StateBase) Update(ctx Context, dt time.Duration) (State, error) { return s.ChangeTo, nil } -func (s *StateBase) Handle(ctx Context, ev allegro5.Event) error { +func (s *StateBase) Handle(ctx Context, ev allg5.Event) error { if nil != s.Control { s.Control.Handle(ctx, ev) } diff --git a/ui/statusbar.go b/ui/statusbar.go index 9cca90d..e33216a 100644 --- a/ui/statusbar.go +++ b/ui/statusbar.go @@ -3,7 +3,7 @@ package ui import ( "math" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -26,12 +26,12 @@ func (b *StatusBar) Render(ctx Context) { var min = b.Bounds.Min.To32() var max = b.Bounds.Max.To32() - allegro5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, ctx.Palette().Primary()) + allg5.DrawFilledRectangle(min.X, min.Y, max.X, max.Y, ctx.Palette().Primary()) var fnt = fonts.Get("default") var y = min.Y + float32(.5*b.Bounds.Dy()) - .67*fnt.Ascent() - fnt.Draw(min.X+leftMargin, y, ctx.Palette().Lightest(), allegro5.AlignLeft, b.Text) - fnt.Draw(max.X-leftMargin, y, ctx.Palette().Lightest(), allegro5.AlignRight, b.RightText) + fnt.Draw(min.X+leftMargin, y, ctx.Palette().Lightest(), allg5.AlignLeft, b.Text) + fnt.Draw(max.X-leftMargin, y, ctx.Palette().Lightest(), allg5.AlignRight, b.RightText) b.ControlBase.Render(ctx) } diff --git a/ui/wrapper.go b/ui/wrapper.go index dfc18aa..a4bc17a 100644 --- a/ui/wrapper.go +++ b/ui/wrapper.go @@ -3,7 +3,7 @@ package ui import ( "time" - "opslag.de/schobers/galleg/allegro5" + "opslag.de/schobers/zntg/allg5" "opslag.de/schobers/geom" ) @@ -28,7 +28,7 @@ func (w *Wrapper) Update(ctx Context, d time.Duration) { w.Wrapped.Update(ctx, d) } -func (w *Wrapper) Handle(ctx Context, ev allegro5.Event) { +func (w *Wrapper) Handle(ctx Context, ev allg5.Event) { w.Wrapped.Handle(ctx, ev) }