green_shoes 1.0.303 → 1.0.309

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.303
1
+ 1.0.309
data/lib/green_shoes.rb CHANGED
@@ -60,6 +60,7 @@ require_relative 'plugins/thread'
60
60
  require_relative 'plugins/httpd'
61
61
  require_relative 'plugins/treeview'
62
62
  require_relative 'plugins/code_box'
63
+ require_relative 'plugins/video'
63
64
 
64
65
  autoload :ChipMunk, File.join(Shoes::DIR, 'ext/chipmunk')
65
66
  autoload :Bloops, File.join(Shoes::DIR, 'ext/bloops')
@@ -0,0 +1,90 @@
1
+ class Shoes
2
+ class Video
3
+ def initialize args
4
+ @initials = args
5
+ args.each do |k, v|
6
+ instance_variable_set "@#{k}", v
7
+ end
8
+ Video.class_eval do
9
+ attr_accessor *args.keys
10
+ end
11
+ args[:real].bus.add_watch do |b, message|
12
+ case message.type
13
+ when Gst::Message::EOS
14
+ @eos = true; pause
15
+ when Gst::Message::WARNING, Gst::Message::ERROR
16
+ p message.parse
17
+ else
18
+ #p message.type
19
+ end
20
+ true
21
+ end
22
+ @app.win.signal_connect('destroy'){@real.stop}
23
+ @stime = 0
24
+ end
25
+
26
+ def playing?
27
+ @eos ? false : @playing
28
+ end
29
+
30
+ def play
31
+ if @playing
32
+ self.time, @eos = 0, nil
33
+ else
34
+ @stime = clock_time - seek_time
35
+ @ready = @playing = true
36
+ (self.time, @eos = 0, nil) if @eos
37
+ end
38
+ @real.play
39
+ end
40
+
41
+ def pause
42
+ if @playing
43
+ @real.pause
44
+ @stime = clock_time - @stime
45
+ @playing = false
46
+ end
47
+ end
48
+
49
+ def stop
50
+ @eos = true
51
+ @real.stop
52
+ end
53
+
54
+ def time
55
+ seek_time / 1_000_000
56
+ end
57
+
58
+ def time=(ms)
59
+ if @ready
60
+ t = ms * 1_000_000
61
+ e = Gst::EventSeek.new 1.0, Gst::Format::TIME, Gst::Seek::FLAG_FLUSH,
62
+ Gst::SeekType::SET, t, Gst::SeekType::NONE, Gst::ClockTime::NONE
63
+ @real.send_event e
64
+ @stime = @playing ? clock_time - t : t
65
+ end
66
+ end
67
+
68
+ def seek_time
69
+ @playing ? clock_time - @stime : @stime
70
+ end
71
+
72
+ def clock_time
73
+ @real.clock ? @real.clock.time : 0
74
+ end
75
+ end
76
+ end
77
+
78
+ class Shoes
79
+ class App
80
+ def video uri
81
+ args = {}
82
+ uri = File.join('file://', uri.gsub("\\", '/').sub(':', '')) unless uri =~ /^(http|https|file):\/\//
83
+ require 'gst'
84
+ v = Gst::ElementFactory.make 'playbin2'
85
+ v.uri = uri
86
+ args[:real], args[:app] = v, self
87
+ Video.new args
88
+ end
89
+ end
90
+ end
@@ -64,14 +64,24 @@ class Shoes
64
64
  def basic_attributes args={}
65
65
  default = BASIC_ATTRIBUTES_DEFAULT
66
66
  default.merge!({nocontrol: true}) if @nolayout
67
+ replace_string_to_float args
67
68
  default.merge args
68
69
  end
69
70
 
70
71
  def slot_attributes args={}
71
72
  default = SLOT_ATTRIBUTES_DEFAULT
73
+ replace_string_to_float args
72
74
  default.merge args
73
75
  end
74
76
 
