feat(GUI): 指针悬浮时,使用 tooltip 显示灯珠数。
This commit is contained in:
parent
58e8c30fe2
commit
958a422672
@ -12,7 +12,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tauri-apps/api": "^1.2.0",
|
"@tauri-apps/api": "^1.2.0",
|
||||||
"solid-js": "^1.4.7"
|
"solid-js": "^1.4.7",
|
||||||
|
"solid-tippy": "^0.2.1",
|
||||||
|
"tippy.js": "^6.3.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^1.2.2",
|
"@tauri-apps/cli": "^1.2.2",
|
||||||
|
@ -7,7 +7,9 @@ specifiers:
|
|||||||
autoprefixer: ^10.4.14
|
autoprefixer: ^10.4.14
|
||||||
postcss: ^8.4.21
|
postcss: ^8.4.21
|
||||||
solid-js: ^1.4.7
|
solid-js: ^1.4.7
|
||||||
|
solid-tippy: ^0.2.1
|
||||||
tailwindcss: ^3.2.7
|
tailwindcss: ^3.2.7
|
||||||
|
tippy.js: ^6.3.7
|
||||||
typescript: ^4.7.4
|
typescript: ^4.7.4
|
||||||
vite: ^4.0.0
|
vite: ^4.0.0
|
||||||
vite-plugin-solid: ^2.3.0
|
vite-plugin-solid: ^2.3.0
|
||||||
@ -15,6 +17,8 @@ specifiers:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 1.2.0
|
'@tauri-apps/api': 1.2.0
|
||||||
solid-js: 1.6.14
|
solid-js: 1.6.14
|
||||||
|
solid-tippy: 0.2.1_rick4tq22pxy45qudhdfrizose
|
||||||
|
tippy.js: 6.3.7
|
||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@tauri-apps/cli': 1.2.3
|
'@tauri-apps/cli': 1.2.3
|
||||||
@ -603,6 +607,10 @@ packages:
|
|||||||
fastq: 1.15.0
|
fastq: 1.15.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/@popperjs/core/2.11.7:
|
||||||
|
resolution: {integrity: sha512-Cr4OjIkipTtcXKjAsm8agyleBuDHvxzeBoa1v543lbv1YaIwQjESsVcmjiWiPEbC1FIeHOG/Op9kdCmAmiS3Kw==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/@tauri-apps/api/1.2.0:
|
/@tauri-apps/api/1.2.0:
|
||||||
resolution: {integrity: sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==}
|
resolution: {integrity: sha512-lsI54KI6HGf7VImuf/T9pnoejfgkNoXveP14pVV7XarrQ46rOejIVJLFqHI9sRReJMGdh2YuCoI3cc/yCWCsrw==}
|
||||||
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
|
engines: {node: '>= 14.6.0', npm: '>= 6.6.0', yarn: '>= 1.19.1'}
|
||||||
@ -1329,6 +1337,17 @@ packages:
|
|||||||
solid-js: 1.6.14
|
solid-js: 1.6.14
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/solid-tippy/0.2.1_rick4tq22pxy45qudhdfrizose:
|
||||||
|
resolution: {integrity: sha512-8qB6X1iMn7nBd5BX+x7tS+5mDVragw5vCaXLOxEQFWUsyRRGKAY8JmbmmyVFIMIvF+pgkIIVIArhNfAGGtYVLA==}
|
||||||
|
engines: {node: '>=10'}
|
||||||
|
peerDependencies:
|
||||||
|
solid-js: ^1.2
|
||||||
|
tippy.js: ^6.3
|
||||||
|
dependencies:
|
||||||
|
solid-js: 1.6.14
|
||||||
|
tippy.js: 6.3.7
|
||||||
|
dev: false
|
||||||
|
|
||||||
/source-map-js/1.0.2:
|
/source-map-js/1.0.2:
|
||||||
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@ -1380,6 +1399,12 @@ packages:
|
|||||||
- ts-node
|
- ts-node
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/tippy.js/6.3.7:
|
||||||
|
resolution: {integrity: sha512-E1d3oP2emgJ9dRQZdf3Kkn0qJgI6ZLpyS5z6ZkY1DF3kaQaBsGZsndEpHwx+eC+tYM41HaSNvNtLx8tU57FzTQ==}
|
||||||
|
dependencies:
|
||||||
|
'@popperjs/core': 2.11.7
|
||||||
|
dev: false
|
||||||
|
|
||||||
/to-fast-properties/2.0.0:
|
/to-fast-properties/2.0.0:
|
||||||
resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
|
resolution: {integrity: sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==}
|
||||||
engines: {node: '>=4'}
|
engines: {node: '>=4'}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Component, createMemo } from 'solid-js';
|
import { Component, createMemo, ParentComponent } from 'solid-js';
|
||||||
import { LedStripConfigOfBorders } from '../models/display-config';
|
import { LedStripConfigOfBorders } from '../models/display-config';
|
||||||
import { DisplayInfo } from '../models/display-info.model';
|
import { DisplayInfo } from '../models/display-info.model';
|
||||||
import { displayStore } from '../stores/display.store';
|
import { displayStore } from '../stores/display.store';
|
||||||
@ -30,20 +30,21 @@ export const DisplayView: Component<DisplayViewProps> = (props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
class="absolute grid grid-cols-[16px,auto,16px] grid-rows-[16px,auto,16px] overflow-hidden group"
|
class="absolute grid grid-cols-[16px,auto,16px] grid-rows-[16px,auto,16px] overflow-hidden"
|
||||||
style={style()}
|
style={style()}
|
||||||
>
|
>
|
||||||
<ScreenView
|
<ScreenView
|
||||||
class="row-start-2 col-start-2"
|
class="row-start-2 col-start-2 group"
|
||||||
displayId={props.display.id}
|
displayId={props.display.id}
|
||||||
style={{
|
style={{
|
||||||
'object-fit': 'contain',
|
'object-fit': 'contain',
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
<DisplayInfoPanel
|
<DisplayInfoPanel
|
||||||
display={props.display}
|
display={props.display}
|
||||||
class="absolute bg-slate-700/20 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded backdrop-blur w-1/3 min-w-[300px] text-black group-hover:opacity-100 opacity-0 transition-opacity"
|
class="absolute bg-slate-700/20 top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 rounded backdrop-blur w-1/3 min-w-[300px] text-black group-hover:opacity-100 opacity-0 transition-opacity"
|
||||||
/>
|
/>
|
||||||
|
</ScreenView>
|
||||||
<LedStripPart
|
<LedStripPart
|
||||||
class="row-start-1 col-start-2 flex-row overflow-hidden"
|
class="row-start-1 col-start-2 flex-row overflow-hidden"
|
||||||
config={ledStripConfigs().find((c) => c.border === 'Top')}
|
config={ledStripConfigs().find((c) => c.border === 'Top')}
|
||||||
|
@ -4,12 +4,15 @@ import {
|
|||||||
Component,
|
Component,
|
||||||
createEffect,
|
createEffect,
|
||||||
createMemo,
|
createMemo,
|
||||||
|
createRoot,
|
||||||
createSignal,
|
createSignal,
|
||||||
For,
|
For,
|
||||||
JSX,
|
JSX,
|
||||||
onCleanup,
|
onCleanup,
|
||||||
splitProps,
|
splitProps,
|
||||||
} from 'solid-js';
|
} from 'solid-js';
|
||||||
|
import { useTippy } from 'solid-tippy';
|
||||||
|
import { followCursor } from 'tippy.js';
|
||||||
import { LedStripConfig } from '../models/led-strip-config';
|
import { LedStripConfig } from '../models/led-strip-config';
|
||||||
|
|
||||||
type LedStripPartProps = {
|
type LedStripPartProps = {
|
||||||
@ -49,6 +52,7 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
const [ledSamplePoints, setLedSamplePoints] = createSignal();
|
const [ledSamplePoints, setLedSamplePoints] = createSignal();
|
||||||
const [colors, setColors] = createSignal<string[]>([]);
|
const [colors, setColors] = createSignal<string[]>([]);
|
||||||
|
|
||||||
|
// get led strip colors when screenshot updated
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
const samplePoints = ledSamplePoints();
|
const samplePoints = ledSamplePoints();
|
||||||
if (!localProps.config || !samplePoints) {
|
if (!localProps.config || !samplePoints) {
|
||||||
@ -88,17 +92,38 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// get led strip sample points
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (localProps.config) {
|
if (localProps.config) {
|
||||||
invoke('get_led_strips_sample_points', {
|
invoke('get_led_strips_sample_points', {
|
||||||
config: localProps.config,
|
config: localProps.config,
|
||||||
}).then((points) => {
|
}).then((points) => {
|
||||||
console.log({ points });
|
|
||||||
setLedSamplePoints(points);
|
setLedSamplePoints(points);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [anchor, setAnchor] = createSignal<HTMLElement>();
|
||||||
|
|
||||||
|
useTippy(anchor, {
|
||||||
|
hidden: true,
|
||||||
|
props: {
|
||||||
|
trigger: 'mouseenter focus',
|
||||||
|
followCursor: true,
|
||||||
|
|
||||||
|
plugins: [followCursor],
|
||||||
|
|
||||||
|
content: () =>
|
||||||
|
createRoot(() => {
|
||||||
|
return (
|
||||||
|
<span class="rounded-lg bg-slate-400/50 backdrop-blur text-white p-2 drop-shadow">
|
||||||
|
Count: {localProps.config?.len ?? '--'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}) as Element,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const onWheel = (e: WheelEvent) => {
|
const onWheel = (e: WheelEvent) => {
|
||||||
if (localProps.config) {
|
if (localProps.config) {
|
||||||
invoke('patch_led_strip_len', {
|
invoke('patch_led_strip_len', {
|
||||||
@ -129,6 +154,7 @@ export const LedStripPart: Component<LedStripPartProps> = (props) => {
|
|||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
{...rootProps}
|
{...rootProps}
|
||||||
|
ref={setAnchor}
|
||||||
class={
|
class={
|
||||||
'flex flex-nowrap justify-around items-center overflow-hidden ' + rootProps.class
|
'flex flex-nowrap justify-around items-center overflow-hidden ' + rootProps.class
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,7 @@ export const ScreenView: Component<ScreenViewProps> = (props) => {
|
|||||||
class={'overflow-hidden h-full w-full ' + rootProps.class}
|
class={'overflow-hidden h-full w-full ' + rootProps.class}
|
||||||
>
|
>
|
||||||
<canvas ref={canvas!} />
|
<canvas ref={canvas!} />
|
||||||
|
{rootProps.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user