Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

add implementation for resizable panes, just solve the issue #274 #5902

Merged
merged 24 commits into from
Apr 15, 2015

Conversation

liuxiong332
Copy link
Contributor

this commit request implement resizable panes and achieve the feature of #274.

printscreen:
resizepane

approach

the approach is inserting resizable view (named pane-resize-handle-view) between two panes. when user move the resizable view, I will change the pane's flexGrow style value by two pane's width or height ratio. for example, if the left pane is 200px and the right pane is 600px, then I will modify flexGrow style to 0.5 and 1.5.
This way is like tree view's resizable view.

@@ -0,0 +1,67 @@
{$, View} = require 'atom-space-pen-views'
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove all references of view and jQuery? We're no longer using space pen or jQuery in core. In place of jQuery, please use the raw DOM APIs.

@benogle
Copy link
Contributor

benogle commented Mar 9, 2015

This looks interesting! A couple things before we can merge:

  • Can you please write some specs?
  • Please remove all references to jQuery and View

@liuxiong332
Copy link
Contributor Author

I have remove all references to jQeury and View @benogle and add specs for pane axis element to make sure the insertion logic of resizable view is correct.
But, I have no idea how to write specs for resizable element. Maybe the good test way is the UI test using some tools such as chrome driver, but now it cannot achieve.

@philipgiuliani
Copy link
Contributor

Really cool! Thanks for this :) Finally split-views make sense! 👏

event.preventDefault()
event.stopPropagation()
@getModel().activate()
pathsToOpen = _.pluck(event.dataTransfer.files, 'path')
Copy link
Contributor

Choose a reason for hiding this comment

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

You could write the following i think, so you could remove the dependency to _ (i just saw they are trying that in new packages currently)...

pathsToOpen = event.dataTransfer.files.map (file) -> file.path

See array.map

Update:
I just saw that dataTransfer.files returns a FileList, so array.map won't be available unless you convert it to one :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I have removed the dependency to _ and replaced with Array::map.

pathsToOpen = Array::map.call event.dataTransfer.files, (file) -> file.path

Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you push this change? I'm still seeing _ being used at the head of your branch.

Copy link
Contributor

Choose a reason for hiding this comment

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

He removed it in the second PR #5910

Copy link
Contributor

Choose a reason for hiding this comment

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

I really would like to merge this stuff, but I need a single consolidated PR with good test coverage first. Can someone else from the community collaborate on the test side of things?

@rmartin
Copy link
Contributor

rmartin commented Mar 13, 2015

hey @liuxiong332 ,

I had a chance to take a look at this today and overall this looks great. The approach I had taken was to integrate this within the resize-pane package, but that had several challenges when purely relying on the callbacks. I like the approach you took here of adding this to core and making the necessary changes to the Pane Axis to adjust the children. I also liked a few additions that I hadn't considered like double-click to balance the frames.

Overall this looks like a great fix and if this gets integrated into core then I can just shelve the work I was doing on the other package. Looking through your repo, it looks like you've also updated but not yet committed the resize-pane package to accommodated for this new approach, which is great.

I just had a few comments on my end based on my experience working on that the last few weeks, but nothing that should prevent moving forward with this.

  • Resize Pane Width - When doing research on determining what size this should be, I found Chris Coyier's approach helpful (http://codepen.io/chriscoyier/blog/design-is-hard). My suggestion would be to follow suite there with the height / width of the resize panes and adjust them from the current 8px down to 6px. This is an opinion more than anything but after playing around with them for a while this seemed like the 'right' size.
  • Rebalance Panes After Close - One thing I noted in your solution, that I also struggled with, is that after you resize a pane it 'retains' the flex width value. You took the similar approach that I did by clearing this out for the last element. One suggestion I would have is to 'rebalance' the panes when one of the panes close. This is also likely a minor item that can be improved in the future. Here is one scenario to see this would be to do the following:
    • Open a single editor, split right, split right. So you have three total panes.
    • resize the first pane so that it's smaller.
    • close the second and third pane
    • split right the first pane. Notice that because the first pane still has a flexbox width that the pane is not 50/50 width instead it retained the old value.
  • Spec Tests - One thing to add here would be to actually test a few different scenarios by splitting the panes. That way you can simulate the user scenarios of splitting the pane. Although it needed to be refactored, you can see this in action within this spec test. https://github.com/rmartin/resize-panes/blob/issue-7-resize-with-mouse/spec/resize-pane-view-spec.coffee

