rabbit 3.0.5 → 4.0.1

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.
Files changed (241) hide show
  1. checksums.yaml +4 -4
  2. data/data/locale/ja/LC_MESSAGES/rabbit.mo +0 -0
  3. data/doc/_config.yml +2 -2
  4. data/doc/en/news.rd +63 -0
  5. data/doc/ja/news.rd +63 -0
  6. data/lib/rabbit/actions.rb +446 -0
  7. data/lib/rabbit/author-configuration.rb +7 -10
  8. data/lib/rabbit/canvas.rb +74 -42
  9. data/lib/rabbit/command/rabbit-slide.rb +11 -13
  10. data/lib/rabbit/command/rabbit-theme.rb +10 -12
  11. data/lib/rabbit/command/rabbit.rb +31 -43
  12. data/lib/rabbit/console.rb +20 -22
  13. data/lib/rabbit/dependency-canvas.rb +2 -2
  14. data/lib/rabbit/element/base.rb +93 -6
  15. data/lib/rabbit/element/block-element.rb +17 -1
  16. data/lib/rabbit/element/block.rb +17 -1
  17. data/lib/rabbit/element/container-element.rb +59 -3
  18. data/lib/rabbit/element/description-list.rb +18 -2
  19. data/lib/rabbit/element/enum-list.rb +18 -2
  20. data/lib/rabbit/element/footnote.rb +18 -2
  21. data/lib/rabbit/element/image-title-slide.rb +17 -1
  22. data/lib/rabbit/element/image.rb +32 -2
  23. data/lib/rabbit/element/index-slide.rb +29 -13
  24. data/lib/rabbit/element/item-list.rb +18 -2
  25. data/lib/rabbit/element/method-list.rb +18 -2
  26. data/lib/rabbit/element/poppler-page.rb +17 -1
  27. data/lib/rabbit/element/poppler-slide.rb +18 -2
  28. data/lib/rabbit/element/poppler-title-slide.rb +18 -2
  29. data/lib/rabbit/element/preformatted.rb +18 -2
  30. data/lib/rabbit/element/slide-element.rb +29 -2
  31. data/lib/rabbit/element/slide.rb +18 -2
  32. data/lib/rabbit/element/syntax-highlighting.rb +17 -1
  33. data/lib/rabbit/element/table.rb +19 -3
  34. data/lib/rabbit/element/tag.rb +18 -2
  35. data/lib/rabbit/element/text-block-element.rb +18 -2
  36. data/lib/rabbit/element/text-container-element.rb +41 -2
  37. data/lib/rabbit/element/text-element.rb +17 -1
  38. data/lib/rabbit/element/text-renderer.rb +17 -1
  39. data/lib/rabbit/element/text.rb +4 -4
  40. data/lib/rabbit/element/title-slide.rb +19 -3
  41. data/lib/rabbit/element/video.rb +157 -56
  42. data/lib/rabbit/element.rb +20 -20
  43. data/lib/rabbit/formatter.rb +18 -1
  44. data/lib/rabbit/frame.rb +101 -93
  45. data/lib/rabbit/front.rb +11 -4
  46. data/lib/rabbit/gem-finder.rb +4 -8
  47. data/lib/rabbit/gem-pusher.rb +4 -4
  48. data/lib/rabbit/gesture/handler.rb +26 -21
  49. data/lib/rabbit/graffiti/config-dialog.rb +18 -2
  50. data/lib/rabbit/graffiti/processor.rb +20 -4
  51. data/lib/rabbit/gtk.rb +48 -14
  52. data/lib/rabbit/html/generator.rb +18 -18
  53. data/{test/helper/fixture.rb → lib/rabbit/icon.rb} +16 -6
  54. data/lib/rabbit/image/base.rb +7 -6
  55. data/lib/rabbit/image/default.rb +17 -1
  56. data/lib/rabbit/image/dia.rb +2 -2
  57. data/lib/rabbit/image/eps.rb +16 -2
  58. data/lib/rabbit/image/gimp.rb +28 -11
  59. data/lib/rabbit/image/mermaid.rb +3 -3
  60. data/lib/rabbit/image/pdf.rb +3 -3
  61. data/lib/rabbit/image/svg.rb +2 -2
  62. data/lib/rabbit/image.rb +8 -8
  63. data/lib/rabbit/info-window.rb +55 -18
  64. data/lib/rabbit/key-handler.rb +381 -0
  65. data/lib/rabbit/keys.rb +31 -2
  66. data/lib/rabbit/logger/base.rb +17 -1
  67. data/lib/rabbit/logger/gui.rb +20 -4
  68. data/lib/rabbit/logger/stderr.rb +16 -2
  69. data/lib/rabbit/logger.rb +4 -4
  70. data/lib/rabbit/menu.rb +200 -220
  71. data/lib/rabbit/parser/base.rb +17 -1
  72. data/lib/rabbit/parser/ext/aafigure.rb +17 -1
  73. data/lib/rabbit/parser/ext/blockdiag.rb +17 -1
  74. data/lib/rabbit/parser/ext/charty.rb +2 -2
  75. data/lib/rabbit/parser/ext/coderay.rb +20 -4
  76. data/lib/rabbit/parser/ext/enscript.rb +31 -15
  77. data/lib/rabbit/parser/ext/entity.rb +17 -1
  78. data/lib/rabbit/parser/ext/image.rb +6 -6
  79. data/lib/rabbit/parser/ext/inline.rb +17 -1
  80. data/lib/rabbit/parser/ext/rouge.rb +7 -4
  81. data/lib/rabbit/parser/ext/tex.rb +18 -2
  82. data/lib/rabbit/parser/ext/video.rb +4 -4
  83. data/lib/rabbit/parser/image.rb +20 -4
  84. data/lib/rabbit/parser/markdown/converter.rb +12 -13
  85. data/lib/rabbit/parser/markdown.rb +18 -2
  86. data/lib/rabbit/parser/pause-support.rb +1 -0
  87. data/lib/rabbit/parser/pdf.rb +3 -3
  88. data/lib/rabbit/parser/rd/ext/base.rb +20 -4
  89. data/lib/rabbit/parser/rd/ext/block-verbatim.rb +24 -28
  90. data/lib/rabbit/parser/rd/ext/character-reference.rb +18 -2
  91. data/lib/rabbit/parser/rd/ext/image.rb +3 -3
  92. data/lib/rabbit/parser/rd/ext/inline-verbatim.rb +6 -6
  93. data/lib/rabbit/parser/rd/ext/refer.rb +18 -2
  94. data/lib/rabbit/parser/rd/ext/video.rb +19 -2
  95. data/lib/rabbit/parser/rd/rd2rabbit-lib.rb +24 -8
  96. data/lib/rabbit/parser/rd/rt/rt2rabbit-lib.rb +18 -2
  97. data/lib/rabbit/parser/rd/visitor.rb +18 -2
  98. data/lib/rabbit/parser/rd.rb +18 -2
  99. data/lib/rabbit/parser/wiki/output.rb +25 -28
  100. data/lib/rabbit/parser/wiki.rb +18 -2
  101. data/lib/rabbit/parser.rb +6 -6
  102. data/lib/rabbit/path-manipulatable.rb +4 -4
  103. data/lib/rabbit/progress.rb +17 -1
  104. data/lib/rabbit/properties.rb +3 -3
  105. data/lib/rabbit/rabbit.rb +15 -7
  106. data/lib/rabbit/readme-parser.rb +4 -6
  107. data/lib/rabbit/renderer/base.rb +44 -36
  108. data/lib/rabbit/renderer/color.rb +18 -2
  109. data/lib/rabbit/renderer/display/base.rb +10 -12
  110. data/lib/rabbit/renderer/display/button-handler.rb +141 -60
  111. data/lib/rabbit/renderer/display/cursor.rb +4 -5
  112. data/lib/rabbit/renderer/display/drawing-area-base.rb +32 -48
  113. data/lib/rabbit/renderer/display/drawing-area-primitive.rb +10 -61
  114. data/lib/rabbit/renderer/display/drawing-area-view-only.rb +19 -8
  115. data/lib/rabbit/renderer/display/drawing-area.rb +19 -15
  116. data/lib/rabbit/renderer/display/gesture.rb +9 -9
  117. data/lib/rabbit/renderer/display/graffiti.rb +22 -13
  118. data/lib/rabbit/renderer/display/info.rb +22 -2
  119. data/lib/rabbit/renderer/display/magnifier.rb +30 -17
  120. data/lib/rabbit/renderer/display/mask.rb +17 -1
  121. data/lib/rabbit/renderer/display/menu.rb +27 -3
  122. data/lib/rabbit/renderer/display/motion-handler.rb +45 -0
  123. data/lib/rabbit/renderer/display/progress.rb +17 -2
  124. data/lib/rabbit/renderer/display/scroll-handler.rb +60 -13
  125. data/lib/rabbit/renderer/display/search.rb +19 -2
  126. data/lib/rabbit/renderer/display/spotlight.rb +39 -25
  127. data/lib/rabbit/renderer/display.rb +16 -36
  128. data/lib/rabbit/renderer/engine/cairo.rb +4 -11
  129. data/lib/rabbit/renderer/engine.rb +17 -1
  130. data/lib/rabbit/renderer/kernel.rb +2 -20
  131. data/lib/rabbit/renderer/offscreen.rb +8 -14
  132. data/lib/rabbit/renderer/print-layout.rb +2 -2
  133. data/lib/rabbit/renderer/printer.rb +9 -16
  134. data/lib/rabbit/renderer/scene-background-widget.rb +95 -0
  135. data/lib/rabbit/renderer/scene-node-widget.rb +63 -0
  136. data/lib/rabbit/renderer/scene.rb +508 -0
  137. data/lib/rabbit/renderer.rb +6 -6
  138. data/lib/rabbit/search-window.rb +18 -2
  139. data/lib/rabbit/searcher.rb +15 -1
  140. data/lib/rabbit/size.rb +9 -1
  141. data/lib/rabbit/slide-configuration.rb +11 -14
  142. data/lib/rabbit/soap/driver.rb +20 -4
  143. data/lib/rabbit/soap/server.rb +17 -1
  144. data/lib/rabbit/source/argf.rb +5 -5
  145. data/lib/rabbit/source/base.rb +5 -6
  146. data/lib/rabbit/source/file.rb +5 -5
  147. data/lib/rabbit/source/memory.rb +20 -4
  148. data/lib/rabbit/source/uri.rb +9 -11
  149. data/lib/rabbit/source-generator/hiki.rb +2 -7
  150. data/lib/rabbit/source-generator/markdown.rb +2 -7
  151. data/lib/rabbit/source-generator/rd.rb +2 -7
  152. data/lib/rabbit/source-generator.rb +4 -4
  153. data/lib/rabbit/source.rb +5 -5
  154. data/lib/rabbit/task/slide.rb +13 -11
  155. data/lib/rabbit/task/theme.rb +8 -11
  156. data/lib/rabbit/task.rb +3 -3
  157. data/lib/rabbit/theme/applier.rb +27 -11
  158. data/lib/rabbit/theme/clear-blue/clear-blue.rb +1 -1
  159. data/lib/rabbit/theme/color-circle/color-circle.rb +18 -1
  160. data/lib/rabbit/theme/cozmixng/cozmixng.rb +1 -1
  161. data/lib/rabbit/theme/default/default.rb +1 -0
  162. data/lib/rabbit/theme/default-icon/default-icon.rb +1 -1
  163. data/lib/rabbit/theme/default-item-mark-setup/default-item-mark-setup.rb +17 -1
  164. data/lib/rabbit/theme/default-preformatted/default-preformatted.rb +9 -1
  165. data/lib/rabbit/theme/enishi-green/enishi-green.rb +1 -1
  166. data/lib/rabbit/theme/entry.rb +10 -12
  167. data/lib/rabbit/theme/icon/icon.rb +3 -8
  168. data/lib/rabbit/theme/image-slide-number/image-slide-number.rb +5 -5
  169. data/lib/rabbit/theme/image-timer/image-timer.rb +3 -3
  170. data/lib/rabbit/theme/lightning-simple/lightning-simple.rb +1 -0
  171. data/lib/rabbit/theme/lightning-talk/lightning-talk.rb +1 -0
  172. data/lib/rabbit/theme/manager.rb +19 -9
  173. data/lib/rabbit/theme/rabbit-icon/rabbit-icon.rb +1 -1
  174. data/lib/rabbit/theme/ranguba/ranguba.rb +1 -1
  175. data/lib/rabbit/theme/red-frame/red-frame.rb +6 -2
  176. data/lib/rabbit/theme/ruby-gnome2/ruby-gnome2.rb +1 -0
  177. data/lib/rabbit/theme/ruby-gnome2-icon/ruby-gnome2-icon.rb +1 -1
  178. data/lib/rabbit/theme/searcher.rb +23 -7
  179. data/lib/rabbit/theme/slide-number/slide-number.rb +1 -1
  180. data/lib/rabbit/theme/slide-show/slide-show.rb +1 -1
  181. data/lib/rabbit/theme/table/table.rb +2 -2
  182. data/lib/rabbit/theme/video/property.rb +3 -0
  183. data/lib/rabbit/theme/video/video.rb +5 -0
  184. data/lib/rabbit/theme-configuration.rb +9 -11
  185. data/lib/rabbit/utils.rb +12 -94
  186. data/lib/rabbit/version.rb +1 -1
  187. data/lib/rabbit/xmlrpc/client.rb +17 -1
  188. data/lib/rabbit/xmlrpc/server.rb +17 -1
  189. data/po/en/rabbit.edit.po +324 -316
  190. data/po/en/rabbit.po +61 -55
  191. data/po/fr/rabbit.edit.po +324 -316
  192. data/po/fr/rabbit.po +61 -55
  193. data/po/ja/rabbit.edit.po +345 -370
  194. data/po/ja/rabbit.po +83 -80
  195. data/rabbit.gemspec +4 -2
  196. data/sample/block-quote.rab +13 -0
  197. data/sample/description-list.rab +17 -0
  198. data/sample/mermaid.rab +16 -0
  199. data/sample/rabbit-en.hiki +0 -1
  200. data/sample/rabbit-en.md +0 -1
  201. data/sample/rabbit-en.rd +0 -1
  202. data/sample/rabbit.hiki +0 -1
  203. data/sample/rabbit.md +0 -1
  204. data/sample/rabbit.rd +0 -1
  205. data/sample/video.rab +17 -0
  206. metadata +33 -65
  207. data/lib/rabbit/action/basic.rb +0 -304
  208. data/lib/rabbit/action/radio.rb +0 -78
  209. data/lib/rabbit/action/toggle.rb +0 -82
  210. data/lib/rabbit/action.rb +0 -140
  211. data/lib/rabbit/renderer/display/gl.rb +0 -98
  212. data/lib/rabbit/renderer/display/key-handler.rb +0 -321
  213. data/lib/rabbit/renderer/gl.rb +0 -95
  214. data/lib/rabbit/renderer/screen.rb +0 -286
  215. data/lib/rabbit/renderer/widget/drawing-area.rb +0 -93
  216. data/lib/rabbit/stock.rb +0 -31
  217. data/lib/rabbit/trackball.rb +0 -228
  218. data/lib/rabbit/video-window.rb +0 -123
  219. data/test/command/test-rabbit.rb +0 -101
  220. data/test/helper/parser.rb +0 -48
  221. data/test/helper.rb +0 -24
  222. data/test/image/test-dia.rb +0 -54
  223. data/test/image/test-eps.rb +0 -41
  224. data/test/parser/test-markdown.rb +0 -360
  225. data/test/parser/test-rd.rb +0 -43
  226. data/test/parser/test-wiki.rb +0 -71
  227. data/test/run-test.rb +0 -27
  228. data/test/source-generator/test-hiki.rb +0 -68
  229. data/test/source-generator/test-markdown.rb +0 -67
  230. data/test/source-generator/test-rd.rb +0 -69
  231. data/test/test-applier.rb +0 -73
  232. data/test/test-author-configuration.rb +0 -37
  233. data/test/test-canvas.rb +0 -70
  234. data/test/test-color.rb +0 -51
  235. data/test/test-element.rb +0 -103
  236. data/test/test-readme-parser.rb +0 -160
  237. data/test/test-size.rb +0 -155
  238. data/test/test-slide-configuration.rb +0 -74
  239. data/test/test-source.rb +0 -122
  240. data/test/test-theme-configuration.rb +0 -47
  241. data/test/test-utils.rb +0 -64