77
+ def replace_string_to_float args={}
78
+ [:width, :height, :left, :top].each do |k|
79
+ if args[k].is_a? String
80
+ args[k] = args[k].include?('%') ? args[k].to_f / 100 : args[k].to_i
81
+ end
82
+ end
83
+ end
84
+
75
85
  def create_tmp_png surface
76
86
  surface.write_to_png TMP_PNG_FILE
77
87
  Gtk::Image.new TMP_PNG_FILE
@@ -165,9 +175,11 @@ class Shoes
165
175
  next
166
176
  end
167
177
  tmp = max
168
- max = ele.positioning x, y, max
178
+ max, flag = ele.positioning x, y, max
169
179
  x, y = ele.left + ele.width, ele.top + ele.height
170
- slot_height += max.height unless max == tmp
180
+ unless max == tmp
181
+ slot_height = flag ? [slot_height, y].max : slot_height + max.height
182
+ end
171
183
  end
172
184
  slot_height
173
185
  end
data/lib/shoes/slot.rb CHANGED
@@ -58,10 +58,12 @@ class Shoes
58
58
  move3 x + parent.margin_left, max.top + parent.margin_top
59
59
  @height = Shoes.contents_alignment self
60
60
  max = self if max.height < @height
61
+ flag = true
61
62
  else
62
63
  move3 parent.left + parent.margin_left, max.top + max.height + parent.margin_top
63
64
  @height = Shoes.contents_alignment self
64
65
  max = self
66
+ flag = false
65
67
  end
66
68
  case @initials[:height]
67
69
  when 0
@@ -71,7 +73,7 @@ class Shoes
71
73
  max.height = @height = @initials[:height]
72
74
  end
73
75
  contents.each &:fix_size
74
- max
76
+ return max, flag
75
77
  end
76
78
 
77
79
  def fix_size; end
@@ -0,0 +1,24 @@
1
+ require '../lib/green_shoes'
2
+
3
+ Shoes.app width: 300, height: 100, title: 'Teeny-weeny MP3 player' do
4
+ space = ' '
5
+ background gold..cyan, angle: 30
6
+ song = para 'song.mp3', stroke: firebrick, left: 0, top: 70
7
+ file = 'https://github.com/ashbb/teeny-weeny_mp3_player/raw/master/samples/song.mp3'
8
+ v = video file
9
+
10
+ para link('select'){
11
+ unless v.playing?
12
+ f = ask_open_file
13
+ file = f if f
14
+ v = video file
15
+ song.text = fg(file.gsub("\\", '/').split('/').last, firebrick)
16
+ end
17
+ }, space, link('play'){v.play}, space, link('pause'){v.pause}, space, link('stop'){v.stop}
18
+
19
+ img = image Dir.pwd + '/loogink.png'
20
+ n = 0
21
+ animate 5 do
22
+ img.move (n+=1) % 300 , 40 - rand(10) if file && v.playing?
23
+ end
24
+ end
Binary file
Binary file
Binary file
data/static/manual-en.txt CHANGED
@@ -347,7 +347,7 @@ differently. To be sure that the end of the slot is chopped off perfectly, the
347
347
  slot becomes a '''nested window'''. A new layer is created by the operating
348
348
  system to keep the slot in a fixed square.
349
349
 
350
- On difference between normal slots and nested window slots is that the latter
350
+ One difference between normal slots and nested window slots is that the latter
351
351
  can have scrollbars.
352
352
 
