# As shoes does not provide a listview, here's the start # of one. Yes, I know, pretty crude... module BulletList STAR_BULLET = :star CIRCLE_BULLET = :circle PLUS_BULLET = :plus SPACE_BULLET = :space BULLETS = { :star => lambda{|app| app.star(-6,13,5,6,3)}, :circle => lambda{|app| app.oval(-7,10,7)}, :plus => lambda do |app| # rect(x,y,w,h) NOTE, docs are wrong length = 9 beam = 1 app.rect(-5,8,beam,length,1) # vertical bar app.rect(-9,12,length,beam,1) # horizontal bar end, :space => lambda {|app| } } public # create the bullet list and return as a stack instance # values is an array of DirItem instances # # list_opts is a hash of options for the list itself # Example: # list_opts => { :bullet => lambda{ |filename| star_bullet } } # TODO a lot more docs here def bullet_list(values, list_opts={}) # app.stroke = app.black # app.fill = app.red app.stack(:margin_bottom => 10) do values.each do |dir_item| opts = dir_item.options slot_opts = {} slot_opts[:height] = opts[:height] unless opts[:height].nil? slot_opts[:scroll] = opts[:scroll] unless opts[:scroll].nil? right = 0 right += opts[:margin_right] unless opts[:margin_right].nil? left = 10 app.flow(:margin_left => 15) do unless list_opts[:bullet].nil? # app.debug "list_opts[:bullet] => #{list_opts[:bullet].inspect}.call(#{dir_item})" BULLETS[list_opts[:bullet].call(dir_item)].call(app) end app.stack(slot_opts) do if opts[:background] app.background(opts[:background], :margin_left => left) left += 5 end if opts[:click].nil? app.para(dir_item.path, :margin_left => left, :margin_right => right, :margin_bottom => 0) else app.para(app.link(dir_item.path, :click => opts[:click]), :margin_left => left, :margin_right => right, :margin_bottom => 0) end end end end end end end