diff --git a/sysgo/UI/keyboard.go b/sysgo/UI/keyboard.go new file mode 100644 index 0000000..8c88f81 --- /dev/null +++ b/sysgo/UI/keyboard.go @@ -0,0 +1,48 @@ +package UI + +import ( + "github.com/cuu/gogame/color" +) +//sysgo/UI/keyboard_keys.layout +type KeyboardIcon struct { + IconItem + Color *color.Color + + Str string +} + +func NewKeyboardIcon() *KeyboardIcon { + p := &KeyboardIcon{} + + p.MyType = ICON_TYPES["NAV"] + + return p +} + +type KeyboardSelector struct { + PageSelector + Parent *Keyboard +} + + +func NewKeyboardSelector() * KeyboardSelector { + p := &KeyboardSelector{} + + return p +} + +func (self *KeyboardSelector) Draw() { + +} + +type Keyboard { + Page + + SectionNumbers int + SectionIndex int + Icons map[string]UI.IconItemInterface + + KeyboardLayoutFile string ///sysgo/UI/keyboard_keys.layout + + +} diff --git a/sysgo/UI/keyboard_keys.layout b/sysgo/UI/keyboard_keys.layout new file mode 100644 index 0000000..a77e2ff --- /dev/null +++ b/sysgo/UI/keyboard_keys.layout @@ -0,0 +1,14 @@ +1 2 3 4 5 6 7 8 9 0 +q w e r t y u i o p +a s d f g h j k l +_L z x c v b n m _R + +1 2 3 4 5 6 7 8 9 0 +Q W E R T Y U I O P +A S D F G H J K L +_L Z X C V B N M _R + +! @ # $ % ^ & * ( ) +- _ + = ~ ` [ ] { } +| \ : ; " ' < > , . +_L ? / _R _S diff --git a/sysgo/UI/textarea.go b/sysgo/UI/textarea.go new file mode 100644 index 0000000..639afec --- /dev/null +++ b/sysgo/UI/textarea.go @@ -0,0 +1,107 @@ +package UI + +import ( + "github.com/veandco/go-sdl2/sdl" + "github.com/veandco/go-sdl2/ttf" + + "github.com/cuu/gogame/color" +) + +type Textarea struct { + Widget + BackgroundColor *color.Color + CanvasHWND *sdl.Surface + MyWords []string + BlitWords []string + FontObj *ttf.Font + LineNumber int + TextLimit int + TextFull bool + TextIndex int + BlitIndex int +} + +func NewTextarea() *Textarea { + p := &Textarea{} + + p.TextLimit = 63 + p.TextFull = false + + p.MyWords = make([]string,0) + p.BlitWords = make([]string,0) + + p.BackgroundColor = &color.Color{228,228,228,255} + + return p +} + +func (self *Textarea) Init() { + self.FontObj = Fonts["veramono24"] +} + +func (self *Textarea) SubTextIndex() { + self.TextIndex -= 1 + if self.TextIndex < 0 { + self.TextIndex = 0 + } +} + +func (self *Textarea) AddTextIndex() { + + self.TextIndex += 1 + if self.TextIndex > len(self.MyWords) { + self.TextIndex = len(self.MyWords) + } +} + +func (self *Textarea) ResetMyWords() { + self.MyWords = nil + self.TextIndex = 0 +} + +func (self *Textarea) RemoveFromLastText() []string { + if len(self.MyWords) > 0 { + self.SubTextIndex() + if self.TextIndex < len(self.MyWords) { + self.MyWords = append(self.MyWords[:self.TextIndex],self.MyWords[(self.TextIndex+1):]...) + } + } + + return self.MyWords +} + + +func (self *Textarea) AppendText( alphabet string) { + self.AppendAndBlitText(alphabet) +} + +func (self *Textarea) AppendAndBlitText(alphabet string) { + if self.TextFull == false { + + if self.TextIndex <= len(self.MyWords) { + m = append(m[:idx], append([]string{"U"}, m[idx:]...)...) + self.MyWords = append(self.MyWords[:self.TextIndex], + append([]string{alphabet},self.MyWords[self.TextIndex:]...)...) + + self.BlitText() + self.AddTextIndex() + } + + }else { + fmt.Printf("is Full %s",strings.Join(self.MyWords,"")) + } + +} + +func (self *Textarea) BuildBlitText() { + blit_rows := make([][]string,0) + + w := 0 + xmargin := 5 + endmargin :=15 + x := self.PosX + xmargin + linenumber := 0 + cursor_row := 0 + + +}