mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-13 00:18:52 +01:00
add TimeZone selection in settings
This commit is contained in:
parent
af6e325bb3
commit
fe210d5561
@ -28,7 +28,8 @@ import (
|
|||||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/PowerOptions"
|
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/PowerOptions"
|
||||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Airplane"
|
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/Airplane"
|
||||||
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/ButtonsLayout"
|
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/ButtonsLayout"
|
||||||
|
"github.com/cuu/LauncherGoDev/Menu/GameShell/10_Settings/TimeZone"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
@ -107,6 +108,8 @@ func (self *SettingsPage) GenList() []*UI.UIPlugin {
|
|||||||
&UI.UIPlugin{0,"", "Sound", "Sound Volume" , &Sound.APIOBJ},
|
&UI.UIPlugin{0,"", "Sound", "Sound Volume" , &Sound.APIOBJ},
|
||||||
&UI.UIPlugin{0,"", "Brightness", "BackLight Brightness", &Brightness.APIOBJ},
|
&UI.UIPlugin{0,"", "Brightness", "BackLight Brightness", &Brightness.APIOBJ},
|
||||||
&UI.UIPlugin{0,"", "Storage", "", &Storage.APIOBJ},
|
&UI.UIPlugin{0,"", "Storage", "", &Storage.APIOBJ},
|
||||||
|
&UI.UIPlugin{0,"", "TimeZone", "Timezone", &TimeZone.APIOBJ},
|
||||||
|
|
||||||
&UI.UIPlugin{0,"", "Languages", "Languages", &Languages.APIOBJ},
|
&UI.UIPlugin{0,"", "Languages", "Languages", &Languages.APIOBJ},
|
||||||
&UI.UIPlugin{0,"", "Update", "Update", &Update.APIOBJ},
|
&UI.UIPlugin{0,"", "Update", "Update", &Update.APIOBJ},
|
||||||
&UI.UIPlugin{0,"", "About", "About", &About.APIOBJ},
|
&UI.UIPlugin{0,"", "About", "About", &About.APIOBJ},
|
||||||
|
|||||||
105
Menu/GameShell/10_Settings/TimeZone/list_item.go
Normal file
105
Menu/GameShell/10_Settings/TimeZone/list_item.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package TimeZone
|
||||||
|
|
||||||
|
import (
|
||||||
|
//"fmt"
|
||||||
|
//"strings"
|
||||||
|
//"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
//"github.com/veandco/go-sdl2/sdl"
|
||||||
|
//"github.com/cuu/gogame/surface"
|
||||||
|
//"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
var TimeZoneListPageListItemDefaultHeight = 30
|
||||||
|
|
||||||
|
type TimeZoneListPageInterface interface {
|
||||||
|
UI.PageInterface
|
||||||
|
GetMapIcons() map[string]UI.IconItemInterface
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimeZoneListPageListItem struct {
|
||||||
|
UI.HierListItem
|
||||||
|
Parent TimeZoneListPageInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTimeZoneListPageListItem() *TimeZoneListPageListItem {
|
||||||
|
p := &TimeZoneListPageListItem{}
|
||||||
|
p.Labels = make(map[string]UI.LabelInterface)
|
||||||
|
p.Icons = make( map[string]UI.IconItemInterface)
|
||||||
|
p.Fonts = make(map[string]*ttf.Font)
|
||||||
|
|
||||||
|
p.MyType = UI.ICON_TYPES["EXE"]
|
||||||
|
p.Height = TimeZoneListPageListItemDefaultHeight
|
||||||
|
p.Width = 0
|
||||||
|
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPageListItem) Init(text string) {
|
||||||
|
l := UI.NewLabel()
|
||||||
|
l.PosX = 20
|
||||||
|
|
||||||
|
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||||
|
|
||||||
|
if self.IsDir() == true || self.IsFile() == true {
|
||||||
|
self.Path = text
|
||||||
|
}
|
||||||
|
|
||||||
|
label_text := filepath.Base(text)
|
||||||
|
|
||||||
|
if self.IsDir() == true {
|
||||||
|
l.Init(label_text, self.Fonts["normal"],nil)
|
||||||
|
}else {
|
||||||
|
l.Init(label_text,self.Fonts["normal"],nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Labels["Text"] = l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPageListItem) Draw() {
|
||||||
|
x,y := self.Labels["Text"].Coord()
|
||||||
|
_,h := self.Labels["Text"].Size()
|
||||||
|
|
||||||
|
|
||||||
|
if self.Path != "[..]" {
|
||||||
|
self.Labels["Text"].NewCoord(23,y)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
self.Labels["Text"].NewCoord(3,y)
|
||||||
|
}
|
||||||
|
|
||||||
|
x,y = self.Labels["Text"].Coord()
|
||||||
|
self.Labels["Text"].NewCoord(x, self.PosY + (self.Height-h)/2)
|
||||||
|
|
||||||
|
self.Labels["Text"].Draw()
|
||||||
|
|
||||||
|
parent_icons := self.Parent.GetMapIcons()
|
||||||
|
_,h = parent_icons["sys"].Size()
|
||||||
|
|
||||||
|
if self.IsDir() == true && self.Path != "[..]" {
|
||||||
|
parent_icons["sys"].SetIconIndex (0)
|
||||||
|
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||||
|
parent_icons["sys"].Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.IsFile() == true {
|
||||||
|
parent_icons["sys"].SetIconIndex(1)
|
||||||
|
parent_icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||||
|
parent_icons["sys"].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)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
39
Menu/GameShell/10_Settings/TimeZone/plugin_init.go
Normal file
39
Menu/GameShell/10_Settings/TimeZone/plugin_init.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package TimeZone
|
||||||
|
|
||||||
|
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/LauncherGoDev/sysgo/UI"
|
||||||
|
//"github.com/cuu/LauncherGoDev/sysgo/DBUS"
|
||||||
|
)
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
type TimeZonePlugin struct {
|
||||||
|
UI.Plugin
|
||||||
|
TimeZonePage *TimeZoneListPage
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *TimeZonePlugin) Init( main_screen *UI.MainScreen ) {
|
||||||
|
self.TimeZonePage = NewTimeZoneListPage()
|
||||||
|
self.TimeZonePage.SetScreen( main_screen)
|
||||||
|
self.TimeZonePage.SetName("Timezone Selection")
|
||||||
|
self.TimeZonePage.Init()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZonePlugin) Run( main_screen *UI.MainScreen ) {
|
||||||
|
if main_screen != nil {
|
||||||
|
main_screen.PushCurPage()
|
||||||
|
main_screen.SetCurPage(self.TimeZonePage)
|
||||||
|
main_screen.Draw()
|
||||||
|
main_screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var APIOBJ TimeZonePlugin
|
||||||
360
Menu/GameShell/10_Settings/TimeZone/time_zone_page.go
Normal file
360
Menu/GameShell/10_Settings/TimeZone/time_zone_page.go
Normal file
@ -0,0 +1,360 @@
|
|||||||
|
package TimeZone
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
"github.com/cuu/gogame/event"
|
||||||
|
"github.com/cuu/gogame/time"
|
||||||
|
|
||||||
|
"github.com/cuu/LauncherGoDev/sysgo/UI"
|
||||||
|
|
||||||
|
)
|
||||||
|
var TimeZonePath = "/usr/share/zoneinfo/posix"
|
||||||
|
|
||||||
|
type ListPageSelector struct {
|
||||||
|
UI.InfoPageSelector
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListPageSelector() *ListPageSelector {
|
||||||
|
|
||||||
|
p := &ListPageSelector{}
|
||||||
|
|
||||||
|
p.Width = UI.Width
|
||||||
|
p.BackgroundColor = &color.Color{131,199,219,255} //SkinManager().GiveColor('Front')
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *ListPageSelector) Draw() {
|
||||||
|
|
||||||
|
idx := self.Parent.GetPsIndex()
|
||||||
|
mylist := self.Parent.GetMyList()
|
||||||
|
|
||||||
|
if idx < len(mylist) {
|
||||||
|
x,y := mylist[idx].Coord()
|
||||||
|
_,h := mylist[idx].Size()
|
||||||
|
|
||||||
|
self.PosX = x+2
|
||||||
|
self.PosY = y+1
|
||||||
|
self.Height = h-3
|
||||||
|
|
||||||
|
canvas_ := self.Parent.GetCanvasHWND()
|
||||||
|
rect_ := rect.Rect(self.PosX,self.PosY,self.Width-4, self.Height)
|
||||||
|
|
||||||
|
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
type TimeZoneListPage struct {
|
||||||
|
UI.Page
|
||||||
|
|
||||||
|
Scroller *UI.ListScroller
|
||||||
|
|
||||||
|
Icons map[string]UI.IconItemInterface
|
||||||
|
|
||||||
|
ListFont *ttf.Font
|
||||||
|
MyStack *UI.FolderStack
|
||||||
|
BGpng *UI.IconItem
|
||||||
|
BGwidth int
|
||||||
|
BGheight int
|
||||||
|
|
||||||
|
SwapMyList []UI.ListItemInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
type ListEle struct {
|
||||||
|
|
||||||
|
Name string
|
||||||
|
FilePath string
|
||||||
|
IsFile bool
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func NewTimeZoneListPage() *TimeZoneListPage {
|
||||||
|
p := &TimeZoneListPage{}
|
||||||
|
|
||||||
|
p.BGwidth = 56
|
||||||
|
p.BGheight = 70
|
||||||
|
|
||||||
|
p.FootMsg = [5]string{ "Nav","","","Back","Select" }
|
||||||
|
|
||||||
|
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||||
|
|
||||||
|
p.MyStack = UI.NewFolderStack()
|
||||||
|
p.MyStack.SetRootPath( TimeZonePath )
|
||||||
|
|
||||||
|
p.Icons = make(map[string]UI.IconItemInterface )
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) GetMapIcons() map[string]UI.IconItemInterface {
|
||||||
|
return self.Icons
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) buildDirectoryList(path string) []*ListEle {
|
||||||
|
|
||||||
|
//[*ListEle{},*ListEle{}]
|
||||||
|
var ret []*ListEle
|
||||||
|
|
||||||
|
file_paths,err := filepath.Glob(path+"/*")//sorted
|
||||||
|
if err == nil {
|
||||||
|
for _, u := range file_paths {
|
||||||
|
e := &ListEle{}
|
||||||
|
e.Name = filepath.Base(u)
|
||||||
|
e.FilePath = u
|
||||||
|
if UI.IsAFile(u) {
|
||||||
|
e.IsFile = true
|
||||||
|
}else {
|
||||||
|
e.IsFile = false
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = append(ret,e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) SyncList(path string) {
|
||||||
|
|
||||||
|
alist := self.buildDirectoryList(path)
|
||||||
|
if len(alist) == 0 {
|
||||||
|
fmt.Println("buildDirectoryList empty")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.MyList = nil
|
||||||
|
self.SwapMyList = nil
|
||||||
|
|
||||||
|
|
||||||
|
start_x := 0
|
||||||
|
start_y := 0
|
||||||
|
|
||||||
|
hasparent := 0
|
||||||
|
|
||||||
|
if self.MyStack.Length() > 0 {
|
||||||
|
hasparent = 1
|
||||||
|
|
||||||
|
li := NewTimeZoneListPageListItem()
|
||||||
|
li.Parent = self
|
||||||
|
li.PosX = start_x
|
||||||
|
li.PosY = start_y
|
||||||
|
li.Width = UI.Width
|
||||||
|
li.Fonts["normal"] = self.ListFont
|
||||||
|
li.MyType = UI.ICON_TYPES["DIR"]
|
||||||
|
li.Init("[..]")
|
||||||
|
|
||||||
|
self.MyList = append(self.MyList,li)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for i,v := range alist{
|
||||||
|
li := NewTimeZoneListPageListItem()
|
||||||
|
li.Parent = self
|
||||||
|
li.PosX = start_x
|
||||||
|
li.PosY = start_y + (i+hasparent) *TimeZoneListPageListItemDefaultHeight
|
||||||
|
li.Width = UI.Width
|
||||||
|
li.Fonts["normal"] = self.ListFont
|
||||||
|
li.MyType = UI.ICON_TYPES["FILE"]
|
||||||
|
|
||||||
|
if v.IsFile == false {
|
||||||
|
li.MyType = UI.ICON_TYPES["DIR"]
|
||||||
|
}else{
|
||||||
|
li.MyType = UI.ICON_TYPES["FILE"]
|
||||||
|
}
|
||||||
|
|
||||||
|
li.Init(v.Name)
|
||||||
|
li.Path = v.FilePath
|
||||||
|
|
||||||
|
self.MyList = append(self.MyList,li)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for _,v := range self.MyList {
|
||||||
|
self.SwapMyList = append(self.SwapMyList,v)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) Init() {
|
||||||
|
self.PosX = self.Index * self.Screen.Width
|
||||||
|
self.Width = self.Screen.Width
|
||||||
|
self.Height = self.Screen.Height
|
||||||
|
|
||||||
|
self.CanvasHWND = self.Screen.CanvasHWND
|
||||||
|
|
||||||
|
ps := NewListPageSelector()
|
||||||
|
ps.Parent = self
|
||||||
|
|
||||||
|
self.Ps = ps
|
||||||
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
self.SyncList( TimeZonePath )
|
||||||
|
|
||||||
|
icon_for_list := UI.NewMultiIconItem()
|
||||||
|
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||||
|
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||||
|
icon_for_list.Parent = self
|
||||||
|
|
||||||
|
icon_for_list.Adjust(0,0,18,18,0)
|
||||||
|
self.Icons["sys"] = icon_for_list
|
||||||
|
|
||||||
|
bgpng := UI.NewIconItem()
|
||||||
|
bgpng.ImgSurf = UI.MyIconPool.GetImgSurf("empty")
|
||||||
|
bgpng.MyType = UI.ICON_TYPES["STAT"]
|
||||||
|
bgpng.Parent = self
|
||||||
|
bgpng.AddLabel("No timezones found on system!", UI.MyLangManager.TrFont("varela22"))
|
||||||
|
bgpng.SetLabelColor( UI.MySkinManager.GiveColor("Disabled") )
|
||||||
|
bgpng.Adjust(0,0,self.BGwidth,self.BGheight,0)
|
||||||
|
|
||||||
|
self.BGpng = bgpng
|
||||||
|
|
||||||
|
self.Scroller = UI.NewListScroller()
|
||||||
|
self.Scroller.Parent = self
|
||||||
|
self.Scroller.PosX = self.Width - 10
|
||||||
|
self.Scroller.PosY = 2
|
||||||
|
self.Scroller.Init()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) Click() {
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_li := self.MyList[self.PsIndex].(*TimeZoneListPageListItem)
|
||||||
|
|
||||||
|
if cur_li.MyType == UI.ICON_TYPES["DIR"] {
|
||||||
|
if cur_li.Path == "[..]" {
|
||||||
|
self.MyStack.Pop()
|
||||||
|
self.SyncList(self.MyStack.Last())
|
||||||
|
self.PsIndex = 0
|
||||||
|
}else {
|
||||||
|
self.MyStack.Push( self.MyList[self.PsIndex].(*TimeZoneListPageListItem).Path)
|
||||||
|
self.SyncList(self.MyStack.Last())
|
||||||
|
self.PsIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if cur_li.MyType == UI.ICON_TYPES["FILE"] { //set the current timezone
|
||||||
|
self.Screen.MsgBox.SetText("Applying")
|
||||||
|
self.Screen.MsgBox.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
time.BlockDelay(300)
|
||||||
|
cpCmd := exec.Command("sudo","cp", cur_li.Path,"/etc/localtime")
|
||||||
|
err := cpCmd.Run()
|
||||||
|
if err != nil{
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println("add ",cur_li.Path)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) Rescan() {
|
||||||
|
self.SyncList(TimeZonePath)
|
||||||
|
self.PsIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) KeyDown(ev *event.Event) {
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Menu"] || ev.Data["Key"] == UI.CurKeys["A"] {
|
||||||
|
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["Right"] {
|
||||||
|
self.FastScrollDown(5)
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Left"] {
|
||||||
|
self.FastScrollUp(5)
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == UI.CurKeys["Enter"] {
|
||||||
|
self.Click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *TimeZoneListPage) Draw() {
|
||||||
|
self.ClearCanvas()
|
||||||
|
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
self.BGpng.NewCoord(self.Width/2,self.Height/2)
|
||||||
|
self.BGpng.Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(self.MyList) *TimeZoneListPageListItemDefaultHeight > self.Height {
|
||||||
|
|
||||||
|
self.Ps.(*ListPageSelector).Width = self.Width - 11
|
||||||
|
self.Ps.Draw()
|
||||||
|
|
||||||
|
for _,v := range self.MyList {
|
||||||
|
if v.(*TimeZoneListPageListItem).PosY > self.Height + self.Height/2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
self.Scroller.UpdateSize( len(self.MyList)*TimeZoneListPageListItemDefaultHeight,
|
||||||
|
self.PsIndex*TimeZoneListPageListItemDefaultHeight)
|
||||||
|
self.Scroller.Draw()
|
||||||
|
|
||||||
|
}else {
|
||||||
|
self.Ps.(*ListPageSelector).Width = self.Width
|
||||||
|
self.Ps.Draw()
|
||||||
|
|
||||||
|
for _,v := range self.MyList {
|
||||||
|
if v.(*TimeZoneListPageListItem).PosY > self.Height + self.Height/2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if v.(*TimeZoneListPageListItem).PosY < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2
main.go
2
main.go
@ -189,7 +189,7 @@ func InspectionTeam(main_screen *UI.MainScreen) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if UI.FileExists(sysgo.BackLight) {
|
if UI.FileExists(sysgo.BackLight) { //hdmi does not have BackLight dev node
|
||||||
d := []byte(fmt.Sprintf("%d",last_brt))
|
d := []byte(fmt.Sprintf("%d",last_brt))
|
||||||
ioutil.WriteFile(sysgo.BackLight,d,0644)
|
ioutil.WriteFile(sysgo.BackLight,d,0644)
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ type FavListPage struct {
|
|||||||
UI.Page
|
UI.Page
|
||||||
Icons map[string]UI.IconItemInterface
|
Icons map[string]UI.IconItemInterface
|
||||||
ListFont *ttf.Font
|
ListFont *ttf.Font
|
||||||
MyStack *EmuStack
|
MyStack *UI.FolderStack
|
||||||
EmulatorConfig *ActionConfig
|
EmulatorConfig *ActionConfig
|
||||||
|
|
||||||
RomSoConfirmDownloadPage *RomSoConfirmPage
|
RomSoConfirmDownloadPage *RomSoConfirmPage
|
||||||
@ -48,7 +48,7 @@ func NewFavListPage() *FavListPage {
|
|||||||
p.Icons=make(map[string]UI.IconItemInterface)
|
p.Icons=make(map[string]UI.IconItemInterface)
|
||||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||||
|
|
||||||
p.MyStack = NewEmuStack()
|
p.MyStack = UI.NewFolderStack()
|
||||||
|
|
||||||
p.BGwidth = 75
|
p.BGwidth = 75
|
||||||
p.BGheight = 73
|
p.BGheight = 73
|
||||||
@ -194,10 +194,10 @@ func (self *FavListPage) Init() {
|
|||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
self.PsIndex = 0
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
|
||||||
|
|
||||||
self.SyncList( self.EmulatorConfig.ROM )
|
self.SyncList( self.EmulatorConfig.ROM )
|
||||||
|
|
||||||
self.MyStack.EmulatorConfig = self.EmulatorConfig
|
|
||||||
|
|
||||||
icon_for_list := UI.NewMultiIconItem()
|
icon_for_list := UI.NewMultiIconItem()
|
||||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||||
@ -492,7 +492,7 @@ func (self *FavListPage) Draw() {
|
|||||||
self.Icons["bg"].Draw()
|
self.Icons["bg"].Draw()
|
||||||
}else{
|
}else{
|
||||||
_,h := self.Ps.Size()
|
_,h := self.Ps.Size()
|
||||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
|
||||||
|
|
||||||
self.Ps.NewSize(self.Width - 10, h)
|
self.Ps.NewSize(self.Width - 10, h)
|
||||||
self.Ps.Draw()
|
self.Ps.Draw()
|
||||||
@ -511,7 +511,8 @@ func (self *FavListPage) Draw() {
|
|||||||
v.Draw()
|
v.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.Scroller.UpdateSize( len(self.MyList)*HierListItemDefaultHeight, self.PsIndex*HierListItemDefaultHeight)
|
self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight,
|
||||||
|
self.PsIndex*UI.HierListItemDefaultHeight)
|
||||||
self.Scroller.Draw()
|
self.Scroller.Draw()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/veandco/go-sdl2/ttf"
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
//"github.com/veandco/go-sdl2/sdl"
|
//"github.com/veandco/go-sdl2/sdl"
|
||||||
"github.com/cuu/gogame/surface"
|
//"github.com/cuu/gogame/surface"
|
||||||
"github.com/cuu/gogame/rect"
|
//"github.com/cuu/gogame/rect"
|
||||||
"github.com/cuu/gogame/color"
|
"github.com/cuu/gogame/color"
|
||||||
|
|
||||||
"github.com/cuu/gogame/draw"
|
"github.com/cuu/gogame/draw"
|
||||||
@ -24,153 +24,8 @@ type EmulatorPageInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type ListItemIcon struct {
|
|
||||||
UI.IconItem
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewListItemIcon() *ListItemIcon {
|
|
||||||
p := &ListItemIcon{}
|
|
||||||
p.MyType = UI.ICON_TYPES["EXE"]
|
|
||||||
|
|
||||||
p.Align = UI.ALIGN["VCenter"]
|
|
||||||
|
|
||||||
p.Width = 18
|
|
||||||
p.Height = 18
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *ListItemIcon) Draw() {
|
|
||||||
_,h := self.Parent.Size()
|
|
||||||
|
|
||||||
rect_ := rect.Rect(self.PosX,self.PosY+(h-self.Height)/2,self.Width,self.Height)
|
|
||||||
|
|
||||||
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// [..] [.]
|
|
||||||
type HierListItem struct {
|
|
||||||
UI.ListItem
|
|
||||||
MyType int
|
|
||||||
Path string
|
|
||||||
Active bool
|
|
||||||
Playing bool
|
|
||||||
}
|
|
||||||
|
|
||||||
var HierListItemDefaultHeight = 32
|
|
||||||
|
|
||||||
func NewHierListItem() *HierListItem {
|
|
||||||
p := &HierListItem{}
|
|
||||||
p.Labels = make(map[string]UI.LabelInterface)
|
|
||||||
p.Icons = make( map[string]UI.IconItemInterface)
|
|
||||||
p.Fonts = make(map[string]*ttf.Font)
|
|
||||||
|
|
||||||
p.MyType = UI.ICON_TYPES["EXE"]
|
|
||||||
p.Height = HierListItemDefaultHeight
|
|
||||||
p.Width = 0
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *HierListItem) IsFile() bool {
|
|
||||||
if self.MyType == UI.ICON_TYPES["FILE"] {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func (self *HierListItem) IsDir() bool {
|
|
||||||
if self.MyType == UI.ICON_TYPES["DIR"] {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func (self *HierListItem) Init(text string) {
|
|
||||||
l := UI.NewLabel()
|
|
||||||
l.PosX = 20
|
|
||||||
if self.Parent == nil {
|
|
||||||
fmt.Println("Parent nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
|
||||||
|
|
||||||
if self.IsDir() == true || self.IsFile() == true {
|
|
||||||
self.Path = text
|
|
||||||
}
|
|
||||||
|
|
||||||
label_text := filepath.Base(text)
|
|
||||||
ext:= filepath.Ext(text)
|
|
||||||
if ext != "" {
|
|
||||||
alias_file := strings.Replace(text,ext,"",-1) + ".alias"
|
|
||||||
|
|
||||||
if UI.FileExists(alias_file) == true {
|
|
||||||
b, err := ioutil.ReadFile(alias_file)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Print(err)
|
|
||||||
}else {
|
|
||||||
label_text = string(b)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.IsDir() == true {
|
|
||||||
l.Init(label_text, self.Fonts["normal"],nil)
|
|
||||||
}else {
|
|
||||||
l.Init(label_text,self.Fonts["normal"],nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
self.Labels["Text"] = l
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *HierListItem) Draw() {
|
|
||||||
|
|
||||||
x,y := self.Labels["Text"].Coord()
|
|
||||||
_,h := self.Labels["Text"].Size()
|
|
||||||
|
|
||||||
if self.Path != "[..]" {
|
|
||||||
self.Labels["Text"].NewCoord(23,y)
|
|
||||||
|
|
||||||
}else {
|
|
||||||
self.Labels["Text"].NewCoord(3,y)
|
|
||||||
}
|
|
||||||
|
|
||||||
x,y = self.Labels["Text"].Coord()
|
|
||||||
self.Labels["Text"].NewCoord(x, self.PosY + (self.Height-h)/2)
|
|
||||||
|
|
||||||
self.Labels["Text"].Draw()
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
w,h := self.Parent.Icons["sys"].Size()
|
|
||||||
|
|
||||||
if self.IsDir() == true && self.Path != "[..]" {
|
|
||||||
self.Parent.Icons["sys"].IconIndex = 0
|
|
||||||
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
|
||||||
self.Parent.Icons["sys"].Draw()
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.IsFile() == true {
|
|
||||||
self.Parent.Icons["sys"].IconIndex = 1
|
|
||||||
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
|
||||||
self.Parent.Icons["sys"].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)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
type EmulatorListItem struct {
|
type EmulatorListItem struct {
|
||||||
HierListItem
|
UI.HierListItem
|
||||||
Parent EmulatorPageInterface
|
Parent EmulatorPageInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,7 +21,7 @@ type RomListPage struct {
|
|||||||
UI.Page
|
UI.Page
|
||||||
Icons map[string]UI.IconItemInterface
|
Icons map[string]UI.IconItemInterface
|
||||||
ListFont *ttf.Font
|
ListFont *ttf.Font
|
||||||
MyStack *EmuStack
|
MyStack *UI.FolderStack
|
||||||
EmulatorConfig *ActionConfig
|
EmulatorConfig *ActionConfig
|
||||||
|
|
||||||
RomSoConfirmDownloadPage *RomSoConfirmPage
|
RomSoConfirmDownloadPage *RomSoConfirmPage
|
||||||
@ -49,7 +49,7 @@ func NewRomListPage() *RomListPage {
|
|||||||
p.Icons=make(map[string]UI.IconItemInterface)
|
p.Icons=make(map[string]UI.IconItemInterface)
|
||||||
p.ListFont = UI.Fonts["notosanscjk15"]
|
p.ListFont = UI.Fonts["notosanscjk15"]
|
||||||
|
|
||||||
p.MyStack = NewEmuStack()
|
p.MyStack = UI.NewFolderStack()
|
||||||
|
|
||||||
p.BGwidth = 56
|
p.BGwidth = 56
|
||||||
p.BGheight = 70
|
p.BGheight = 70
|
||||||
@ -211,6 +211,8 @@ func (self *RomListPage) Init() {
|
|||||||
self.Ps = ps
|
self.Ps = ps
|
||||||
self.PsIndex = 0
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
self.MyStack.SetRootPath(self.EmulatorConfig.ROM)
|
||||||
|
|
||||||
self.SyncList( self.EmulatorConfig.ROM )
|
self.SyncList( self.EmulatorConfig.ROM )
|
||||||
|
|
||||||
err := os.MkdirAll( self.EmulatorConfig.ROM+"/.Trash", 0700)
|
err := os.MkdirAll( self.EmulatorConfig.ROM+"/.Trash", 0700)
|
||||||
@ -222,9 +224,7 @@ func (self *RomListPage) Init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.MyStack.EmulatorConfig = self.EmulatorConfig
|
|
||||||
|
|
||||||
icon_for_list := UI.NewMultiIconItem()
|
icon_for_list := UI.NewMultiIconItem()
|
||||||
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
icon_for_list.ImgSurf = UI.MyIconPool.GetImgSurf("sys")
|
||||||
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
icon_for_list.MyType = UI.ICON_TYPES["STAT"]
|
||||||
@ -543,7 +543,7 @@ func (self *RomListPage) Draw() {
|
|||||||
self.Icons["bg"].Draw()
|
self.Icons["bg"].Draw()
|
||||||
}else{
|
}else{
|
||||||
_,h := self.Ps.Size()
|
_,h := self.Ps.Size()
|
||||||
if len(self.MyList) * HierListItemDefaultHeight > self.Height {
|
if len(self.MyList) * UI.HierListItemDefaultHeight > self.Height {
|
||||||
|
|
||||||
self.Ps.NewSize(self.Width - 10,h)
|
self.Ps.NewSize(self.Width - 10,h)
|
||||||
self.Ps.Draw()
|
self.Ps.Draw()
|
||||||
@ -555,7 +555,8 @@ func (self *RomListPage) Draw() {
|
|||||||
v.Draw()
|
v.Draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.Scroller.UpdateSize( len(self.MyList)*HierListItemDefaultHeight, self.PsIndex*HierListItemDefaultHeight)
|
self.Scroller.UpdateSize( len(self.MyList)*UI.HierListItemDefaultHeight,
|
||||||
|
self.PsIndex*UI.HierListItemDefaultHeight)
|
||||||
self.Scroller.Draw()
|
self.Scroller.Draw()
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
|
|||||||
@ -91,4 +91,8 @@ func init() {
|
|||||||
MyLangManager.Init()
|
MyLangManager.Init()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if MySkinManager == nil {
|
||||||
|
MySkinManager = NewSkinManager()
|
||||||
|
MySkinManager.Init()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,24 +1,18 @@
|
|||||||
package Emulator
|
package UI
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
//"github.com/cuu/LauncherGoDev/sysgo/UI"
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type element struct {
|
type FolderStack struct {
|
||||||
data interface{}
|
|
||||||
next *element
|
|
||||||
}
|
|
||||||
|
|
||||||
type EmuStack struct {
|
|
||||||
lock *sync.Mutex
|
lock *sync.Mutex
|
||||||
head *element
|
head *element
|
||||||
Size int
|
Size int
|
||||||
EmulatorConfig *ActionConfig
|
RootPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stk *EmuStack) Push(data interface{}) {
|
func (stk *FolderStack) Push(data interface{}) {
|
||||||
stk.lock.Lock()
|
stk.lock.Lock()
|
||||||
|
|
||||||
element := new(element)
|
element := new(element)
|
||||||
@ -31,7 +25,7 @@ func (stk *EmuStack) Push(data interface{}) {
|
|||||||
stk.lock.Unlock()
|
stk.lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stk *EmuStack) Pop() interface{} {
|
func (stk *FolderStack) Pop() interface{} {
|
||||||
if stk.head == nil {
|
if stk.head == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -45,21 +39,25 @@ func (stk *EmuStack) Pop() interface{} {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stk *EmuStack) Length() int {
|
func (stk *FolderStack) SetRootPath(path string) {
|
||||||
|
stk.RootPath = path
|
||||||
|
}
|
||||||
|
|
||||||
|
func (stk *FolderStack) Length() int {
|
||||||
return stk.Size
|
return stk.Size
|
||||||
}
|
}
|
||||||
|
|
||||||
func (stk *EmuStack) Last() string {
|
func (stk *FolderStack) Last() string {
|
||||||
idx := stk.Length() -1
|
idx := stk.Length() -1
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
return stk.EmulatorConfig.ROM
|
return stk.RootPath
|
||||||
}else {
|
}else {
|
||||||
return stk.head.data.(string)
|
return stk.head.data.(string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEmuStack() *EmuStack {
|
func NewFolderStack() *FolderStack {
|
||||||
stk := new(EmuStack)
|
stk := new(FolderStack)
|
||||||
stk.lock = &sync.Mutex{}
|
stk.lock = &sync.Mutex{}
|
||||||
return stk
|
return stk
|
||||||
}
|
}
|
||||||
161
sysgo/UI/hier_list_item.go
Normal file
161
sysgo/UI/hier_list_item.go
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
package UI
|
||||||
|
|
||||||
|
import(
|
||||||
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/veandco/go-sdl2/ttf"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/rect"
|
||||||
|
|
||||||
|
"github.com/cuu/gogame/surface"
|
||||||
|
"github.com/cuu/gogame/draw"
|
||||||
|
"github.com/cuu/gogame/color"
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
type ListItemIcon struct {
|
||||||
|
IconItem
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewListItemIcon() *ListItemIcon {
|
||||||
|
p := &ListItemIcon{}
|
||||||
|
p.MyType = ICON_TYPES["EXE"]
|
||||||
|
|
||||||
|
p.Align = ALIGN["VCenter"]
|
||||||
|
|
||||||
|
p.Width = 18
|
||||||
|
p.Height = 18
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *ListItemIcon) Draw() {
|
||||||
|
_,h := self.Parent.Size()
|
||||||
|
|
||||||
|
rect_ := rect.Rect(self.PosX,self.PosY+(h-self.Height)/2,self.Width,self.Height)
|
||||||
|
|
||||||
|
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,&rect_,nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [..] [.]
|
||||||
|
type HierListItem struct {
|
||||||
|
ListItem
|
||||||
|
MyType int
|
||||||
|
Path string
|
||||||
|
Active bool
|
||||||
|
Playing bool
|
||||||
|
}
|
||||||
|
|
||||||
|
var HierListItemDefaultHeight = 32
|
||||||
|
|
||||||
|
func NewHierListItem() *HierListItem {
|
||||||
|
p := &HierListItem{}
|
||||||
|
p.Labels = make(map[string]LabelInterface)
|
||||||
|
p.Icons = make( map[string]IconItemInterface)
|
||||||
|
p.Fonts = make(map[string]*ttf.Font)
|
||||||
|
|
||||||
|
p.MyType = ICON_TYPES["EXE"]
|
||||||
|
p.Height = HierListItemDefaultHeight
|
||||||
|
p.Width = 0
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HierListItem) IsFile() bool {
|
||||||
|
if self.MyType == ICON_TYPES["FILE"] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *HierListItem) IsDir() bool {
|
||||||
|
if self.MyType == ICON_TYPES["DIR"] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *HierListItem) Init(text string) {
|
||||||
|
l := NewLabel()
|
||||||
|
l.PosX = 20
|
||||||
|
if self.Parent == nil {
|
||||||
|
fmt.Println("Parent nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
l.SetCanvasHWND(self.Parent.GetCanvasHWND())
|
||||||
|
|
||||||
|
if self.IsDir() == true || self.IsFile() == true {
|
||||||
|
self.Path = text
|
||||||
|
}
|
||||||
|
|
||||||
|
label_text := filepath.Base(text)
|
||||||
|
ext:= filepath.Ext(text)
|
||||||
|
if ext != "" {
|
||||||
|
alias_file := strings.Replace(text,ext,"",-1) + ".alias"
|
||||||
|
|
||||||
|
if FileExists(alias_file) == true {
|
||||||
|
b, err := ioutil.ReadFile(alias_file)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Print(err)
|
||||||
|
}else {
|
||||||
|
label_text = string(b)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.IsDir() == true {
|
||||||
|
l.Init(label_text, self.Fonts["normal"],nil)
|
||||||
|
}else {
|
||||||
|
l.Init(label_text,self.Fonts["normal"],nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.Labels["Text"] = l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *HierListItem) Draw() {
|
||||||
|
|
||||||
|
x,y := self.Labels["Text"].Coord()
|
||||||
|
_,h := self.Labels["Text"].Size()
|
||||||
|
|
||||||
|
if self.Path != "[..]" {
|
||||||
|
self.Labels["Text"].NewCoord(23,y)
|
||||||
|
|
||||||
|
}else {
|
||||||
|
self.Labels["Text"].NewCoord(3,y)
|
||||||
|
}
|
||||||
|
|
||||||
|
x,y = self.Labels["Text"].Coord()
|
||||||
|
self.Labels["Text"].NewCoord(x, self.PosY + (self.Height-h)/2)
|
||||||
|
|
||||||
|
self.Labels["Text"].Draw()
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
w,h := self.Parent.Icons["sys"].Size()
|
||||||
|
|
||||||
|
if self.IsDir() == true && self.Path != "[..]" {
|
||||||
|
self.Parent.Icons["sys"].IconIndex = 0
|
||||||
|
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||||
|
self.Parent.Icons["sys"].Draw()
|
||||||
|
}
|
||||||
|
|
||||||
|
if self.IsFile() == true {
|
||||||
|
self.Parent.Icons["sys"].IconIndex = 1
|
||||||
|
self.Parent.Icons["sys"].NewCoord(self.PosX+12,self.PosY+(self.Height-h)/2+h/2)
|
||||||
|
self.Parent.Icons["sys"].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)
|
||||||
|
|
||||||
|
}
|
||||||
@ -1065,3 +1065,65 @@ func (self *Page) ScrollDown() {
|
|||||||
// self.Scrolled -=1
|
// self.Scrolled -=1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func (self *Page) FastScrollUp(step int) {
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if step < 1 {
|
||||||
|
step = 1
|
||||||
|
}
|
||||||
|
tmp := self.PsIndex
|
||||||
|
self.PsIndex -=step
|
||||||
|
|
||||||
|
if self.PsIndex < 0 {
|
||||||
|
self.PsIndex = 0
|
||||||
|
}
|
||||||
|
dy := tmp - self.PsIndex
|
||||||
|
|
||||||
|
cur_li := self.MyList[self.PsIndex]
|
||||||
|
x,y := cur_li.Coord()
|
||||||
|
_,h := cur_li.Size()
|
||||||
|
if y < 0 {
|
||||||
|
for i,_ := range self.MyList{
|
||||||
|
x,y = self.MyList[i].Coord()
|
||||||
|
_, h = self.MyList[i].Size()
|
||||||
|
self.MyList[i].NewCoord(x,y + h*dy)
|
||||||
|
}
|
||||||
|
|
||||||
|
//self.Scrolled +=1
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *Page) FastScrollDown(step int) {
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if step < 1 {
|
||||||
|
step =1
|
||||||
|
}
|
||||||
|
tmp := self.PsIndex
|
||||||
|
self.PsIndex +=step
|
||||||
|
|
||||||
|
if self.PsIndex >= len(self.MyList) {
|
||||||
|
self.PsIndex = len(self.MyList) - 1
|
||||||
|
}
|
||||||
|
dy := self.PsIndex - tmp
|
||||||
|
|
||||||
|
cur_li := self.MyList[self.PsIndex]
|
||||||
|
x,y := cur_li.Coord()
|
||||||
|
_,h := cur_li.Size()
|
||||||
|
|
||||||
|
if y+ h > self.Height {
|
||||||
|
for i,_ := range self.MyList{
|
||||||
|
x,y = self.MyList[i].Coord()
|
||||||
|
_, h = self.MyList[i].Size()
|
||||||
|
self.MyList[i].NewCoord(x,y - h*dy)
|
||||||
|
}
|
||||||
|
// self.Scrolled -=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,6 +59,8 @@ func (self *SkinManager) Init() {
|
|||||||
self.Colors["Line"] = &color.Color{169,169,169,255}
|
self.Colors["Line"] = &color.Color{169,169,169,255}
|
||||||
self.Colors["TitleBg"] = &color.Color{228,228,228,255}
|
self.Colors["TitleBg"] = &color.Color{228,228,228,255}
|
||||||
self.Colors["Active"] = &color.Color{175,90,0,255}
|
self.Colors["Active"] = &color.Color{175,90,0,255}
|
||||||
|
self.Colors["Disabled"] = &color.Color{204,204,204,255}
|
||||||
|
|
||||||
self.Colors["White"] = &color.Color{255,255,255,255}
|
self.Colors["White"] = &color.Color{255,255,255,255}
|
||||||
self.Colors["Black"] = &color.Color{0,0,0,255}
|
self.Colors["Black"] = &color.Color{0,0,0,255}
|
||||||
|
|
||||||
@ -97,3 +99,4 @@ func (self *SkinManager) GiveColor(name string) *color.Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var MySkinManager *SkinManager
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user