Skip to content

Commit f44125b

Browse files
committed
INT-663 extract windows size constants from window-manager.js
squashed: :bug: fix window config sizing
1 parent c939cfd commit f44125b

File tree

5 files changed

+46
-33
lines changed

5 files changed

+46
-33
lines changed

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ gulp.task('watch', function() {
9595
gulp.watch(['src/*.jade'], ['build:pages']);
9696
gulp.watch('images/{*,**/*}', ['copy:images']);
9797
gulp.watch('fonts/*', ['copy:fonts']);
98-
gulp.watch(['src/electron/*'], ['copy:js']);
98+
gulp.watch(['src/electron/{*,**/*}'], ['copy:js']);
9999
gulp.watch('package.json', function() {
100100
gutil.log('package.json changed!');
101101
sequence('copy:package.json', 'npm:install');
@@ -238,7 +238,7 @@ gulp.task('copy:js', function() {
238238
return merge(
239239
gulp.src(['main.js'])
240240
.pipe(gulp.dest('build/')),
241-
gulp.src(['src/electron/*'])
241+
gulp.src(['src/electron/{*,**/*}'])
242242
.pipe(gulp.dest('build/src/electron'))
243243
);
244244
});

src/connect/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var authFields = require('./auth-fields');
33
var sslFields = require('./ssl-fields');
44
var SidebarView = require('./sidebar');
55
var ConnectionCollection = require('../models/connection-collection');
6+
var config = require('../electron/config');
67

78
var format = require('util').format;
89
var $ = require('jquery');
@@ -90,11 +91,14 @@ var ConnectView = View.extend({
9091
},
9192
{
9293
type: function(el, authOpen) {
94+
var width = config.windows.DEFAULT_WIDTH_DIALOG;
95+
var height = config.windows.DEFAULT_HEIGHT_DIALOG;
9396
if (authOpen) {
94-
window.resizeTo(window.outerWidth, 630);
95-
} else {
96-
window.resizeTo(window.outerWidth, 410);
97+
// Account for extra height added by auth fields so
98+
// the user doesnt have to scroll.
99+
height += 220;
97100
}
101+
window.resizeTo(width, height);
98102
}
99103
}
100104
],

src/electron/config/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
windows: require('./windows')
3+
};

src/electron/config/windows.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Constants for window sizes on multiple platforms
3+
*/
4+
5+
/**
6+
* The outer dimensions to use for new windows.
7+
*/
8+
exports.DEFAULT_WIDTH = 1024;
9+
exports.DEFAULT_HEIGHT = 700;
10+
11+
/**
12+
* The outer window dimensions to use for new dialog
13+
* windows like the connection and setup dialogs.
14+
*/
15+
exports.DEFAULT_WIDTH_DIALOG = 640;
16+
exports.DEFAULT_HEIGHT_DIALOG = 470;
17+
/**
18+
* Adjust the heights to account for platforms
19+
* that use a single menu bar at the top of the screen.
20+
*/
21+
if (process.platform === 'linux') {
22+
exports.DEFAULT_HEIGHT_DIALOG -= 30;
23+
exports.DEFAULT_HEIGHT -= 30;
24+
} else if (process.platform === 'darwin') {
25+
exports.DEFAULT_HEIGHT_DIALOG -= 60;
26+
exports.DEFAULT_HEIGHT -= 60;
27+
}
28+
29+
module.exports = exports;

src/electron/window-manager.js

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var _ = require('lodash');
88
var app = require('app');
99
var attachMenu = require('./menu');
1010
var BrowserWindow = require('browser-window');
11+
var config = require('./config');
1112
var debug = require('debug')('scout-electron:window-manager');
1213

1314
/**
@@ -21,30 +22,6 @@ var RESOURCES = path.resolve(__dirname, '../../');
2122
*/
2223
var DEFAULT_URL = 'file://' + path.join(RESOURCES, 'index.html#connect');
2324

24-
/**
25-
* The outer dimensions to use for new windows.
26-
*/
27-
var DEFAULT_WIDTH = 1024;
28-
var DEFAULT_HEIGHT = 700;
29-
30-
/**
31-
* The outer window dimensions to use for new dialog
32-
* windows like the connection and setup dialogs.
33-
*/
34-
var DEFAULT_WIDTH_DIALOG = 640;
35-
var DEFAULT_HEIGHT_DIALOG = 470;
36-
/**
37-
* Adjust the heights to account for platforms
38-
* that use a single menu bar at the top of the screen.
39-
*/
40-
if (process.platform === 'linux') {
41-
DEFAULT_HEIGHT_DIALOG -= 30;
42-
DEFAULT_HEIGHT -= 30;
43-
} else if (process.platform === 'darwin') {
44-
DEFAULT_HEIGHT_DIALOG -= 60;
45-
DEFAULT_HEIGHT -= 60;
46-
}
47-
4825
/**
4926
* We want want the Connect dialog window to be special
5027
* and for there to ever only be one instance of it
@@ -71,8 +48,8 @@ var windowsOpenCount = 0;
7148
*/
7249
module.exports.create = function(opts) {
7350
opts = _.defaults(opts || {}, {
74-
width: DEFAULT_WIDTH,
75-
height: DEFAULT_HEIGHT,
51+
width: config.windows.DEFAULT_WIDTH,
52+
height: config.windows.DEFAULT_HEIGHT,
7653
url: DEFAULT_URL
7754
});
7855

@@ -135,8 +112,8 @@ app.on('show connect dialog', function(opts) {
135112

136113
opts = opts || {};
137114
opts = _.extend(opts || {}, {
138-
height: DEFAULT_HEIGHT_DIALOG,
139-
width: DEFAULT_WIDTH_DIALOG,
115+
width: config.windows.DEFAULT_WIDTH_DIALOG,
116+
height: config.windows.DEFAULT_HEIGHT_DIALOG,
140117
url: DEFAULT_URL
141118
});
142119
module.exports.create(opts);

0 commit comments

Comments
 (0)