2 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
12 # The above copyright notice and this permission notice shall be
13 # included in all copies or substantial portions of the Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #TYPE_SET_DRAG_VAL = 4
30 #TYPE_STEP_DRAG_VAL = 5
31 #TYPE_PAGE_DRAG_VAL = 6
36 attr_reader :collection, :id, :name, :after, :signal, :source,
39 def initialize(collection, id, name)
40 @collection = collection
43 @name = name.to_str.dup.freeze
46 @after = ProgramArgs.new(collection)
58 @signal = v.to_str.dup
62 @source = v.to_str.dup
68 "wrong argument type #{v.class.name} " +
78 "wrong argument type #{v.class.name} " +
94 "signal" => [@signal],
95 "source" => [@source],
96 "in.from" => [@in_from, :double],
97 "in.range" => [@in_range, :double],
102 class SetStateProgram < Program
103 attr_reader :targets, :state, :value, :time
106 def initialize(collection, id, name)
109 @type = TYPE_SET_STATE
114 @targets = ProgramArgs.new(collection)
118 @state = v.to_str.dup
122 unless v.is_a?(Float)
124 "wrong argument type #{v.class.name} " +
132 unless v.is_a?(Float)
134 "wrong argument type #{v.class.name} " +
142 def to_eet_properties
149 raise(RedactError, "invalid mode - #{@mode}")
153 {"state" => [@state],
154 "value" => [@value, :double],
155 "tween.mode" => [mode],
156 "tween.time" => [@time, :double],
157 "targets" => [@targets]})
161 class StopProgramProgram < Program
162 def initialize(collection, id, name)
165 @type = TYPE_STOP_PROGRAM
166 @targets = ProgramArgs.new(collection)
170 def to_eet_properties
171 super.merge!({"targets" => [@targets]})
175 class EmitSignalProgram < Program
176 attr_reader :emission_signal, :emission_source
178 def initialize(collection, id, name)
181 @type = TYPE_EMIT_SIGNAL
182 @emission_signal = ""
183 @emission_source = ""
186 def emission_signal=(v)
187 @emission_signal = v.to_str.dup
190 def emission_source=(v)
191 @emission_source = v.to_str.dup
195 def to_eet_properties
197 {"state" => [@emission_signal],
198 "state2" => [@emission_source]})
202 class ExecScriptProgram < Program
205 def initialize(collection, id, name)
208 @type = TYPE_EXEC_SCRIPT
214 @script = (File.exist?(v) ? File.read(v) : v).dup
218 class ProgramArgs < Array
219 attr_reader :collection
221 def initialize(collection)
222 @collection = collection
226 if v.collection != @collection
227 raise(ArgumentError, "items not in the same collection")
235 attr_reader :collection
238 @collection = v.collection
243 def to_eet_properties
248 class ProgramAfter < ProgramArg
255 class ProgramTarget < ProgramArg
258 "Edje_Program_Target"