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