@@ -1,93 +0,0 @@
1
- # Copyright (C) 2006-2018 Kouhei Sutou <kou@cozmixng.org>
2
- #
3
- # This program is free software; you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation; either version 2 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
-
17
- require "rabbit/renderer/engine/cairo"
18
-
19
- module Rabbit
20
- module Renderer
21
- module Widget
22
- class DrawingArea
23
- include Engine::Cairo
24
-
25
- def initialize(canvas)
26
- @canvas = canvas
27
- @area = Gtk::DrawingArea.new
28
- clear_compiled_slides
29
- set_draw
30
- end
31
-
32
- def raw
33
- @area
34
- end
35
-
36
- def queue_redraw
37
- @area.queue_redraw
38
- end
39
-
40
- def clear_compiled_slide(slide=nil)
41
- @compiled_slides.delete(slide || @canvas.current_slide)
42
- end
43
-
44
- def clear_compiled_slides
45
- @compiled_slides = {}
46
- end
47
-
48
- def width
49
- @area.allocation.width
50
- end
51
-
52
- def height
53
- @area.allocation.height
54
- end
55
-
56
- private
57
- def set_draw
58
- @area.signal_connect(:draw) do |widget, context|
59
- init_context(context)
60
- draw(widget)
61
- finish_renderer
62
- Gdk::Event::PROPAGATE
63
- end
64
- end
65
-
66
- def draw(widget)
67
- draw_current_slide
68
- end
69
-
70
- def draw_current_slide
71
- slide = @canvas.current_slide
72
- if slide
73
- begin
74
- compile_slide(slide) unless compiled_slide?(slide)
75
- slide.draw(@canvas, false)
76
- rescue
77
- @canvas.logger.warn($!)
78
- end
79
- end
80
- end
81
-
82
- def compiled_slide?(slide)
83
- @compiled_slides.has_key?(slide)
84
- end
85
-
86
- def compile_slide(slide)
87
- @compiled_slides[slide] = true
88
- slide.draw(@canvas, true)
89
- end
90
- end
91
- end
92
- end
93
- end
data/lib/rabbit/stock.rb DELETED
@@ -1,31 +0,0 @@
1
- require 'rabbit/gtk'
2
-
3
- require 'rabbit/rabbit'
4
-
5
- module Rabbit
6
- module Stock
7
- include GetText
8
-
9
- RABBIT = "rabbit-rabbit"
10
-
11
- @@loaded = false
12
-
13
- module_function
14
- def init(canvas)
15
- return if @@loaded
16
- @@loaded = true
17
- Gtk::Stock.add(RABBIT.to_sym, N_("Rabbit"))
18
- begin
19
- image_theme = Theme::Searcher.find_theme("rabbit-images", true)
20
- file = Theme::Searcher.find_file("lavie-icon.png", [image_theme])
21
- loader = ImageLoader.new(file)
22
- loader.resize(32, 32)
23
- factory = Gtk::IconFactory.new
24
- factory.add(RABBIT, Gtk::IconSet.new(loader.pixbuf))
25
- factory.add_default
26
- rescue LoadError
27
- canvas.logger.warn($!)
28
- end
29
- end
30
- end
31
- end
@@ -1,228 +0,0 @@
1
- # Based on trackball.rb in the Logo demo code:
2
- # http://ruby-gnome2.sourceforge.jp/hiki.cgi?Logo
3
- #
4
- # Original code license is:
5
- #
6
- =begin
7
- trackball.rb
8
- Implementation of a virtual trackball and vector.
9
-
10
- Copyright (c) 2004 Masao Mutoh
11
-
12
- You can redistribute it and/or modify it under the terms of
13
- the original code license below.
14
-
15
- Original code license is:
16
-
17
- /*
18
- * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
19
- * ALL RIGHTS RESERVED
20
- * Permission to use, copy, modify, and distribute this software for
21
- * any purpose and without fee is hereby granted, provided that the above
22
- * copyright notice appear in all copies and that both the copyright notice
23
- * and this permission notice appear in supporting documentation, and that
24
- * the name of Silicon Graphics, Inc. not be used in advertising
25
- * or publicity pertaining to distribution of the software without specific,
26
- * written prior permission.
27
- *
28
- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
29
- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
30
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
31
- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
32
- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
33
- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
34
- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
35
- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
36
- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
37
- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
38
- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
39
- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
40
- *
41
- * US Government Users Restricted Rights
42
- * Use, duplication, or disclosure by the Government is subject to
43
- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
44
- * (c)(1)(ii) of the Rights in Technical Data and Computer Software
45
- * clause at DFARS 252.227-7013 and/or in similar or successor
46
- * clauses in the FAR or the DOD or NASA FAR Supplement.
47
- * Unpublished-- rights reserved under the copyright laws of the
48
- * United States. Contractor/manufacturer is Silicon Graphics,
49
- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
50
- *
51
- * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
52
- */
53
- /*
54
- * Trackball code:
55
- *
56
- * Implementation of a virtual trackball.
57
- * Implemented by Gavin Bell, lots of ideas from Thant Tessman and
58
- * the August '88 issue of Siggraph's "Computer Graphics," pp. 121-129.
59
- *
60
- * Vector manip code:
61
- *
62
- * Original code from:
63
- * David M. Ciemiewicz, Mark Grossman, Henry Moreton, and Paul Haeberli
64
- *
65
- * Much mucking with by:
66
- * Gavin Bell
67
- */
68
- =end
69
-
70
- module Rabbit
71
- module TrackBall
72
-
73
- class Vector < Array
74
- def vsub(other, range = nil)
75
- range = [size, other.size].min unless range
76
- (0...range).inject(Vector.new){|ret, i| ret << self[i] - other[i]}
77
- end
78
-
79
- def vcross(other)
80
- dst = Vector.new
81
- dst << (self[1] * other[2]) - (self[2] * other[1])
82
- dst << (self[2] * other[0]) - (self[0] * other[2])
83
- dst << (self[0] * other[1]) - (self[1] * other[0])
84
- end
85
-
86
- def vlength
87
- Math.sqrt(inject(0){|ret, i| ret + i ** 2})
88
- end
89
-
90
- def vscale(div); collect{|v| v *= div}; end
91
- def vnormal; vscale(1.0 / vlength); end
92
-
93
- def vdot(other, range = nil)
94
- range = [size, other.size].min unless range
95
- (0...range).inject(0.0){|ret, i| ret + self[i] * other[i]}
96
- end
97
-
98
- def vadd(other, range = nil)
99
- range = [size, other.size].min unless range
100
- (0...range).inject(Vector.new){|ret, i| ret << self[i] + other[i]}
101
- end
102
-
103
- #
104
- # Quaternions always obey: a^2 + b^2 + c^2 + d^2 = 1.0
105
- # If they don't add up to 1.0, dividing by their magnitued will
106
- # renormalize them.
107
- #
108
- # Note: See the following for more information on quaternions:
109
- #
110
- # - Shoemake, K., Animating rotation with quaternion curves, Computer
111
- # Graphics 19, No 3 (Proc. SIGGRAPH'85), 245-254, 1985.
112
- # - Pletinckx, D., Quaternion calculus as a basic tool in computer
113
- # graphics, The Visual Computer 5, 2-13, 1989.
114
- #
115
- def normalize_quat
116
- collect{|q| q = q / inject(0){|ret, i| ret + i ** 2}}
117
- end
118
-
119
- # Build a rotation matrix, given a quaternion rotation.
120
- def build_rotmatrix
121
- m = []
122
- m << [1.0 - 2.0 * (self[1] * self[1] + self[2] * self[2]),
123
- 2.0 * (self[0] * self[1] - self[2] * self[3]),
124
- 2.0 * (self[2] * self[0] + self[1] * self[3]), 0.0]
125
- m << [2.0 * (self[0] * self[1] + self[2] * self[3]),
126
- 1.0 - 2.0 * (self[2] * self[2] + self[0] * self[0]),
127
- 2.0 * (self[1] * self[2] - self[0] * self[3]), 0.0]
128
- m << [2.0 * (self[2] * self[0] - self[1] * self[3]),
129
- 2.0 * (self[1] * self[2] + self[0] * self[3]),
130
- 1.0 - 2.0 * (self[1] * self[1] + self[0] * self[0]), 0.0]
131
- m << [0.0, 0.0, 0.0, 1.0]
132
- m
133
- end
134
-
135
- # Given an axis and angle, compute quaternion.
136
- def axis_to_quat(phi)
137
- b, c, d = self.vnormal.vscale(Math.sin(phi/2.0))
138
- Vector.new([b, c, d, Math.cos(phi/2.0)])
139
- end
140
-
141
- def collect(&block)
142
- Vector.new(super)
143
- end
144
- end
145
-
146
- #
147
- # This size should really be based on the distance from the center of
148
- # rotation to the point on the object underneath the mouse. That
149
- # point would then track the mouse as closely as possible. This is a
150
- # simple example, though, so that is left as an Exercise for the
151
- # Programmer.
152
- #
153
- SIZE = 0.8
154
-
155
- module_function
156
- def trackball(p1x, p1y, p2x, p2y)
157
- if (p1x == p2x && p1y == p2y)
158
- return Vector.new([0.0, 0.0, 0.0, 1.0])
159
- end
160
-
161
- # First, figure out z-coordinates for projection of P1 and P2 to
162
- # deformed sphere
163
- p1 = Vector.new([p1x, p1y, tb_project_to_sphere(SIZE, p1x, p1y)])
164
- p2 = Vector.new([p2x, p2y, tb_project_to_sphere(SIZE, p2x, p2y)])
165
-
166
- # Now, we want the cross product of P1 and P2
167
- a = p2.vcross(p1)
168
-
169
- # Figure out how much to rotate around that axis.
170
- d = p1.vsub(p2)
171
- t = d.vlength / (2.0 * SIZE)
172
-
173
- # Avoid problems with out-of-control values...
174
- t = 1.0 if (t > 1.0)
175
- t = -1.0 if (t < -1.0)
176
- phi = 2.0 * Math.asin(t)
177
-
178
- a.axis_to_quat(phi)
179
- end
180
-
181
- #
182
- # Project an x,y pair onto a sphere of radius r OR a hyperbolic sheet
183
- # if we are away from the center of the sphere.
184
- #
185
- def tb_project_to_sphere(r, x, y)
186
- d = Math.sqrt(x * x + y * y)
187
- if (d < r * 0.70710678118654752440) # Inside sphere
188
- z = Math.sqrt(r * r - d * d)
189
- else # On hyperbola
190
- t = r / 1.41421356237309504880
191
- z = t * t / d
192
- end
193
- z
194
- end
195
-
196
- #
197
- # Given two rotations, e2 and e2, expressed as quaternion rotations,
198
- # figure out the equivalent single rotation and stuff it into dest.
199
- #
200
- # This routine also normalizes the result every RENORM_COUNT times it is
201
- # called, to keep error from creeping in.
202
- #
203
- # NOTE: This routine is written so that q1 or q2 may be the same
204
- # as dest (or each other).
205
- #
206
-
207
- RENORM_COUNT = 97
208
-
209
- @@quats_count = 0
210
- def add_quats(q1, q2)
211
- t1 = q1.vscale(q2[3])
212
- t2 = q2.vscale(q1[3])
213
- t3 = q2.vcross(q1)
214
- tf = t1.vadd(t2)
215
- tf = t3.vadd(tf)
216
-
217
- tf[3] = q1[3] * q2[3] - q1.vdot(q2, 3)
218
-
219
- @@quats_count += 1
220
- ret = tf
221
- if (@@quats_count > RENORM_COUNT)
222
- @@quats_count = 0
223
- ret = tf.normalize_quat
224
- end
225
- ret
226
- end
227
- end
228
- end
@@ -1,123 +0,0 @@
1
- # Copyright (C) 2012 Narihiro Nakamura <authornari@gmail.com>
2
- # Copyright (C) 2015-2018 Kouhei Sutou <kou@cozmixng.org>
3
- #
4
- # This program is free software; you can redistribute it and/or modify
5
- # it under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation; either version 2 of the License, or
7
- # (at your option) any later version.
8
- #
9
- # This program is distributed in the hope that it will be useful,
10
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- # GNU General Public License for more details.
13
- #
14
- # You should have received a copy of the GNU General Public License along
15
- # with this program; if not, write to the Free Software Foundation, Inc.,
16
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
-
18
- case ENV["RABBIT_GTK"]
19
- when "4"
20
- else
21
- require "clutter-gtk"
22
- require "clutter-gst"
23
- end
24
-
25
- require "rabbit/gtk"
26
-
27
- module Rabbit
28
- class VideoWindow
29
- # TODO: Implemented in renderer or something
30
- class << self
31
- def show(window, element)
32
- @instance ||= VideoWindow.new(window)
33
- @instance.show(element)
34
- end
35
-
36
- def unset_instance
37
- @instance = nil
38
- end
39
- end
40
-
41
- def initialize(window)
42
- @parent_window = window
43
- init_window
44
- init_keys
45
- end
46
-
47
- def show(element)
48
- @player.filename = element.filename
49
- @window.resize(element.width, element.height)
50
- @window.show_all
51
- @player.playing = true
52
- end
53
-
54
- private
55
- def init_window
56
- @window = Gtk::ApplicationWindow.new(Rabbit.application)
57
- @window.modal = true
58
- @window.set_transient_for(@parent_window)
59
-
60
- @embed = ClutterGtk::Embed.new
61
- @window.add(@embed)
62
-
63
- @stage = @embed.stage
64
- @player = ClutterGst::Playback.new
65
- @player.seek_flags = :accurate
66
- @player.signal_connect(:eos) do
67
- @player.progress = 0.0
68
- @player.playing = true
69
- end
70
-
71
- @aspect_ratio = ClutterGst::Aspectratio.new
72
- @aspect_ratio.player = @player
73
- @video = Clutter::Actor.new
74
- @video.width = @stage.width
75
- @video.height = @stage.height
76
- @video.content = @aspect_ratio
77
-
78
- @stage.add_child(@video)
79
-
80
- @window.signal_connect(:button_press_event) do |widget, event|
81
- @player.playing = !@player.playing?
82
- end
83
-
84
- @window.signal_connect(:destroy) do
85
- @player.playing = false
86
- self.class.unset_instance
87
- end
88
- end
89
-
90
- def init_keys
91
- @window.signal_connect(:key_press_event) do |widget, key|
92
- case key.keyval
93
- when Gdk::Keyval::KEY_space
94
- @player.playing = !@player.playing?
95
- when Gdk::Keyval::KEY_plus
96
- seek(10)
97
- when Gdk::Keyval::KEY_minus
98
- seek(-10)
99
- when *[
100
- Keys::MOVE_TO_NEXT_KEYS, Keys::MOVE_TO_PREVIOUS_KEYS,
101
- Keys::MOVE_TO_LAST_KEYS, Keys::MOVE_TO_LAST_KEYS,
102
- ].flatten
103
- @window.destroy
104
- Gtk::AccelGroup.activate(@parent_window, key.keyval, key.state)
105
- else
106
- Gtk::AccelGroup.activate(@parent_window, key.keyval, key.state)
107
- end
108
- true
109
- end
110
- end
111
-
112
- def seek(second)
113
- duration = @player.duration
114
- progress = @player.progress + (second / duration)
115
- if progress < 0.0
116
- progress = 0.0
117
- elsif progress > 1.0
118
- progress = 1.0
119
- end
120
- @player.progress = progress
121
- end
122
- end
123
- end
@@ -1,101 +0,0 @@
1
- # Copyright (C) 2018-2019 Kouhei Sutou <kou@cozmixng.org>
2
- #
3
- # This program is free software; you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation; either version 2 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
-
17
- class RabbitCommandRabbitTest < Test::Unit::TestCase
18
- def setup
19
- @base_dir = File.expand_path(File.join(__dir__, "..", ".."))
20
- @dir = Dir.mktmpdir
21
- end
22
-
23
- def teardown
24
- FileUtils.rm_rf(@dir)
25
- end
26
-
27
- def rabbit(*arguments)
28
- Dir.chdir(@dir) do
29
- pid = spawn({
30
- "LANG" => "C",
31
- },
32
- RbConfig.ruby,
33
- "-I", File.join(@base_dir, "lib"),
34
- File.join(@base_dir, "bin", "rabbit"),
35
- *arguments,
36
- {
37
- :out => "stdout",
38
- :err => "stderr",
39
- })
40
- _, status = Process.waitpid2(pid)
41
- return status.success?, File.read("stdout"), File.read("stderr")
42
- end
43
- end
44
-
45
- test("--save-as-image") do
46
- omit("log isn't outputted on GitHub Actions...") if ENV["CI"]
47
- File.open(File.join(@dir, "slide.rab"), "w") do |slide|
48
- slide.puts(<<-'SLIDE')
49
- = ス\nラ/イ\ド:タイトル
50
-
51
- = ページタイトル
52
- SLIDE
53
- end
54
- success, stdout, stderr = rabbit("--save-as-image", "slide.rab")
55
- Dir.chdir(@dir) do
56
- assert_equal([
57
- true,
58
- "",
59
- "[INFO]\nCreating a image for the 0th page\n" +
60
- "[INFO]\nCreating a image for the 1th page\n",
61
- [
62
- "スラ-イ-ド-タイトル-0.png",
63
- "スラ-イ-ド-タイトル-1.png",
64
- ],
65
- ],
66
- [
67
- success,
68
- stdout,
69
- stderr,
70
- Dir.glob("*.png").sort,
71
- ])
72
- end
73
- end
74
-
75
- test("--print") do
76
- File.open(File.join(@dir, "slide.rab"), "w") do |slide|
77
- slide.puts(<<-'SLIDE')
78
- = ス\nラ/イ\ド:タイトル
79
-
80
- = ページタイトル
81
- SLIDE
82
- end
83
- success, stdout, stderr = rabbit("--print", "slide.rab")
84
- Dir.chdir(@dir) do
85
- assert_equal([
86
- true,
87
- "",
88
- "",
89
- [
90
- "スラ-イ-ド-タイトル.pdf",
91
- ],
92
- ],
93
- [
94
- success,
95
- stdout,
96
- stderr,
97
- Dir.glob("*.pdf").sort,
98
- ])
99
- end
100
- end
101
- end
@@ -1,48 +0,0 @@
1
- # Copyright (C) 2014-2019 Kouhei Sutou <kou@cozmixng.org>
2
- #
3
- # This program is free software; you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation; either version 2 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
-
17
- module Helper
18
- module Parser
19
- private
20
- def parse(parser_class, text)
21
- canvas = []
22
- def canvas.logger
23
- Rabbit::Logger.default
24
- end
25
- source = Rabbit::Source::Memory.new("UTF-8", nil)
26
- source.source = text
27
- parser = parser_class.new(canvas, source)
28
- parser.parse
29
- canvas
30
- end
31
-
32
- def inspect_canvas(canvas)
33
- canvas.collect do |page|
34
- inspect_element(page)
35
- end
36
- end
37
-
38
- def inspect_element(element)
39
- name = element.class.name.split(/::/).last
40
- if element.respond_to?(:elements)
41
- children = element.elements.collect {|child| inspect_element(child)}
42
- else
43
- children = [element.text]
44
- end
45
- [name, *children]
46
- end
47
- end
48
- end
data/test/helper.rb DELETED
@@ -1,24 +0,0 @@
1
- # Copyright (C) 2004-2024 Sutou Kouhei <kou@cozmixng.org>
2
- #
3
- # This program is free software; you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation; either version 2 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
-
17
- require "fileutils"
18
- require "rbconfig"
19
- require "tmpdir"
20
-
21
- require "test-unit"
22
-
23
- require "helper/fixture"
24
- require "helper/parser"
@@ -1,54 +0,0 @@
1
- # Copyright (C) 2012-2019 Kouhei Sutou <kou@cozmixng.org>
2
- #
3
- # This program is free software; you can redistribute it and/or modify
4
- # it under the terms of the GNU General Public License as published by
5
- # the Free Software Foundation; either version 2 of the License, or
6
- # (at your option) any later version.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License along
14
- # with this program; if not, write to the Free Software Foundation, Inc.,
15
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
-
17
- require "rabbit/image/dia"
18
-
19
- class TestImageDia < Test::Unit::TestCase
20
- include Helper::Fixture
21
-
22
- private
23
- def fixture_path(base_name)
24
- super("image", "dia", base_name)
25
- end
26
-
27
- class TestMatch < self
28
- private
29
- def match?(base_name)
30
- Rabbit::ImageManipulable::Dia.match?(fixture_path(base_name))
31
- end
32
-
33
- class TestWithExtension < self
34
- def test_not_compressed
35
- assert_true(match?("not-compressed.dia"))
36
- end
37
-
38
- def test_compressed
39
- assert_true(match?("compressed.dia"))
40
- end
41
- end
42
-
43
- class TestWithoutExtension < self
44
- def test_not_compressed
45
- assert_true(match?("not-compressed"))
46
- end
47
-
48
- def test_compressed
49
- # Not supported yet.
50
- assert_false(match?("compressed"))
51
- end
52
- end
53
- end
54
- end