Skip to content

Commit

Permalink
Reworked chapter 00506 - 00515, edited acknowledgments
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen428 committed Feb 17, 2009
1 parent a7bbab4 commit 2052d4f
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 50 deletions.
1 change: 1 addition & 0 deletions changelog.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,6 @@
Change log: Change log:
----------- -----------
Feb 17th, 2009: citizen428: edited chapters 00506 to 00515. <br>
Feb 16th, 2009: Merged citizen428's pull requests edited 00501 to 00505 and added sample 30-1, a tip of COLORS, into 00516. <br> Feb 16th, 2009: Merged citizen428's pull requests edited 00501 to 00505 and added sample 30-1, a tip of COLORS, into 00516. <br>
Feb 12th, 2009: Merged citizen428's pull requests edited 00300 to 00410. <br> Feb 12th, 2009: Merged citizen428's pull requests edited 00300 to 00410. <br>
Feb 10th, 2009: Clarified link to installation instructions in chapter 00200. <br> Feb 10th, 2009: Clarified link to installation instructions in chapter 00200. <br>
Expand Down
8 changes: 4 additions & 4 deletions mdowns/00506_Scope__A_tip_of_using_the_YAML_file.mdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Scope: A tip about using YAML files
![sample19.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample19.png) ![sample19.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample19.png)


The top-level namespace in any Shoes app is Shoes <br> The top-level namespace in any Shoes app is Shoes <br>
so in sample19.rb <br> so in the sample <br>


Gang = Struct.new :name, :country <br> Gang = Struct.new :name, :country <br>


It really make a Shoes::Gang struct, not a Gang struct, <br> we actually create a Shoes::Gang struct, not a Gang struct. <br>
so change that line to this and it (sample19-1.rb) works well. <br> To achieve the desired behavior, we will have to modify the statement like this (see sample19-1.rb). <br>


::Gang = Struct.new :name, :country <br> ::Gang = Struct.new :name, :country <br>


Modified code is Here you can see the updated example:




# sample19-1.rb # sample19-1.rb
Expand Down
23 changes: 10 additions & 13 deletions mdowns/00507_keypress,_mouse_and_clipboard.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,7 @@
keypress, mouse and clipboard keypress, mouse and clipboard
----------------------------- -----------------------------


We can get mouse events. A Shoes proggram can react to mouse events and interact with the system's clipboard.
We can get a string from the system clipboard and also store a string into the clipboard.


# sample20.rb # sample20.rb
Shoes.app :title => 'Sorter', :width => 180, :height => 80 do Shoes.app :title => 'Sorter', :width => 180, :height => 80 do
Expand All @@ -25,9 +24,9 @@ We can get a string from the system clipboard and also store a string into the c


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


An example of the output. <br> Let's hee see how this program manipulates the clipboard <br>


before: <br> *Before:* <br>
Creatures name list is: <br> Creatures name list is: <br>
looginkff <br> looginkff <br>
cy <br> cy <br>
Expand All @@ -37,21 +36,20 @@ shaha <br>


Copy the above list into the system clipboard. <br> Copy the above list into the system clipboard. <br>
Click Yar and she will rotate (\*1). <br> Click Yar and she will rotate (\*1). <br>
Then paste the clipboard text into the place you want. <br> Paste the clipboard text into the place you want. <br>




\*1: With Shoes-0.r925, Yar rotates well as expected. But with Shoes-0.r970, Yar rotates when the mouse moves out of the Shoes window. This behavior is a bug. It has been fixed in Shoes-0.r1057. <br> \*1: With Shoes-0.r925, Yar rotates as expected, but with Shoes-0.r970, Yar rotates when the mouse moves out of the Shoes window. This behavior is a bug. It has been fixed in Shoes-0.r1057. <br>
Oops, Shoes-0.r1091 behaves as same as Shoes-0.r970. Maybe it's a bug again...


after: <br> *After:* <br>
Creatures name list is: <br> Creatures name list is: <br>
cy <br> cy <br>
kamome <br> kamome <br>
loogink <br> loogink <br>
shaha <br> shaha <br>
yar <br> yar <br>


We can get keypress events. <br> How to work with keypress events: <br>


# sample21.rb # sample21.rb
Shoes.app :width => 250, :height => 40 do Shoes.app :width => 250, :height => 40 do
Expand All @@ -66,12 +64,11 @@ We can get keypress events. <br>


ATTENTION ATTENTION
--------- ---------
I'm not sure why... But may be a bug of Shows, I guess... Please be aware of the following behavior which may be cause by a bug in Shoes:


