HotCocoa / hotcocoa

MacRuby HotCocoa UI library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UI glitches in layout_view example

ColMcp opened this issue · comments

  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.

Hi @ColMcp,

Sorry for not getting to this sooner. It's been a busy week. I've confirmed the problems and your fixes all work, so I'll apply them right away.

Thanks!