Skip to content
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

Refactor main bar inputs #528

Merged
merged 16 commits into from
Oct 3, 2018
Merged

Refactor main bar inputs #528

merged 16 commits into from
Oct 3, 2018

Conversation

karaggeorge
Copy link
Member

@karaggeorge karaggeorge commented Sep 26, 2018

Aims to fix the weird behaviors experienced with the main bar width/height/ratio inputs


Fixes #539

width: PropTypes.number,
height: PropTypes.number,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels a bit dirty that width can be both a number and a string...

@karaggeorge
Copy link
Member Author

@sindresorhus updated 👍

@sindresorhus
Copy link
Contributor

sindresorhus commented Sep 27, 2018

I still see some weird behavior even with this PR. I'm gonna include my feedback here, but I would be happy to move some of the points over to a new issue if you feel they're out of scope for this PR:

  • The cropper aspect ratio dropdown should not open right under wherever the mouse is, but rather open like a normal dropdown menu always placed underneath the input.
  • The same as above applies to the ... menu.
  • In the width/height input, if I use the down arrow key to go down from 10, it continues even to negative numbers. It should stop at 0.
  • The width/height input needs a minimum value. It makes no sense to support dimensions like 100 width and 0 height. I suggest 20 be the minimum as 20x20 is the smallest we can make the cropper without the drag handles overlapping.
  • Selecting an aspect ratio should active the width/height lock. Otherwise, what's the point of selecting aspect ratio if it's not enforced when you change width or height.
  • Putting the crop rectangle right at the right edge and then changing the width is not allowed and makes the width input shake. This should be allowed and the crop rectangle should just expand outwards to the left.
  • Similar as the above, if I make the crop rectangle 100x200 and then put it at the right edge, then click the swap button twice, the size has changed. The size should be the same as it was
  • With an aspect ratio set and the width/height lock on, if I click and hold the top-left drag handle and drag the mouse over to the top-right drag handle the cursor changes and it starts to resize from the top-right instead. The drag direction should not change during a drag operation.

@karaggeorge
Copy link
Member Author

These are good points. We've talked about most of them in the past and I've worked on some but last time I did was when I first started the re-write. I'll work on it a bit more, see how it goes, and if it seems like it's going to be a lot of extra work, I'll see about splitting into two PRs

@karaggeorge
Copy link
Member Author

This also fixes #539 now

@@ -85,6 +97,18 @@ MainControls.Left = connect(
)(Left);

class Right extends React.Component {
icon = React.createRef();

openMenu = () => {
Copy link
Contributor

@sindresorhus sindresorhus Sep 28, 2018

Choose a reason for hiding this comment

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

Should really make a reusable component for this as a Electron dropdown menu like this is used in many places.

@sindresorhus
Copy link
Contributor

@karaggeorge In #528 (comment), can you check the things you've fixed?

@karaggeorge
Copy link
Member Author

karaggeorge commented Sep 28, 2018

@sindresorhus it's all of them (hopefully) 😄 I went ahead and checked them though

Also, for the ratio menu I used the itemPositioning option of the menu api to show the selected one under the cursor. I saw it was osx specific, so I'm guessing is standard osx practice?

@sindresorhus
Copy link
Contributor

sindresorhus commented Sep 29, 2018

Also, for the ratio menu I used the itemPositioning option of the menu api to show the selected one under the cursor. I saw it was osx specific, so I'm guessing is standard osx practice?

Not cursor, but yes it's common practise to show it under the element that triggered the menu. It needs to be better aligned though. When the menu is open, the active menu item should be vertically centered to our white dropdown widget.

Example:

screen shot 2018-09-30 at 02 48 43

Notice how the active menu item is vertically centered with the dropdown button.

@sindresorhus
Copy link
Contributor

I'm getting this error every time I click the Kap menu bar icon:

screen shot 2018-09-30 at 02 45 20

@sindresorhus
Copy link
Contributor

Selecting an aspect ratio should active the width/height lock. Otherwise, what's the point of selecting aspect ratio if it's not enforced when you change width or height.

Doesn't look like this is done. If I select an item in the aspect ratio dropdown, the lock button is not highlighted.

@skllcrn
Copy link
Member

skllcrn commented Sep 30, 2018

I can't recreate the issue @sindresorhus is having when clicking the menubar icon, I can however confirm that selecting an spect ratio does not lock the dimensions, which I think it should.

Overall this is such a massive improvement, after testing the branch for a few days I haven't had a single issue with it and it feels great to use. The only thing I might add is for the inputs to only allow number input, however that's not really common practice. In a future update a nice to have would be the ability to do simple math in the inputs, e.g. 64+64 would change the input to 128 on enter/blur.

@skllcrn skllcrn self-requested a review September 30, 2018 16:58
@sindresorhus
Copy link
Contributor

@karaggeorge Can you fix the merge conflict?

@sindresorhus
Copy link
Contributor

I'm no longer getting the focus error when clicking the menu bar icon. Weird...

@sindresorhus
Copy link
Contributor

The only thing left is #528 (comment)

@karaggeorge
Copy link
Member Author

@sindresorhus I'll fix the merge conflicts when I get some down-time. About the other comment, I tried to get it as close to centered as I could. Bringing it one more pixel makes it even worse. Any idea of a consistent way to do it?

@sindresorhus
Copy link
Contributor

About the other comment, I tried to get it as close to centered as I could. Bringing it one more pixel makes it even worse. Any idea of a consistent way to do it?

Hmm, actually it looks enough for me now. Must have been something weird when I tried earlier as I could swear it was not aligned then.

@karaggeorge
Copy link
Member Author

Should be all good. Also, I found a bug where the validation was pulling the primary display screen's size instead of the one we sent through ipc. So in external displays, the cropper was limited to the primary display size. Should be fixed now

@sindresorhus sindresorhus merged commit 0a24c47 into master Oct 3, 2018
@sindresorhus sindresorhus deleted the fix-cropper-controls branch October 3, 2018 11:53
@sindresorhus
Copy link
Contributor

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crop window's starting point slightly off
3 participants