Skip to content

Commit 325799e

Browse files
committed
Add row layout for wide screens
1 parent 593406e commit 325799e

File tree

3 files changed

+89
-2
lines changed

3 files changed

+89
-2
lines changed

src/ts/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@ async function createWindow(): Promise<void> {
1010
const mainWindow = new BrowserWindow({
1111
height: 1000,
1212
width: 1800,
13+
autoHideMenuBar: true,
1314
webPreferences: {
1415
nodeIntegrationInWorker: true,
1516
nodeIntegration: true,
16-
contextIsolation: false
17+
contextIsolation: false,
18+
zoomFactor: 1.0,
1719
},
1820
});
1921

2022
mainWindow.maximize();
2123

2224
await mainWindow.loadFile(path.join(__dirname, index));
2325

24-
mainWindow.webContents.openDevTools();
26+
// mainWindow.webContents.openDevTools();
2527
}
2628

2729
if (process && process.type === 'renderer') {

src/ts/ui/layout/engine/default.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {ProcessesInfoWidget} from "../../process";
66
import MemoryUsageWidget from "../../memory";
77
import {NetworkStatusWidget, NetworkUsageWidget, PingWidget, WebRequestWidget} from "../../network";
88
import PartitionWidget from "../../disk";
9+
import RowLayoutEngine from "./row";
910

1011
interface PropType {
1112
windowSize: Size;
@@ -16,6 +17,10 @@ export default class ResponsiveLayoutEngine extends React.Component<PropType, {}
1617
render() {
1718
const totalWidth = numPointsX(this.props.windowSize) - 1;
1819
const totalHeight = numPointsY(this.props.windowSize) - 1;
20+
21+
if (totalWidth > totalHeight * 3) {
22+
return <RowLayoutEngine windowSize={this.props.windowSize} />
23+
}
1924
const padding = 1;
2025
let cpuSize = Math.min(6, totalHeight, totalWidth);
2126
if (cpuSize / totalHeight < 0.3) {

src/ts/ui/layout/engine/row.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import {Size} from "../../../util/vec2";
2+
import * as React from "react";
3+
import {numPointsX, numPointsY} from "../points";
4+
import CpuUsageWidget from "../../cpu";
5+
import {ProcessesInfoWidget} from "../../process";
6+
import MemoryUsageWidget from "../../memory";
7+
import {NetworkStatusWidget, NetworkUsageWidget} from "../../network";
8+
9+
interface PropType {
10+
windowSize: Size;
11+
}
12+
13+
export default class RowLayoutEngine extends React.Component<PropType, {}> {
14+
15+
render() {
16+
const totalWidth = numPointsX(this.props.windowSize) - 1;
17+
const totalHeight = numPointsY(this.props.windowSize) - 1;
18+
const padding = 1;
19+
let cpuSize = totalHeight;
20+
const fullCpuSize = cpuSize + padding;
21+
22+
let networkFlowWidth = 10;
23+
const networkFlowTotalWidth = networkFlowWidth + padding;
24+
25+
const pingWidth = 6;
26+
const totalPingWidth = pingWidth + padding;
27+
28+
const memoryWidth = totalWidth - fullCpuSize - networkFlowTotalWidth - totalPingWidth;
29+
30+
return (
31+
<>
32+
<CpuUsageWidget
33+
topLeft={{x: 0, y: 0}}
34+
size={{width: cpuSize, height: cpuSize}}
35+
windowSize={this.props.windowSize}
36+
/>
37+
{memoryWidth > 0 && <MemoryUsageWidget
38+
topLeft={{x: fullCpuSize, y: 0}}
39+
size={{width: memoryWidth, height: cpuSize}}
40+
windowSize={this.props.windowSize}
41+
/>}
42+
<NetworkUsageWidget
43+
topLeft={{x: fullCpuSize + memoryWidth + padding, y: 0}}
44+
size={{width: networkFlowWidth, height: totalHeight - padding * 4}}
45+
windowSize={this.props.windowSize}
46+
/>
47+
<NetworkStatusWidget
48+
topLeft={{x: fullCpuSize + memoryWidth + padding + networkFlowWidth + padding, y: 0}}
49+
size={{width: pingWidth, height: totalHeight - padding * 4}}
50+
windowSize={this.props.windowSize}
51+
/>
52+
<ProcessesInfoWidget
53+
topLeft={{x: fullCpuSize + memoryWidth + padding, y: totalHeight - padding * 3}}
54+
size={{width: networkFlowWidth + pingWidth + padding, height: padding * 3}}
55+
windowSize={this.props.windowSize}
56+
/>
57+
{/*{diskHeight > 0 && <PartitionWidget*/}
58+
{/* topLeft={{x: 0, y: fullCpuSize + networkFlowHeight + padding}}*/}
59+
{/* size={{width: networkFlowWidth + padding + pingWebWidth, height: diskHeight}}*/}
60+
{/* windowSize={this.props.windowSize}*/}
61+
{/*/>}*/}
62+
{/*{swapHeight !== 0 && <SwapUsageWidget*/}
63+
{/* topLeft={{x: fullCpuWidth + fullProcessWidth, y: memoryHeight}}*/}
64+
{/* size={{width: memoryNetworkWidth, height: swapHeight}}*/}
65+
{/* windowSize={this.props.windowSize}*/}
66+
{/*/>}*/}
67+
{/*{networkHeight !== 0 && <NetworkUsageWidget*/}
68+
{/* topLeft={{x: fullCpuWidth + fullProcessWidth, y: memoryHeight + swapHeight}}*/}
69+
{/* size={{width: memoryNetworkWidth, height: networkHeight}}*/}
70+
{/* windowSize={this.props.windowSize}*/}
71+
{/*/>}*/}
72+
{/*{detailsWidth !== 0 && <DetailsWidget*/}
73+
{/* topLeft={{x: fullCpuWidth + fullProcessWidth + fullMemoryNetworkWidth, y: 0}}*/}
74+
{/* size={{width: detailsWidth, height: totalHeight}}*/}
75+
{/* windowSize={this.props.windowSize}*/}
76+
{/*/>}*/}
77+
</>
78+
);
79+
}
80+
}

0 commit comments

Comments
 (0)