Skip to content

Commit 69d7e8e

Browse files
author
Alberto Iannaccone
authored
Window min size (#1151)
* set min widow size * format document * fix dialogs sizes
1 parent 7f2b849 commit 69d7e8e

File tree

5 files changed

+87
-35
lines changed

5 files changed

+87
-35
lines changed

Diff for: arduino-ide-extension/src/browser/dialogs/settings/settings-component.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class SettingsComponent extends React.Component<
119119
'Show files inside Sketches'
120120
)}
121121
</label>
122-
<div className="flex-line">
122+
<div className="column-container">
123123
<div className="column">
124124
<div className="flex-line">
125125
{nls.localize(

Diff for: arduino-ide-extension/src/browser/dialogs/settings/settings-dialog.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as React from '@theia/core/shared/react';
2-
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
2+
import {
3+
injectable,
4+
inject,
5+
postConstruct,
6+
} from '@theia/core/shared/inversify';
37
import { Widget } from '@theia/core/shared/@phosphor/widgets';
48
import { Message } from '@theia/core/shared/@phosphor/messaging';
5-
import { DialogError, ReactWidget } from '@theia/core/lib/browser';
6-
import { AbstractDialog, DialogProps } from '@theia/core/lib/browser';
9+
import { DialogError, DialogProps, ReactWidget } from '@theia/core/lib/browser';
710
import { Settings, SettingsService } from './settings';
811
import { FileService } from '@theia/filesystem/lib/browser/file-service';
912
import { WindowService } from '@theia/core/lib/browser/window/window-service';
@@ -12,6 +15,7 @@ import { nls } from '@theia/core/lib/common';
1215
import { SettingsComponent } from './settings-component';
1316
import { AsyncLocalizationProvider } from '@theia/core/lib/common/i18n/localization';
1417
import { AdditionalUrls } from '../../../common/protocol';
18+
import { AbstractDialog } from '../../theia/dialogs/dialogs';
1519

1620
@injectable()
1721
export class SettingsWidget extends ReactWidget {
@@ -59,6 +63,7 @@ export class SettingsDialog extends AbstractDialog<Promise<Settings>> {
5963
protected override readonly props: SettingsDialogProps
6064
) {
6165
super(props);
66+
this.node.classList.add('arduino-settings-dialog-container');
6267
this.contentNode.classList.add('arduino-settings-dialog');
6368
this.appendCloseButton(
6469
nls.localize('vscode/issueMainService/cancel', 'Cancel')
@@ -73,7 +78,9 @@ export class SettingsDialog extends AbstractDialog<Promise<Settings>> {
7378
);
7479
}
7580

76-
protected override async isValid(settings: Promise<Settings>): Promise<DialogError> {
81+
protected override async isValid(
82+
settings: Promise<Settings>
83+
): Promise<DialogError> {
7784
const result = await this.settingsService.validate(settings);
7885
if (typeof result === 'string') {
7986
return result;

Diff for: arduino-ide-extension/src/browser/style/dialogs.css

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
.p-Widget.dialogOverlay .dialogBlock {
22
border-radius: 3px;
3-
padding: 0 28px;
43
box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.25);
5-
min-height: 0px;
4+
margin: 15px 20px;
5+
6+
/*
7+
padding (left + right) = 56px
8+
margin (left + right) = 40px
9+
total = padding + margin = 96px
10+
*/
11+
max-width: calc(100% - 96px) !important;
12+
padding: 0 28px;
613
}
714

815
.p-Widget.dialogOverlay .dialogBlock .dialogTitle {

Diff for: arduino-ide-extension/src/browser/style/settings-dialog.css

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
.arduino-settings-dialog {
2-
width: 740px;
1+
.arduino-settings-dialog-container > .dialogBlock {
2+
width: calc(100% - 96px);
3+
max-width: 740px !important;
34
}
45

56
.arduino-settings-dialog .content {
67
padding: 5px;
7-
height: 300px;
88
}
99

1010
.arduino-settings-dialog .flex-line {
@@ -26,8 +26,13 @@
2626
vertical-align: middle;
2727
}
2828

29+
.arduino-settings-dialog .column-container {
30+
display: flex;
31+
gap: 20px;
32+
}
33+
2934
.arduino-settings-dialog .stretch {
30-
width: 100% !important;
35+
flex: 1;
3136
}
3237

3338
.arduino-settings-dialog .flex-line .theia-button.shrink {
@@ -50,14 +55,20 @@
5055
.additional-urls-dialog .link:hover {
5156
color: var(--theia-textLink-activeForeground);
5257
}
58+
5359
.arduino-settings-dialog .react-tabs__tab-panel {
5460
padding-bottom: 25px;
5561
}
62+
5663
.arduino-settings-dialog .react-tabs__tab-list {
5764
display: flex;
5865
justify-content: center;
5966
}
6067

68+
.additional-urls-dialog textarea {
69+
width: 100%;
70+
}
71+
6172
.p-Widget.dialogOverlay .dialogBlock .dialogContent.additional-urls-dialog {
6273
display: block;
6374
}

Diff for: arduino-ide-extension/src/electron-main/theia/electron-main-application.ts

+51-24
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ import { TheiaBrowserWindowOptions } from '@theia/core/lib/electron-main/theia-e
3030
app.commandLine.appendSwitch('disable-http-cache');
3131

3232
interface WorkspaceOptions {
33-
file: string
34-
x: number
35-
y: number
36-
width: number
37-
height: number
38-
isMaximized: boolean
39-
isFullScreen: boolean
40-
time: number
33+
file: string;
34+
x: number;
35+
y: number;
36+
width: number;
37+
height: number;
38+
isMaximized: boolean;
39+
isFullScreen: boolean;
40+
time: number;
4141
}
4242

4343
const WORKSPACES = 'workspaces';
@@ -147,7 +147,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
147147
if (os.isOSX) {
148148
app.on('open-file', async (event, uri) => {
149149
event.preventDefault();
150-
if (uri.endsWith('.ino') && await fs.pathExists(uri)) {
150+
if (uri.endsWith('.ino') && (await fs.pathExists(uri))) {
151151
this.openFilePromise.reject();
152152
await this.openSketch(dirname(uri));
153153
}
@@ -159,10 +159,12 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
159159
}
160160

161161
protected async isValidSketchPath(uri: string): Promise<boolean | undefined> {
162-
return typeof uri === 'string' && await fs.pathExists(uri);
162+
return typeof uri === 'string' && (await fs.pathExists(uri));
163163
}
164164

165-
protected override async launch(params: ElectronMainExecutionParams): Promise<void> {
165+
protected override async launch(
166+
params: ElectronMainExecutionParams
167+
): Promise<void> {
166168
try {
167169
// When running on MacOS, we either have to wait until
168170
// 1. The `open-file` command has been received by the app, rejecting the promise
@@ -173,13 +175,14 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
173175
return;
174176
}
175177

176-
if (!os.isOSX && await this.launchFromArgs(params)) {
178+
if (!os.isOSX && (await this.launchFromArgs(params))) {
177179
// Application has received a file in its arguments and will skip the default application launch
178180
return;
179181
}
180182

181183
this.startup = true;
182-
const workspaces: WorkspaceOptions[] | undefined = this.electronStore.get(WORKSPACES);
184+
const workspaces: WorkspaceOptions[] | undefined =
185+
this.electronStore.get(WORKSPACES);
183186
let useDefault = true;
184187
if (workspaces && workspaces.length > 0) {
185188
console.log(
@@ -198,12 +201,17 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
198201
}
199202
}
200203

201-
protected async launchFromArgs(params: ElectronMainExecutionParams): Promise<boolean> {
204+
protected async launchFromArgs(
205+
params: ElectronMainExecutionParams
206+
): Promise<boolean> {
202207
// Copy to prevent manipulation of original array
203208
const argCopy = [...params.argv];
204209
let uri: string | undefined;
205210
for (const possibleUri of argCopy) {
206-
if (possibleUri.endsWith('.ino') && await this.isValidSketchPath(possibleUri)) {
211+
if (
212+
possibleUri.endsWith('.ino') &&
213+
(await this.isValidSketchPath(possibleUri))
214+
) {
207215
uri = possibleUri;
208216
break;
209217
}
@@ -215,7 +223,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
215223
return false;
216224
}
217225

218-
protected async openSketch(workspace: WorkspaceOptions | string): Promise<BrowserWindow> {
226+
protected async openSketch(
227+
workspace: WorkspaceOptions | string
228+
): Promise<BrowserWindow> {
219229
const options = await this.getLastWindowOptions();
220230
let file: string;
221231
if (typeof workspace === 'object') {
@@ -229,19 +239,26 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
229239
} else {
230240
file = workspace;
231241
}
232-
const [uri, electronWindow] = await Promise.all([this.createWindowUri(), this.createWindow(options)]);
242+
const [uri, electronWindow] = await Promise.all([
243+
this.createWindowUri(),
244+
this.createWindow(options),
245+
]);
233246
electronWindow.loadURL(uri.withFragment(encodeURI(file)).toString(true));
234247
return electronWindow;
235248
}
236249

237-
protected override avoidOverlap(options: TheiaBrowserWindowOptions): TheiaBrowserWindowOptions {
250+
protected override avoidOverlap(
251+
options: TheiaBrowserWindowOptions
252+
): TheiaBrowserWindowOptions {
238253
if (this.startup) {
239254
return options;
240255
}
241256
return super.avoidOverlap(options);
242257
}
243258

244-
protected override getTitleBarStyle(config: FrontendApplicationConfig): 'native' | 'custom' {
259+
protected override getTitleBarStyle(
260+
config: FrontendApplicationConfig
261+
): 'native' | 'custom' {
245262
return 'native';
246263
}
247264

@@ -255,8 +272,15 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
255272
});
256273
}
257274

258-
protected override async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
259-
if (!os.isOSX && await this.launchFromArgs({ cwd, argv, secondInstance: true })) {
275+
protected override async onSecondInstance(
276+
event: ElectronEvent,
277+
argv: string[],
278+
cwd: string
279+
): Promise<void> {
280+
if (
281+
!os.isOSX &&
282+
(await this.launchFromArgs({ cwd, argv, secondInstance: true }))
283+
) {
260284
// Application has received a file in its arguments
261285
return;
262286
}
@@ -268,7 +292,7 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
268292
*
269293
* @param options
270294
*/
271-
override async createWindow(
295+
override async createWindow(
272296
asyncOptions: MaybePromise<TheiaBrowserWindowOptions> = this.getDefaultTheiaWindowOptions()
273297
): Promise<BrowserWindow> {
274298
let options = await asyncOptions;
@@ -339,6 +363,9 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
339363
options.webPreferences = {};
340364
}
341365
options.webPreferences.v8CacheOptions = 'bypassHeatCheck'; // TODO: verify this. VS Code use this V8 option.
366+
options.useContentSize = true;
367+
options.minWidth = 680;
368+
options.minHeight = 565;
342369
return options;
343370
}
344371

@@ -456,8 +483,8 @@ export class ElectronMainApplication extends TheiaElectronMainApplication {
456483
isMaximized: window.isMaximized(),
457484
isFullScreen: window.isFullScreen(),
458485
file: workspaceUri.fsPath,
459-
time: now
460-
})
486+
time: now,
487+
});
461488
}
462489
});
463490
}

0 commit comments

Comments
 (0)