go fmt ./...

This commit is contained in:
cuu
2021-10-11 13:55:54 +08:00
parent 0fe6399441
commit 7382cc40b1
88 changed files with 10028 additions and 10478 deletions

View File

@@ -2,24 +2,21 @@ package UI
import (
"github.com/veandco/go-sdl2/ttf"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/color"
"github.com/cuu/gogame/draw"
)
type ListItemInterface interface {
Init(text string)
Size() (int,int)
NewSize(w,h int)
Coord() (int,int)
NewCoord(x,y int)
Size() (int, int)
NewSize(w, h int)
Coord() (int, int)
NewCoord(x, y int)
GetLinkObj() PluginInterface
Draw()
}
type ListItem struct {
@@ -29,57 +26,52 @@ type ListItem struct {
Fonts map[string]*ttf.Font
LinkObj PluginInterface
Parent PageInterface
}
func NewListItem() *ListItem {
i := &ListItem{}
i.Labels = make(map[string]LabelInterface)
i.Icons = make( map[string]IconItemInterface)
i.Fonts = make(map[string]*ttf.Font)
i.Icons = make(map[string]IconItemInterface)
i.Fonts = make(map[string]*ttf.Font)
i.Height = 30
i.Width = 0
i.Width = 0
return i
}
func (self *ListItem) Init(text string) {
l := NewLabel()
l.PosX = 16
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
l.Init(text,self.Fonts["normal"],nil)
l.Init(text, self.Fonts["normal"], nil)
self.Labels["Text"] = l
}
func (self *ListItem) Coord() (int,int) {
return self.PosX,self.PosY
func (self *ListItem) Coord() (int, int) {
return self.PosX, self.PosY
}
func (self *ListItem) Size() (int,int) {
return self.Width,self.Height
func (self *ListItem) Size() (int, int) {
return self.Width, self.Height
}
func (self *ListItem) GetLinkObj() PluginInterface {
return self.LinkObj
}
func (self *ListItem) Draw() {
x_,_ := self.Labels["Text"].Coord()
_,h_ := self.Labels["Text"].Size()
self.Labels["Text"].NewCoord(x_, self.PosY+(self.Height - h_)/2)
x_, _ := self.Labels["Text"].Coord()
_, h_ := self.Labels["Text"].Size()
self.Labels["Text"].NewCoord(x_, self.PosY+(self.Height-h_)/2)
self.Labels["Text"].Draw()
draw.Line(self.Parent.GetCanvasHWND(),&color.Color{169,169,169,255},
self.PosX, (self.PosY+self.Height-1),
(self.PosX+self.Width),(self.PosY+self.Height-1),1)
draw.Line(self.Parent.GetCanvasHWND(), &color.Color{169, 169, 169, 255},
self.PosX, (self.PosY + self.Height - 1),
(self.PosX + self.Width), (self.PosY + self.Height - 1), 1)
}