From f3d72301b223bd6350442ce212c5f9d24c9b245c Mon Sep 17 00:00:00 2001 From: isark Date: Sat, 18 Nov 2023 16:04:34 +0100 Subject: [PATCH] Updated notes display and scaling. Moved carousel to absolute pixel positions manually calculated instead of % since that didn't work too well..." --- src-tauri/src/main.rs | 6 +-- src-tauri/tauri.conf.json | 2 +- src/app/Scalable/scalable.component.html | 5 ++ src/app/Scalable/scalable.component.ts | 51 +++++++++++++++++++ src/app/carousel/carousel.component.html | 2 +- src/app/carousel/carousel.component.ts | 45 +++++++++++----- src/app/editor/notes/notes.component.ts | 10 ++-- .../plan-display/plan-display.component.html | 14 +++-- .../plan-display/plan-display.component.ts | 4 -- src/app/plan-display/plan-display.module.ts | 4 +- 10 files changed, 109 insertions(+), 34 deletions(-) create mode 100644 src/app/Scalable/scalable.component.html create mode 100644 src/app/Scalable/scalable.component.ts diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 8ed83b2..931bd30 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -156,9 +156,9 @@ fn main() { ); } - // app.get_window("Overlay") - // .expect("Could not get main overlay window") - // .open_devtools(); + app.get_window("Overlay") + .expect("Could not get main overlay window") + .open_devtools(); Ok(()) }) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 8428f10..97ac930 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Nothing", - "version": "0.0.0" + "version": "0.0.1" }, "tauri": { "systemTray": { diff --git a/src/app/Scalable/scalable.component.html b/src/app/Scalable/scalable.component.html new file mode 100644 index 0000000..d1ba39b --- /dev/null +++ b/src/app/Scalable/scalable.component.html @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff --git a/src/app/Scalable/scalable.component.ts b/src/app/Scalable/scalable.component.ts new file mode 100644 index 0000000..583d35a --- /dev/null +++ b/src/app/Scalable/scalable.component.ts @@ -0,0 +1,51 @@ +import { AfterViewInit, Component, ElementRef, ViewChild } from '@angular/core'; +import { AngularResizeEventModule, ResizedEvent } from 'angular-resize-event'; + +@Component({ + selector: 'scalable', + templateUrl: './scalable.component.html', + imports: [ AngularResizeEventModule ], + standalone: true +}) +export class ScalableComponent implements AfterViewInit { + @ViewChild('container') container?: ElementRef; + @ViewChild('element') element?: ElementRef; + + ngAfterViewInit(): void { + if (!this.container || !this.element) { + return; + } + + setTimeout(() => this.update()); + } + + update() { + if(!this.container || !this.element) { + return; + } + + const containerWidth = this.container?.nativeElement.clientWidth; + const containerHeight = this.container?.nativeElement.clientHeight; + const elementWidth = this.element?.nativeElement.clientWidth; + const elementHeight = this.element?.nativeElement.clientHeight; + + this.element.nativeElement.style.transform = ""; + + this.element.nativeElement.style.left = '0'; + this.element.nativeElement.style.top = '0'; + + this.element.nativeElement.style.transformOrigin = "left top"; + + let scale = containerWidth / elementWidth; + + if(containerHeight < elementHeight * scale) { + scale = containerHeight / elementHeight; + } + + this.element.nativeElement.style.transform += `scale(${scale}, ${scale})`; + } + + onResize(_event: ResizedEvent) { + this.update(); + } +} diff --git a/src/app/carousel/carousel.component.html b/src/app/carousel/carousel.component.html index c5a15ab..968efa9 100644 --- a/src/app/carousel/carousel.component.html +++ b/src/app/carousel/carousel.component.html @@ -1,5 +1,5 @@ -