See the following snippet. <br> In the following code snippet, cases 1, 3 and 4 will crash. Case 2 works because it creates a new empty string object ('') which it assigns to `self.clipboard` instead of `p2.text` in case the latter is empty.
Case 1,3,4 will crash. Only case 2 is okay (not crash). Because it creates a new empty String object `''`, then assigns it to the `self.clipboard` instead of `p2.text` itself.


*I noticed this problem when I read the code of [rotten.rb](http://github.com/citizen428/littlesteps/blob/c15ee6a7838b962cbc64bbf3c1570d116bd9c9c1/rotten/rotten.rb) created by [Michael Kohl](http://citizen428.net/).* *This problem was discovered in the code of [rotten.rb](http://github.com/citizen428/littlesteps/blob/c15ee6a7838b962cbc64bbf3c1570d116bd9c9c1/rotten/rotten.rb) created by [Michael Kohl](http://citizen428.net/). It does not seem to affect Shoes on Mac OS X where the program is developed.*


# sample65.rb # sample65.rb
Shoes.app :width => 400, :height => 50 do Shoes.app :width => 400, :height => 50 do
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
the Widget class The Widget class
---------------- ----------------


A custom Shoes widget is set up by inheriting from the Widget class. A custom Shoes widget is set up by inheriting from the Widget class.
Expand Down Expand Up @@ -37,8 +37,8 @@ Shoes then creates a method using the lowercased name of the class which is used


One more example One more example
---------------- ----------------
We can use __:left__ and __:top__ without definition in the custom class attributes. We can use __:left__ and __:top__ without definition in the custom class attributes,
Because inherited from Shoes::Widget. because they are inherited from Shoes::Widget.


# sample49.rb # sample49.rb
class Shoes::Widgy < Shoes::Widget class Shoes::Widgy < Shoes::Widget
Expand All @@ -62,4 +62,4 @@ Because inherited from Shoes::Widget.


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


*Original idea is provided by Emanue Carnevale, in the Shoes ML.* *Original idea was provided by Emanue Carnevale, in the Shoes ML.*
12 changes: 5 additions & 7 deletions mdowns/00509_shape.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,7 @@
shape shape
----- -----


We can make arbitrary shapes, We can create arbitrary shapes, starting at the coordinates (left, top).
beginning at coordinates (left, top).


# sample23.rb # sample23.rb
Shoes.app :width => 140, :height => 120 do Shoes.app :width => 140, :height => 120 do
Expand All @@ -19,13 +18,12 @@ beginning at coordinates (left, top).


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


Oops, with Shoes-0.r925, it doesn't work well. <br> There seems to be a bug with Shoes-0.r925. Please note the difference in the two screenshots,
I'm not sure this behavior is the new spec or bug... <br> where the above was taken using Shoes-0.r905 and the second one using Shoes-0.r925.
The above screenshot is with Shoes-0.r905. <br>


**sample23-1.png** **sample23-1.png**


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


With Shoes-0.r970, it works well. Although it is a little bit different than the above pic... <br> From Shoes version 0.r-970 it seems to be working again, although the result doesn't exactly
After Shoes-0.r1057, it works like Shoes-0.r970. <br> look like the first image. After Shoes-0.r970 we are back to the 0.r-925 behavior.
5 changes: 2 additions & 3 deletions mdowns/00510_mask.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,9 @@
mask mask
---- ----


We can use a masking layer. See the following information. The use of a masking layer is described by Shoes' author _why in the folling article:


Cut Holes In Shoes And Get A Mask <br> [Cut Holes In Shoes And Get A Mask](http://hackety.org/2007/08/28/cutHolesInShoesAndGetAMask.html)
<http://hackety.org/2007/08/28/cutHolesInShoesAndGetAMask.html> <br>


# sample24.rb # sample24.rb
Shoes.app :width => 160, :height => 80 do Shoes.app :width => 160, :height => 80 do
Expand Down
8 changes: 4 additions & 4 deletions mdowns/00511_Drawing_directly_on_to_images.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,8 @@
Drawing directly onto images Drawing directly onto images
----------------------------- -----------------------------


We can add elements to images. <br> It's possible to add elements to an image. <br>
In the sample app below, Cy (green creature) has a star! <br> In the following example Cy (the green creature) had a star added to it.




# sample25.rb # sample25.rb
Expand Down Expand Up @@ -32,6 +32,6 @@ In the sample app below, Cy (green creature) has a star! <br>


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


If you are using Shoes-0.r970, you need move the mouse off of the image once. After that it works well. <br> Please note that if you are using Shoes-0.r970, you need to move the mouse off the image once. After that it will works as expected. <br>
With Shoes-0.r1057, there is no need to do that. With Shoes-0.r1057, there is no need to do this.


6 changes: 2 additions & 4 deletions mdowns/00512_Style.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
Style Style
----- -----


We can change the style of the element with the style method. Calling the style method with no arguments returns a hash of the styles presently applied to the element. We can change the style of an element with the style method, whereas calling the method without arguments returns a hash of the styles presently applied to the element.


More information can be found in section 6.3, Styling Master List More information can be found in section 6.3, Styling Master List


Expand Down Expand Up @@ -42,8 +42,7 @@ More information can be found in section 6.3, Styling Master List
![sample26.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample26.png) ![sample26.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample26.png)




We can style an entire class of elements at a time. :-D <br> We can style an entire class of elements at a time like this: <br>
But slot-by-slot would be impossible now. :(


# sample56.rb # sample56.rb
Shoes.app :width => 200, :height => 160 do Shoes.app :width => 200, :height => 160 do
Expand All @@ -60,4 +59,3 @@ But slot-by-slot would be impossible now. :(
![sample56.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample56.png) ![sample56.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample56.png)





7 changes: 3 additions & 4 deletions mdowns/00513_Shoes.setup.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,10 +1,9 @@
Shoes.setup Shoes.setup
----------- -----------


If your Shoes app requires some libraries, this might be useful. See the following information. If your Shoes app requires some libraries, this might be useful. See the following information:


Clearing Up The Whole Shoes And RubyGems Deal <br> [Clearing Up The Whole Shoes And RubyGems Deal](http://hackety.org/2008/05/08/clearingUpTheWholeShoesAndRubyGemsDeal.html)
<http://hackety.org/2008/05/08/clearingUpTheWholeShoesAndRubyGemsDeal.html> <br>




# sample27.rb # sample27.rb
Expand Down Expand Up @@ -40,4 +39,4 @@ One more example


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


*Original snippet was written by Massimiliano in the personal mail discussion.* *Original snippet was written by Massimiliano in a personal mail discussion.*
8 changes: 5 additions & 3 deletions mdowns/00514_Downloader.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,10 @@
Downloader Downloader
---------- ----------


The methods download and progress are so cool. <br> This method starts a download thread running in the background and displays a handy progress bar.
Although percent and length methods don't work well now, transferred and fraction work well. <br> Please keep in mind that the 'percent' and 'length' methods don't seem to work well at this time,
whereas 'transferred' and 'fraction' do.



# sample28.rb # sample28.rb
Shoes.app :width => 450, :height => 100 do Shoes.app :width => 450, :height => 100 do
Expand All @@ -26,5 +28,5 @@ Although percent and length methods don't work well now, transferred and fractio


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


For more information about downloader, see the built-in manual. <br>
Shoes includes the Hpricot library for parsing HTML. <br> Shoes includes the Hpricot library for parsing HTML. <br>
For more information about downloader, please consult the Shoes manual. <br>
3 changes: 1 addition & 2 deletions mdowns/00515_Assign_Shoes_URL_dynamically.mdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Assign Shoes URLs dynamically


We can use regular expressions to assign Shoes URLs dynamically. <br> We can use regular expressions to assign Shoes URLs dynamically. <br>
Shoes passes the match data to the method as the argument. <br> Shoes passes the match data to the method as the argument. <br>
The following sample code revises the above sample11.rb. <br> The following sample code modifies sample11.rb from before. <br>


# sample29.rb # sample29.rb
class PhotoFrame < Shoes class PhotoFrame < Shoes
Expand All @@ -29,4 +29,3 @@ The following sample code revises the above sample11.rb. <br>
Shoes.app :width => 200, :height => 120, :title => 'Photo Frame' Shoes.app :width => 200, :height => 120, :title => 'Photo Frame'


# sample29.png <br> # sample29.png <br>
is almost the same as the above sample11.png. <br>
8 changes: 6 additions & 2 deletions mdowns/01000_Acknowledgment.mdown
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,12 @@
Acknowledgment Acknowledgment
-------------- --------------
Under consideration... :)


*memo* *Authors:*

Satoshi Asakaw (aka ashbb): main author
Michael Kohl (aka citizen428): corrections, additions, clarifications

*Contributors:*


- Peter corrected the shoes\_course\_text file. - Peter corrected the shoes\_course\_text file.
- Michele corrected the ReadMeFirst file. - Michele corrected the ReadMeFirst file.
Expand Down

0 comments on commit 2052d4f

Please sign in to comment.