#
#  untitled
#
#  Created by backup on 2009-04-13.
#  Copyright (c) 2009 __MyCompanyName__. All rights reserved.
#

require 'yaml'
# require 'myshape'

Shoes.app do
  @images = {}
  @imagenames = %w(pcb-bottom)
  @imagenames.each do | imgname |
    para("#{imgname}.png")
    @images[imgname] = image("#{imgname}.png")
    # end
  end
  @boxes = []
  @buttons = {}
  @clickdown = rect :left => left, :top => top, :width => 0, :height => 0
  click do |button, left, top|
     @clickdown.left = left
     @clickdown.top = top
     tehRect = rect :left => left, :top => top, :width => 1, :height => 1
     @boxes << tehRect
     @buttons[button] = true
  end
  release do |button, left, top|
     box = @boxes[-1]
     box.left = [@clickdown.left, left].min()
     box.top = [@clickdown.top, top].min()
     box.width = (@clickdown.left - left).abs()
     box.height = (@clickdown.top - top).abs()
     @buttons[button] = false
  end
  motion do |left, top|
    if @buttons[1]
      box = @boxes[-1]
      box.left = [@clickdown.left, left].min
      box.top = [@clickdown.top, top].min
      box.width = (@clickdown.left - left).abs()
      box.height = (@clickdown.top - top).abs()
    end  
  end
end
