Skip to content

Commit

Permalink
add scale answer (first pard)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibakaidov committed Dec 18, 2023
1 parent 32cc881 commit 39363a1
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 67 deletions.
1 change: 0 additions & 1 deletion src/common/interfaces/PageElementsState.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface PageElementsState{
id: string,
bottom: number,
bounds: DOMRect[]
}
export interface BrowserElementsState extends PageElementsState{
Expand Down
15 changes: 9 additions & 6 deletions src/electron/tobii/backWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class BackWatch {
tobii?: TobiiProcess = undefined;
window?: BrowserWindow;
hid = "";
constructor (win: BrowserWindow) {
multiplyScale = false;
constructor(win: BrowserWindow) {
this.window = win;
if (platform() === "win32") {
try {
Expand All @@ -20,9 +21,8 @@ export class BackWatch {
ipcMain.on("eye-elements", (event, data: PageElementsState) => {
this.hid = data.id;
const winBounds = win.getContentBounds();
const p = winBounds.height / data.bottom;

const m = p === 1 ? 1 : (screen.getPrimaryDisplay().scaleFactor);
const m = this.multiplyScale ? (screen.getPrimaryDisplay().scaleFactor) : 1;

const bounds: Bound[] = data.bounds.map((el: DOMRect) => {
return Bound.fromArray([el.x + winBounds.x, el.y + winBounds.y, el.width, el.height].map(el => Math.round(el * m)));
Expand All @@ -34,14 +34,17 @@ export class BackWatch {
ipcMain.on("button_timeout", (event, value) => {
this.tobii?.setTimeout(value);
});
ipcMain.on("button_multiply_scale", (event, value) => {
this.multiplyScale = value;
});
} catch (error) {
dialog
.showErrorBox("Ошибка запуска обработчика айтрекера", "Для исправления проблемы установите Visual Studio 2012 (VC++ 11.0) с обновлением 4 или свяжитесь с Бакаидовым.");
}
}
}

onClick (index: number, count: number) {
onClick(index: number, count: number) {
if (!this.window?.isFocused()) return;
this.window?.webContents.send("eye-click", {
elementIndex: index,
Expand All @@ -50,13 +53,13 @@ export class BackWatch {
});
}

onExit () {
onExit() {
this.window?.webContents.send("eye-exit", {
id: this.hid
});
}

onEnter (index: number) {
onEnter(index: number) {
this.window?.webContents.send("eye-enter", {
elementIndex: index,
id: this.hid
Expand Down
5 changes: 0 additions & 5 deletions src/electron/tobii/pageWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export class PageWatcher {
private elements: BrowserElementsState = {
id: "",
elements: [],
bottom: 0,
bounds: [] as DOMRect[]
};

Expand Down Expand Up @@ -102,9 +101,6 @@ export class PageWatcher {
}

watchElementsChange (force = false) {
const screenTest = document.getElementById("screen-test");
if (!screenTest) return;
const bottom = screenTest.getBoundingClientRect().bottom;

const eyes = [...document.getElementsByClassName(PageWatcher.CLASS)];
const bounds = eyes.map((el) => el.getBoundingClientRect());
Expand All @@ -119,7 +115,6 @@ export class PageWatcher {
this.elements = {
elements: eyes,
bounds,
bottom,
id: uuid()
};
ipcRenderer.send("eye-elements", JSON.parse(JSON.stringify(this.elements)));
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import EditorViewAppBar from "@/frontend/views/EditorView.appbar.vue";
import SettingsView from "@/frontend/views/SettingsView.vue";
import SettingsViewAppBar from "@/frontend/views/SettingsView.appbar.vue";
import { storageService } from "@/frontend/services/card-storage-service";
import CalibrationView from "../views/CalibrationView.vue";

const routes: Array<RouteRecordRaw> = [
{
Expand Down Expand Up @@ -42,6 +43,12 @@ const routes: Array<RouteRecordRaw> = [
default: SettingsView,
appbar: SettingsViewAppBar
}
},
{
path: "/calibration",
components:{
default: CalibrationView
}
}
];

Expand Down
3 changes: 2 additions & 1 deletion src/frontend/store/LINKaStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export interface LINKaStore {
borders: number;
enabled: boolean;
clickSound: boolean;
animation: boolean
animation: boolean,
multiplyScale: boolean
},
ui: {
disabled: boolean,
Expand Down
Loading

0 comments on commit 39363a1

Please sign in to comment.