royw-shoeshine 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -5,13 +5,14 @@ This is a collection of UI elements for shoes (http://shoooes.net).
5
5
  The collection currently includes:
6
6
 
7
7
  * UnorderedList is an unordered lists with various bullets
8
+ * with/without bullets
9
+ * vertical or horizontal orientation
8
10
  * ListItems is a handy wrapper for placing things in the list
9
11
  * DropDownMenu is an inplace drop down menu that can serve as popup menus
10
12
  * An example application to show them off with
11
13
 
12
14
  TODOs include:
13
15
  * ordered lists
14
- * horizontal lists
15
16
  * toolbar (horizontal list of icons)
16
17
  * maybe a menubar
17
18
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 2
3
3
  :major: 0
4
4
  :minor: 0
@@ -5,6 +5,7 @@ Shoes.setup do
5
5
  end
6
6
 
7
7
  require File.join(File.dirname(__FILE__), '..', 'lib', 'shoeshine')
8
+ $:.push(File.join(File.dirname(__FILE__)))
8
9
 
9
10
  require 'nav'
10
11
  require 'action'
@@ -2,6 +2,7 @@ require 'shoeshine/widget'
2
2
 
3
3
  class UnorderedListWidget
4
4
  include Widget
5
+ include Nav
5
6
 
6
7
  def initialize
7
8
  end
@@ -22,6 +23,12 @@ class UnorderedListWidget
22
23
  list_two({:bullet => List::STAR_BULLET})
23
24
  list_two({:bullet => List::PLUS_BULLET})
24
25
  end
26
+ app.stack(opt) do
27
+ list_horizontal({})
28
+ list_horizontal({:bullet => List::CIRCLE_BULLET})
29
+ list_horizontal({:bullet => List::STAR_BULLET})
30
+ list_horizontal({:bullet => List::PLUS_BULLET})
31
+ end
25
32
  end
26
33
  end
27
34
 
@@ -45,4 +52,17 @@ class UnorderedListWidget
45
52
  end
46
53
  end
47
54
 
55
+ def list_horizontal(options)
56
+ app.stack do
57
+ list = UnorderedList.new(app, options.merge(:orientation => :horizontal, :width => '100%'))
58
+ %w(alpha bravo charlie).each do |item|
59
+ list.add(ListItem.new(item))
60
+ end
61
+ %w(delta echo foxtrot).each do |item|
62
+ list.add(ListItem.new(item, :click => lambda{alert("#{item} clicked")}))
63
+ end
64
+ list.show
65
+ end
66
+ end
67
+
48
68
  end
@@ -10,46 +10,50 @@ class ListItem
10
10
  end
11
11
 
12
12
  def show(list_options={})
13
- item_opts = self.options
14
- right = (list_options[:margin_right].nil? ? 0 : list_options[:margin_right])
15
- left = 10
16
- bullet = @options[:bullet] || item_opts[:bullet] || list_options[:bullet]
17
- icon = @options[:image] || item_opts[:image] || list_options[:image]
18
- menu_items = @options[:menu_items] || item_opts[:menu_items] || list_options[:menu_items]
13
+ list_options ||= {}
14
+ show_options = list_options.merge(self.options)
15
+
16
+ bullet = show_options[:bullet]
17
+ icon = show_options[:image]
18
+ menu_items = show_options[:menu_items]
19
+
19
20
  indent = (bullet.nil? ? 0 : 15)
20
- app.flow(:margin_left => indent) do
21
- unless icon.nil?
22
- icon_image = app.image icon
23
- indent = icon_image.full_width + 5
24
- else
25
- unless bullet.nil?
26
- indent = 15
27
- List::BULLETS[bullet].call(app)
28
- end
29
- end
30
- app.stack do
31
- bg = item_opts[:background] || list_options[:background]
32
- unless bg.nil?
33
- app.background(bg, :margin_left => left)
34
- left += 5
35
- end
36
- unless menu_items.nil?
37
- menu_options = {
38
- :margin_top => 4,
39
- :margin_left => left,
40
- :margin_right => right,
41
- :margin_bottom => 0,
42
- :background => app.gainsboro,
43
- :border => app.gray
44
- }.merge(@options[:menu_options] || item_opts[:menu_options] || list_options[:menu_options] || {})
45
- trigger = @options[:menu_trigger] || DropDownMenuWidget::RIGHT_BUTTON
46
- menu = DropDownMenuWidget.new(app, self, trigger, menu_items, menu_options)
47
- menu.show
48
- else
49
- app.para(self.as_value(app), :margin_left => left, :margin_right => right, :margin_bottom => 0)
50
- end
21
+ right = (show_options[:margin_right].nil? ? 0 : show_options[:margin_right])
22
+ left = (show_options[:margin_left].nil? ? 10 : show_options[:margin_left])
23
+
24
+ unless icon.nil?
25
+ icon_image = app.image icon
26
+ indent = icon_image.full_width + 5
27
+ else
28
+ unless bullet.nil?
29
+ indent = 15
30
+ List::BULLETS[bullet].call(app)
51
31
  end
52
32
  end
33
+
34
+ unless show_options[:background].nil?
35
+ app.background(show_options[:background], :margin_left => left)
36
+ left += 5
37
+ end
38
+ unless menu_items.nil?
39
+ trigger = show_options[:menu_trigger] || DropDownMenuWidget::RIGHT_BUTTON
40
+ menu = DropDownMenuWidget.new(app, self, trigger, menu_items, menu_options(show_options))
41
+ menu.show
42
+ else
43
+ para_opts = {:margin_left => left, :margin_right => right, :margin_bottom => 0}
44
+ app.para(self.as_value(app), para_opts)
45
+ end
46
+ end
47
+
48
+ def menu_options(show_options)
49
+ {
50
+ :margin_top => 4,
51
+ :margin_left => (show_options[:margin_left].nil? ? 10 : show_options[:margin_left]),
52
+ :margin_right => (show_options[:margin_right].nil? ? 0 : show_options[:margin_right]),
53
+ :margin_bottom => 0,
54
+ :background => app.gainsboro,
55
+ :border => app.gray
56
+ }.merge(show_options[:menu_options])
53
57
  end
54
58
 
55
59
  def as_value(app)
@@ -19,14 +19,34 @@ class UnorderedList < List
19
19
  # :background => app.background argument
20
20
  # }
21
21
  def show(opts={})
22
- list_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?
22
+ show_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?
23
23
 
24
- app.stack(list_options) do
25
- @list_items.each do |item|
26
- item.app = app
27
- item.show @list_opts
24
+ orientation = show_options[:orientation]
25
+ orientation = :vertical if orientation.nil?
26
+ case orientation.to_sym
27
+ when :vertical
28
+ app.stack(show_options) do
29
+ @list_items.each do |item|
30
+ item.app = app
31
+ app.flow do
32
+ item.show @list_opts
33
+ end
34
+ end
28
35
  end
36
+ when :horizontal
37
+ app.flow(show_options) do
38
+ @list_items.each do |item|
39
+ item.app = app
40
+ app.stack(:width => 80) do
41
+ item.show @list_opts
42
+ end
43
+ end
44
+ end
45
+ else
46
+ app.error "Invalid orientation value: '#{orientation.to_s}'"
29
47
  end
30
48
  end
31
49
 
50
+ def show_items
51
+ end
32
52
  end
data/lib/shoeshine.rb CHANGED
@@ -5,8 +5,6 @@ $:.push(File.join(File.dirname(__FILE__)))
5
5
  # require 'singleton'
6
6
  # require 'ruby-debug'
7
7
 
8
- puts "shoeshine"
9
-
10
8
  require 'shoeshine/widget'
11
9
  require 'shoeshine/list'
12
10
  require 'shoeshine/list_item'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-shoeshine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roy Wright