package gui import . "git.danitheskunk.com/squishy/blooblib" type Button struct { BaseWidget label string } func NewButton(label string) *Button { return &Button{ BaseWidget: BaseWidget{ Size: Vec2i{X: 80, Y: 22}, }, label: label, } } func (w *Button) Draw(target *Image) { //col1 := Color(0xffffff) col2 := Color(0xccccdd) col3 := Color(0x888899) col4 := Color(0x555566) //col5 := Color(0x444444) pressed := false if pressed { //todo: non-filled target.DrawRectRounded(Recti{Pos: w.Pos, Size: w.Size}, 0, 2) target.DrawHLine(Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + 1}, w.Size.X-4, col4) target.DrawVLine(Vec2i{X: w.Pos.X + 1, Y: w.Pos.Y + 2}, w.Size.Y-4, col4) target.DrawHLine(Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + w.Size.Y - 2}, w.Size.X-4, col2) target.DrawVLine(Vec2i{X: w.Pos.X + w.Size.X - 2, Y: w.Pos.Y + 2}, w.Size.Y-4, col2) innerRect := Recti{Pos: Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + 2}, Size: Vec2i{X: w.Size.X - 4, Y: w.Size.Y - 4}} target.DrawRect(innerRect, col3) innerRect.Pos.X += 1 innerRect.Pos.Y += 1 target.DrawTextOutlineCenter(w.label, DefaultFont, innerRect, col2, 0x000000) } else { //todo: non-filled target.DrawRectRounded(Recti{Pos: w.Pos, Size: w.Size}, 0, 2) target.DrawHLine(Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + 1}, w.Size.X-4, col2) target.DrawVLine(Vec2i{X: w.Pos.X + 1, Y: w.Pos.Y + 2}, w.Size.Y-4, col2) target.DrawHLine(Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + w.Size.Y - 2}, w.Size.X-4, col4) target.DrawVLine(Vec2i{X: w.Pos.X + w.Size.X - 2, Y: w.Pos.Y + 2}, w.Size.Y-4, col4) innerRect := Recti{Pos: Vec2i{X: w.Pos.X + 2, Y: w.Pos.Y + 2}, Size: Vec2i{X: w.Size.X - 4, Y: w.Size.Y - 4}} target.DrawRect(innerRect, col3) target.DrawTextOutlineCenter(w.label, DefaultFont, innerRect, col2, 0x000000) } }