UI glitches in layout_view example
ColMcp opened this issue · comments
- 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 itsrect
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 assignmentrect = bounds
as the first line in #drawRect. Cocoa will clip the drawing to the original value ofrect
. - 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 addintValue => init_value,
to the slider creation options. The calls ofcreate_slider_layout
that create the 'Spacing' and 'Margin' sliders would supply the current values of win's spacing and margin attributes as initial values.