Skip to content

Commit

Permalink
Tool panel
Browse files Browse the repository at this point in the history
resize buttons work with bugs
  • Loading branch information
sqrd-max committed Oct 17, 2024
1 parent 3a1874d commit a171b92
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 53 deletions.
49 changes: 0 additions & 49 deletions firebird-ng/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,55 +51,6 @@
<!--&lt;!&ndash; </li>&ndash;&gt;-->
<!-- </ul>-->
<!-- </div>-->
<!--&lt;!&ndash; <div class="phoenix-menu">&ndash;&gt;-->
<!--&lt;!&ndash; &lt;!&ndash; Event selector &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-event-selector></app-event-selector>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Zoom in and zoom out controls &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-zoom-controls></app-zoom-controls>&ndash;&gt;-->

<!--&lt;!&ndash; <app-view-options></app-view-options>&ndash;&gt;-->

<!--&lt;!&ndash; <app-auto-rotate></app-auto-rotate>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Dark theme toggle &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-dark-theme></app-dark-theme>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for clipping geometries &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-object-clipping></app-object-clipping>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Main view toggle &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-main-view-toggle></app-main-view-toggle>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for overlay panel &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-overlay-view></app-overlay-view>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for selected object panel &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-object-selection></app-object-selection>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for animating the event data &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-animate-event></app-animate-event>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for collections info &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-collections-info></app-collections-info>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for geometry browser &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-geometry-browser></app-geometry-browser>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for performance &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-performance-toggle></app-performance-toggle>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for loading geometries modal&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <eic-io-options></eic-io-options>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Toggle for shareable link constructor modal&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-share-link></app-share-link>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Info panel &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <app-info-panel></app-info-panel>&ndash;&gt;-->

<!--&lt;!&ndash; &lt;!&ndash; Extra options &ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash; <ng-content></ng-content>&ndash;&gt;-->
<!--&lt;!&ndash; </div>&ndash;&gt;-->
<!--</nav>-->
<router-outlet></router-outlet>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="tool-panel-wrapper">
<div class="tool-panel" [class.collapsed]="isCollapsed">
<div class="content">
<button class="icon-button toggle-button" title="Toggle Panel" (click)="togglePanel()">
<mat-icon>{{ isCollapsed ? 'keyboard_arrow_left' : 'keyboard_arrow_right' }}</mat-icon>
</button>
<div class="action-buttons" *ngIf="!isCollapsed">
<button class="icon-button" title="Zoom In"
(click)="onLeftClick($event, 'zoomIn')"
(mouseup)="clearZoom()"
(mouseleave)="clearZoom()"
(touchend)="clearZoom()"
(touchcancel)="clearZoom()">
<mat-icon>zoom_in</mat-icon>
</button>
<button class="icon-button" title="Zoom Out"
(click)="onLeftClick($event, 'zoomOut')"
(mouseup)="clearZoom()"
(mouseleave)="clearZoom()"
(touchend)="clearZoom()"
(touchcancel)="clearZoom()">
<mat-icon>zoom_out</mat-icon>
</button>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
.tool-panel-wrapper {
position: fixed;
top: 20%;
right: 0;
display: flex;
align-items: center;
}

.tool-panel {
width: 60px;
height: auto;
background-color: #2e2e2e;
box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
border-radius: 8px 0 0 8px;
display: flex;
flex-direction: column;
align-items: center;
transition: transform 0.3s ease;
padding: 10px;
}

.tool-panel.collapsed {
transform: translateX(calc(100% - 60px));
}

.icon-button {
background: none;
border: none;
cursor: pointer;
padding: 10px;
display: flex;
justify-content: center;
align-items: center;

border-radius: 50%;
transition: background-color 0.3s ease;

&:hover {
background-color: #5c5c5c;
}

mat-icon {
font-size: 24px;
color: white;
}
}

.toggle-button {
z-index: 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ToolPanelComponent } from './tool-panel.component';

describe('ToolPanelComponent', () => {
let component: ToolPanelComponent;
let fixture: ComponentFixture<ToolPanelComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ToolPanelComponent]
})
.compileComponents();

