-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
geometry tree window works with bugs
- Loading branch information
Showing
9 changed files
with
236 additions
and
4 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
firebird-ng/src/app/geometry-tree/geometry-tree-window/geometry-tree-window.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<button mat-icon-button (click)="toggleWindow()" class="tree-button"> | ||
<mat-icon>{{windowOpenState ? 'close' : 'account_tree'}}</mat-icon> | ||
</button> | ||
|
||
<div class="window" *ngIf="windowOpenState" #windowContainer> | ||
<div class="window-header" #windowHeader> | ||
<span>Geometry Tree</span> | ||
</div> | ||
|
||
<app-geometry-tree *ngIf="windowOpenState"></app-geometry-tree> | ||
|
||
<div class="resize-handle" #resizeHandle></div> | ||
</div> |
59 changes: 59 additions & 0 deletions
59
firebird-ng/src/app/geometry-tree/geometry-tree-window/geometry-tree-window.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.tree-button { | ||
background-color: #2e2e2e; | ||
color: white; | ||
border-radius: 50%; | ||
width: 48px; | ||
height: 48px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
transition: background-color 0.3s; | ||
position: fixed; | ||
top: 150px; | ||
right: 20px; | ||
|
||
&:hover { | ||
background-color: #95A5A5; | ||
} | ||
|
||
mat-icon { | ||
font-size: 24px; | ||
} | ||
} | ||
|
||
|
||
.window { | ||
position: absolute; | ||
width: 400px; | ||
height: 400px; | ||
border: 1px solid #ccc; | ||
background-color: #2e2e2e; | ||
display: flex; | ||
flex-direction: column; | ||
border-radius: 8px; | ||
overflow: hidden; | ||
resize: both; | ||
min-width: 200px; | ||
min-height: 200px; | ||
color: white; | ||
overflow-y: auto; | ||
} | ||
|
||
.window-header { | ||
background-color: #3e3e3e; | ||
padding: 8px; | ||
cursor: move; | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.resize-handle { | ||
width: 16px; | ||
height: 16px; | ||
background-color: #ccc; | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
cursor: se-resize; | ||
} |
23 changes: 23 additions & 0 deletions
23
...bird-ng/src/app/geometry-tree/geometry-tree-window/geometry-tree-window.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GeometryTreeWindowComponent } from './geometry-tree-window.component'; | ||
|
||
describe('GeometryDialogComponent', () => { | ||
let component: GeometryTreeWindowComponent; | ||
let fixture: ComponentFixture<GeometryTreeWindowComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [GeometryTreeWindowComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GeometryTreeWindowComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
112 changes: 112 additions & 0 deletions
112
firebird-ng/src/app/geometry-tree/geometry-tree-window/geometry-tree-window.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core'; | ||
import {MatIconButton} from "@angular/material/button"; | ||
import {MatIcon} from "@angular/material/icon"; | ||
import {GeometryTreeComponent} from "../geometry-tree.component"; | ||
import {NgIf} from "@angular/common"; | ||
|
||
@Component({ | ||
selector: 'geometry-tree-window', | ||
templateUrl: 'geometry-tree-window.component.html', | ||
styleUrls: ['geometry-tree-window.component.scss'], | ||
imports: [ | ||
MatIconButton, | ||
MatIcon, | ||
GeometryTreeComponent, | ||
NgIf | ||
], | ||
standalone: true | ||
}) | ||
export class GeometryTreeWindowComponent implements AfterViewInit { | ||
windowOpenState = true; | ||
|
||
@ViewChild('windowContainer', { static: false }) windowContainer!: ElementRef; | ||
@ViewChild('windowHeader', { static: false }) windowHeader!: ElementRef; | ||
@ViewChild('resizeHandle', { static: false }) resizeHandle!: ElementRef; | ||
|
||
private isDragging = false; | ||
private isResizing = false; | ||
private lastX = 0; | ||
private lastY = 0; | ||
|
||
ngAfterViewInit() { | ||
if (this.windowOpenState) { | ||
this.initDrag(); | ||
this.initResize(); | ||
} | ||
} | ||
|
||
toggleWindow() { | ||
this.windowOpenState = !this.windowOpenState; | ||
|
||
if (this.windowOpenState) { | ||
setTimeout(() => { | ||
this.initDrag(); | ||
this.initResize(); | ||
}); | ||
} | ||
} | ||
|
||
initDrag() { | ||
if (!this.windowContainer) return; | ||
|
||
const windowElement = this.windowContainer.nativeElement; | ||
|
||
windowElement.addEventListener('mousedown', (e: MouseEvent) => { | ||
if ((<HTMLElement>e.target).classList.contains('window-header')) { | ||
this.isDragging = true; | ||
this.lastX = e.clientX; | ||
this.lastY = e.clientY; | ||
e.preventDefault(); | ||
} | ||
}); | ||
|
||
document.addEventListener('mousemove', (e: MouseEvent) => { | ||
if (this.isDragging) { | ||
const dx = e.clientX - this.lastX; | ||
const dy = e.clientY - this.lastY; | ||
|
||
const rect = windowElement.getBoundingClientRect(); | ||
windowElement.style.left = rect.left + dx + 'px'; | ||
windowElement.style.top = rect.top + dy + 'px'; | ||
|
||
this.lastX = e.clientX; | ||
this.lastY = e.clientY; | ||
} | ||
}); | ||
|
||
document.addEventListener('mouseup', () => { | ||
this.isDragging = false; | ||
}); | ||
} | ||
|
||
initResize() { | ||
if (!this.resizeHandle || !this.windowContainer) return; | ||
|
||
const resizeHandle = this.resizeHandle.nativeElement; | ||
const windowElement = this.windowContainer.nativeElement; | ||
|
||
resizeHandle.addEventListener('mousedown', (e: MouseEvent) => { | ||
this.isResizing = true; | ||
this.lastX = e.clientX; | ||
this.lastY = e.clientY; | ||
e.preventDefault(); | ||
}); | ||
|
||
document.addEventListener('mousemove', (e: MouseEvent) => { | ||
if (this.isResizing) { | ||
const dx = e.clientX - this.lastX; | ||
const dy = e.clientY - this.lastY; | ||
|
||
windowElement.style.width = windowElement.offsetWidth + dx + 'px'; | ||
windowElement.style.height = windowElement.offsetHeight + dy + 'px'; | ||
|
||
this.lastX = e.clientX; | ||
this.lastY = e.clientY; | ||
} | ||
}); | ||
|
||
document.addEventListener('mouseup', () => { | ||
this.isResizing = false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters