Skip to content

Commit bb123dd

Browse files
committed
- Toevoegen context menu in het situatieschema voor snellere aanpassing van symbool-eigenschappen.
- Adreslocatie roteert mee indien via het contextmenu een rotatie wordt uitgevoerd. - In het print-menu twee HTML veldjes een formeel id gegeven (warning google Chrome) - Enter toets op een symbool opent nu ook de symbooleigenschappen - Ctrl-pijlen doet nu een symbool roteren in het situatieschema
1 parent b95cb94 commit bb123dd

File tree

9 files changed

+559
-89
lines changed

9 files changed

+559
-89
lines changed

builddate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
var CONF_builddate="20250202-152459"
1+
var CONF_builddate="20250209-140637"

css/styles.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,3 +398,38 @@ table {
398398
transform: translate(-50%, -50%);
399399
pointer-events: none; /* Allow clicks to pass through the SVG */
400400
}
401+
402+
.context-menu {
403+
position: absolute;
404+
display: none;
405+
border: 1px solid #aaa;
406+
background-color: #f0f0f0;
407+
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
408+
z-index: 999999999; /* Try to always be on top */
409+
font-size: 12px;
410+
line-height: 1.0;
411+
}
412+
413+
.context-menu-item {
414+
padding: 4px 6px;
415+
cursor: pointer;
416+
display: flex;
417+
justify-content: space-between;
418+
align-items: center;
419+
}
420+
421+
.context-menu-item:hover {
422+
background-color: #e0e0e0;
423+
}
424+
425+
.context-menu-shortcut {
426+
margin-left: 16px;
427+
color: #888;
428+
}
429+
430+
.context-menu-separator {
431+
border: none;
432+
border-top: 1px solid #ddd;
433+
margin: 2px 0;
434+
}
435+

eendraadschema.js

Lines changed: 249 additions & 36 deletions
Large diffs are not rendered by default.

src/main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ function restart_all() {
295295

296296
function toggleAppView(type: '2col' | 'config' | 'draw') {
297297
let lastview = structure.properties.currentView;
298+
if ((structure.sitplanview != null) && (structure.sitplanview.contextMenu != null)) structure.sitplanview.contextMenu.hide();
298299

299300
structure.properties.currentView = type;
300301
if (type === '2col') {
@@ -354,10 +355,12 @@ function load_example(nr: number) {
354355
}
355356

356357
function undoClicked() {
358+
if ((structure.sitplanview != null) && (structure.sitplanview.contextMenu != null)) structure.sitplanview.contextMenu.hide();
357359
undostruct.undo();
358360
}
359361

360362
function redoClicked() {
363+
if ((structure.sitplanview != null) && (structure.sitplanview.contextMenu != null)) structure.sitplanview.contextMenu.hide();
361364
undostruct.redo();
362365
}
363366

src/print/Print_Table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ class Print_Table {
309309

310310
insertHTMLselectPaperSize(div: HTMLElement, redrawCallBack: RedrawCallBackFunction): void {
311311
var select: HTMLSelectElement = document.createElement('select');
312+
select.id = 'select_papersize_input';
312313

313314
var optionA4: HTMLOptionElement = document.createElement('option');
314315
optionA4.value = 'A4';
@@ -342,6 +343,7 @@ class Print_Table {
342343

343344
insertHTMLselectdpi(div: HTMLElement, redrawCallBack: RedrawCallBackFunction): void {
344345
var select: HTMLSelectElement = document.createElement('select');
346+
select.id = "select_dpi_input";
345347

346348
var option300: HTMLOptionElement = document.createElement('option');
347349
option300.value = '300';

src/sitplan/ContextMenu.ts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
class ContextMenu {
2+
private menuItems: { label: string, shortcut?: string, callback: () => void }[] = [];
3+
private menuElement: HTMLElement | null = null;
4+
5+
/**
6+
* Constructor voor het initialiseren van het contextmenu-element.
7+
* @param div - Het HTML-element waaraan het contextmenu wordt toegevoegd.
8+
*/
9+
constructor(div: HTMLElement = document.body) {
10+
this.menuElement = document.createElement('div');
11+
this.menuElement.className = 'context-menu';
12+
div.appendChild(this.menuElement);
13+
}
14+
15+
/**
16+
* Wis alle menu-items.
17+
*/
18+
clearMenu(): void {
19+
this.menuItems = [];
20+
if (this.menuElement) {
21+
this.menuElement.innerHTML = '';
22+
}
23+
}
24+
25+
/**
26+
* Voeg een menu-item toe met een optionele sneltoets.
27+
* @param label - De tekstlabel van het menu-item.
28+
* @param callback - De functie die wordt aangeroepen bij het klikken op het menu-item.
29+
* @param shortcut - De optionele sneltoets voor het menu-item.
30+
*/
31+
addMenuItem(label: string, callback: () => void, shortcut?: string): void {
32+
this.menuItems.push({ label, shortcut, callback });
33+
}
34+
35+
/**
36+
* Voeg een scheidingslijn toe aan het menu.
37+
*/
38+
addLine(): void {
39+
this.menuItems.push({ label: 'separator', callback: () => {} });
40+
}
41+
42+
/**
43+
* Render de menu-items.
44+
*/
45+
private renderMenu(): void {
46+
if (this.menuElement) {
47+
this.menuElement.innerHTML = '';
48+
this.menuItems.forEach((item, index) => {
49+
if (item.label === 'separator') {
50+
const separator = document.createElement('hr');
51+
separator.className = 'context-menu-separator';
52+
this.menuElement.appendChild(separator);
53+
} else {
54+
const menuItem = document.createElement('div');
55+
menuItem.className = 'context-menu-item';
56+
57+
const labelElement = document.createElement('span');
58+
labelElement.textContent = item.label;
59+
60+
const shortcutElement = document.createElement('span');
61+
shortcutElement.textContent = item.shortcut || '';
62+
shortcutElement.className = 'context-menu-shortcut';
63+
64+
menuItem.appendChild(labelElement);
65+
menuItem.appendChild(shortcutElement);
66+
67+
menuItem.addEventListener('click', () => {
68+
item.callback();
69+
this.hide();
70+
});
71+
72+
this.menuElement.appendChild(menuItem);
73+
}
74+
});
75+
}
76+
}
77+
78+
/**
79+
* Toon het contextmenu op de locatie van de muisklik.
80+
* @param event - Het muisgebeurtenisobject.
81+
*/
82+
show(event: MouseEvent): void {
83+
if (this.menuElement) {
84+
this.renderMenu();
85+
this.menuElement.style.display = 'block';
86+
const { clientX, clientY } = event;
87+
const { innerWidth, innerHeight } = window;
88+
const { offsetWidth, offsetHeight } = this.menuElement;
89+
90+
let left = clientX;
91+
let top = clientY;
92+
93+
if (left + offsetWidth > innerWidth) {
94+
left = innerWidth - offsetWidth;
95+
}
96+
if (top + offsetHeight > innerHeight) {
97+
top = innerHeight - offsetHeight;
98+
}
99+
100+
this.menuElement.style.left = `${left}px`;
101+
this.menuElement.style.top = `${top}px`;
102+
}
103+
}
104+
105+
/**
106+
* Verberg het contextmenu.
107+
*/
108+
hide(): void {
109+
if (this.menuElement) {
110+
this.menuElement.style.display = 'none';
111+
}
112+
}
113+
}

src/sitplan/SituationPlanElement.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ class SituationPlanElement {
125125
if (this.adrestype === 'manueel') this.adres = adres; else this.adres = null;
126126
}
127127

128+
/**
129+
* setAdresLocation
130+
*
131+
* @param adreslocation string: 'rechts' of 'links' of 'boven' of 'onder'
132+
*/
133+
134+
135+
setAdresLocation(adreslocation: AdresLocation) {
136+
this.adreslocation = adreslocation;
137+
}
138+
128139
/**
129140
* getAdresType
130141
*

0 commit comments

Comments
 (0)