353
353
  {{{
@@ -365,7 +365,7 @@ These nested windows require more memory. They tax the application a bit more.
365
365
  So if you're experiencing some slowness with hundreds of fixed-height slots,
366
366
  try a different approach.
367
367
 
368
- '''Note''': Fixed height magic (the slot becomes a nested window) is not implemented
368
+ '''Note:''' Fixed height magic (the slot becomes a nested window) is not implemented
369
369
  in Green Shoes so far. Scrollbar will appear automatically but at main window only.
370
370
 
371
371
  {{{
@@ -441,7 +441,7 @@ The point is: it's easy to group shapes together into image or shape blocks, so
441
441
  give it a try if you're looking to gain some speed. Shape blocks particularly
442
442
  will save you some memory and speed.
443
443
 
444
- '''NOTE''': Green Shoes doesn't support this magic (grouping shapes together
444
+ ''Note:'' Green Shoes doesn't support this magic (grouping shapes together
445
445
  into image or shape blocks) so far.
446
446
 
447
447
  ==== UTF-8 Everywhere ====
@@ -1023,7 +1023,7 @@ query google's search engine.
1023
1023
  As you can see from the above example, Green Shoes includes the Hpricot
1024
1024
  library for parsing HTML.
1025
1025
 
1026
- '''Note''': Windows platform only so far.
1026
+ '''Note:''' Windows platform only so far.
1027
1027
 
1028
1028
  === location() » a string ===
1029
1029
 
@@ -2319,9 +2319,7 @@ Creates a Title text block. Green Shoes styles these elements to 34 pixels high
2319
2319
 
2320
2320
  === video(path or url) » Shoes::Video ===
2321
2321
 
2322
- Embeds a movie in this slot.
2323
-
2324
- '''Note:''' Green Shoes doesn't support `video` method.
2322
+ Play some audio files.
2325
2323
 
2326
2324
  === window(styles) { ... } » Shoes::App ===
2327
2325
 
@@ -2805,8 +2803,6 @@ For specific commands, see the other links to the left in the Elements section.
2805
2803
  Like if you want to pause or play a video file, check the [[Video]] section,
2806
2804
  since pausing and playing is peculiar to videos. No sense pausing a button.
2807
2805
 
2808
- '''Note:''' Green Shoes doesn't support `video` method.
2809
-
2810
2806
  === displace(left: a number, top: a number) » self ===
2811
2807
 
2812
2808
  Displacing an element moves it. But without changing the layout around it.
@@ -3779,20 +3775,11 @@ already running, it is stopped.
3779
3775
 
3780
3776
  == Video ==
3781
3777
 
3782
- Shoes supports embedding of QuickTime, Flash video (FLV), DivX, Xvid and
3783
- various other popular video formats. This is all thanks to VideoLAN and ffmpeg,
3784
- two sensational open source libraries. Use the `video` method on a slot to
3785
- setup a Shoes::Video object.
3786
-
3787
- '''Note:''' Green Shoes doesn't support any video formats. !{:margin_left => 100}man-ele-video.png!
3778
+ Green Shoes is trying to support embedding of MP4 video format with Ruby/GStreamer.
3779
+ But for now, not available any video formats. Just available some audio formats,
3780
+ such as MP3 and Ogg Vorbis.
3788
3781
 
3789
- In addition to video formats, some audio formats are also supported, such as
3790
- MP3, WAV and Ogg Vorbis.
3791
-
3792
- Video support is optional in Shoes and some builds do not support video. For
3793
- example, video support is unavailable for PowerPC. When you download Shoes, the
3794
- build for your platform will be marked `novideo` in the filename if no video
3795
- support is available.
3782
+ '''Note:''' Green Shoes doesn't support any video formats so far. !{:margin_left => 70}man-ele-video.png!
3796
3783
 
3797
3784
  === hide() » self ===
3798
3785
 
@@ -3800,16 +3787,22 @@ Hides the video. If already playing, the video will continue to play. This just
3800
3787
  turns off display of the video. One possible use of this method is to collapse
3801
3788
  the video area when it is playing an audio file, such as an MP3.
3802
3789
 
3790
+ '''Note:''' Green Shoes doesn't support hide method so far.
3791
+
3803
3792
  === length() » a number ===
3804
3793
 
3805
3794
  The full length of the video in milliseconds. Returns nil if the video is not
3806
3795
  yet loaded.
3807
3796
 
3797
+ '''Note:''' Green Shoes doesn't support length method so far.
3798
+
3808
3799
  === move(left, top) » self ===
3809
3800
 
3810
3801
  Moves the video to specific coordinates, the (left, top) being the upper left
3811
3802
  hand corner of the video.
3812
3803
 
3804
+ '''Note:''' Green Shoes doesn't support move method so far.
3805
+
3813
3806
  === pause() » self ===
3814
3807
 
3815
3808
  Pauses the video, if it is playing.
@@ -3830,19 +3823,27 @@ The position of the video as a decimanl number (a Float) between the beginning
3830
3823
  (0.0) and the end (1.0). For instance, a Float value of 0.5 indicates the
3831
3824
  halfway point of the video.
3832
3825
 
3826
+ '''Note:''' Green Shoes doesn't support position method so far.
3827
+
3833
3828
  === position = a decimal ===
3834
3829
 
3835
3830
  Sets the position of the video using a Float value. To move the video to its
3836
3831
  25% position: `@video.position = 0.25`.
3837
3832
 
3833
+ '''Note:''' Green Shoes doesn't support position= method so far.
3834
+
3838
3835
  === remove() » self ===
3839
3836
 
3840
3837
  Removes the video from its slot. This will stop the video as well.
3841
3838
 
3839
+ '''Note:''' Green Shoes doesn't support remove method so far.
3840
+
3842
3841
  === show() » self ===
3843
3842
 
3844
3843
  Reveals the video, if it has been hidden by the `hide()` method.
3845
3844
 
3845
+ '''Note:''' Green Shoes doesn't support show method so far.
3846
+
3846
3847
  === stop() » self ===
3847
3848
 
3848
3849
  Stops the video, if it is playing.
@@ -3861,6 +3862,8 @@ Set the position of the video to a time in milliseconds.
3861
3862
  Toggles the visibility of the video. If the video can be seen, then `hide` is
3862
3863
  called. Otherwise, `show` is called.
3863
3864
 
3865
+ '''Note:''' Green Shoes doesn't support tobble method so far.
3866
+
3864
3867
  = AndSoForth =
3865
3868
 
3866
3869
  A place for some other information.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: green_shoes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.303
4
+ version: 1.0.309
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-19 00:00:00.000000000Z
12
+ date: 2011-10-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk2
16
- requirement: &16927836 !ruby/object:Gem::Requirement
16
+ requirement: &16500636 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16927836
24
+ version_requirements: *16500636
25
25
  description: Green Shoes is one of colorful Shoes, written in pure Ruby with Ruby/GTK2.
26
26
  email: ashbbb@gmail.com
27
27
  executables: []
@@ -66,6 +66,7 @@ files:
66
66
  - lib/plugins/systray.rb
67
67
  - lib/plugins/thread.rb
68
68
  - lib/plugins/treeview.rb
69
+ - lib/plugins/video.rb
69
70
  - lib/shoes/anim.rb
70
71
  - lib/shoes/app.rb
71
72
  - lib/shoes/basic.rb
@@ -203,6 +204,7 @@ files:
203
204
  - samples/sample55.rb
204
205
  - samples/sample56.rb
205
206
  - samples/sample57.rb
207
+ - samples/sample58.rb
206
208
  - samples/sample6.rb
207
209
  - samples/sample7.rb
208
210
  - samples/sample8.rb
@@ -268,6 +270,7 @@ files:
268
270
  - snapshots/sample55.png
269
271
  - snapshots/sample56.png
270
272
  - snapshots/sample57.png
273
+ - snapshots/sample58.png
271
274
  - snapshots/sample6.png
272
275
  - snapshots/sample7.png
273
276
  - snapshots/sample8.png
@@ -334,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
337
  version: '0'
335
338
  requirements: []
336
339
  rubyforge_project:
337
- rubygems_version: 1.7.2
340
+ rubygems_version: 1.8.10
338
341
  signing_key:
339
342
  specification_version: 3
340
343
  summary: Green Shoes