sound_page,brightness_page,struct inherited bug,Draw

This commit is contained in:
cuu
2018-12-05 22:31:42 +08:00
parent 9261a1ae27
commit 947cfae038
5 changed files with 151 additions and 3 deletions

View File

@@ -5,7 +5,14 @@ import(
"io/ioutil"
"strconv"
"github.com/veandco/go-sdl2/sdl"
"github.com/cuu/gogame/event"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/rect"
"github.com/cuu/LauncherGoDev/sysgo"
"github.com/cuu/LauncherGoDev/sysgo/UI"
)
@@ -25,6 +32,35 @@ func NewSliderIcon() *SliderIcon {
return p
}
func (self *SliderIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderIcon Draw Parent nil")
return
}
parent_x,parent_y := self.Parent.Coord()
if self.Label != nil {
// lab_x,lab_y := self.Label.Coord()
lab_w,lab_h:= self.Label.Size()
if self.Align == UI.ALIGN["VCenter"] {
// fmt.Println("IconItem Draw VCenter:",lab_w,lab_h,self.Label.GetText())
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6+parent_y)
}else if self.Align == UI.ALIGN["HLeft"] {
self.Label.NewCoord( self.PosX + self.Width/2+3+parent_x, self.PosY - lab_h/2 + parent_y)
}
self.Label.Draw()
}
if self.ImgSurf != nil {
surface.Blit(self.Parent.GetCanvasHWND(), self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
self.Width,self.Height, UI.Width, UI.Height),nil)
}
}
type SliderMultiIcon struct {
UI.MultiIconItem
Parent *BSlider
@@ -42,6 +78,35 @@ func NewSliderMultiIcon() *SliderMultiIcon {
return p
}
func (self *SliderMultiIcon) Draw() {
if self.Parent == nil {
fmt.Println("Error: SliderMultiIcon Draw Parent nil")
return
}
parent_x,parent_y := self.Parent.Coord()
if self.Label != nil {
// lab_x,lab_y := self.Label.Coord()
lab_w,lab_h:= self.Label.Size()
if self.Align == UI.ALIGN["VCenter"] {
self.Label.NewCoord( self.PosX - lab_w/2 + parent_x, self.PosY + self.Height/2+6 + parent_y)
}else if self.Align == UI.ALIGN["HLeft"] {
self.Label.NewCoord( self.PosX + self.Width/2+3 + parent_x, self.PosY - lab_h/2 + parent_y )
}
self.Label.Draw()
}
if self.ImgSurf != nil {
portion := rect.Rect(0,self.IconIndex*self.IconHeight,self.IconWidth,self.IconHeight)
surface.Blit(self.Parent.GetCanvasHWND(),
self.ImgSurf,draw.MidRect(self.PosX + parent_x, self.PosY + parent_y,
self.Width,self.Height, UI.Width, UI.Height),&portion)
}
}
type BSlider struct {
UI.Slider
@@ -67,6 +132,10 @@ func NewBSlider() *BSlider {
return p
}
func (self *BSlider) GetCanvasHWND() *sdl.Surface {
return self.CanvasHWND
}
func (self *BSlider) Init() {
self.Width = self.Parent.Width