Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Virtual Keyboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Escriptorium
Virtual Keyboard
Commits
eb9ba04e
Commit
eb9ba04e
authored
3 years ago
by
Valentin Rigal
Committed by
Bastien Abadie
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow to resize a keyboard
parent
0d86ebca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!12
Allow to resize a keyboard
Pipeline
#5657
passed with warnings
3 years ago
Stage: test
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/KeyboardConfiguration.vue
+10
-7
10 additions, 7 deletions
src/components/KeyboardConfiguration.vue
src/components/KeyboardDisplay.vue
+71
-7
71 additions, 7 deletions
src/components/KeyboardDisplay.vue
with
81 additions
and
14 deletions
src/components/KeyboardConfiguration.vue
+
10
−
7
View file @
eb9ba04e
<
template
>
<
template
>
<div
class=
"conf-div"
>
<div
class=
"conf-div"
>
<div>
<div>
<UTF8Picker
v-if=
"picker"
:selectedChar.sync=
"selectedChar"
/>
<keep-alive>
<KeyboardDisplay
<UTF8Picker
v-if=
"picker"
:selectedChar.sync=
"selectedChar"
/>
v-else
<KeyboardDisplay
:keyboard-index=
"keyboardIndex"
v-else
:selectedKey=
"selectedKey"
:keyboard-index=
"keyboardIndex"
v-on:input=
"(i) => (selectedKey = i)"
:selectedKey=
"selectedKey"
/>
v-on:input=
"(i) => (selectedKey = i)"
resizable
/>
</keep-alive>
</div>
</div>
<div
class=
"picker"
>
<div
class=
"picker"
>
<template
v-if=
"selectedKey"
>
<template
v-if=
"selectedKey"
>
...
...
This diff is collapsed.
Click to expand it.
src/components/KeyboardDisplay.vue
+
71
−
7
View file @
eb9ba04e
<
template
>
<
template
>
<div
v-if=
"characters && characters.length"
>
<div>
<div
v-if=
"!charTable"
>
An error occured loading the keyboard
</div>
<div
v-if=
"!charTable"
>
An error occured loading the keyboard
</div>
<div
v-else
v-for=
"(row, i) in charTable"
:key=
"i"
>
<div
v-else
v-for=
"(row, i) in charTable"
:key=
"i"
>
<span
v-for=
"(char, j) in row"
:key=
"j"
>
<span
v-for=
"(char, j) in row"
:key=
"j"
>
...
@@ -19,11 +19,31 @@
...
@@ -19,11 +19,31 @@
</button>
</button>
</span>
</span>
</div>
</div>
<
template
v-if=
"resizable"
>
<label>
Rows
</label>
<!-- Directly parse field value to handle integers only -->
<input
:value=
"rows"
v-on:change.prevent=
"(e) => updateRows(e.target.value)"
:min=
"rowsCount"
:max=
"maxKeyboardSize"
type=
"number"
/>
<label>
Columns
</label>
<input
:value=
"columns"
v-on:change.prevent=
"(e) => updateColumns(e.target.value)"
:min=
"columnsCount"
:max=
"maxKeyboardSize"
type=
"number"
/>
</
template
>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
import
{
mapState
}
from
"
vuex
"
;
import
{
mapState
}
from
"
vuex
"
;
import
{
maxKeyboardSize
}
from
"
../config.js
"
;
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -36,29 +56,46 @@ export default {
...
@@ -36,29 +56,46 @@ export default {
type
:
Object
,
type
:
Object
,
default
:
null
,
default
:
null
,
},
},
resizable
:
{
type
:
Boolean
,
default
:
false
,
},
},
},
data
:
()
=>
({
// Rows and columns including a potential resize of the keyboard
rows
:
0
,
columns
:
0
,
maxKeyboardSize
,
}),
computed
:
{
computed
:
{
...
mapState
([
"
keyboards
"
]),
...
mapState
([
"
keyboards
"
]),
keyboard
()
{
return
this
.
keyboards
[
this
.
keyboardIndex
];
},
characters
()
{
characters
()
{
return
this
.
keyboard
s
[
this
.
keyboard
Index
]
.
characters
;
return
this
.
keyboard
&&
this
.
keyboard
.
characters
;
},
},
rowsCount
()
{
rowsCount
()
{
// Return the number of rows from keyboard characters
if
(
!
this
.
characters
.
length
)
return
1
;
return
(
return
(
this
.
characters
&&
Math
.
max
(...
this
.
characters
.
map
((
c
)
=>
c
.
row
))
+
1
this
.
characters
&&
Math
.
max
(...
this
.
characters
.
map
((
c
)
=>
c
.
row
))
+
1
);
);
},
},
columnsCount
()
{
columnsCount
()
{
// Return the number of columns from keyboard characters
if
(
!
this
.
characters
.
length
)
return
1
;
return
(
return
(
this
.
characters
&&
Math
.
max
(...
this
.
characters
.
map
((
c
)
=>
c
.
column
))
+
1
this
.
characters
&&
Math
.
max
(...
this
.
characters
.
map
((
c
)
=>
c
.
column
))
+
1
);
);
},
},
charTable
()
{
charTable
()
{
if
(
!
this
.
columnsCount
||
!
this
.
rowsCount
)
return
;
const
[
tableRows
,
tableCols
]
=
this
.
resizable
?
[
this
.
rows
,
this
.
columns
]
:
[
this
.
rowsCount
,
this
.
columnsCount
];
if
(
!
tableRows
||
!
tableCols
)
return
;
// Return a list of every column with padding
// Return a list of every column with padding
const
table
=
Array
.
from
(
const
table
=
Array
.
from
(
Array
(
tableRows
),
()
=>
new
Array
(
tableCols
));
Array
(
this
.
rowsCount
),
()
=>
new
Array
(
this
.
columnsCount
)
);
if
(
!
this
.
characters
)
return
table
;
if
(
!
this
.
characters
)
return
table
;
this
.
characters
.
forEach
((
c
)
=>
{
this
.
characters
.
forEach
((
c
)
=>
{
table
[
c
.
row
][
c
.
column
]
=
c
;
table
[
c
.
row
][
c
.
column
]
=
c
;
...
@@ -66,6 +103,33 @@ export default {
...
@@ -66,6 +103,33 @@ export default {
return
table
;
return
table
;
},
},
},
},
methods
:
{
// We need to handle input changes manually as v-model.number allows random numbers or empty strings
updateRows
(
value
)
{
if
(
isNaN
(
value
)
||
value
<
this
.
rowsCount
||
value
>
maxKeyboardSize
)
return
;
this
.
rows
=
parseInt
(
value
);
},
updateColumns
(
value
)
{
if
(
isNaN
(
value
)
||
value
<
this
.
columnsCount
||
value
>
maxKeyboardSize
)
return
;
this
.
columns
=
parseInt
(
value
);
},
},
watch
:
{
rowsCount
:
{
immediate
:
true
,
handler
(
n
)
{
if
(
!
this
.
rows
)
this
.
rows
=
n
||
1
;
},
},
columnsCount
:
{
immediate
:
true
,
handler
(
n
)
{
if
(
!
this
.
columns
)
this
.
columns
=
n
||
1
;
},
},
},
};
};
</
script
>
</
script
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment