Skip to content

Commit

Permalink
Added a new chapter 00547.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbb committed May 30, 2010
1 parent d08629a commit 671469b
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 6 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -2,9 +2,7 @@ Shoes Tutorial Note
===================
**- For the Shoes App Rookie Creators -**

April 17th, 2010 by ashbb (Satoshi Asakawa), citizen428 (Michael Kohl), kotp (Victor H. Goff III)

**Note: Now under revising with Policeman!**
May 30th, 2010 by ashbb

Table of contents
-----------------
Expand Down Expand Up @@ -69,6 +67,7 @@ Table of contents
- [00544 recognize the enter-key pressed in the edit_line area (sample76.rb)](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00544_recognize_the_enter-key_pressed_in_the_edit_line_area.mdown)
- [00545 dash (sample77.rb)](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00545_dash.mdown)
- [00546 XMLRPC4R (sample78.rb, sample78-1.rb)](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00546_XMLRPC4R.mdown)
- [00547 scroll location control (sample79.rb, sample79-1.rb)](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00547_scroll_location_control.mdown)
6. Hot Topics in the Shoes ML and Shoooes.net
- [00601 External Fonts](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00601_External_Fonts.mdown)
- [00602 Locking edit\_box](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00602_Locking_edit__box.mdown)
Expand Down
1 change: 1 addition & 0 deletions changelog.mdown
@@ -1,5 +1,6 @@
Change log:
-----------
May 30th, 2010: Added a new chapter 00547
Apr 17th, 2010: Added a new chapter 00546
Jan 31st, 2010: Added a new chapter 00545
Dec 13th, 2009: Added a new chapter 00544 and 00613
Expand Down
Binary file added images/sample79-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/sample79.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions inner_links.mdown
Expand Up @@ -60,6 +60,7 @@
- [00544 recognize the enter-key pressed in the edit_line area](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00544_recognize_the_enter-key_pressed_in_the_edit_line_area.mdown)
- [00545 dash](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00545_dash.mdown)
- [00546 XMLRPC4R](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00546_XMLRPC4R.mdown)
- [00547 scroll location control](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00547_scroll_location_control.mdown)
6. Hot Topics in the Shoes ML and Shoooes.net
- [00601 External Fonts](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00601_External_Fonts.mdown)
- [00602 Locking edit\_box](http://github.com/ashbb/shoes_tutorial_html/tree/master/mdowns/00602_Locking_edit__box.mdown)
Expand Down
69 changes: 69 additions & 0 deletions mdowns/00547_scroll_location_control.mdown
@@ -0,0 +1,69 @@
scroll location control
-----------------------

**Patrick Smith**'s post in Shoes-ML (shoes@librelist.com Sun, May 30, 2010 at 4:36 AM):

> I was wondering if there was a scroll location control for a para.
> For example, if you wanted to print out a phone book contact list
> (many screens in length) and wanted to start focused on a particular entry.
Interesting! So, let me try. :)

First attempt
-------------

# sample79.rb
Shoes.app width: 360, height: 360 do
stack top: 30, left: 30, width: 300, height: 300, scroll: true do
100.times do |i|
flow do
bg = background(pink).hide
para "phone number #{i}"
hover{bg.show}
leave{bg.hide}
click{alert "hi! no.#{i}"}
end
end
end
end

**sample79.png**

![sample79.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample79.png)

Looks good. But there was a problem Devyn and Cecil suggested:

> The problem is, if the list is huge, Shoes takes a long time to redraw
> (it draws everything, not just what's on screen.)
That's right.

Second shot
-----------

# sample79-1.rb
Shoes.app width: 360, height: 360 do
bgs = []
9.times do |i|
bgs << background(pink, top: 30+34*i, left: 30, width: 270, height: 30).hide
end
s = stack top: 30, left: 30, width: 300, height: 300, scroll: true do
1000.times{|i| para "phone number #{i}"}
end
9.times do |i|
flow top: 30+34*i, left: 30, width: 270, height: 30 do
border black
hover{bgs[i].show}
leave{bgs[i].hide}
click{alert "hi! no. #{s.scroll_top.zero? ? i : (s.scroll_top + 10) / 34 + i}"}
end
end
end

**sample79-1.png**

![sample79-1.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample79-1.png)

I know this is not an ultimate solution, but a little. ;-)
20 changes: 20 additions & 0 deletions src/sample79-1.rb
@@ -0,0 +1,20 @@
# sample79-1.rb
Shoes.app width: 360, height: 360 do
bgs = []
9.times do |i|
bgs << background(pink, top: 30+34*i, left: 30, width: 270, height: 30).hide
end

s = stack top: 30, left: 30, width: 300, height: 300, scroll: true do
1000.times{|i| para "phone number #{i}"}
end

9.times do |i|
flow top: 30+34*i, left: 30, width: 270, height: 30 do
border black
hover{bgs[i].show}
leave{bgs[i].hide}
click{alert "hi! no. #{s.scroll_top.zero? ? i : (s.scroll_top + 10) / 34 + i}"}
end
end
end
14 changes: 14 additions & 0 deletions src/sample79.rb
@@ -0,0 +1,14 @@
# sample79.rb
Shoes.app width: 360, height: 360 do
stack top: 30, left: 30, width: 300, height: 300, scroll: true do
100.times do |i|
flow do
bg = background(pink).hide
para "phone number #{i}"
hover{bg.show}
leave{bg.hide}
click{alert "hi! no.#{i}"}
end
end
end
end
5 changes: 2 additions & 3 deletions tools/table_of_contents.txt
Expand Up @@ -2,9 +2,7 @@ Shoes Tutorial Note
===================
**- For the Shoes App Rookie Creators -**

April 17th, 2010 by ashbb (Satoshi Asakawa), citizen428 (Michael Kohl), kotp (Victor H. Goff III)

**Note: Now under revising with Policeman!**
May 30th, 2010 by ashbb

Table of contents
-----------------
Expand Down Expand Up @@ -69,6 +67,7 @@ Table of contents
00544. recognize the enter-key pressed in the edit_line area
00545. dash
00546. XMLRPC4R
00547. scroll location control
00600.#Hot Topics in the Shoes ML and Shoooes.net
00601. External Fonts
00602. Locking edit\_box
Expand Down

0 comments on commit 671469b

Please sign in to comment.