royw-shoeshine 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +2 -1
- data/VERSION.yml +1 -1
- data/examples/example_app.rb +1 -0
- data/examples/unordered_list_widget.rb +20 -0
- data/lib/shoeshine/list_item.rb +41 -37
- data/lib/shoeshine/unordered_list.rb +25 -5
- data/lib/shoeshine.rb +0 -2
- metadata +1 -1
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
data/examples/example_app.rb
CHANGED
@@ -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
|
data/lib/shoeshine/list_item.rb
CHANGED
@@ -10,46 +10,50 @@ class ListItem
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def show(list_options={})
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
bullet =
|
17
|
-
icon =
|
18
|
-
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
22
|
+
show_options = {:margin_bottom => 10}.merge(@list_opts.merge(opts)) unless opts.nil?
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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