适配新的窗口坐标代码

This commit is contained in:
fangxiang 2021-12-15 16:42:19 +08:00
parent 3344512a77
commit c13dfc7acb
3 changed files with 85 additions and 18 deletions

View File

@ -49,6 +49,14 @@ export default class RemoteDataExangeProcesser {
"setWallRow", "setWallRow",
global_data.applicationConfig.wall_row global_data.applicationConfig.wall_row
); );
$store.commit(
"setDeviceScreenWidth",
global_data.applicationConfig.screen_width
);
$store.commit(
"setDeviceScreenHeight",
global_data.applicationConfig.screen_height
);
} }
} }
} }

View File

@ -187,6 +187,14 @@ export namespace Protocol {
return Commands.PROTOCOL_PREFIX + "RpcSetSubtitle"; return Commands.PROTOCOL_PREFIX + "RpcSetSubtitle";
} }
public static get kRpcGetScreenSize() {
return Commands.PROTOCOL_PREFIX + "RpcGetScreenSize";
}
public static get kScreenSizeChanged() {
return Commands.PROTOCOL_PREFIX + "ScreenSizeChanged";
}
static _all_commands = new Set([ static _all_commands = new Set([
Commands.kUnKnowCommand, Commands.kUnKnowCommand,
Commands.kSearchDevice, Commands.kSearchDevice,
@ -228,6 +236,8 @@ export namespace Protocol {
Commands.kSetApplicationConfig, Commands.kSetApplicationConfig,
Commands.kRpcGetSubtitle, Commands.kRpcGetSubtitle,
Commands.kRpcSetSubtitle, Commands.kRpcSetSubtitle,
Commands.kRpcGetScreenSize,
Commands.kScreenSizeChanged,
]); ]);
public static get AllCommands() { public static get AllCommands() {
@ -1076,4 +1086,32 @@ export namespace Protocol {
this.command = Protocol.Commands.kRpcSetSubtitle; this.command = Protocol.Commands.kRpcSetSubtitle;
} }
} }
export class GetScreenSizeRequestEntity extends Protocol.PacketEntity {
timestamp = new Date().getMilliseconds();
constructor(rcp_id?: number) {
super();
this.rpc_id = rcp_id ?? 0;
this.command = Protocol.Commands.kRpcGetScreenSize;
}
}
export class GetScreenSizeResponseEntity extends Protocol.PacketEntity {
width: number = 0;
height: number = 0;
constructor() {
super();
this.command = Protocol.Commands.kRpcGetScreenSize;
}
}
export class ScreenSizeChangedNotifyEntity extends PacketEntity {
width: number = 0;
height: number = 0;
constructor() {
super();
this.command = Commands.kScreenSizeChanged;
}
}
} }

View File

@ -6,7 +6,7 @@
@dragleave="onDragLeave" @dragleave="onDragLeave"
@dragover="onDragOver" @dragover="onDragOver"
@drop="onDrop" @drop="onDrop"
style="background-color:#bce0f0;" style="background-color: #bce0f0"
> >
<div id="windows" style="position: absolute"> <div id="windows" style="position: absolute">
<window <window
@ -26,10 +26,20 @@
:signal_source_table_uuid="item.signal_source_table_uuid" :signal_source_table_uuid="item.signal_source_table_uuid"
:window="item" :window="item"
:style="{ :style="{
top: item.y / wall_height_scaler + 'px', top:
left: item.x / wall_width_scaler + 'px', (item.y * $store.state.device_screen_height) / wall_height_scaler +
width: item.width / wall_width_scaler + 'px', 'px',
height: item.height / wall_height_scaler + 'px', left:
(item.x * $store.state.device_screen_width) / wall_width_scaler +
'px',
width:
(item.width * $store.state.device_screen_width) /
wall_width_scaler +
'px',
height:
(item.height * $store.state.device_screen_height) /
wall_height_scaler +
'px',
}" }"
/> />
</div> </div>
@ -302,9 +312,6 @@ export default defineComponent({
item_height, item_height,
wall_width_scaler, wall_width_scaler,
wall_height_scaler, wall_height_scaler,
loga(a: any) {
console.log(a);
},
onDrop(e: DragEvent) { onDrop(e: DragEvent) {
e.preventDefault(); e.preventDefault();
let target = e.target as any; let target = e.target as any;
@ -329,10 +336,14 @@ export default defineComponent({
?.openWindow( ?.openWindow(
new Protocol.OpenWindowRequestEntity( new Protocol.OpenWindowRequestEntity(
signal_source.uuid, signal_source.uuid,
dom.offsetLeft * wall_width_scaler.value, (dom.offsetLeft * wall_width_scaler.value) /
dom.offsetTop * wall_height_scaler.value, $store.state.device_screen_width,
dom.offsetWidth * wall_width_scaler.value, (dom.offsetTop * wall_height_scaler.value) /
dom.offsetHeight * wall_height_scaler.value $store.state.device_screen_height,
(dom.offsetWidth * wall_width_scaler.value) /
$store.state.device_screen_width,
(dom.offsetHeight * wall_height_scaler.value) /
$store.state.device_screen_height
) )
); );
} else if (dom.classList.contains("window_flag")) { } else if (dom.classList.contains("window_flag")) {
@ -409,27 +420,37 @@ export default defineComponent({
{ {
window, window,
property_name: "x", property_name: "x",
value: window.x + offset_x * wall_width_scaler.value, value:
window.x +
(offset_x * wall_width_scaler.value) /
$store.state.device_screen_width,
}, },
{ {
window, window,
property_name: "y", property_name: "y",
value: window.y + offset_y * wall_height_scaler.value, value:
window.y +
(offset_y * wall_height_scaler.value) /
$store.state.device_screen_height,
}, },
{ {
window, window,
property_name: "width", property_name: "width",
value: Math.max( value: Math.max(
window.width + offset_width * wall_width_scaler.value, window.width +
32 (offset_width * wall_width_scaler.value) /
$store.state.device_screen_width,
32 / $store.state.device_screen_width
), ),
}, },
{ {
window, window,
property_name: "height", property_name: "height",
value: Math.max( value: Math.max(
window.height + offset_height * wall_height_scaler.value, window.height +
32 (offset_height * wall_height_scaler.value) /
$store.state.device_screen_height,
32 / $store.state.device_screen_height
), ),
}, },
]); ]);