ferrous26/hotcocoa — Issue #39: UI glitches in layout_view example
Author: ColMcp
Created: 2011-10-31 12:47:56+00:00
State: open

1. The example sometimes draws incorrectly-sized MyView instances. For example, build and run the app and without touching any of the other controls click 'Add view' twice. After the second click the '1' view will have a smaller version of itself superimposed on the original version. The reason is that ```MyView#drawRect``` assumes that its ```rect``` parameter represents the whole view but it actually represents that part of its view that Cocoa is asking it to redraw. Since MyView instances are not very big I think a suitable fix is to insert the assignment ```rect = bounds``` as the first line in #drawRect. Cocoa will clip the drawing to the original value of ```rect```.

2. The 'Spacing' and 'Margin' sliders are drawn with initial values of 0 but that does not match the default values of 10 set up for the window 'win'. One fix would be to set win's spacing and margin values to 0 on creation. An alternative would be to add an 'initial_value' parameter (with a default of 0) to ```create_slider_layout``` and add ```intValue => init_value, ``` to the slider creation options. The calls of ```create_slider_layout``` that create the 'Spacing' and 'Margin' sliders would supply the current values of win's spacing and margin attributes as initial values.