green_shoes 1.1.348 → 1.1.354

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.348
1
+ 1.1.354
data/lib/ext/chipmunk.rb CHANGED
@@ -1,4 +1,8 @@
1
- require_relative 'chipmunk/chipmunk'
1
+ begin
2
+ require 'chipmunk'
3
+ rescue LoadError
4
+ require_relative 'chipmunk/chipmunk'
5
+ end
2
6
 
3
7
  module ChipMunk
4
8
  def cp_space
data/lib/plugins/video.rb CHANGED
@@ -105,6 +105,7 @@ class Shoes
105
105
  require 'win32api'
106
106
  v = Gst::ElementFactory.make 'playbin2'
107
107
  v.video_sink = Gst::ElementFactory.make('dshowvideosink')
108
+ v.video_sink = Gst::ElementFactory.make('directdrawsink') unless v.video_sink
108
109
  v.uri = uri
109
110
  args[:real], args[:app] = v, self
110
111
  Video.new args
data/lib/shoes/app.rb CHANGED
@@ -31,7 +31,7 @@ class Shoes
31
31
  attr_accessor :cslot, :cmask, :top_slot, :contents, :canvas, :app, :mccs, :mrcs, :mmcs,
32
32
  :mhcs, :mlcs, :shcs, :mcs, :win, :swin, :width_pre, :height_pre, :order, :dics, :fronts, :backs, :focusables, :focus_ele
33
33
  attr_writer :mouse_button, :mouse_pos
34
- attr_reader :link_style, :linkhover_style, :animates, :owner, :textcursors, :textmarkers, :location
34
+ attr_reader :link_style, :linkhover_style, :animates, :owner, :textcursors, :textmarkers, :location, :pinning_elements
35
35
 
36
36
  def visit url
37
37
  if url =~ /^(http|https):\/\//
@@ -178,7 +178,7 @@ class Shoes
178
178
  d = download name, save: tmpname
179
179
  img = Gtk::Image.new File.join(DIR, '../static/downloading.png')
180
180
  downloading = true
181
- elsif name =~ /\.(png|jpg|gif)$/
181
+ elsif name =~ /\.(png|jpg|gif|PNG|JPG|GIF)$/
182
182
  img = Gtk::Image.new name
183
183
  downloading = false
184
184
  else
@@ -634,7 +634,7 @@ class Shoes
634
634
  end
635
635
 
636
636
  def rgb r, g, b, l=1.0
637
- (r < 1 and g < 1 and b < 1) ? [r, g, b, l] : [r/255.0, g/255.0, b/255.0, l]
637
+ (r <= 1 and g <= 1 and b <= 1) ? [r, g, b, l] : [r/255.0, g/255.0, b/255.0, l]
638
638
  end
639
639
 
640
640
  %w[fill stroke strokewidth].each do |name|
@@ -690,7 +690,7 @@ class Shoes
690
690
  end
691
691
 
692
692
  def background pat, args={}
693
- pat = eval(pat) if pat.is_a?(String) and !((File.extname(pat).downcase) =~ /\.[png|jpg|gif]/)
693
+ pat = eval(pat) if pat.is_a?(String) and !((File.extname(pat).downcase) =~ /\.[png|jpg|gif|PNG|JPG|GIF]/)
694
694
  args[:pattern] = pat
695
695
  args = basic_attributes args
696
696
 
@@ -772,6 +772,24 @@ class Shoes
772
772
  @swin.vscrollbar.value = n
773
773
  end
774
774
 
775
+ def scrolled?
776
+ @_scroll_top ||= 0
777
+ d = scroll_top - @_scroll_top
778
+ @_scroll_top = scroll_top
779
+ d.zero? ? false : d
780
+ end
781
+
782
+ def scrolled=(n)
783
+ @_scroll_top = n
784
+ end
785
+
786
+ def pinning *eles
787
+ eles.each do |ele|
788
+ ele.is_a?(Basic) ? (@pinning_elements << ele) : ele.contents.each{|e| (@pinning_elements << e) if e.is_a? Basic}
789
+ end
790
+ @pinning_elements.uniq!
791
+ end
792
+
775
793
  def gutter
776
794
  @swin.vscrollbar.size_request.first
777
795
  end
@@ -36,8 +36,8 @@ class Shoes
36
36
 
37
37
  module Mod2
