Skip to content
This repository has been archived by the owner on Jun 29, 2019. It is now read-only.

Implement sophisticated draggable window functionality #270

Merged
merged 9 commits into from
Jun 11, 2018

Conversation

dannya
Copy link
Member

@dannya dannya commented Jun 9, 2018

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).

* 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).
@dannya
Copy link
Member Author

dannya commented Jun 9, 2018

@appetizermonster can you make me a member of the Hain organisation (https://github.com/hainproject) ?

},

"posX": {
"condition": ".position.positionWindow=='specified'",
Copy link
Member Author

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!

Copy link
Collaborator

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 😄

Copy link
Collaborator

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
      }
    ]
  }
} 

Copy link
Member Author

@dannya dannya Jun 10, 2018

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.

Copy link
Member

@cpriest cpriest left a 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();
Copy link
Member

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()...

Copy link
Member Author

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

Copy link
Member

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();
Copy link
Member

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())

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator

@appetizermonster appetizermonster left a 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.

…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.
@dannya
Copy link
Member Author

dannya commented Jun 10, 2018

@appetizermonster @cpriest please see latest changes

@dannya dannya merged commit dcd3ba0 into develop Jun 11, 2018
@dannya dannya deleted the feature/draggable-window branch June 11, 2018 20:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants