Dolphin Tip - Split a FramingLayout

By: Steve Waring
Home Pages: Journal Dolphinharbor
Created: 20021120
Last Update: 20021120

Overview

A Splitter is normally used with a Proportional LayoutManager, however it can be used with a FramingLayout which allows greater control when the view changes size.

frameSplitter

Background

I wanted a layout which would allow the user to change the proportions of subViews, but would not automatically resize a subView when the total size changed.

Jumping right in ...

I will often start building a view using the Border and Proportional LayoutManagers, but if I need more control I always look to the Framing LayoutManager.

I started by creating a new Shell subclass, changed the Shell's layoutManager to "FramingLayout" and added a Splitter. I set the arrangements as follows:

splitterArrange

Making the splitter the first subView will mean that we can make use of the "*Previous*" constraints for the following views. I added two containers and set the arrangements as follows:

c1Arrange

In the above screenshot the important arrangement is #rightFraming. This is set to #fixedPreviousLeft which attaches it to the left-side of the splitter.

c2Arrange

In the above screenshot the important arrangement is #leftFraming. This is set to #fixedPreviousRight which attaches it to the right-side of the first container (which is in turn attached to the left-side of the splitter). The #leftOffset is set to 5 so the splitter can be seen.

Does it work ??? ...

One way to find out, "show" the Shell and find out. It was looking good until my cursor passed over the splitter and I got this walkback:

debugger

(From the Debugging Views tip,) I follow these rules; 1/ Dont Panic, Dont terminate. 2/ Fix the source of the walkbacks 3/ Debug all walkbacks, returning defaults and "Go"ing.

This one is easy, hit the "Debug" button, implement #isVertical in FramingLayout to answer false, and hit "Go" (F5).

It works!

Clean up

We still need to deal with the method that was added in the debugger. While you could make it a loose method in one of your packages, I decided to add a subclass to FramingLayout with a single instanceVariable "isVertical" I created accessors and an initialize method, which initializes isVertical to be false. If you put your class in the "MVP-Layout Managers-General" class category, it will automatically show up in the ViewComposer.

Copyright Steve Waring 2002.