38
38
  def init_app_vars
39
- @contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups, @textcursors, @textmarkers, @fronts, @backs, @focusables =
40
- [], [], [], [], [], [], [], [], [], [], [], {}, {}, {}, [], [], []
39
+ @contents, @mccs, @mrcs, @mmcs, @mhcs, @mlcs, @shcs, @mcs, @order, @dics, @animates, @radio_groups, @textcursors, @textmarkers, @fronts, @backs, @focusables, @pinning_elements =
40
+ [], [], [], [], [], [], [], [], [], [], [], {}, {}, {}, [], [], [], []
41
41
  @cmask, @focus_ele, @location = nil, nil, '/'
42
42
  @mouse_button, @mouse_pos = 0, [0, 0]
43
43
  @fill, @stroke = black, black
@@ -400,7 +400,7 @@ class Shoes
400
400
  app.dics.each do |e, d, tmpname|
401
401
  args = e.args
402
402
  if d.finished?
403
- flag = true
403
+ flag = true
404
404
  app.canvas.remove e.real
405
405
  img = Gtk::Image.new tmpname
406
406
  e.full_width, e.full_height = img.size_request
@@ -417,4 +417,10 @@ class Shoes
417
417
  end
418
418
  flag
419
419
  end
420
+
421
+ def self.pinning_control app
422
+ if d = app.scrolled?
423
+ app.pinning_elements.each{|e| e.move e.left, e.top + d}
424
+ end
425
+ end
420
426
  end
data/lib/shoes/main.rb CHANGED
@@ -96,6 +96,7 @@ class Shoes
96
96
  app.width_pre, app.height_pre = app.width, app.height
97
97
  end
98
98
  show_hide_control app
99
+ pinning_control app
99
100
  set_cursor_type app
100
101
  end
101
102
  true
data/lib/shoes/style.rb CHANGED
@@ -21,6 +21,7 @@ class Shoes
21
21
 
22
22
  class ShapeBase
23
23
  def style args
24
+ args.each{|k, v| send("#{k}=", v) if self.class.method_defined? "#{k}="}
24
25
  real.clear
25
26
  @args[:nocontrol] = @args[:noorder] = true
26
27
  m = self.class.to_s.downcase[7..-1]
data/lib/shoes/text.rb CHANGED
@@ -10,7 +10,7 @@ class Shoes
10
10
  define_method m do |*str|
11
11
  color = str.pop
12
12
  str = str.join
13
- rgb = color[0, 3].map{|e| (e*255.0).to_i}.map{|i| sprintf("%#02X", i)[-2,2]}.join
13
+ rgb = color[0, 3].map{|e| (e*255.0).to_i}.map{|i| sprintf("%02X", i)[-2,2]}.join
14
14
  "<span #{tag}='##{rgb}'>#{str}</span>"
15
15
  end
16
16
  end
data/samples/sample36.rb CHANGED
@@ -24,6 +24,7 @@ class Book < Shoes
24
24
 
25
25
  def incident num
26
26
  self.scroll_top = 0
27
+ self.scrolled = 0
27
28
  num = num.to_i
28
29
  stack margin_left: 190 do
29
30
  banner "Incident"
@@ -32,7 +33,7 @@ class Book < Shoes
32
33
 
33
34
  flow do
34
35
  flow width: 180, margin_left: 10 do
35
- para *table_of_contents, size: 8
36
+ pinning para( *table_of_contents, size: 8 )
36
37
  end
37
38
 
38
39
  stack width: -180, margin_left: 10 do
data/samples/sample58.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'green_shoes'
2
2
 
3
- Shoes.app width: 300, height: 100, title: 'Teeny-weeny MP3 player' do
3
+ Shoes.app width: 300, height: 100, title: 'Teeny-weeny Audio player' do
4
4
  space = ' '
5
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'
6
+ song = para 'song.ogg', stroke: firebrick, left: 0, top: 70
7
+ file = 'http://www.rin-shun.com/shoes/song.ogg'
8
8
  v = video file
9
9
 
10
10
  para link('select'){
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.1.348
4
+ version: 1.1.354
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-12-23 00:00:00.000000000 Z
12
+ date: 2012-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gtk2
16
- requirement: &14175360 !ruby/object:Gem::Requirement
16
+ requirement: &17359116 !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: *14175360
24
+ version_requirements: *17359116
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: