Skip to content

Commit

Permalink
Context menu fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerIn-wonderland committed Jan 17, 2024
1 parent 1567e68 commit f4b982c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/anura.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ nav li {
position: absolute;
border: 1px solid #000000;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 20px;
padding: 10px 0;
width: 300px;
border-radius: 5px;
padding: 5px 0;
width: 150px;
box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);

z-index: 10000;
Expand All @@ -116,6 +116,7 @@ nav li {
color: #ffffff;
cursor: pointer;
user-select: none;
font-size: 14px;
}
.custom-menu-item:hover {
background-color: rgba(255, 255, 255, 0.1);
Expand All @@ -127,7 +128,7 @@ nav li {
.custom-menu-item {
display: flex;
align-items: center;
padding: 8px 12px;
padding: 4px 12px;
color: #ffffff;
cursor: pointer;
user-select: none;
Expand Down
22 changes: 22 additions & 0 deletions src/api/ContextMenuAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,34 @@ class ContextMenuAPI {
);
}
show(x: number, y: number) {
// Reset out of bound fixes
this.#element.style.bottom = "";
this.#element.style.right = "";

this.#element.style.top = y.toString() + "px";
this.#element.style.left = x.toString() + "px";
document.body.appendChild(this.#element);
this.#isShown = true;
this.#element.focus();

// Check for bounding and fix if necessary
console.log(this.#element.getBoundingClientRect());
console.log(document.body.getBoundingClientRect());
if (
this.#element.getBoundingClientRect().bottom >=
document.body.getBoundingClientRect().bottom
) {
this.#element.style.top = "";
this.#element.style.bottom = 0;
}
if (
this.#element.getBoundingClientRect().right >=
document.body.getBoundingClientRect().right
) {
this.#element.style.left = "";
this.#element.style.right = 0;
}

return this.#element;
}
hide() {
Expand Down
4 changes: 2 additions & 2 deletions src/coreapps/XFrogApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class XFrogApp extends App {
if (this.activeWin && this.activeWin != win) {
const newImg = document.createElement("img");

const blob: any = await new Promise(
(resolve) => anura.x86?.vgacanvas.toBlob(resolve),
const blob: any = await new Promise((resolve) =>
anura.x86?.vgacanvas.toBlob(resolve),
)!;
const url = URL.createObjectURL(blob);
newImg.src = url;
Expand Down

0 comments on commit f4b982c

Please sign in to comment.