In either case, glad to see that this is getting added and if there is anything that I can do to help get that merged into core let me know. Overall great work.

Cheers,
Roy

@nathansobo
Copy link
Contributor

@simurai Can you weigh in on the design aspects of this? Note the thickened draggable border that's added between panes.

screenshot 2015-03-16 12 20 42

@liuxiong332 The updated pane size isn't being serialized down into the model, so it gets blown away on refresh. Could you explore adding that? We really want refresh to be a first-class concept so the view state is retained as much as possible when people do it.

createdCallback: ->
@classList.add('test-root')

TestItemElement = document.registerElement 'atom-test-item-element', prototype: TestItemElement.prototype
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be able to use a generic div element to test this rather than registering your own. Adding a custom element here adds complexity and it also can never be registered with the current custom elements API.

- Keeps most themes unaffected
- More consistent with the tree-view resizer
@simurai
Copy link
Contributor

simurai commented Mar 17, 2015

Note the thickened draggable border that's added between panes.

Wouldn't be a huge issue, but to keep most themes visually untouched, I made a PR on top of this one: liuxiong332#1 It removes the "thickened draggable border" and instead the atom-pane-resize-handle overlap the editors on each side a bit. Themes could still override it if the space between fits better.

resize-pane

@philipgiuliani
Copy link
Contributor

Looks really good @simurai :) Already happy to get this one merged!

absolute positions the pane resize-handles and overlap the editor
@liuxiong332
Copy link
Contributor Author

Looks good @simurai . Thank you!

@pitaj
Copy link

pitaj commented Mar 18, 2015

I implemented something like this as a temporary fix before this is merged

https://github.com/pitaj/atom-resize-panes/

leftPane.close()
expectPaneScale [rightPane, 1]

it "split or close panes in orthogonal direction", ->
Copy link
Contributor

Choose a reason for hiding this comment

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

splits or closes adjacent panes

Again, not sure if this is accurate

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just want to test that the scale of horizontal panes is not changed when the vertical panes are added or removed.

@nathansobo
Copy link
Contributor

/cc @maxbrunsfeld

@maxbrunsfeld
Copy link
Contributor

Thanks a lot @liuxiong332. A lot of people will be excited to have this feature.

maxbrunsfeld pushed a commit that referenced this pull request Apr 15, 2015
add  implementation for resizable panes, just solve the issue #274
@maxbrunsfeld maxbrunsfeld merged commit 632c57d into atom:master Apr 15, 2015
@philipgiuliani
Copy link
Contributor

Whaaat its mergeeed 💥 Thanks @liuxiong332 for working on this!! :)

@thomasjo
Copy link
Contributor

Awesome ⚡❗

@benogle
Copy link
Contributor

benogle commented Apr 15, 2015

🎉 🎉 Pulling and building...

@rmartin
Copy link
Contributor

rmartin commented Apr 15, 2015

Yahoo! well done @liuxiong332

@liuxiong332
Copy link
Contributor Author

Awesome!!

@jordiorlando
Copy link

Wow, fantastic work @liuxiong332!

@simurai
Copy link
Contributor

simurai commented Apr 16, 2015

😻

@liuxiong332 liuxiong332 deleted the pane-resize branch April 16, 2015 08:50
@mikemcbride
Copy link

👏 so pumped about this. awesome work @liuxiong332. thank you!

@atticoos
Copy link

👏 thanks @liuxiong332!

@trkoch
Copy link

trkoch commented Apr 22, 2015

Thanks @liuxiong332! One minor issue: The resize icon is not the same that appears when resizing the file drawer.

@nathansobo
Copy link
Contributor

One minor issue: The resize icon is not the same that appears when resizing the file drawer.

/cc @simurai on this slight inconsistency.

@chrishough
Copy link

I noticed this recently broke in the latest version of atom. I can no longer use cmd+alt-- to shrink or expand windows, thoughts?

@mmcintyre123
Copy link

Can you add this to atom in ubuntu? I'm running on ubuntu 14.04 LTS and atom 1.0.2 and none of the panes are resizable. Also commented on #274. Thanks!

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.