From 3e73a6effbdab74e65b5a9e01c052ebe00942516 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Fri, 27 Dec 2019 19:12:00 -0800 Subject: [PATCH] Change types int32 -> int per upstream render library --- button.go | 2 +- frame_pack.go | 22 ++++++++++----------- label.go | 6 +++--- main_window.go | 4 ++-- supervisor.go | 4 ++-- widget.go | 52 +++++++++++++++++++++++++------------------------- 6 files changed, 45 insertions(+), 45 deletions(-) diff --git a/button.go b/button.go index 1df20d0..0de40bd 100644 --- a/button.go +++ b/button.go @@ -101,7 +101,7 @@ func (w *Button) Present(e render.Engine, P render.Point) { w.DrawBox(e, P) // Offset further if we are currently sunken. - var clickOffset int32 + var clickOffset int if w.clicked { clickOffset++ } diff --git a/frame_pack.go b/frame_pack.go index f160263..0cde58e 100644 --- a/frame_pack.go +++ b/frame_pack.go @@ -16,9 +16,9 @@ type Pack struct { FillX bool FillY bool - Padding int32 // Equal padding on X and Y. - PadX int32 - PadY int32 + Padding int // Equal padding on X and Y. + PadX int + PadY int Expand bool // Widget should grow its allocated space to better fill the parent. } @@ -66,8 +66,8 @@ func (w *Frame) computePacked(e render.Engine) { // was configured with an explicit Size, the Frame will be that Size, // but we still calculate how much space the widgets _actually_ take // so we can expand them to fill remaining space in fixed size widgets. - maxWidth int32 - maxHeight int32 + maxWidth int + maxHeight int visited = []packedWidget{} expanded = []packedWidget{} ) @@ -80,10 +80,10 @@ func (w *Frame) computePacked(e render.Engine) { } var ( - x int32 - y int32 - yDirection int32 = 1 - xDirection int32 = 1 + x int + y int + yDirection int = 1 + xDirection int = 1 ) if anchor.IsSouth() { @@ -150,8 +150,8 @@ func (w *Frame) computePacked(e render.Engine) { if len(expanded) > 0 && !frameSize.IsZero() && frameSize.Bigger(computedSize) { // Divy up the size available. growBy := render.Rect{ - W: ((frameSize.W - computedSize.W) / int32(len(expanded))) - w.BoxThickness(4), - H: ((frameSize.H - computedSize.H) / int32(len(expanded))) - w.BoxThickness(4), + W: ((frameSize.W - computedSize.W) / len(expanded)) - w.BoxThickness(4), + H: ((frameSize.H - computedSize.H) / len(expanded)) - w.BoxThickness(4), } for _, pw := range expanded { pw.widget.ResizeBy(growBy) diff --git a/label.go b/label.go index f670aca..1255f24 100644 --- a/label.go +++ b/label.go @@ -23,8 +23,8 @@ type Label struct { IntVariable *int Font render.Text - width int32 - height int32 + width int + height int lineHeight int } @@ -127,7 +127,7 @@ func (w *Label) Present(e render.Engine, P render.Point) { text.Text = line e.DrawText(text, render.Point{ X: P.X + border + padX, - Y: P.Y + border + padY + int32(i*w.lineHeight), + Y: P.Y + border + padY + (i * w.lineHeight), }) } } diff --git a/main_window.go b/main_window.go index 46a5b3c..37f054a 100644 --- a/main_window.go +++ b/main_window.go @@ -67,8 +67,8 @@ func (mw *MainWindow) Pack(w Widget, pack Pack) { // resized handles the window being resized. func (mw *MainWindow) resized() { mw.frame.Resize(render.Rect{ - W: int32(mw.w), - H: int32(mw.h), + W: mw.w, + H: mw.h, }) } diff --git a/supervisor.go b/supervisor.go index 2d92812..fe7f7c9 100644 --- a/supervisor.go +++ b/supervisor.go @@ -82,8 +82,8 @@ var ( func (s *Supervisor) Loop(ev *event.State) error { var ( XY = render.Point{ - X: int32(ev.CursorX), - Y: int32(ev.CursorY), + X: ev.CursorX, + Y: ev.CursorY, } ) diff --git a/widget.go b/widget.go index daf7dc2..b8c52d5 100644 --- a/widget.go +++ b/widget.go @@ -38,12 +38,12 @@ type Widget interface { Event(Event, render.Point) // called internally to trigger an event // Thickness of the padding + border + outline. - BoxThickness(multiplier int32) int32 + BoxThickness(multiplier int) int DrawBox(render.Engine, render.Point) // Widget configuration getters. - Margin() int32 // Margin away from other widgets - SetMargin(int32) // + Margin() int // Margin away from other widgets + SetMargin(int) // Background() render.Color // Background color SetBackground(render.Color) // Foreground() render.Color // Foreground color @@ -52,12 +52,12 @@ type Widget interface { SetBorderStyle(BorderStyle) // BorderColor() render.Color // Border color (default is Background) SetBorderColor(render.Color) // - BorderSize() int32 // Border size (default 0) - SetBorderSize(int32) // + BorderSize() int // Border size (default 0) + SetBorderSize(int) // OutlineColor() render.Color // Outline color (default Invisible) SetOutlineColor(render.Color) // - OutlineSize() int32 // Outline size (default 0) - SetOutlineSize(int32) // + OutlineSize() int // Outline size (default 0) + SetOutlineSize(int) // // Visibility Hide() @@ -87,17 +87,17 @@ type Config struct { // keeping the auto-resize property, pass AutoResize=true too. This is // mainly used internally when widgets are calculating their automatic sizes. AutoResize bool - Width int32 - Height int32 - Margin int32 - MarginX int32 - MarginY int32 + Width int + Height int + Margin int + MarginX int + MarginY int Background render.Color Foreground render.Color - BorderSize int32 + BorderSize int BorderStyle BorderStyle BorderColor render.Color - OutlineSize int32 + OutlineSize int OutlineColor render.Color } @@ -108,17 +108,17 @@ type BaseWidget struct { idFunc func() string fixedSize bool hidden bool - width int32 - height int32 + width int + height int point render.Point - margin int32 + margin int background render.Color foreground render.Color borderStyle BorderStyle borderColor render.Color - borderSize int32 + borderSize int outlineColor render.Color - outlineSize int32 + outlineSize int handlers map[Event][]func(render.Point) hasParent bool parent Widget @@ -266,7 +266,7 @@ func (w *BaseWidget) ResizeAuto(v render.Rect) { // BoxThickness returns the full sum of the padding, border and outline. // m = multiplier, i.e., 1 or 2 -func (w *BaseWidget) BoxThickness(m int32) int32 { +func (w *BaseWidget) BoxThickness(m int) int { if m == 0 { m = 1 } @@ -396,12 +396,12 @@ func (w *BaseWidget) DrawBox(e render.Engine, P render.Point) { } // Margin returns the margin width. -func (w *BaseWidget) Margin() int32 { +func (w *BaseWidget) Margin() int { return w.margin } // SetMargin sets the margin width. -func (w *BaseWidget) SetMargin(v int32) { +func (w *BaseWidget) SetMargin(v int) { w.margin = v } @@ -449,12 +449,12 @@ func (w *BaseWidget) SetBorderColor(c render.Color) { } // BorderSize returns the border thickness. -func (w *BaseWidget) BorderSize() int32 { +func (w *BaseWidget) BorderSize() int { return w.borderSize } // SetBorderSize sets the border thickness. -func (w *BaseWidget) SetBorderSize(v int32) { +func (w *BaseWidget) SetBorderSize(v int) { w.borderSize = v } @@ -469,12 +469,12 @@ func (w *BaseWidget) SetOutlineColor(c render.Color) { } // OutlineSize returns the outline thickness. -func (w *BaseWidget) OutlineSize() int32 { +func (w *BaseWidget) OutlineSize() int { return w.outlineSize } // SetOutlineSize sets the outline thickness. -func (w *BaseWidget) SetOutlineSize(v int32) { +func (w *BaseWidget) SetOutlineSize(v int) { w.outlineSize = v }