fixture = TestBed.createComponent(ToolPanelComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
72 changes: 72 additions & 0 deletions firebird-ng/src/app/components/tool-panel/tool-panel.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {Component, Input} from '@angular/core';
import {NgIf} from "@angular/common";
import {MatIcon} from "@angular/material/icon";
import { EventDisplayService } from 'phoenix-ui-components';

@Component({
selector: 'app-tool-panel',
standalone: true,
imports: [
NgIf,
MatIcon
],
templateUrl: './tool-panel.component.html',
styleUrl: './tool-panel.component.scss'
})
export class ToolPanelComponent {
isCollapsed = false;

/** Factor to zoom by. */
private zoomFactor: number = 1.1;
/** Timeout for clearing mouse hold. */
private zoomTimeout: any;
/** The speed and time of zoom. */
private zoomTime: number = 100;

constructor(private eventDisplay: EventDisplayService) {}

/**
* Zoom all the cameras by a specific zoom factor.
* The factor may either be greater (zoom in) or smaller (zoom out) than 1.
* @param zoomFactor The factor to zoom by.
*/
zoomTo(zoomFactor: number) {
this.zoomTime =
this.zoomTime > 30 ? Math.floor(this.zoomTime / 1.1) : this.zoomTime;

this.eventDisplay.zoomTo(zoomFactor, this.zoomTime);

this.zoomTimeout = setTimeout(() => {
this.zoomTo(zoomFactor);
}, this.zoomTime);
}

onLeftClick(event: MouseEvent, action: string) {
if (event.button === 0) {
if (action === 'zoomIn') {
this.zoomIn();
} else if (action === 'zoomOut') {
this.zoomOut();
}
}
}

zoomIn() {
this.zoomTo(1 / this.zoomFactor);
}
zoomOut() {
this.zoomTo(this.zoomFactor);
}

clearZoom() {
this.zoomTime = 100;
clearTimeout(this.zoomTimeout);
}

togglePanel() {
this.isCollapsed = !this.isCollapsed;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@
<!-- Event selector -->
<app-event-selector></app-event-selector>

<!-- Zoom in and zoom out controls -->
<app-zoom-controls></app-zoom-controls>
<!-- &lt;!&ndash; Zoom in and zoom out controls &ndash;&gt;-->
<!-- <app-zoom-controls></app-zoom-controls>-->

<app-view-options></app-view-options>

Expand Down Expand Up @@ -227,7 +227,7 @@
<div centralPane>
<!-- Central content area -->
<div id="eventDisplay"></div>

<app-tool-panel ></app-tool-panel>
</div>

<div rightPane>
Expand Down Expand Up @@ -279,4 +279,5 @@
</div>
</div>


</app-display-shell>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import {SceneTreeComponent} from "../geometry-tree/scene-tree.component";
import {DisplayShellComponent} from "../../components/display-shell/display-shell.component";
import {DataModelPainter} from "../../painters/data-model-painter";
import {AppComponent} from "../../app.component";
import {ToolPanelComponent} from "../../components/tool-panel/tool-panel.component";


// import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
Expand All @@ -55,7 +56,7 @@ import {AppComponent} from "../../app.component";
@Component({
selector: 'app-test-experiment',
templateUrl: './main-display.component.html',
imports: [PhoenixUIModule, IoOptionsComponent, MatSlider, MatIcon, MatButton, MatSliderThumb, DecimalPipe, MatTooltip, MatFormField, MatSelect, MatOption, NgForOf, AngularSplitModule, SceneTreeComponent, NgClass, MatIconButton, DisplayShellComponent, AppComponent, RouterOutlet, RouterLink],
imports: [PhoenixUIModule, IoOptionsComponent, MatSlider, MatIcon, MatButton, MatSliderThumb, DecimalPipe, MatTooltip, MatFormField, MatSelect, MatOption, NgForOf, AngularSplitModule, SceneTreeComponent, NgClass, MatIconButton, DisplayShellComponent, AppComponent, RouterOutlet, RouterLink, ToolPanelComponent],
standalone: true,
styleUrls: ['./main-display.component.scss']
})
Expand Down

0 comments on commit a171b92

Please sign in to comment.