lib/rubygoo/check_box.rb in rubygoo-0.0.5 vs lib/rubygoo/check_box.rb in rubygoo-0.0.6

- old
+ new

@@ -29,47 +29,57 @@ end end def check() @checked = true - fire :checked + fire :checked, self end def uncheck() @checked = false - fire :checked + fire :checked, self end # called when there is a mouse click def mouse_up(event) toggle end + # called when there is a mouse click at the end of a drag + def mouse_drag(event) + toggle + end + # called when a key press is sent to us def key_pressed(event) case event.data[:key] when K_SPACE toggle end end - def draw(screen) + def draw(adapter) + x1 = @rect[0] + y1 = @rect[1] + x2 = @rect[2] + x1 + y2 = @rect[3] + y1 if @focussed - screen.fill @focus_color, @rect + adapter.fill x1, y1, x2, y2, @focus_color elsif @bg_color - screen.fill @bg_color, @rect + adapter.fill x1, y1, x2, y2, @bg_color end if @checked - screen.fill @checked_color, @rect.inflate(-@x_pad,-@y_pad) + rect = @rect.inflate(-@x_pad,-@y_pad) + cx1 = rect[0] + cy1 = rect[1] + cx2 = rect[2] + x1 + cy2 = rect[3] + y1 + adapter.fill cx1, cy1, cx2, cy2, @checked_color end if @border_color - x1 = @rect[0] - y1 = @rect[1] - x2 = @rect[2] + x1 - y2 = @rect[3] + y1 - screen.draw_box x1, y1, x2, y2, @border_color + adapter.draw_box x1, y1, x2, y2, @border_color end end end end