|
|
|
@ -135,8 +135,8 @@ func (k *Keyboard) updateKeyRects() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO user configurable
|
|
|
|
|
cellPaddingW := 2 |
|
|
|
|
cellPaddingH := 2 |
|
|
|
|
cellPaddingW := 1 |
|
|
|
|
cellPaddingH := 1 |
|
|
|
|
|
|
|
|
|
cellH := (k.h - (cellPaddingH * (len(k.keys) - 1))) / len(k.keys) |
|
|
|
|
|
|
|
|
@ -368,15 +368,16 @@ func (k *Keyboard) drawBackground() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Draw key background
|
|
|
|
|
// TODO configurable
|
|
|
|
|
img.Fill(color.RGBA{90, 90, 90, 255}) |
|
|
|
|
|
|
|
|
|
// Draw key label
|
|
|
|
|
label := key.LowerLabel |
|
|
|
|
if shift { |
|
|
|
|
label = key.UpperLabel |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Draw key background
|
|
|
|
|
img.Fill(color.RGBA{100, 100, 100, 255}) |
|
|
|
|
|
|
|
|
|
// Draw key label
|
|
|
|
|
bounds := text.BoundString(k.labelFont, label) |
|
|
|
|
x := (key.w - bounds.Dx()) / 2 |
|
|
|
|
if x < 0 { |
|
|
|
@ -385,6 +386,18 @@ func (k *Keyboard) drawBackground() {
|
|
|
|
|
y := key.h / 2 |
|
|
|
|
text.Draw(img, label, k.labelFont, x, y, color.White) |
|
|
|
|
|
|
|
|
|
// Draw border
|
|
|
|
|
lightShade := color.RGBA{150, 150, 150, 255} |
|
|
|
|
darkShade := color.RGBA{30, 30, 30, 255} |
|
|
|
|
for j := 0; j < key.w; j++ { |
|
|
|
|
img.Set(j, 0, lightShade) |
|
|
|
|
img.Set(j, key.h-1, darkShade) |
|
|
|
|
} |
|
|
|
|
for j := 0; j < key.h; j++ { |
|
|
|
|
img.Set(0, j, lightShade) |
|
|
|
|
img.Set(key.w-1, j, darkShade) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Draw key
|
|
|
|
|
k.op.GeoM.Reset() |
|
|
|
|
k.op.GeoM.Translate(float64(key.x), float64(key.y)) |
|
|
|
@ -438,6 +451,16 @@ func (k *Keyboard) Draw(target *ebiten.Image) {
|
|
|
|
|
|
|
|
|
|
target.DrawImage(background.SubImage(image.Rect(key.x, key.y, key.x+key.w, key.y+key.h)).(*ebiten.Image), k.op) |
|
|
|
|
k.op.ColorM.Reset() |
|
|
|
|
|
|
|
|
|
// Draw border
|
|
|
|
|
darkShade := color.RGBA{60, 60, 60, 255} |
|
|
|
|
ox, oy := k.x+key.x, k.y+key.y |
|
|
|
|
for j := 0; j < key.w; j++ { |
|
|
|
|
target.Set(ox+j, oy, darkShade) |
|
|
|
|
} |
|
|
|
|
for j := 0; j < key.h; j++ { |
|
|
|
|
target.Set(ox, oy+j, darkShade) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|