Skip to content

Commit

Permalink
POC of basic UI for Keymap configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-github committed Dec 30, 2022
1 parent afc13aa commit 35f1377
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 16 deletions.
41 changes: 27 additions & 14 deletions src/components/Controls/Fields/ItemsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const ItemControl = ({
setValue,
validationfn,
fixed,
nodelete,
editable,
sorted,
}) => {
const iconsList = { ...iconsTarget, ...iconsFeather }
Expand All @@ -65,7 +67,10 @@ const ItemControl = ({
const icon = value ? value[indexIcon != -1 ? indexIcon : 0].value : null
const name = value ? value[indexName != -1 ? indexName : 0].value : null
const controlIcon = iconsList[icon] ? iconsList[icon] : ""

if (idList == "keymap") {
console.log(itemData)
console.log(completeList)
}
const onEdit = (state) => {
completeList[index].editionMode = state
setValue([...completeList])
Expand Down Expand Up @@ -139,13 +144,13 @@ const ItemControl = ({
)}

<div class="item-list-name">
{!fixed && (
{(!fixed || editable) && (
<ButtonImg
m2
tooltip
data-tooltip={T("S94")}
style={colorStyle}
label={name}
label={`${T(name)}: ${value[1].value}`}
icon={controlIcon}
width="100px"
onClick={(e) => {
Expand All @@ -155,10 +160,12 @@ const ItemControl = ({
}}
/>
)}
{fixed && <label class="m-1">{T(name)}</label>}
{fixed && !editable && (
<label class="m-1">{T(name)}</label>
)}
</div>

{!fixed && (
{!(fixed || nodelete) && (
<ButtonImg
m2
tooltip
Expand Down Expand Up @@ -206,13 +213,15 @@ const ItemControl = ({
/>
)}

<ButtonImg
m2
tooltip
data-tooltip={T("S37")}
icon={<Trash2 />}
onClick={removeItem}
/>
{!nodelete && (
<ButtonImg
m2
tooltip
data-tooltip={T("S37")}
icon={<Trash2 />}
onClick={removeItem}
/>
)}
</div>
</div>
<div class="m-1">
Expand Down Expand Up @@ -280,6 +289,8 @@ const ItemsList = ({
fixed,
sorted,
depend,
nodelete,
editable,
...rest
}) => {
const { interfaceSettings, connectionSettings } = useSettingsContext()
Expand All @@ -288,7 +299,7 @@ const ItemsList = ({
interfaceSettings.current.settings
)
const canshow = connectionDepend(depend, connectionSettings.current)

console.log(id)
const addItem = (e) => {
useUiContextFn.haptic()
e.target.blur()
Expand Down Expand Up @@ -357,7 +368,7 @@ const ItemsList = ({
onClick={addItem}
/>
)}
{fixed && <label class="m-1">{T(label)}</label>}
{fixed && <label class="m-2">{T(label)}</label>}
</legend>

<div class="items-group-content">
Expand All @@ -373,6 +384,8 @@ const ItemsList = ({
setValue={setValue}
fixed={fixed}
sorted={sorted}
nodelete={nodelete}
editable={editable}
/>
)
})}
Expand Down
9 changes: 7 additions & 2 deletions src/tabs/interface/importHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ function formatItem(itemData, index = -1, origineId = "extrapanels") {
newItem.help = "S97"
break
case "name":
newItem.type = "text"
newItem.label = "S129"
if (origineId == "keymap") {
newItem.type = "label"
newItem.label = itemData[key]
} else {
newItem.type = "text"
newItem.label = "S129"
}
break
case "icon":
newItem.type = "icon"
Expand Down
21 changes: 21 additions & 0 deletions src/targets/preferences.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@
"type": "boolean",
"label": "S93",
"value": true
},
{
"id": "keymap",
"sorted": false,
"fixed": true,
"nodelete": true,
"editable": true,
"label": "S212",
"type": "list",
"value": [
{
"id": "btn+X",
"name": "btn+X",
"key": "ArrowUp"
},
{
"id": "btn-X",
"name": "btn-X",
"key": "ArrowDown"
}
]
}
],
"notification": [
Expand Down
4 changes: 4 additions & 0 deletions src/targets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@
"S209": "Invert X",
"S210": "Invert Y",
"S211": "Swap X and Y",
"S212": "Key mapping",
"btn+X": "Button X+",
"btn-X": "Button X-",
"key": "Key",
"panels": "Panels",
"processing": "Processing",
"no stream": "No stream",
Expand Down

0 comments on commit 35f1377

Please sign in to comment.