mirror of
https://github.com/clockworkpi/LauncherGoDev.git
synced 2025-12-12 16:08:52 +01:00
keyboard
This commit is contained in:
parent
e398324c97
commit
d793dc93ab
48
sysgo/UI/keyboard.go
Normal file
48
sysgo/UI/keyboard.go
Normal file
@ -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
|
||||
|
||||
|
||||
}
|
||||
14
sysgo/UI/keyboard_keys.layout
Normal file
14
sysgo/UI/keyboard_keys.layout
Normal file
@ -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
|
||||
107
sysgo/UI/textarea.go
Normal file
107
sysgo/UI/textarea.go
Normal file
@ -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
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user