Focus feature works (when there is a sequence set. STill has bugs
This commit is contained in:
parent
0d30b4d5bb
commit
b231f8cd48
|
@ -13,6 +13,7 @@ class Display {
|
||||||
private img : HTMLImageElement;
|
private img : HTMLImageElement;
|
||||||
private screen : any;
|
private screen : any;
|
||||||
private sequence : boolean = false;
|
private sequence : boolean = false;
|
||||||
|
private focus : boolean = false;
|
||||||
|
|
||||||
private offsetX : number = 0;
|
private offsetX : number = 0;
|
||||||
private offsetY : number = 0;
|
private offsetY : number = 0;
|
||||||
|
@ -89,7 +90,7 @@ class Display {
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDisplay () {
|
public updateDisplay () {
|
||||||
if (!this.sequence) {
|
if (!this.sequence && !this.focus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//console.log(this.sequence);
|
//console.log(this.sequence);
|
||||||
|
@ -120,6 +121,7 @@ class Display {
|
||||||
|
|
||||||
public set (state : State) {
|
public set (state : State) {
|
||||||
this.sequence = true;
|
this.sequence = true;
|
||||||
|
this.focus = false;
|
||||||
this.offsetX = state.offset.x;
|
this.offsetX = state.offset.x;
|
||||||
this.offsetY = state.offset.y;
|
this.offsetY = state.offset.y;
|
||||||
this.width = state.display.width;
|
this.width = state.display.width;
|
||||||
|
@ -127,6 +129,14 @@ class Display {
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setFocus () {
|
||||||
|
this.focus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsetFocus () {
|
||||||
|
this.focus = false;
|
||||||
|
}
|
||||||
|
|
||||||
private onResize (event : any) {
|
private onResize (event : any) {
|
||||||
this.updateSize();
|
this.updateSize();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
@ -325,6 +335,8 @@ class Client {
|
||||||
case 'focus' :
|
case 'focus' :
|
||||||
this.receiveFocus(msg);
|
this.receiveFocus(msg);
|
||||||
break;
|
break;
|
||||||
|
case 'unfocus' :
|
||||||
|
this.receiveUnfocus(msg);
|
||||||
case 'display' :
|
case 'display' :
|
||||||
this.receiveDisplay(msg);
|
this.receiveDisplay(msg);
|
||||||
break;
|
break;
|
||||||
|
@ -460,6 +472,12 @@ class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
private receiveFocus (msg : Message) {
|
private receiveFocus (msg : Message) {
|
||||||
|
this.display.setFocus();
|
||||||
|
this.display.updateImage();
|
||||||
|
}
|
||||||
|
|
||||||
|
private receiveUnfocus (msg : Message) {
|
||||||
|
this.display.unsetFocus();
|
||||||
this.display.updateImage();
|
this.display.updateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,9 @@ async function select(id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function start() {
|
function start() {
|
||||||
|
if (focus !== null) {
|
||||||
|
stopFocus();
|
||||||
|
}
|
||||||
sequence.start();
|
sequence.start();
|
||||||
}
|
}
|
||||||
function stop() {
|
function stop() {
|
||||||
|
@ -307,6 +310,10 @@ async function focus() {
|
||||||
let dims;
|
let dims;
|
||||||
let state;
|
let state;
|
||||||
let filePath;
|
let filePath;
|
||||||
|
if (focusImage !== null) {
|
||||||
|
await stopFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (sequence.isLoaded()) {
|
if (sequence.isLoaded()) {
|
||||||
state = sequence.getState();
|
state = sequence.getState();
|
||||||
pos = {
|
pos = {
|
||||||
|
@ -326,8 +333,15 @@ async function focus() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
focusImage = await testimage_1.TestImage.Focus(pos.w, pos.h);
|
focusImage = await testimage_1.TestImage.Focus(pos.w, pos.h);
|
||||||
|
await fd.load(focusImage, pos.x, pos.y, pos.w, pos.h);
|
||||||
|
await fd.display(focusImage);
|
||||||
send({ cmd: 'focus' });
|
send({ cmd: 'focus' });
|
||||||
}
|
}
|
||||||
|
async function stopFocus() {
|
||||||
|
focusImage = null;
|
||||||
|
await fd.stop(focusImage);
|
||||||
|
send({ cmd: 'unfocus' });
|
||||||
|
}
|
||||||
function offset(msg) {
|
function offset(msg) {
|
||||||
let current = sequence.getCurrent();
|
let current = sequence.getCurrent();
|
||||||
if (current !== null) {
|
if (current !== null) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
15
src/index.ts
15
src/index.ts
|
@ -284,6 +284,9 @@ async function select (id : string) : Promise<boolean> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function start () {
|
function start () {
|
||||||
|
if (focus !== null) {
|
||||||
|
stopFocus();
|
||||||
|
}
|
||||||
sequence.start();
|
sequence.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,6 +310,10 @@ async function focus () {
|
||||||
let dims : Dimensions;
|
let dims : Dimensions;
|
||||||
let state : State;
|
let state : State;
|
||||||
let filePath : string;
|
let filePath : string;
|
||||||
|
if (focusImage !== null) {
|
||||||
|
await stopFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (sequence.isLoaded()) {
|
if (sequence.isLoaded()) {
|
||||||
state = sequence.getState();
|
state = sequence.getState();
|
||||||
pos = {
|
pos = {
|
||||||
|
@ -325,9 +332,17 @@ async function focus () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
focusImage = await TestImage.Focus(pos.w, pos.h);
|
focusImage = await TestImage.Focus(pos.w, pos.h);
|
||||||
|
await fd.load (focusImage, pos.x, pos.y, pos.w, pos.h);
|
||||||
|
await fd.display(focusImage);
|
||||||
send({ cmd : 'focus' });
|
send({ cmd : 'focus' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function stopFocus () {
|
||||||
|
focusImage = null;
|
||||||
|
await fd.stop(focusImage);
|
||||||
|
send({ cmd : 'unfocus' });
|
||||||
|
}
|
||||||
|
|
||||||
function offset (msg : Message) {
|
function offset (msg : Message) {
|
||||||
let current : ImageObject = sequence.getCurrent();
|
let current : ImageObject = sequence.getCurrent();
|
||||||
if (current !== null) {
|
if (current !== null) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ declare class Display {
|
||||||
private img;
|
private img;
|
||||||
private screen;
|
private screen;
|
||||||
private sequence;
|
private sequence;
|
||||||
|
private focus;
|
||||||
private offsetX;
|
private offsetX;
|
||||||
private offsetY;
|
private offsetY;
|
||||||
private width;
|
private width;
|
||||||
|
@ -37,6 +38,8 @@ declare class Display {
|
||||||
updateImage(): void;
|
updateImage(): void;
|
||||||
update(msg: Message): void;
|
update(msg: Message): void;
|
||||||
set(state: State): void;
|
set(state: State): void;
|
||||||
|
setFocus(): void;
|
||||||
|
unsetFocus(): void;
|
||||||
private onResize;
|
private onResize;
|
||||||
}
|
}
|
||||||
declare class Client {
|
declare class Client {
|
||||||
|
@ -83,6 +86,7 @@ declare class Client {
|
||||||
private receiveDisplay;
|
private receiveDisplay;
|
||||||
sendFocus(): void;
|
sendFocus(): void;
|
||||||
private receiveFocus;
|
private receiveFocus;
|
||||||
|
private receiveUnfocus;
|
||||||
sendOffset(x: number, y: number): void;
|
sendOffset(x: number, y: number): void;
|
||||||
sendSize(width: number, height: number): void;
|
sendSize(width: number, height: number): void;
|
||||||
sendScale(scale: number): void;
|
sendScale(scale: number): void;
|
||||||
|
|
|
@ -8,6 +8,7 @@ var SequenceStatus;
|
||||||
class Display {
|
class Display {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.sequence = false;
|
this.sequence = false;
|
||||||
|
this.focus = false;
|
||||||
this.offsetX = 0;
|
this.offsetX = 0;
|
||||||
this.offsetY = 0;
|
this.offsetY = 0;
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
|
@ -72,7 +73,7 @@ class Display {
|
||||||
this.ctx.stroke();
|
this.ctx.stroke();
|
||||||
}
|
}
|
||||||
updateDisplay() {
|
updateDisplay() {
|
||||||
if (!this.sequence) {
|
if (!this.sequence && !this.focus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const screenScaleX = this.screenWidth / this.screen.width;
|
const screenScaleX = this.screenWidth / this.screen.width;
|
||||||
|
@ -96,12 +97,19 @@ class Display {
|
||||||
}
|
}
|
||||||
set(state) {
|
set(state) {
|
||||||
this.sequence = true;
|
this.sequence = true;
|
||||||
|
this.focus = false;
|
||||||
this.offsetX = state.offset.x;
|
this.offsetX = state.offset.x;
|
||||||
this.offsetY = state.offset.y;
|
this.offsetY = state.offset.y;
|
||||||
this.width = state.display.width;
|
this.width = state.display.width;
|
||||||
this.height = state.display.height;
|
this.height = state.display.height;
|
||||||
this.updateDisplay();
|
this.updateDisplay();
|
||||||
}
|
}
|
||||||
|
setFocus() {
|
||||||
|
this.focus = true;
|
||||||
|
}
|
||||||
|
unsetFocus() {
|
||||||
|
this.focus = false;
|
||||||
|
}
|
||||||
onResize(event) {
|
onResize(event) {
|
||||||
this.updateSize();
|
this.updateSize();
|
||||||
this.clear();
|
this.clear();
|
||||||
|
@ -265,6 +273,8 @@ class Client {
|
||||||
case 'focus':
|
case 'focus':
|
||||||
this.receiveFocus(msg);
|
this.receiveFocus(msg);
|
||||||
break;
|
break;
|
||||||
|
case 'unfocus':
|
||||||
|
this.receiveUnfocus(msg);
|
||||||
case 'display':
|
case 'display':
|
||||||
this.receiveDisplay(msg);
|
this.receiveDisplay(msg);
|
||||||
break;
|
break;
|
||||||
|
@ -378,6 +388,11 @@ class Client {
|
||||||
this.client.send(JSON.stringify({ cmd: 'focus' }));
|
this.client.send(JSON.stringify({ cmd: 'focus' }));
|
||||||
}
|
}
|
||||||
receiveFocus(msg) {
|
receiveFocus(msg) {
|
||||||
|
this.display.setFocus();
|
||||||
|
this.display.updateImage();
|
||||||
|
}
|
||||||
|
receiveUnfocus(msg) {
|
||||||
|
this.display.unsetFocus();
|
||||||
this.display.updateImage();
|
this.display.updateImage();
|
||||||
}
|
}
|
||||||
sendOffset(x, y) {
|
sendOffset(x, y) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue