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

@@ -4,6 +4,11 @@ import(
"fmt"
"github.com/veandco/go-sdl2/sdl"
"github.com/cuu/gogame/event"
"github.com/cuu/gogame/surface"
"github.com/cuu/gogame/draw"
"github.com/cuu/gogame/rect"
"github.com/cuu/LauncherGoDev/sysgo/UI"
)
@@ -14,6 +19,7 @@ type SliderIcon struct {
Parent *SoundSlider
}
func NewSliderIcon() *SliderIcon {
p := &SliderIcon{}
p.MyType = UI.ICON_TYPES["EXE"]
@@ -22,6 +28,36 @@ 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 *SoundSlider
@@ -39,6 +75,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 SoundSlider struct {
UI.Slider
@@ -131,6 +196,7 @@ func (self *SoundSlider) StepBack() {
func (self *SoundSlider) Draw() {
self.BGpng.NewCoord(self.Width/2,self.Height/2)
fmt.Printf("%x\n",self.BGpng.Parent)
self.BGpng.Draw()
self.Scale.NewCoord(self.Width/2,self.Height/2)