Giter VIP home page Giter VIP logo

dmsplitview's Introduction

DMSplitView: Powerful NSSplitView subclass with animated transitions

===========

By Daniele Margutti

Introduction

DMSplitView is a revisited version of the standard OSX's NSSplitView control. The e problem with NSSplitView is that some things which should be simple require implementing unintuitive delegate methods, which gets to be pretty annoying. DMSplitView offer a powerful control over some important settings of NSSplitView such like:

  • subview's size and constraint (Specificy uniform, proportional, or priority-based resizing, min/max sizes for subviews)
  • dividers positions
  • collapsible subviews (specify whether a subview can collapse)
  • animatable transitions (both on dividers and subview's sizes)
  • control over divider thickness and style
  • save/restore state of dividers (using standard's OS X autosave feature)

Special thanks:

Contact

Daniele Margutti

License

DMSplitView is available under the MIT license. Copyright © 2013 Daniele Margutti Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

dmsplitview's People

Contributors

cbess avatar emiscience avatar jakepetroules avatar malcommac avatar tbaranes avatar terhechte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dmsplitview's Issues

applyPriorityResizeFromOldSize: can incorrectly skip height resizing on certain views

High level overview of the bug: You're using a dictionary for priorityIndexes, so you effectively loose sight of view indexes if you have 2 or more subviews set to the same priority.

Here was my specific scenario:
I have a vertical DMSplitView with 3 subviews. I want the middle subview to be resized when the window is resized, but I'd like the outer subviews to stay at a fixed size (unless they are manually resized).

So in my setup, I had the following priorities set for my subviews:
subview 0: 490
subview 1: 1
subview 2: 490

Because priorityIndexes uses priority as the key, it lost sight of subview 0 (because when I made the call to setPriority: 490 ofSubviewIndex: 2, that overwrote the entry in the dictionary for subview 0.

The main problem this created was that subview 0 would no longer get vertically resized because subview 0 wasn't in the priorityIndexes dictionary anymore.

The obvious workaround for my case was to simply set subview 2's priority to 489 and now it resizes as expected.

Message being sent to delegate when it should be sent to eventsDelegate

In the following method:

  • (BOOL) setPositions:(NSArray *)newPositions ofDividersAtIndexes:(NSArray *)indexes animated:(BOOL) animated completitionBlock:(void (^)(BOOL isEnded)) completition

near the top of that method, you have the following:

        if ([self.eventsDelegate respondsToSelector:@selector(splitView:splitViewIsAnimating:)])
            [((id <DMSplitViewDelegate>)self.delegate) splitView:self splitViewIsAnimating:YES];

You should be sending the call to splitView:splitViewIsAnimating: to self.eventsDelegate, but you are actually sending it to self.delegate

Sizes of views change on window resize

Hey,

I know this is not trivial and you may ignore me if this is to much work, but would be nice to have.

When the window resizes the views changes size also. It is desired that when window resized only the middle view should change size while the left and right view should stay at the same size. Check out XCode to see this behaviour.

Crashes when resizing window

Very nice controller. Thank you for sharing it. Right now it crashes when the window gets resized. In your demo you can test this by resizing the window down.

MaxSize is ignored

When dragging pane dividers, the MaxSize of a pane is not taken into consideration; only the MinSize.

MaxSize seems to not take effect on initial resize either.

Splitview inconsistent state error when using autoSaveName to restore state of split view

When you set an autoSaveName for the split view, collapse a view, then quit and re-launch the app, the following error is displayed:

<DMSplitView: 0x100192e20>: the delegate <DMSplitView: 0x100192e20> was sent -splitView:resizeSubviewsWithOldSize: and left the subview frames in an inconsistent state:
Split view bounds: {{0, 0}, {816, 337}}
Subview frame: {{0, 0}, {100, 337}}
Subview frame: {{110, 0}, {644, 337}}
Subview frame: {{764, 0}, {152, 337}}
DMSplitViewExample[41225:303] The outer edges of the subview frames are supposed to line up with the split view's bounds' edges. NSSplitView is working around the problem, perhaps at the cost of more redrawing. (This message is only logged once per NSSplitView.)

The same thing is happening in my app as happens in the example app.

Alignment bug with centre aligned subviews when toggling panels

If you have a subview within a panel that is supposed to be aligned centred (either no strut is selected or the top strut is the only one selected for Autosizing in Interface Builder), then when you toggle any of the panels, the subview will end up being right-aligned instead of maintaining its centre position.

For example, the initial view with the icons properly centred:

Screen Shot 2013-02-16 at 6 35 46 PM

Then after clicking on the Toggle buttons (left and right), it looks like this:

Screen Shot 2013-02-16 at 6 35 58 PM

It's happening in the example app and in my app that's using DMSplitView too.

I'm not sure what's causing this problem. It doesn't happen if you drag the left pane so it's fully closed, but it does with the right most pane. It also doesn't happen on the left pane if you double-click on the divider bar to collapse or expand the view.

Also, after this happens, no amount of dragging the divider bar will correct it. The subview (the icon in this case) is stuck to the right edge of its superview.

And it doesn't matter if you use animated transitions or not. Same problem.

Any workaround for this that you know of?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.