Settings,about

This commit is contained in:
cuu
2018-09-21 04:42:39 +08:00
parent 74723955d9
commit c0f57bd88c
25 changed files with 531 additions and 60 deletions

View File

@@ -10,6 +10,31 @@ import (
"github.com/cuu/LauncherGo/sysgo"
)
type Widget struct {
PosX int
PosY int
Width int
Height int
}
func (self *Widget) Size() (int,int) {
return self.Width,self.Height
}
func (self *Widget) NewSize(w,h int) {
self.Width = w
self.Height = h
}
func (self *Widget) Coord() (int,int) {
return self.PosX,self.PosY
}
func (self *Widget) NewCoord(x,y int) {
self.PosX = x
self.PosY = y
}
func Init() {
font.Init()

View File

@@ -37,10 +37,10 @@ type IconItemInterface interface {
Coord() (int,int)
NewCoord(x,y int)
Size() (int,int)
NewSize(w,h int)
TotalWidth() int
Size() (int,int)
AddLabel(text string, fontobj *ttf.Font)
GetLinkPage() PageInterface
@@ -59,10 +59,7 @@ type IconItemInterface interface {
}
type IconItem struct {
PosX int
PosY int
Width int
Height int
Widget
ImageName string
ImgSurf *sdl.Surface
Parent PageInterface

View File

@@ -16,6 +16,7 @@ type LabelInterface interface {
Coord() (int,int)
Size() (int,int)
NewCoord(x,y int)
NewSize(w,h int)
SetColor(col *color.Color )
GetText() string
SetText(text string)
@@ -23,10 +24,7 @@ type LabelInterface interface {
}
type Label struct {
PosX int
PosY int
Width int
Height int
Widget
Text string
FontObj *ttf.Font
Color *color.Color

78
sysgo/UI/list_item.go Normal file
View File

@@ -0,0 +1,78 @@
package UI
import (
"github.com/veandco/go-sdl2/ttf"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/color"
)
type ListItemInterface interface {
Init(text string)
Size() (int,int)
NewSize(w,h int)
Coord() (int,int)
NewCoord(x,y int)
Draw()
}
type ListItem struct {
Widget
Labels map[string]LabelInterface
Icons map[string]IconItemInterface
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.Height = 30
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)
self.Labels["Text"] = l
}
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) Draw() {
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)
}

View File

@@ -14,10 +14,7 @@ import (
//MultiLabel is also a LabelInterface
type MultiLabel struct {
PosX int
PosY int
Width int
Height int
Widget
Text string
FontObj *ttf.Font
Color *color.Color
@@ -52,19 +49,6 @@ func (self *MultiLabel) SetCanvasHWND( canvas *sdl.Surface) {
self.CanvasHWND = canvas
}
func (self *MultiLabel) Coord() (int,int) {
return self.PosX,self.PosY
}
func (self *MultiLabel) Size() (int,int) {
return self.Width,self.Height
}
func (self *MultiLabel) NewCoord(x,y int) {
self.PosX = x
self.PosY = y
}
func (self *MultiLabel) SetColor(col *color.Color){
if col != nil {

View File

@@ -73,20 +73,23 @@ type PageSelectorInterface interface {
Adjust(x,y,w,h,alpha int)
GetOnShow() bool
SetOnShow(onshow bool)
Coord() (int,int)
NewCoord(x,y int)
Size() (int,int)
NewSize(w,h int)
Draw()
}
type PageSelector struct {
Widget
PosX int
PosY int
Width int
Height int
Parent PageInterface
Alpha int
OnShow bool
IconSurf *sdl.Surface
Parent PageInterface
}
func NewPageSelector() *PageSelector {
@@ -176,8 +179,11 @@ type PageInterface interface {
GetIconIndex() int
Coord() (int, int)
NewCoord(x,y int)
Size() (int,int)
NewSize(w,h int)
UpdateIconNumbers()
GetIconNumbers() int
@@ -188,6 +194,8 @@ type PageInterface interface {
AppendIcon( it interface{} )
ClearIcons()
DrawIcons()
GetMyList() []ListItemInterface
GetName() string
SetName(n string)
@@ -212,10 +220,7 @@ type PageInterface interface {
}
type Page struct {
PosX int
PosY int
Width int
Height int
Widget
Icons []IconItemInterface // slice ,use append
IconNumbers int
IconIndex int
@@ -231,6 +236,8 @@ type Page struct {
CanvasHWND *sdl.Surface
HWND *sdl.Surface
MyList []ListItemInterface
OnShow bool
Name string
Screen *MainScreen
@@ -851,7 +858,9 @@ func (self *Page) DrawIcons() {
}
}
func (self *Page) GetMyList() []ListItemInterface {
return self.MyList
}
func (self *Page) KeyDown( ev *event.Event) {
if ev.Data["Key"] == CurKeys["A"] {
@@ -967,15 +976,6 @@ func (self *Page) GetIconIndex() int {
}
func (self *Page) Coord() (int,int) {
return self.PosX,self.PosY
}
func (self *Page) Size() (int,int) {
return self.Width,self.Height
}
func (self *Page) GetName() string {
return self.Name
}

View File

@@ -14,10 +14,7 @@ import (
)
type ListScroller struct{
PosX int
PosY int
Width int
Height int
Widget
MinHeight int
Parent PageInterface
Color *color.Color
@@ -40,6 +37,8 @@ func NewListScroller() *ListScroller {
func (self *ListScroller) Init() {
//just set the CanvasHWND
cav_ := self.Parent.GetCanvasHWND()
self.SetCanvasHWND(cav_)
}
func (self *ListScroller) SetCanvasHWND( canvas *sdl.Surface) {

View File

@@ -15,11 +15,7 @@ import (
type UntitledIcon struct {
PosX int
PosY int
Width int
Height int
Widget
Words []string
FontObj *ttf.Font
BG *sdl.Surface