Skip to content

Commit

Permalink
distance on overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-party committed Jun 23, 2024
1 parent f597c4c commit 85cce7b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/mtc-artillery-overlay/src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tauri-build = { version = "1", features = [] }

[dependencies]
dotenv = "0.15"
tauri = { version = "1", features = [ "macos-private-api", "window-close", "window-start-dragging"] }
tauri = { version = "1", features = [ "window-set-size", "macos-private-api", "window-close", "window-start-dragging"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
octocrab = "0.38.0"
Expand Down
5 changes: 3 additions & 2 deletions packages/mtc-artillery-overlay/src/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "mtc-artillery-overlay",
"version": "0.2.3"
"version": "0.2.4"
},
"tauri": {
"allowlist": {
Expand All @@ -18,6 +18,7 @@
"window": {
"all": false,
"close": true,
"setSize": true,
"startDragging": true
}
},
Expand Down Expand Up @@ -49,7 +50,7 @@
"alwaysOnTop": true,
"decorations": false,
"fileDropEnabled": false,
"height": 546,
"height": 1000,
"label": "main",
"maximizable": false,
"minimizable": false,
Expand Down
5 changes: 5 additions & 0 deletions src/components/tauri/atoms/RowContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export default function RowContainer({
alignItems: 'center',
justifyContent: 'space-between',
gap: 1,

'& .datacontainer': {
flexDirection: 'column',
gap: 0,
},
},
sx,
)}
Expand Down
1 change: 1 addition & 0 deletions src/components/tauri/templates/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function Navigation() {
onClick={async () => {
try {
const { appWindow } = await import('@tauri-apps/api/window');

appWindow.close();
} catch (error) {
console.error(error);
Expand Down
46 changes: 34 additions & 12 deletions src/views/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';

import ColumnContainer from '@/components/atoms/ColumnContainer';
import AzimuthValue from '@/components/organisms/configuration/Azimuth';
import DistanceValue from '@/components/organisms/configuration/Distance';
import ElevationValue from '@/components/organisms/configuration/Elevation';
import MapSelection from '@/components/organisms/configuration/Map';
import ProjectileSelection from '@/components/organisms/configuration/Projectile';
Expand All @@ -19,6 +20,10 @@ declare global {
}
}

const navigationHeight = 40;
const canvasHeight = 326;
const dataHeight = 225;

export default function OverlayView() {
React.useEffect(() => {
const timeout = setTimeout(() => {
Expand All @@ -32,6 +37,24 @@ export default function OverlayView() {
return () => clearTimeout(timeout);
}, []);

React.useEffect(() => {
async function updateSize() {
try {
const { appWindow, LogicalSize } = await import(
'@tauri-apps/api/window'
);

await appWindow.setSize(
new LogicalSize(326, navigationHeight + canvasHeight + dataHeight),
);
} catch (error) {
console.error(error);
}
}

updateSize();
}, []);

return (
<>
<GlobalStyles
Expand All @@ -49,7 +72,7 @@ export default function OverlayView() {
<Box
sx={{
display: 'grid',
gridTemplateRows: '40px 326px 180px',
gridTemplateRows: `${navigationHeight}px ${canvasHeight}px ${dataHeight}px`,

borderRadius: 8,
backgroundColor: 'black',
Expand All @@ -74,18 +97,17 @@ export default function OverlayView() {
padding: 2,
}}
>
<RowContainer
sx={{
'& .datacontainer': {
flexDirection: 'column',
gap: 0,
},
}}
>
<ElevationValue />
<ColumnContainer sx={{ gap: 1 }}>
<RowContainer>
<ElevationValue />

<AzimuthValue />
</RowContainer>
<AzimuthValue />
</RowContainer>

<RowContainer>
<DistanceValue />
</RowContainer>
</ColumnContainer>

<ColumnContainer
sx={{
Expand Down

0 comments on commit 85cce7b

Please sign in to comment.