mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-13 00:18:52 +01:00
Settings ScrollUp bug fix
This commit is contained in:
parent
6bfe64c59b
commit
01a1ca08c5
@ -0,0 +1,203 @@
|
|||||||
|
package Bluetooth
|
||||||
|
|
||||||
|
type BleForgetConfirmPage struct {
|
||||||
|
|
||||||
|
UI.ConfirmPage
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBleForgetConfirmPage() *BleForgetConfirmPage {
|
||||||
|
p := &BleForgetConfirmPage{}
|
||||||
|
|
||||||
|
p.ConfirmText = "Confirm Forget?"
|
||||||
|
p.UI.ConfirmPage.ConfirmText = p.ConfirmText
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleForgetConfirmPage) KeyDown(ev *event.Event) {
|
||||||
|
|
||||||
|
if ev.Data["Key"] == CurKeys["A"] || ev.Data["Key"] == CurKeys["Menu"] {
|
||||||
|
self.ReturnToUpLevelPage()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
}
|
||||||
|
|
||||||
|
if ev.Data["Key"] == CurKeys["B"] {
|
||||||
|
self.SnapMsg("Deleting")
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
|
||||||
|
|
||||||
|
time.BlockDelay(400)
|
||||||
|
self.ReturnToUpLevelPage()
|
||||||
|
self.Screen.Draw()
|
||||||
|
self.Screen.SwapAndShow()
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleForgetConfirmPage) Draw() {
|
||||||
|
self.DrawBG()
|
||||||
|
for _,v := range self.MyList{
|
||||||
|
v.Draw()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type BleInfoPageSelector struct {
|
||||||
|
UI.InfoPageSelector
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBleInfoPageSelector() *BleInfoPageSelector{
|
||||||
|
p := &BleInfoPageSelector{}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleInfoPageSelector) Draw() {
|
||||||
|
idx := self.Parent.GetPsIndex()
|
||||||
|
mylist := self.Parent.GetMyList()
|
||||||
|
|
||||||
|
if idx < len(mylist) {
|
||||||
|
_,y := mylist[idx].Coord()
|
||||||
|
_,h := mylist[idx].Size()
|
||||||
|
|
||||||
|
x := self.PosX+2
|
||||||
|
self.PosY = y+1
|
||||||
|
self.Height = h-3
|
||||||
|
|
||||||
|
canvas_ := self.Parent.GetCanvasHWND()
|
||||||
|
rect_ := rect.Rect(x,self.PosY,self.Width-4, self.Height)
|
||||||
|
|
||||||
|
draw.AARoundRect(canvas_,&rect_,self.BackgroundColor,4,0,self.BackgroundColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type BleInfoPage struct {
|
||||||
|
UI.Page
|
||||||
|
|
||||||
|
ListFontObj *ttf.Font
|
||||||
|
ListSmFontObj *ttf.Font
|
||||||
|
ListSm2FontObj *ttf.Font
|
||||||
|
|
||||||
|
MyList []UI.ListItemInterface
|
||||||
|
|
||||||
|
ConfirmPage1 *BleForgetConfirmPage
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func NewBleInfoPage() *BleInfoPage {
|
||||||
|
p :=&BleInfoPage{}
|
||||||
|
|
||||||
|
p.FootMsg = [5]string{"Nav","Disconnect","Forget","Back","" }
|
||||||
|
|
||||||
|
p.ListFontObj = UI.Fonts["varela15"]
|
||||||
|
p.ListSmFontObj = UI.Fonts["varela12"]
|
||||||
|
p.ListSm2FontObj = UI.Fonts["varela11"]
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *BleInfoPage) Init() {
|
||||||
|
|
||||||
|
if self.Screen != nil {
|
||||||
|
if self.Screen.CanvasHWND != nil && self.CanvasHWND == nil {
|
||||||
|
self.CanvasHWND = self.Screen.CanvasHWND
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.PosX = self.Index*self.Screen.Width
|
||||||
|
self.Width = self.Screen.Width // equals to screen width
|
||||||
|
self.Height = self.Screen.Height
|
||||||
|
|
||||||
|
ps := NewBleInfoPageSelector()
|
||||||
|
ps.Parent = self
|
||||||
|
self.Ps = ps
|
||||||
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
self.GenList()
|
||||||
|
|
||||||
|
self.Scroller = UI.NewListScroller()
|
||||||
|
self.Scroller.Parent = self
|
||||||
|
self.Scroller.PosX = 2
|
||||||
|
self.Scroller.PosY = 2
|
||||||
|
self.Scroller.Init()
|
||||||
|
|
||||||
|
self.ConfirmPage1 = BleForgetConfirmPage()
|
||||||
|
self.ConfirmPage1.Screen = self.Screen
|
||||||
|
self.ConfirmPage1.Name = "Confirm Forget"
|
||||||
|
self.ConfirmPage1.Parent = self
|
||||||
|
self.ConfirmPage1.Init()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleInfoPage) GenList() {
|
||||||
|
if len(self.AList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
self.MyList = nil
|
||||||
|
|
||||||
|
self.PsIndex = 0
|
||||||
|
|
||||||
|
start_x := 0
|
||||||
|
start_y := 0
|
||||||
|
|
||||||
|
i := 0
|
||||||
|
for k,v := range self.AList {
|
||||||
|
li := UI.NewInfoPageListItem()
|
||||||
|
li.Parent = self
|
||||||
|
li.PosX = start_x
|
||||||
|
li.PosY = start_y +i*NetItemDefaultHeight
|
||||||
|
li.Width = UI.Width
|
||||||
|
|
||||||
|
li.Fonts["normal"] = self.ListFontObj
|
||||||
|
if k =="UUIDs" {
|
||||||
|
li.Fonts["small"] = self.ListSm2FontObj
|
||||||
|
}else{
|
||||||
|
li.Fonts["small"] = self.ListSmFontObj
|
||||||
|
}
|
||||||
|
|
||||||
|
li.Init(k)
|
||||||
|
li.Flag = k
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleInfoPage) ScrollUp() {
|
||||||
|
if len(self.MyList) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.PsIndex -= 1
|
||||||
|
|
||||||
|
if self.PsIndex < 0 {
|
||||||
|
self.PsIndex = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_li = self.MyList[self.PsIndex]
|
||||||
|
|
||||||
|
x,y := cur_li.Coord()
|
||||||
|
|
||||||
|
if y < 0 {
|
||||||
|
for i,v := range self.MyList {
|
||||||
|
x,y = v.Coord()
|
||||||
|
_,h := v.Size()
|
||||||
|
self.MyList[i].NewCoord(x,y+h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *BleInfoPage) ScrollDown() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package Bluetooth
|
||||||
|
|
||||||
|
var NetItemDefaultHeight = 30
|
||||||
|
|
||||||
|
type NetItemMultiIcon struct {
|
||||||
|
UI.MultiIconItem
|
||||||
|
CanvasHWND *sdl.Surface // self._Parent._CanvasHWND
|
||||||
|
Parent UI.WidgetInterface //
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNetItemMultiIcon() *NetItemMultiIcon{
|
||||||
|
p := &NetItemMultiIcon{}
|
||||||
|
p.IconIndex = 0
|
||||||
|
p.IconWidth = 18
|
||||||
|
p.IconHeight = 18
|
||||||
|
|
||||||
|
p.Width = 18
|
||||||
|
p.Height = 18
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *NetItemMultiIcon) Draw() {
|
||||||
|
_,h_ := self.Parent.Size()
|
||||||
|
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2, self.Width,self.Height)
|
||||||
|
area_rect := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
|
||||||
|
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,&area_rect)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type NetItemIcon struct {
|
||||||
|
UI.IconItem
|
||||||
|
CanvasHWND *sdl.Surface
|
||||||
|
Parent UI.WidgetInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewNetItemIcon() *NetItemIcon {
|
||||||
|
p := &NetItemIcon{}
|
||||||
|
p.Width = 18
|
||||||
|
p.Height = 18
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
|
func (self *NetItemIcon) Draw() {
|
||||||
|
_,h_ := self.Parent.Size()
|
||||||
|
|
||||||
|
dest_rect := rect.Rect(self.PosX,self.PosY+(h_-self.Height)/2,self.Width,self.Height)
|
||||||
|
|
||||||
|
surface.Blit(self.CanvasHWND,self.ImgSurf,&dest_rect,nil)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
type NetItem struct {
|
||||||
|
UI.Widget
|
||||||
|
|
||||||
|
Channel string //'10'
|
||||||
|
Stren string //19%
|
||||||
|
|
||||||
|
Icons map[string]UI.IconItemInterface
|
||||||
|
Labels map[string]UI.LabelInterface
|
||||||
|
|
||||||
|
IsActive bool
|
||||||
|
FontObj *ttf.Font
|
||||||
|
RSSI int // 0
|
||||||
|
MacAddr string //
|
||||||
|
|
||||||
|
Path string ///org/bluez/hci0/dev_34_88_5D_97_FF_26
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func NewNetItem() *NetItem {
|
||||||
|
p:= &NetItem{}
|
||||||
|
|
||||||
|
p.Height = NetItemDefaultHeight
|
||||||
|
|
||||||
|
p.Labels = make(map[string]UI.LabelInterface)
|
||||||
|
p.Icons = make( map[string]UI.IconItemInterface)
|
||||||
|
|
||||||
|
return p
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *NetItem) SetActive(act bool) {
|
||||||
|
self.IsActive = act
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (self *NetItem) Init(path string ) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
package Bluetooth
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ func (self *SettingsPage) ScrollUp() {
|
|||||||
}
|
}
|
||||||
cur_li := self.MyList[self.PsIndex]
|
cur_li := self.MyList[self.PsIndex]
|
||||||
x,y := cur_li.Coord()
|
x,y := cur_li.Coord()
|
||||||
if x < 0 {
|
if y < 0 {
|
||||||
for i:=0;i<len(self.MyList);i++ {
|
for i:=0;i<len(self.MyList);i++ {
|
||||||
_,h := self.MyList[i].Size()
|
_,h := self.MyList[i].Size()
|
||||||
x,y = self.MyList[i].Coord()
|
x,y = self.MyList[i].Coord()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user