-
Notifications
You must be signed in to change notification settings - Fork 155
Implement sophisticated draggable window functionality #270
Conversation
* Implement sophisticated draggable window functionality, with ability to specify whether or not to remember the dragged window position. * New Window preferences UI also allows us to always open the window at a specified screen position (or to ignore this and always open in the center of the screen), or on a specified screen (for multi-screen environments).
@appetizermonster can you make me a member of the Hain organisation (https://github.com/hainproject) ? |
}, | ||
|
||
"posX": { | ||
"condition": ".position.positionWindow=='specified'", |
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.
@appetizermonster I tried a couple of different approaches but couldn't work out the best way to achieve this in the rendering code, but you can see what I'd like to achieve here.
I'd like some of these items to only be visible under specific conditions (as noted).
Is this something you'd be able to implement?
The feature is OK without it, but it'd make it nicer!
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'll review this issue sooner, before that I'll invite you for hain organization 😄
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.
How do you think about this shape of query like mongodb?
{
"condition": {
"$and": [
".position.positionWindow": {
"$eq": "specified"
},
".position.x": {
"$gte": 0.5
}
]
}
}
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 actually took the condition format from the docs for the existing json-schema docs (which we seem to be implementing?):
https://github.com/json-schema-form/json-schema-form/wiki/Documentation#condition
I'm not against implementing it as a different format, but thought that maybe you wanted to maintain compatibility with the json-schema specification.
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.
Looks great otherwise
@@ -81,6 +83,48 @@ module.exports = class MainWindow { | |||
this.hide(true); | |||
}); | |||
|
|||
// process list of available displays into user-friendly list | |||
const displays = electron.screen.getAllDisplays(); |
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.
This should be asynchronously handled so that it doesn't slow the load time. new Promise()...
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 can add this, but I just timed it and it takes 1.1ms
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.
1.1ms isn't a big deal, but this plus other startup items can add up over time, no worries though.
@@ -24,19 +26,51 @@ function centerWindowOnSelectedScreen(window, openOnActiveDisplay) { | |||
selectedDisplay = display; | |||
break; | |||
} | |||
} else if (openOnDisplay) { | |||
// specified screen ID, match ID against display object | |||
const displays = screen.getAllDisplays(); |
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.
This could be more succinctly written with an Array.find() such as:
selectedDisplay = screen.getAllDisplays()
.find((display) => display.id === openOnDisplay);
If screen.getAllDisplays()
doesn't return an array, you could use Array.from(..getAllDisplays())
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.
Done
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.
Code and functionality look great!
A minor suggestion: it would be nicer if the query textfield got focused after the window moved.
* Implement review feedback
* Implement review feedback
…ditional event fired on window hide, overwriting the expected window position. Introduce a lock variable that is reset after the hide has completed to avoid this issue.
@appetizermonster @cpriest please see latest changes |
Implements #241
Refactor preferences UI with a new "Window" page.
Implement sophisticated draggable window functionality, with ability to specify whether or not to remember the dragged window position.
New Window preferences UI also allows us to always open the window at a specified screen position (or to ignore this and always open in the center of the screen), or on a specified screen (for multi-screen environments).