lib/molecules/intuition/utilities.rb in atome-0.5.7.5.1 vs lib/molecules/intuition/utilities.rb in atome-0.5.7.5.3

- old
+ new

@@ -147,10 +147,38 @@ box.left((box_width + spacing) * (index % matrix_cells.collect.length ** (0.5)) + spacing) box.top((box_height + spacing) * (index / matrix_cells.collect.length ** (0.5)).floor + spacing) end end + + def drop_down(params, &code) + data_f = params.delete(:data) + text_f = params.delete(:text) || {component: {size: 12}, color: :lightgray} + margin = params.delete(:margin) || 6 + default_params = { width: 150, + height: 25, + } + params=default_params.merge(params) + b=box(params) + item_height=(params[:height]+margin) + if text_f[:component][:size] > item_height + item_height = text_f[:component][:size]+margin*2 + end + b.height(data_f.length*item_height) + temp_width=0 + data_f.each_with_index do |label, index| + item_f= b.text(text_f.merge({ left: margin, data: label, position: :absolute, top: item_height * index + margin })) + if item_f.to_px(:width) > temp_width + temp_width=item_f.to_px(:width) + end + item_f.touch(:down) do + code.call(label) + b.delete(true) + end + end + b.width(temp_width+margin*2) + end end new(molecule: :input) do |params, bloc| params[:height] ||= 15 params[:width] ||= 222 @@ -666,12 +694,10 @@ end end new_page end - - new(molecule: :buttons) do |params, &bloc| keys_to_keep = [:inactive, :active] remaining_params = remove_key_pair_but(params, keys_to_keep) params = filter_keys_to_keep(params, keys_to_keep) @@ -705,6 +731,7 @@ label = part_f[:text] code = part_f[:code] main.create_new_button(item_id, index, label, code) end main -end \ No newline at end of file +end +