-
-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow window resizing down to 800x600 #502
Conversation
js/main.js
Outdated
const INNER_BOUNDS_WIDTH = 1340; | ||
const INNER_BOUNDS_HEIGHT = 900; | ||
const INNER_BOUNDS_WIDTH = 800; | ||
const INNER_BOUNDS_HEIGHT = 600; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add more parameters here.
They are used here:
blackbox-log-viewer/js/main.js
Lines 114 to 118 in 556198c
gui.Window.open(INITIAL_APP_PAGE, | |
{ | |
'min_width' : INNER_BOUNDS_WIDTH, | |
'min_height' : INNER_BOUNDS_HEIGHT, | |
}, |
And the parameters accepted are here: https://docs.nwjs.io/en/latest/References/Manifest%20Format/#window-subfields
The most important is id
, if we pass it, it will remember the latest position/size in theory, and it will use it for the new window.
We have one "id": "main" for the main window, but this, that are for additional windows, maybe we must have one id for them.
Something like :
const ID_SECONDARY_WINDOW = 'ID_SECONDARY_WINDOW';
...
gui.Window.open(INITIAL_APP_PAGE,
{
'id' : ID_SECONDARY_WINDOW,
'min_width' : INNER_BOUNDS_WIDTH,
'min_height' : INNER_BOUNDS_HEIGHT,
},
I think a better solution will be to add a number to the id, like:
- 'ID_ SECONDARY_WINDOW_1'
- 'ID_ SECONDARY_WINDOW_2'
- 'ID_ SECONDARY_WINDOW_3'
- ...
In this way it will remember various secondary windows positions and size, and they will be always the same if we open more than 1. But maybe we can let this for a future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the Chrome window, if we use the same ID for all maybe it simply focuses the window created: https://developer.chrome.com/docs/extensions/reference/app_window/#type-CreateWindowOptions
So maybe we need to go to the _1, _2, _3 version. If you can test it we can know more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your feedback ... I have no clue about JS or windows but will try :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a width and height that operates on opening a secondary window.
This is working really well.
After starting the app, the initial window opens at the same location and size as on the last run of the app. It can be resized down to 800x560. This is good.
With the secondary window code, when a secondary window is opened, it opens at the position of the most recent (previous) secondary window at 1000x760px. It also can be resized as small as 800x560. If it is closed, a new secondary window opens at the location of the previous secondary window. This too is good.
The only problem is that we can only create one single secondary window.
So I commented that out.
With it commented out, all secondary windows open centred at 1000x760, which is quite OK I think.
So either we put code with IDs 1_, 2_, 3_ for secondary windows, or keep it simple and have each open in the centre.
I think its OK opening secondary windows in centre, as now, and the code is simpler :-) So I'm happy with it working as it is now. If you're OK I can remove the secondary window code, which is commented out.
b88e463
to
472af72
Compare
I think the code now solves the issues that concerned me. |
0ad819e
to
9a96271
Compare
SonarCloud Quality Gate failed.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have an ID with _1, _2, etc. but your code is not worse than previous one, so to me is ok.
I would be happy with ID _1, _2 also... if you could demonstrate exactly the code required to do it, I will test it out. |
The best solution will be to remember "the latest" width an height of a window. Catching the "onclose" event and write it to the storage of the app. But to simplify the _1, _2, _3 solution I think will be enough. If you want to try it, to implement, simply declare a "windowCounter" variable, with value 0, at the top of the file: const WINDOW_ID = 'SECONDARY';
let windowCounter = 0; Then, increment it at each call: gui.Window.open(INITIAL_APP_PAGE,
{
'id' : `${WINDOW_ID}_${windowCounter++}`,
'width' : NEW_WINDOW_WIDTH,
'height' : NEW_WINDOW_HEIGHT,
'min_width' : INNER_BOUNDS_WIDTH,
'min_height' : INNER_BOUNDS_HEIGHT,
}, I think this will work. |
This PR is a quick and dirty one that allows re-sizing of Blackbox windows down to 800x600, so that I can easily view multiple log windows at once. Currently they cannot be made any smaller than 134x900.
I'm sure this is not the most elegant solution, but it works. I targeted all the instances of 1340x900 I could find :-)
The
chrome.background.js
file may not be required, I don't know what it does.The behaviour isn't ideal on my Mac. The initial window on launching BBE opens fairly large, but all new windows (after clicking the 'new window' button are 800x600, centred. They don't need to be that small on opening, could open the same size as the initial window, that would be fine.
I don't mind if windows open at 1340x900, I just wanted to be able to drag them to a smaller size; 800x600 allows quite a few windows open at once on a good screen, making it easy to compare multiple files at once.
Thanks!
PS: the window size changes may have been initiated in #450