switch render logic to canvas
This commit is contained in:
parent
e04c3c364f
commit
3ee9624d54
|
@ -0,0 +1,165 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
31
index.html
31
index.html
|
@ -3,16 +3,39 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Virtual Keyboard Config Editor</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<!-- built files will be auto injected -->
|
||||
<% if (process.env.NODE_ENV === 'development') { %>
|
||||
<script>
|
||||
window.webObject = {
|
||||
getText: function () {
|
||||
return '{"vToggle":{"key":"None","rectangle":{"X":36,"Y":12,"Width":64,"Height":64},"autoHidden":false},"buttons":[{"key":"Q","rectangle":{"X":200,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"I","rectangle":{"X":363,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"P","rectangle":{"X":526,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"B","rectangle":{"X":1180,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null}],"buttonsExtend":[{"key":"F1","rectangle":{"X":190,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"F2","rectangle":{"X":290,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"F3","rectangle":{"X":390,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"H","rectangle":{"X":490,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"O","rectangle":{"X":590,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"K","rectangle":{"X":690,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"U","rectangle":{"X":790,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"M","rectangle":{"X":890,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"V","rectangle":{"X":990,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"RightWindows","rectangle":{"X":1090,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":"CMD","command":null},{"key":"S","rectangle":{"X":1080,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"None","rectangle":{"X":980,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":"Zoom","command":"zoom"}]}';
|
||||
}, getMode: function () {
|
||||
return 'tree';
|
||||
}, getLanguage: function () {
|
||||
return 'zh-CN';
|
||||
}, isEditable: function () {
|
||||
return true;
|
||||
}, getHeight: function () {
|
||||
return 720;
|
||||
}, getWidth: function () {
|
||||
return 1280;
|
||||
}, getScale: function () {
|
||||
return 0.2;
|
||||
}, isLandscape: function () {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<% }
|
||||
%>
|
||||
<script>
|
||||
window.getJsonCallback = null;
|
||||
window.webObject = { getText: function(){ return '{"vToggle":{"key":"None","rectangle":{"X":36,"Y":12,"Width":64,"Height":64},"autoHidden":false},"buttons":[{"key":"Q","rectangle":{"X":200,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"I","rectangle":{"X":363,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"P","rectangle":{"X":526,"Y":80,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"B","rectangle":{"X":1180,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null}],"buttonsExtend":[{"key":"F1","rectangle":{"X":190,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"F2","rectangle":{"X":290,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"F3","rectangle":{"X":390,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"H","rectangle":{"X":490,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"O","rectangle":{"X":590,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"K","rectangle":{"X":690,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"U","rectangle":{"X":790,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"M","rectangle":{"X":890,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"V","rectangle":{"X":990,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"RightWindows","rectangle":{"X":1090,"Y":170,"Width":90,"Height":90},"transparency":0.5,"alias":"CMD","command":null},{"key":"S","rectangle":{"X":1080,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":null,"command":null},{"key":"None","rectangle":{"X":980,"Y":12,"Width":90,"Height":90},"transparency":0.5,"alias":"Zoom","command":"zoom"}]}'; }, getMode: function(){ return 'tree';}, getLanguage: function(){ return 'zh-CN';}, isEditable: function(){ return true;}, getHeight: function(){ return 720;}, getWidth: function(){ return 1280;}, };
|
||||
window.getJson = function()
|
||||
{
|
||||
window.getJson = function () {
|
||||
if (window.getJsonCallback != null) {
|
||||
window.webObject.setText(JSON.stringify(window.getJsonCallback()));
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
"version": "7.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.12.1.tgz",
|
||||
"integrity": "sha512-J5AIf3vPj3UwXaAzb5j1xM4WAQDX3EMgemF8rjCP3SoW09LfRKAXQKt6CoVYl230P6iWdRcBbnLDDdnqWxZSCA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"regenerator-runtime": "^0.13.4"
|
||||
},
|
||||
|
@ -31,7 +32,8 @@
|
|||
"regenerator-runtime": {
|
||||
"version": "0.13.7",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz",
|
||||
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew=="
|
||||
"integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -60,16 +62,6 @@
|
|||
"integrity": "sha512-1HcDas8SEj4z1Wc696tH56G8OlRaH/sqZOynNNB+HF0WOeXPaxTtbYzJY2oEfiUxjSKjhCKr+MvR7dCHcEelug==",
|
||||
"dev": true
|
||||
},
|
||||
"@vant/icons": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@vant/icons/-/icons-1.3.2.tgz",
|
||||
"integrity": "sha512-uP0nUWw0pyMMGt3L9BO5fEacz/Cn7QIea0/gFoC/jPLv9ufvUxjPsV9HSyyUJsqMJ3qlYLAI/SxZDbmMZA814A=="
|
||||
},
|
||||
"@vue/babel-helper-vue-jsx-merge-props": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@vue/babel-helper-vue-jsx-merge-props/-/babel-helper-vue-jsx-merge-props-1.2.1.tgz",
|
||||
"integrity": "sha512-QOi5OW45e2R20VygMSNhyQHvpdUwQZqGPc748JLGCYEy+yp8fNFNdbNIGAgZmi9e+2JHPd6i6idRuqivyicIkA=="
|
||||
},
|
||||
"accepts": {
|
||||
"version": "1.3.7",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
|
||||
|
@ -10966,17 +10958,6 @@
|
|||
"spdx-expression-parse": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"vant": {
|
||||
"version": "2.10.10",
|
||||
"resolved": "https://registry.npmjs.org/vant/-/vant-2.10.10.tgz",
|
||||
"integrity": "sha512-B0fCcY+SEfvkPWKEG7bu2Y5RjsUmH02hJzvJWNBZsvttoSDA1PxD1KMl+On++DKfM9xaHdv7ndoAS5yQgeCysA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "7.x",
|
||||
"@vant/icons": "1.3.2",
|
||||
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
|
||||
"vue-lazyload": "1.2.3"
|
||||
}
|
||||
},
|
||||
"vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
|
@ -11000,16 +10981,6 @@
|
|||
"resolved": "https://registry.npmjs.org/vue/-/vue-2.6.12.tgz",
|
||||
"integrity": "sha512-uhmLFETqPPNyuLLbsKz6ioJ4q7AZHzD8ZVFNATNyICSZouqP2Sz0rotWQC8UNBF6VGSCs5abnKJoStA6JbCbfg=="
|
||||
},
|
||||
"vue-draggable-float": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/vue-draggable-float/-/vue-draggable-float-0.0.4.tgz",
|
||||
"integrity": "sha512-icQk28Qdy29FXjo1eT7F0nD9j8EILdjl0bboFBRAfsEG58qm7YGzA99MO10sHymeGtYnqTTa6Bn1Ye6UZhKKUA=="
|
||||
},
|
||||
"vue-draggable-resizable": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vue-draggable-resizable/-/vue-draggable-resizable-2.2.0.tgz",
|
||||
"integrity": "sha512-KjVyzg0OtLsyVhnwD/6NozJkLMD3li41QB/aJIJUr3VS75Gn32UPOWidLvhwsbkwNQcKajXW9QCV1aTrN6MY8w=="
|
||||
},
|
||||
"vue-hot-reload-api": {
|
||||
"version": "2.3.4",
|
||||
"resolved": "https://registry.npmjs.org/vue-hot-reload-api/-/vue-hot-reload-api-2.3.4.tgz",
|
||||
|
@ -11026,11 +10997,6 @@
|
|||
"resolved": "https://registry.npmjs.org/vue-konva/-/vue-konva-2.1.6.tgz",
|
||||
"integrity": "sha512-N0zuxDKDd3N9Y+7eGHkp9yB0Y68pjHc6tDZycozuohuOkDDsQ0GGqb7DloEp5tVKww9tWi+6wsigumG4jIXiGQ=="
|
||||
},
|
||||
"vue-lazyload": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/vue-lazyload/-/vue-lazyload-1.2.3.tgz",
|
||||
"integrity": "sha512-DC0ZwxanbRhx79tlA3zY5OYJkH8FYp3WBAnAJbrcuoS8eye1P73rcgAZhyxFSPUluJUTelMB+i/+VkNU/qVm7g=="
|
||||
},
|
||||
"vue-loader": {
|
||||
"version": "13.7.3",
|
||||
"resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-13.7.3.tgz",
|
||||
|
|
|
@ -13,10 +13,7 @@
|
|||
"element-ui": "^2.13.2",
|
||||
"konva": "^7.1.4",
|
||||
"uuid": "^8.3.1",
|
||||
"vant": "^2.10.10",
|
||||
"vue": "^2.5.2",
|
||||
"vue-draggable-float": "0.0.4",
|
||||
"vue-draggable-resizable": "^2.2.0",
|
||||
"vue-i18n": "^8.22.1",
|
||||
"vue-konva": "^2.1.6"
|
||||
},
|
||||
|
|
|
@ -1,49 +1,41 @@
|
|||
<template>
|
||||
<div>
|
||||
<div :grid='grid' @click="onParentClick"
|
||||
:style="{height: height+'px', width: width + 'px',
|
||||
border: '1px solid #13a8d5', position: 'relative',
|
||||
transform: 'scale(' + scale +')', 'transform-origin': '0 0',
|
||||
'margin-bottom': '-' + height*(1-scale) + 'px'}">
|
||||
<vue-draggable-resizable :parent="true" className="vdr button button-vtg"
|
||||
@dragging="(x,y)=>onDrag(config.vToggle,x,y)" :resizable="false" :scale="scale"
|
||||
@resizing="(x, y, width, height)=>onResize(config.vToggle,x, y, width, height)"
|
||||
:w="config.vToggle.rectangle.Width"
|
||||
:h="config.vToggle.rectangle.Height"
|
||||
:x="config.vToggle.rectangle.X"
|
||||
:y="config.vToggle.rectangle.Y">
|
||||
<p class="button-text" @click="toggle">{{$t('toggle')}}</p>
|
||||
</vue-draggable-resizable>
|
||||
<vue-draggable-resizable v-for="button in config.buttons" :key="firstNotEmpty(button.id, button.key)"
|
||||
:parent="true" className="vdr button" :resizable="false" :scale="scale"
|
||||
@dragging="(x,y)=>onDrag(button,x,y)"
|
||||
@resizing="(x, y, width, height)=>onResize(button,x, y, width, height)"
|
||||
@activated="()=>onActivated(button)"
|
||||
:w="button.rectangle.Width"
|
||||
:h="button.rectangle.Height"
|
||||
:x="button.rectangle.X"
|
||||
:y="button.rectangle.Y">
|
||||
<p class="button-text">{{firstNotEmpty(button.alias, button.key)}}</p>
|
||||
</vue-draggable-resizable>
|
||||
<vue-draggable-resizable v-for="button in config.buttonsExtend" :key="firstNotEmpty(button.id, button.key)"
|
||||
:parent="true" className="vdr button button-ext" v-if="toggleState" :resizable="false" :scale="scale"
|
||||
@dragging="(x,y)=>onDrag(button,x,y)"
|
||||
@resizing="(x, y, width, height)=>onResize(button,x, y, width, height)"
|
||||
@activated="()=>onActivated(button)"
|
||||
:w="button.rectangle.Width"
|
||||
:h="button.rectangle.Height"
|
||||
:x="button.rectangle.X"
|
||||
:y="button.rectangle.Y">
|
||||
<p class="button-text">{{firstNotEmpty(button.alias, button.key)}}</p>
|
||||
</vue-draggable-resizable>
|
||||
</div>
|
||||
<v-stage :config="{height: height, width: width}" @tap="onParentClick"
|
||||
:style="{transform: 'scale(' + scale +')', 'transform-origin': '0 0', 'margin-bottom': '-' + height*(1-scale) + 'px'}">
|
||||
<v-layer>
|
||||
<v-rect
|
||||
:config="{x:0,y:0,width:width,height:height,stroke: 'cyan',strokeWidth: 1 / this.scale, dash: [5 / this.scale, 5 / this.scale]}"></v-rect>
|
||||
<v-rect
|
||||
:config="{x:4,y:16,width:slotSize+24,height:slotSize*24+24,stroke: 'gold',strokeWidth: 1 / this.scale, dash: [3 / this.scale, 3 / this.scale]}"></v-rect>
|
||||
<v-rect
|
||||
:config="{x:16,y:height - slotSize - 28,width:slotSize*24+24,height:slotSize+24,stroke: 'gold',strokeWidth: 1 / this.scale, dash: [3 / this.scale, 3 / this.scale]}"></v-rect>
|
||||
<v-group @tap="toggle">
|
||||
<v-rect :config="getButtonConfig(config.vToggle, 'lightyellow')"></v-rect>
|
||||
<v-text :config="getTextConfig(config.vToggle, $t('toggle'))"></v-text>
|
||||
</v-group>
|
||||
</v-layer>
|
||||
<v-layer>
|
||||
<v-group v-for="button in config.buttons" :key="firstNotEmpty(button.id, button.key)"
|
||||
v-if="button.id !== currentButtonId" @tap="() => onActivated(button)">
|
||||
<v-rect :config="getButtonConfig(button, 'darkorange')"></v-rect>
|
||||
<v-text :config="getTextConfig(button, firstNotEmpty(button.alias, button.key))"></v-text>
|
||||
</v-group>
|
||||
<v-group v-for="button in config.buttonsExtend" :key="firstNotEmpty(button.id, button.key)"
|
||||
v-if="toggleState && button.id !== currentButtonId" @tap="() => onActivated(button)">
|
||||
<v-rect :config="getButtonConfig(button, 'lightyellow')"></v-rect>
|
||||
<v-text :config="getTextConfig(button, firstNotEmpty(button.alias, button.key))"></v-text>
|
||||
</v-group>
|
||||
</v-layer>
|
||||
<v-layer v-if="!isEmpty(currentButtonId)">
|
||||
<v-rect :config="getButtonConfig(currentButton, 'lightcyan')"></v-rect>
|
||||
<v-text :config="getTextConfig(currentButton, firstNotEmpty(currentButton.alias, currentButton.key))"></v-text>
|
||||
</v-layer>
|
||||
</v-stage>
|
||||
<el-drawer
|
||||
title=""
|
||||
:visible.sync="drawer"
|
||||
:direction="rtl"
|
||||
direction="rtl"
|
||||
size="40%"
|
||||
:wrapperClosable="false"
|
||||
:show-close="true"
|
||||
:with-header="true">
|
||||
<el-form ref="form" label-width="50px">
|
||||
<el-form-item :label="$t('X')">
|
||||
|
@ -76,24 +68,17 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
</el-drawer>
|
||||
<draggable
|
||||
:distanceRight='0'
|
||||
:distanceBottom='100'
|
||||
:isScrollHidden='false'
|
||||
:isCanDraggable='true'
|
||||
:zIndex="100">
|
||||
<el-button type="primary" icon="el-icon-edit" circle @click="drawer=true"></el-button>
|
||||
</draggable>
|
||||
<el-button v-if="landscape && !isEmpty(currentButtonId)"
|
||||
type="primary" icon="el-icon-edit" circle @click="drawer=true"
|
||||
class="button-float"></el-button>
|
||||
<el-form ref="form" label-width="80px">
|
||||
<el-form-item :label="$t('key')">
|
||||
<el-select v-model="currentButton.key" filterable :placeholder="$t('key')">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-autocomplete
|
||||
class="inline-input"
|
||||
v-model="currentButton.key"
|
||||
:fetch-suggestions="querySearch"
|
||||
:placeholder="$t('key')"
|
||||
></el-autocomplete>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('alias')">
|
||||
<el-col :span="10">
|
||||
|
@ -157,18 +142,19 @@
|
|||
|
||||
<script>
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
import Draggable from 'vue-draggable-float'
|
||||
|
||||
export default {
|
||||
components:{Draggable},
|
||||
data: function () {
|
||||
return {
|
||||
grid: [5, 5],
|
||||
scale: 0.4,
|
||||
slotSize: 80,
|
||||
width: 1280,
|
||||
height: 720,
|
||||
toggleState: true,
|
||||
drawer: false,
|
||||
landscape: false,
|
||||
currentButtonId: '',
|
||||
currentButton: {
|
||||
key: '',
|
||||
alias: '',
|
||||
|
@ -183,49 +169,10 @@
|
|||
{label: "MouseMiddle", value: "MouseMiddle"},
|
||||
{label: "MouseX1", value: "MouseX1"},
|
||||
{label: "MouseX2", value: "MouseX2"},
|
||||
{label: "ControllerA", value: "ControllerA"},
|
||||
{label: "ControllerB", value: "ControllerB"},
|
||||
{label: "ControllerX", value: "ControllerX"},
|
||||
{label: "ControllerY", value: "ControllerY"},
|
||||
{label: "ControllerBack", value: "ControllerBack"},
|
||||
{label: "ControllerStart", value: "ControllerStart"},
|
||||
{label: "DPadUp", value: "DPadUp"},
|
||||
{label: "DPadDown", value: "DPadDown"},
|
||||
{label: "DPadLeft", value: "DPadLeft"},
|
||||
{label: "DPadRight", value: "DPadRight"},
|
||||
{label: "LeftShoulder", value: "LeftShoulder"},
|
||||
{label: "RightShoulder", value: "RightShoulder"},
|
||||
{label: "LeftTrigger", value: "LeftTrigger"},
|
||||
{label: "RightTrigger", value: "RightTrigger"},
|
||||
{label: "LeftStick", value: "LeftStick"},
|
||||
{label: "RightStick", value: "RightStick"},
|
||||
{label: "BigButton", value: "BigButton"},
|
||||
{label: "LeftThumbstickLeft", value: "LeftThumbstickLeft"},
|
||||
{label: "LeftThumbstickRight", value: "LeftThumbstickRight"},
|
||||
{label: "LeftThumbstickDown", value: "LeftThumbstickDown"},
|
||||
{label: "LeftThumbstickUp", value: "LeftThumbstickUp"},
|
||||
{label: "RightThumbstickLeft", value: "RightThumbstickLeft"},
|
||||
{label: "RightThumbstickRight", value: "RightThumbstickRight"},
|
||||
{label: "RightThumbstickDown", value: "RightThumbstickDown"},
|
||||
{label: "RightThumbstickUp", value: "RightThumbstickUp"},
|
||||
{label: "A", value: "A"},
|
||||
{label: "Add", value: "Add"},
|
||||
{label: "Apps", value: "Apps"},
|
||||
{label: "Attn", value: "Attn"},
|
||||
{label: "B", value: "B"},
|
||||
{label: "Back", value: "Back"},
|
||||
{label: "BrowserBack", value: "BrowserBack"},
|
||||
{label: "BrowserFavorites", value: "BrowserFavorites"},
|
||||
{label: "BrowserForward", value: "BrowserForward"},
|
||||
{label: "BrowserHome", value: "BrowserHome"},
|
||||
{label: "BrowserRefresh", value: "BrowserRefresh"},
|
||||
{label: "BrowserSearch", value: "BrowserSearch"},
|
||||
{label: "BrowserStop", value: "BrowserStop"},
|
||||
{label: "C", value: "C"},
|
||||
{label: "CapsLock", value: "CapsLock"},
|
||||
{label: "ChatPadGreen", value: "ChatPadGreen"},
|
||||
{label: "ChatPadOrange", value: "ChatPadOrange"},
|
||||
{label: "Crsel", value: "Crsel"},
|
||||
{label: "D", value: "D"},
|
||||
{label: "D0", value: "D0"},
|
||||
{label: "D1", value: "D1"},
|
||||
|
@ -244,28 +191,13 @@
|
|||
{label: "E", value: "E"},
|
||||
{label: "End", value: "End"},
|
||||
{label: "Enter", value: "Enter"},
|
||||
{label: "EraseEof", value: "EraseEof"},
|
||||
{label: "Escape", value: "Escape"},
|
||||
{label: "Execute", value: "Execute"},
|
||||
{label: "Exsel", value: "Exsel"},
|
||||
{label: "F", value: "F"},
|
||||
{label: "F1", value: "F1"},
|
||||
{label: "F10", value: "F10"},
|
||||
{label: "F11", value: "F11"},
|
||||
{label: "F12", value: "F12"},
|
||||
{label: "F13", value: "F13"},
|
||||
{label: "F14", value: "F14"},
|
||||
{label: "F15", value: "F15"},
|
||||
{label: "F16", value: "F16"},
|
||||
{label: "F17", value: "F17"},
|
||||
{label: "F18", value: "F18"},
|
||||
{label: "F19", value: "F19"},
|
||||
{label: "F2", value: "F2"},
|
||||
{label: "F20", value: "F20"},
|
||||
{label: "F21", value: "F21"},
|
||||
{label: "F22", value: "F22"},
|
||||
{label: "F23", value: "F23"},
|
||||
{label: "F24", value: "F24"},
|
||||
{label: "F3", value: "F3"},
|
||||
{label: "F4", value: "F4"},
|
||||
{label: "F5", value: "F5"},
|
||||
|
@ -278,27 +210,16 @@
|
|||
{label: "Help", value: "Help"},
|
||||
{label: "Home", value: "Home"},
|
||||
{label: "I", value: "I"},
|
||||
{label: "ImeConvert", value: "ImeConvert"},
|
||||
{label: "ImeNoConvert", value: "ImeNoConvert"},
|
||||
{label: "Insert", value: "Insert"},
|
||||
{label: "J", value: "J"},
|
||||
{label: "K", value: "K"},
|
||||
{label: "Kana", value: "Kana"},
|
||||
{label: "Kanji", value: "Kanji"},
|
||||
{label: "L", value: "L"},
|
||||
{label: "LaunchApplication1", value: "LaunchApplication1"},
|
||||
{label: "LaunchApplication2", value: "LaunchApplication2"},
|
||||
{label: "LaunchMail", value: "LaunchMail"},
|
||||
{label: "Left", value: "Left"},
|
||||
{label: "LeftAlt", value: "LeftAlt"},
|
||||
{label: "LeftControl", value: "LeftControl"},
|
||||
{label: "LeftShift", value: "LeftShift"},
|
||||
{label: "LeftWindows", value: "LeftWindows"},
|
||||
{label: "M", value: "M"},
|
||||
{label: "MediaNextTrack", value: "MediaNextTrack"},
|
||||
{label: "MediaPlayPause", value: "MediaPlayPause"},
|
||||
{label: "MediaPreviousTrack", value: "MediaPreviousTrack"},
|
||||
{label: "MediaStop", value: "MediaStop"},
|
||||
{label: "Multiply", value: "Multiply"},
|
||||
{label: "N", value: "N"},
|
||||
{label: "NumLock", value: "NumLock"},
|
||||
|
@ -313,14 +234,11 @@
|
|||
{label: "NumPad8", value: "NumPad8"},
|
||||
{label: "NumPad9", value: "NumPad9"},
|
||||
{label: "O", value: "O"},
|
||||
{label: "Oem8", value: "Oem8"},
|
||||
{label: "OemAuto", value: "OemAuto"},
|
||||
{label: "OemBackslash", value: "OemBackslash"},
|
||||
{label: "OemClear", value: "OemClear"},
|
||||
{label: "OemCloseBrackets", value: "OemCloseBrackets"},
|
||||
{label: "OemComma", value: "OemComma"},
|
||||
{label: "OemCopy", value: "OemCopy"},
|
||||
{label: "OemEnlW", value: "OemEnlW"},
|
||||
{label: "OemMinus", value: "OemMinus"},
|
||||
{label: "OemOpenBrackets", value: "OemOpenBrackets"},
|
||||
{label: "OemPeriod", value: "OemPeriod"},
|
||||
|
@ -331,14 +249,12 @@
|
|||
{label: "OemSemicolon", value: "OemSemicolon"},
|
||||
{label: "OemTilde", value: "OemTilde"},
|
||||
{label: "P", value: "P"},
|
||||
{label: "Pa1", value: "Pa1"},
|
||||
{label: "PageDown", value: "PageDown"},
|
||||
{label: "PageUp", value: "PageUp"},
|
||||
{label: "Pause", value: "Pause"},
|
||||
{label: "Play", value: "Play"},
|
||||
{label: "Print", value: "Print"},
|
||||
{label: "PrintScreen", value: "PrintScreen"},
|
||||
{label: "ProcessKey", value: "ProcessKey"},
|
||||
{label: "Q", value: "Q"},
|
||||
{label: "R", value: "R"},
|
||||
{label: "Right", value: "Right"},
|
||||
|
@ -349,7 +265,6 @@
|
|||
{label: "S", value: "S"},
|
||||
{label: "Scroll", value: "Scroll"},
|
||||
{label: "Select", value: "Select"},
|
||||
{label: "SelectMedia", value: "SelectMedia"},
|
||||
{label: "Separator", value: "Separator"},
|
||||
{label: "Sleep", value: "Sleep"},
|
||||
{label: "Space", value: "Space"},
|
||||
|
@ -365,8 +280,7 @@
|
|||
{label: "W", value: "W"},
|
||||
{label: "X", value: "X"},
|
||||
{label: "Y", value: "Y"},
|
||||
{label: "Z", value: "Z"},
|
||||
{label: "Zoom", value: "Zoom"},
|
||||
{label: "Z", value: "Z"}
|
||||
],
|
||||
config: {}
|
||||
}
|
||||
|
@ -380,6 +294,8 @@
|
|||
this.$i18n.locale = window.webObject.getLanguage();
|
||||
this.width = window.webObject.getWidth();
|
||||
this.height = window.webObject.getHeight();
|
||||
this.scale = window.webObject.getScale();
|
||||
this.landscape = window.webObject.isLandscape();
|
||||
window.setJson = (json) => {
|
||||
let config = JSON.parse(json);
|
||||
for (let button of config.buttons) {
|
||||
|
@ -392,36 +308,89 @@
|
|||
};
|
||||
window.setJson(window.webObject.getText());
|
||||
window.getJsonCallback = () => {
|
||||
return this.config;
|
||||
let conf = JSON.parse(JSON.stringify(this.config));
|
||||
for (let button of conf.buttons) {
|
||||
delete button.id;
|
||||
}
|
||||
for (let button of conf.buttonsExtend) {
|
||||
delete button.id;
|
||||
}
|
||||
return conf;
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
toggle: function () {
|
||||
getTextConfig: function (button, text) {
|
||||
if(button === undefined) {
|
||||
return {};
|
||||
}
|
||||
debugger
|
||||
return {
|
||||
x: button.rectangle.X,
|
||||
y: button.rectangle.Y,
|
||||
width: button.rectangle.Width,
|
||||
height: button.rectangle.Height,
|
||||
text: text,
|
||||
align: 'center',
|
||||
verticalAlign: 'middle',
|
||||
fontSize: Math.sqrt(144 / this.scale),
|
||||
perfectDrawEnabled: false,
|
||||
transformsEnabled: 'position',
|
||||
};
|
||||
},
|
||||
getButtonConfig: function (button, color) {
|
||||
if(button === undefined) {
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
x: button.rectangle.X,
|
||||
y: button.rectangle.Y,
|
||||
width: button.rectangle.Width,
|
||||
height: button.rectangle.Height,
|
||||
opacity: button.transparency,
|
||||
fill: color,
|
||||
stroke: 'black',
|
||||
strokeWidth: 2 / this.scale,
|
||||
perfectDrawEnabled: false,
|
||||
transformsEnabled: 'position',
|
||||
shadowForStrokeEnabled: false,
|
||||
hitStrokeWidth: 0,
|
||||
};
|
||||
},
|
||||
querySearch: function(queryString, cb) {
|
||||
let results = queryString ? this.options.filter((option)=> option.value.toLowerCase().includes(queryString.toLowerCase())) : this.options;
|
||||
// 调用 callback 返回建议列表的数据
|
||||
results.sort((a,b)=>a.value.length-b.value.length);
|
||||
cb(results);
|
||||
},
|
||||
toggle: function (event) {
|
||||
this.toggleState = !this.toggleState;
|
||||
},
|
||||
onResize: function (button, x, y, width, height) {
|
||||
button.rectangle.X = x
|
||||
button.rectangle.Y = y
|
||||
button.rectangle.Width = width
|
||||
button.rectangle.Height = height
|
||||
},
|
||||
onDrag: function (button, x, y) {
|
||||
button.rectangle.X = x
|
||||
button.rectangle.Y = y
|
||||
event.cancelBubble = true;
|
||||
},
|
||||
onActivated: function (button) {
|
||||
this.currentButton = button;
|
||||
this.currentButtonId = button.id;
|
||||
},
|
||||
getNodeParentFor(node, parentName, attrName){
|
||||
if(node[attrName] !== undefined) {
|
||||
return node;
|
||||
}
|
||||
else if(node[parentName] !== undefined && node[parentName] != null) {
|
||||
return this.getNodeParentFor(node[parentName], parentName, attrName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
onParentClick: function (event) {
|
||||
let dx = event.clientX / this.scale - (this.currentButton.rectangle.X + this.currentButton.rectangle.Width / 2);
|
||||
let dy = event.clientY / this.scale - (this.currentButton.rectangle.Y + this.currentButton.rectangle.Height / 2);
|
||||
let parent = this.getNodeParentFor(event.target, 'parent', 'getPointerPosition');
|
||||
if(parent == null)
|
||||
return;
|
||||
let dx = parent.getPointerPosition().x - (this.currentButton.rectangle.X + this.currentButton.rectangle.Width / 2);
|
||||
let dy = parent.getPointerPosition().y - (this.currentButton.rectangle.Y + this.currentButton.rectangle.Height / 2);
|
||||
let adx = Math.abs(dx);
|
||||
let ady = Math.abs(dy);
|
||||
if (adx > ady) {
|
||||
if (adx < this.currentButton.rectangle.Width / 2) {
|
||||
return;
|
||||
}
|
||||
debugger
|
||||
if (dx > 0) {
|
||||
this.currentButton.rectangle.X += this.grid[0];
|
||||
} else {
|
||||
|
@ -431,7 +400,6 @@
|
|||
if (ady < this.currentButton.rectangle.Height / 2) {
|
||||
return;
|
||||
}
|
||||
debugger
|
||||
if (dy > 0) {
|
||||
this.currentButton.rectangle.Y += this.grid[1];
|
||||
} else {
|
||||
|
@ -493,29 +461,10 @@
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
.button-text {
|
||||
font-size: medium
|
||||
}
|
||||
.vdr {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
background-color: darkorange;
|
||||
}
|
||||
|
||||
.button.active {
|
||||
border-color: deepskyblue;
|
||||
border-width: thick;
|
||||
}
|
||||
|
||||
.button-vtg {
|
||||
background-color: lightyellow;
|
||||
}
|
||||
|
||||
.button-ext {
|
||||
background-color: lightgoldenrodyellow;
|
||||
.button-float {
|
||||
position: fixed;
|
||||
z-index: 99;
|
||||
right: 1%;
|
||||
top: 5%;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -10,9 +10,13 @@ const messages = {
|
|||
alias: "Alias",
|
||||
command: "Command",
|
||||
transparency: "Transparency",
|
||||
X: "X",
|
||||
Y: "Y",
|
||||
Width: "Width",
|
||||
Height: "Height",
|
||||
...enLocale
|
||||
},
|
||||
zh: {
|
||||
"zh-CN": {
|
||||
toggle: "切换",
|
||||
add: "新增",
|
||||
remove: "移除",
|
||||
|
@ -20,6 +24,10 @@ const messages = {
|
|||
alias: "别名",
|
||||
command: "命令",
|
||||
transparency: "透明度",
|
||||
X: "X",
|
||||
Y: "Y",
|
||||
Width: "宽",
|
||||
Height: "高",
|
||||
...zhLocale
|
||||
}
|
||||
}
|
||||
|
|
26
src/main.js
26
src/main.js
|
@ -4,27 +4,33 @@ import Vue from 'vue'
|
|||
import App from './App'
|
||||
import VueI18n from 'vue-i18n'
|
||||
import messages from "./i18n/messages";
|
||||
import VueDraggableResizable from 'vue-draggable-resizable'
|
||||
import { Row, Col, Button, Select, Option, Input, InputNumber, Slider, ColorPicker, Form, FormItem, Drawer } from 'element-ui';
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
Button,
|
||||
Autocomplete,
|
||||
Option,
|
||||
Input,
|
||||
Slider,
|
||||
ColorPicker,
|
||||
Form,
|
||||
FormItem,
|
||||
Drawer
|
||||
} from 'element-ui';
|
||||
import ElementLocale from 'element-ui/lib/locale'
|
||||
import VueKonva from 'vue-konva'
|
||||
|
||||
// optionally import default styles
|
||||
import 'vue-draggable-resizable/dist/VueDraggableResizable.css'
|
||||
|
||||
// register component to use
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(VueI18n)
|
||||
|
||||
Vue.use(VueKonva)
|
||||
Vue.component('vue-draggable-resizable', VueDraggableResizable)
|
||||
Vue.component(Row.name, Row,);
|
||||
Vue.component(Col.name, Col);
|
||||
Vue.component(Button.name, Button);
|
||||
Vue.component(Select.name, Select);
|
||||
Vue.component(Autocomplete.name, Autocomplete);
|
||||
Vue.component(Option.name, Option);
|
||||
Vue.component(Input.name, Input);
|
||||
Vue.component(InputNumber.name, InputNumber);
|
||||
Vue.component(Slider.name, Slider);
|
||||
Vue.component(ColorPicker.name, ColorPicker);
|
||||
Vue.component(Form.name, Form);
|
||||
|
@ -37,11 +43,13 @@ const i18n = new VueI18n({
|
|||
messages, // set locale messages
|
||||
})
|
||||
window.onresize = setHtmlFontSize;
|
||||
|
||||
function setHtmlFontSize() {
|
||||
const htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
||||
const htmlDom = document.getElementsByTagName('html')[0];
|
||||
htmlDom.style.fontSize = htmlWidth / 10 + 'px';
|
||||
};
|
||||
}
|
||||
|
||||
setHtmlFontSize();
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
|
|
Loading…
Reference in New Issue