Settings,about
154
Menu/GameShell/10_Settings/About/about.go
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
|
||||||
|
"github.com/cuu/LauncherGo/sysgo/UI"
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
type InfoPageListItem struct{
|
||||||
|
UI.Widget
|
||||||
|
Labels map[string]UI.LabelInterface
|
||||||
|
Icons map[string]UI.IconItemInterface
|
||||||
|
Fonts map[string]*ttf.Font
|
||||||
|
|
||||||
|
Parent UI.PageInterface
|
||||||
|
|
||||||
|
Flag string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInfoPageListItem() *InfoPageListItem {
|
||||||
|
i := &InfoPageListItem{}
|
||||||
|
i.Labels = make(map[string]UI.LabelInterface)
|
||||||
|
i.Icons = make( map[string]UI.IconItemInterface)
|
||||||
|
i.Fonts = make(map[string]*ttf.Font)
|
||||||
|
|
||||||
|
i.Height = 20
|
||||||
|
i.Width = 0
|
||||||
|
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *InfoPageListItem) Init(text string) {
|
||||||
|
l := UI.NewLabel()
|
||||||
|
l.PosX = 10
|
||||||
|
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||||
|
l.Init(text,self.Fonts["normal"],nil)
|
||||||
|
|
||||||
|
self.Labels["Text"] = l
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *InfoPageListItem) SetSmallText( text string) {
|
||||||
|
l := UI.NewMultiLabel()
|
||||||
|
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||||
|
l.Init(text,self.Fonts["small"],nil)
|
||||||
|
|
||||||
|
self.Labels["Small"] = l
|
||||||
|
|
||||||
|
_,h_ := self.Labels["Small"].Size()
|
||||||
|
if h_>= self.Height {
|
||||||
|
self.Height = h_ + 10
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *InfoPageListItem) Draw() {
|
||||||
|
x_,_ := self.Labels["Text"].Coord()
|
||||||
|
self.Labels["Text"].NewCoord(x_,self.PosY)
|
||||||
|
self.Labels["Text"].Draw()
|
||||||
|
|
||||||
|
if _, ok := self.Labels["Small"]; ok {
|
||||||
|
w_,_ := self.Labels["Text"].Size()
|
||||||
|
self.Labels["Small"].NewCoord(w_+16,self.PosY)
|
||||||
|
self.Labels["Small"].Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type AboutPage struct {
|
||||||
|
UI.Page
|
||||||
|
AList map[string]map[string]string
|
||||||
|
ListFontObj *ttf.Font
|
||||||
|
Scrolled int
|
||||||
|
BGwidth int
|
||||||
|
BGheight int
|
||||||
|
DrawOnce bool
|
||||||
|
Scroller *UI.ListScroller
|
||||||
|
|
||||||
|
MyList []*InfoPageListItem
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAboutPage() *AboutPage {
|
||||||
|
p := &HelloWorldPage{}
|
||||||
|
|
||||||
|
p.FootMsg = [5]string{"Nav.","","","Back",""}
|
||||||
|
|
||||||
|
p.AList = make(map[string]map[string]string)
|
||||||
|
|
||||||
|
p.BGwidth = 320
|
||||||
|
p.BGheight = 300
|
||||||
|
p.DrawOnce = false
|
||||||
|
|
||||||
|
p.MyList = make([]*InfoPageListItem,0)
|
||||||
|
|
||||||
|
p.ListFontObj = UI.Fonts["varela13"]
|
||||||
|
|
||||||
|
p.Index = 0
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (self *AboutPage) Uname() {
|
||||||
|
out := make(map[string]string)
|
||||||
|
|
||||||
|
out["key"] = "uname"
|
||||||
|
out["label"] = "Kernel:"
|
||||||
|
|
||||||
|
out_bytes, err := exec.Command("uname","-srmo").Output()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
out["value"] = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
out_str := strings.Trim(string(out_bytes), "\t\n")
|
||||||
|
|
||||||
|
out["value"]= out_str
|
||||||
|
|
||||||
|
self.AList["uname"] = out
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *AboutPage) CpuMhz() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *AboutPage) CpuInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *AboutPage) MemInfo() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *AboutPage) GenList() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
230
Menu/GameShell/10_Settings/Settings.go
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
// "github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
|
||||||
|
"github.com/cuu/LauncherGo/sysgo/UI"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
type SettingsPageSelector struct {
|
||||||
|
UI.PageSelector
|
||||||
|
BackgroundColor *color.Color
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSettingsPageSelector() *SettingsPageSelector{
|
||||||
|
s := &SettingsPageSelector{}
|
||||||
|
s.BackgroundColor = &color.Color{131,199,219,255}
|
||||||
|
|
||||||
|
s.Width = UI.Width
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPageSelector) Draw() {
|
||||||
|
idx := self.Parent.GetPsIndex()
|
||||||
|
mylist := self.Parent.GetMyList()
|
||||||
|
if idx < len( mylist) {
|
||||||
|
_,y_ := mylist[idx].Coord()
|
||||||
|
_,h_ := mylist[idx].Size()
|
||||||
|
|
||||||
|
x := 2
|
||||||
|
y := y_+1
|
||||||
|
h := h_-3
|
||||||
|
self.PosX = x
|
||||||
|
self.PosY = y
|
||||||
|
self.Height = h
|
||||||
|
|
||||||
|
rect_ := rect.Rect(x,y,self.Width-4,h)
|
||||||
|
canvas_ := self.Parent.GetCanvasHWND()
|
||||||
|
draw.AARoundRect(canvas_, &rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//##############################################//
|
||||||
|
|
||||||
|
type SettingsPage struct {
|
||||||
|
UI.Page
|
||||||
|
AList map[string]map[string]string
|
||||||
|
ListFontObj *ttf.Font
|
||||||
|
Scrolled int
|
||||||
|
BGwidth int
|
||||||
|
BGheight int
|
||||||
|
DrawOnce bool
|
||||||
|
Scroller *UI.ListScroller
|
||||||
|
Icons map[string]UI.IconItemInterface
|
||||||
|
|
||||||
|
MyPath string
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSettingsPage() *SettingsPage {
|
||||||
|
p := &SettingsPage{}
|
||||||
|
p.FootMsg = [5]string{"Nav","","","Back","Enter"}
|
||||||
|
p.ListFontObj = UI.Fonts["varela15"]
|
||||||
|
|
||||||
|
p.MyPath = "Menu/GameShell/10_Settings"
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPage) Init() {
|
||||||
|
if self.Screen != nil {
|
||||||
|
|
||||||
|
self.PosX = self.Index * self.Screen.Width
|
||||||
|
self.Width = self.Screen.Width
|
||||||
|
self.Height = self.Screen.Height
|
||||||
|
self.CanvasHWND = self.Screen.CanvasHWND
|
||||||
|
|
||||||
|
|
||||||
|
ps := &SettingsPageSelector{}
|
||||||
|
ps.Parent = self
|
||||||
|
self.Ps = ps
|
||||||
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
|
||||||
|
alist := [][]string{ // "so file", "folder name", "label text"
|
||||||
|
{"about.so","About","About"},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
start_x := 0
|
||||||
|
start_y := 0
|
||||||
|
|
||||||
|
for i,v := range alist{
|
||||||
|
li := UI.NewListItem()
|
||||||
|
li.Parent = self
|
||||||
|
li.PosX = start_x
|
||||||
|
li.PosY = start_y + i*li.Height
|
||||||
|
li.Width = UI.Width
|
||||||
|
|
||||||
|
li.Fonts["normal"] = self.ListFontObj
|
||||||
|
|
||||||
|
if v[2] != "" {
|
||||||
|
li.Init(v[2])
|
||||||
|
}else{
|
||||||
|
li.Init(v[1])
|
||||||
|
}
|
||||||
|
|
||||||
|
if UI.FileExists( self.MyPath+"/"+v[1]+"/"+v[0]) {
|
||||||
|
pi,err := UI.LoadPlugin(self.MyPath+"/"+v[1]+"/"+v[0] )
|
||||||
|
UI.Assert(err)
|
||||||
|
li.LinkObj = UI.InitPlugin(pi,self.Screen)
|
||||||
|
self.MyList = append(self.MyList,li)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Scroller = UI.NewListScroller()
|
||||||
|
self.Scroller.Parent = self
|
||||||
|
self.Scroller.PosX = self.Width - 10
|
||||||
|
self.Scroller.PosY = 2
|
||||||
|
self.Scroller.Init()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPage) ScrollUp() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *SettingsPage) ScrollDown() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPage) Click() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPage) KeyDown( ev *event.Event) {
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["A"] || ev.Data["Key"] == UI.CurKeys["Menu"] {
|
||||||
|
self.ReturnToUpLevelPage()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Up"] {
|
||||||
|
self.ScrollUp()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Down"] {
|
||||||
|
self.ScrollDown()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Enter"] {
|
||||||
|
self.Click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *SettingsPage) Draw() {
|
||||||
|
self.ClearCanvas()
|
||||||
|
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_,h_ := self.MyList[0].Size()
|
||||||
|
|
||||||
|
if len(self.MyList) * h_ > self.Height {
|
||||||
|
_,ph_ := self.Ps.Size()
|
||||||
|
self.Ps.NewSize(self.Width - 11, ph_)
|
||||||
|
self.Ps.Draw()
|
||||||
|
|
||||||
|
for _,v := range self.MyList {
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Scroller.UpdateSize(len(self.MyList)*h_,self.PsIndex*h_)
|
||||||
|
self.Scroller.Draw()
|
||||||
|
|
||||||
|
}else {
|
||||||
|
_,ph_ := self.Ps.Size()
|
||||||
|
self.Ps.NewSize(self.Width,ph_)
|
||||||
|
self.Ps.Draw()
|
||||||
|
for _,v := range self.MyList {
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
type SettingsPlugin struct {
|
||||||
|
UI.Plugin
|
||||||
|
Page UI.PageInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *SettingsPlugin) Init( main_screen *UI.MainScreen ) {
|
||||||
|
self.Page = NewSettingsPage()
|
||||||
|
self.Page.SetScreen( main_screen)
|
||||||
|
self.Page.SetName("Settings")
|
||||||
|
self.Page.Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *SettingsPlugin) Run( main_screen *UI.MainScreen ) {
|
||||||
|
if main_screen != nil {
|
||||||
|
main_screen.PushPage(self.Page)
|
||||||
|
main_screen.Draw()
|
||||||
|
main_screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var APIOBJ SettingsPlugin
|
||||||
BIN
Menu/GameShell/10_Settings/Settings.so
Normal file
5
Menu/GameShell/10_Settings/plugin.config
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"SO_FILE":"Settings.so",
|
||||||
|
"NAME":"Settings"
|
||||||
|
}
|
||||||
|
|
||||||
@ -13,10 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type InfoPageListItem struct{
|
type InfoPageListItem struct{
|
||||||
PosX int
|
UI.Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Labels map[string]UI.LabelInterface
|
Labels map[string]UI.LabelInterface
|
||||||
Icons map[string]UI.IconItemInterface
|
Icons map[string]UI.IconItemInterface
|
||||||
Fonts map[string]*ttf.Font
|
Fonts map[string]*ttf.Font
|
||||||
@ -83,6 +80,7 @@ type HelloWorldPage struct {
|
|||||||
Scroller *UI.ListScroller
|
Scroller *UI.ListScroller
|
||||||
|
|
||||||
MyList []*InfoPageListItem
|
MyList []*InfoPageListItem
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHelloWorldPage() *HelloWorldPage {
|
func NewHelloWorldPage() *HelloWorldPage {
|
||||||
@ -100,6 +98,8 @@ func NewHelloWorldPage() *HelloWorldPage {
|
|||||||
|
|
||||||
p.ListFontObj = UI.Fonts["varela13"]
|
p.ListFontObj = UI.Fonts["varela13"]
|
||||||
|
|
||||||
|
p.Index = 0
|
||||||
|
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
build.sh
@ -7,3 +7,8 @@ cd Menu/GameShell/HelloWorld/
|
|||||||
go build -o HelloWorld.so -buildmode=plugin
|
go build -o HelloWorld.so -buildmode=plugin
|
||||||
cd -
|
cd -
|
||||||
|
|
||||||
|
|
||||||
|
cd Menu/GameShell/10_Settings
|
||||||
|
go build -o Settings.so -buildmode=plugin
|
||||||
|
cd -
|
||||||
|
|
||||||
|
|||||||
BIN
skin/default/sysgo/gameshell/icons/DialogBoxs.png
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
skin/default/sysgo/gameshell/icons/GS.png
Normal file
|
After Width: | Height: | Size: 599 B |
BIN
skin/default/sysgo/gameshell/icons/airwire.png
Normal file
|
After Width: | Height: | Size: 111 B |
BIN
skin/default/sysgo/gameshell/icons/buttonslayout.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
skin/default/sysgo/gameshell/icons/sheep_bg.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
skin/default/sysgo/gameshell/icons/sheep_body.png
Normal file
|
After Width: | Height: | Size: 4.2 KiB |
BIN
skin/default/sysgo/gameshell/icons/sheep_head.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
skin/default/sysgo/gameshell/icons/tape.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
skin/default/sysgo/gameshell/titlebar_icons/bluetooth.png
Normal file
|
After Width: | Height: | Size: 562 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.4 KiB |
@ -10,6 +10,31 @@ import (
|
|||||||
"github.com/cuu/LauncherGo/sysgo"
|
"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() {
|
func Init() {
|
||||||
font.Init()
|
font.Init()
|
||||||
|
|||||||
@ -37,10 +37,10 @@ type IconItemInterface interface {
|
|||||||
|
|
||||||
Coord() (int,int)
|
Coord() (int,int)
|
||||||
NewCoord(x,y int)
|
NewCoord(x,y int)
|
||||||
|
Size() (int,int)
|
||||||
|
NewSize(w,h int)
|
||||||
|
|
||||||
TotalWidth() int
|
TotalWidth() int
|
||||||
Size() (int,int)
|
|
||||||
|
|
||||||
|
|
||||||
AddLabel(text string, fontobj *ttf.Font)
|
AddLabel(text string, fontobj *ttf.Font)
|
||||||
GetLinkPage() PageInterface
|
GetLinkPage() PageInterface
|
||||||
@ -59,10 +59,7 @@ type IconItemInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IconItem struct {
|
type IconItem struct {
|
||||||
PosX int
|
Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
ImageName string
|
ImageName string
|
||||||
ImgSurf *sdl.Surface
|
ImgSurf *sdl.Surface
|
||||||
Parent PageInterface
|
Parent PageInterface
|
||||||
|
|||||||
@ -16,6 +16,7 @@ type LabelInterface interface {
|
|||||||
Coord() (int,int)
|
Coord() (int,int)
|
||||||
Size() (int,int)
|
Size() (int,int)
|
||||||
NewCoord(x,y int)
|
NewCoord(x,y int)
|
||||||
|
NewSize(w,h int)
|
||||||
SetColor(col *color.Color )
|
SetColor(col *color.Color )
|
||||||
GetText() string
|
GetText() string
|
||||||
SetText(text string)
|
SetText(text string)
|
||||||
@ -23,10 +24,7 @@ type LabelInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Label struct {
|
type Label struct {
|
||||||
PosX int
|
Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Text string
|
Text string
|
||||||
FontObj *ttf.Font
|
FontObj *ttf.Font
|
||||||
Color *color.Color
|
Color *color.Color
|
||||||
|
|||||||
78
sysgo/UI/list_item.go
Normal 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)
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -14,10 +14,7 @@ import (
|
|||||||
|
|
||||||
//MultiLabel is also a LabelInterface
|
//MultiLabel is also a LabelInterface
|
||||||
type MultiLabel struct {
|
type MultiLabel struct {
|
||||||
PosX int
|
Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Text string
|
Text string
|
||||||
FontObj *ttf.Font
|
FontObj *ttf.Font
|
||||||
Color *color.Color
|
Color *color.Color
|
||||||
@ -52,19 +49,6 @@ func (self *MultiLabel) SetCanvasHWND( canvas *sdl.Surface) {
|
|||||||
self.CanvasHWND = canvas
|
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){
|
func (self *MultiLabel) SetColor(col *color.Color){
|
||||||
if col != nil {
|
if col != nil {
|
||||||
|
|||||||
@ -73,20 +73,23 @@ type PageSelectorInterface interface {
|
|||||||
Adjust(x,y,w,h,alpha int)
|
Adjust(x,y,w,h,alpha int)
|
||||||
GetOnShow() bool
|
GetOnShow() bool
|
||||||
SetOnShow(onshow bool)
|
SetOnShow(onshow bool)
|
||||||
|
|
||||||
|
Coord() (int,int)
|
||||||
|
NewCoord(x,y int)
|
||||||
|
Size() (int,int)
|
||||||
|
NewSize(w,h int)
|
||||||
|
|
||||||
Draw()
|
Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
type PageSelector struct {
|
type PageSelector struct {
|
||||||
|
Widget
|
||||||
|
|
||||||
PosX int
|
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Parent PageInterface
|
|
||||||
Alpha int
|
Alpha int
|
||||||
OnShow bool
|
OnShow bool
|
||||||
IconSurf *sdl.Surface
|
IconSurf *sdl.Surface
|
||||||
|
|
||||||
|
Parent PageInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPageSelector() *PageSelector {
|
func NewPageSelector() *PageSelector {
|
||||||
@ -176,7 +179,10 @@ type PageInterface interface {
|
|||||||
GetIconIndex() int
|
GetIconIndex() int
|
||||||
|
|
||||||
Coord() (int, int)
|
Coord() (int, int)
|
||||||
|
NewCoord(x,y int)
|
||||||
Size() (int,int)
|
Size() (int,int)
|
||||||
|
NewSize(w,h int)
|
||||||
|
|
||||||
|
|
||||||
UpdateIconNumbers()
|
UpdateIconNumbers()
|
||||||
GetIconNumbers() int
|
GetIconNumbers() int
|
||||||
@ -189,6 +195,8 @@ type PageInterface interface {
|
|||||||
ClearIcons()
|
ClearIcons()
|
||||||
DrawIcons()
|
DrawIcons()
|
||||||
|
|
||||||
|
GetMyList() []ListItemInterface
|
||||||
|
|
||||||
GetName() string
|
GetName() string
|
||||||
SetName(n string)
|
SetName(n string)
|
||||||
GetFootMsg() [5]string
|
GetFootMsg() [5]string
|
||||||
@ -212,10 +220,7 @@ type PageInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Page struct {
|
type Page struct {
|
||||||
PosX int
|
Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Icons []IconItemInterface // slice ,use append
|
Icons []IconItemInterface // slice ,use append
|
||||||
IconNumbers int
|
IconNumbers int
|
||||||
IconIndex int
|
IconIndex int
|
||||||
@ -231,6 +236,8 @@ type Page struct {
|
|||||||
CanvasHWND *sdl.Surface
|
CanvasHWND *sdl.Surface
|
||||||
HWND *sdl.Surface
|
HWND *sdl.Surface
|
||||||
|
|
||||||
|
MyList []ListItemInterface
|
||||||
|
|
||||||
OnShow bool
|
OnShow bool
|
||||||
Name string
|
Name string
|
||||||
Screen *MainScreen
|
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) {
|
func (self *Page) KeyDown( ev *event.Event) {
|
||||||
if ev.Data["Key"] == CurKeys["A"] {
|
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 {
|
func (self *Page) GetName() string {
|
||||||
return self.Name
|
return self.Name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,10 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ListScroller struct{
|
type ListScroller struct{
|
||||||
PosX int
|
Widget
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
MinHeight int
|
MinHeight int
|
||||||
Parent PageInterface
|
Parent PageInterface
|
||||||
Color *color.Color
|
Color *color.Color
|
||||||
@ -40,6 +37,8 @@ func NewListScroller() *ListScroller {
|
|||||||
|
|
||||||
func (self *ListScroller) Init() {
|
func (self *ListScroller) Init() {
|
||||||
//just set the CanvasHWND
|
//just set the CanvasHWND
|
||||||
|
cav_ := self.Parent.GetCanvasHWND()
|
||||||
|
self.SetCanvasHWND(cav_)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ListScroller) SetCanvasHWND( canvas *sdl.Surface) {
|
func (self *ListScroller) SetCanvasHWND( canvas *sdl.Surface) {
|
||||||
|
|||||||
@ -15,11 +15,7 @@ import (
|
|||||||
|
|
||||||
|
|
||||||
type UntitledIcon struct {
|
type UntitledIcon struct {
|
||||||
|
Widget
|
||||||
PosX int
|
|
||||||
PosY int
|
|
||||||
Width int
|
|
||||||
Height int
|
|
||||||
Words []string
|
Words []string
|
||||||
FontObj *ttf.Font
|
FontObj *ttf.Font
|
||||||
BG *sdl.Surface
|
BG *sdl.Surface
|
||||||
|
|||||||