2 # $Id: program.rb 33 2005-04-24 15:54:39Z tilman $
4 # Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
6 # Permission is hereby granted, free of charge, to any person obtaining
7 # a copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the Software, and to
11 # permit persons to whom the Software is furnished to do so, subject to
12 # the following conditions:
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #TYPE_SET_DRAG_VAL = 4
32 #TYPE_STEP_DRAG_VAL = 5
33 #TYPE_PAGE_DRAG_VAL = 6
38 attr_reader :collection, :id, :name, :after, :signal, :source,
41 def initialize(collection, id, name)
42 @collection = collection
45 @name = name.to_str.dup.freeze
48 @after = ProgramArgs.new(collection)
60 @signal = v.to_str.dup
64 @source = v.to_str.dup
70 "wrong argument type #{v.class.name} " +
80 "wrong argument type #{v.class.name} " +
96 "signal" => [@signal],
97 "source" => [@source],
98 "in.from" => [@in_from, :double],
99 "in.range" => [@in_range, :double],
104 class SetStateProgram < Program
105 attr_reader :targets, :state, :value, :time
108 def initialize(collection, id, name)
111 @type = TYPE_SET_STATE
116 @targets = ProgramArgs.new(collection)
120 @state = v.to_str.dup
124 unless v.is_a?(Float)
126 "wrong argument type #{v.class.name} " +
134 unless v.is_a?(Float)
136 "wrong argument type #{v.class.name} " +
144 def to_eet_properties
151 raise(RedactError, "invalid mode - #{@mode}")
155 {"state" => [@state],
156 "value" => [@value, :double],
157 "tween.mode" => [mode],
158 "tween.time" => [@time, :double],
159 "targets" => [@targets]})
163 class StopProgramProgram < Program
164 def initialize(collection, id, name)
167 @type = TYPE_STOP_PROGRAM
168 @targets = ProgramArgs.new(collection)
172 def to_eet_properties
173 super.merge!({"targets" => [@targets]})
177 class EmitSignalProgram < Program
178 attr_reader :emission_signal, :emission_source
180 def initialize(collection, id, name)
183 @type = TYPE_EMIT_SIGNAL
184 @emission_signal = ""
185 @emission_source = ""
188 def emission_signal=(v)
189 @emission_signal = v.to_str.dup
192 def emission_source=(v)
193 @emission_source = v.to_str.dup
197 def to_eet_properties
199 {"state" => [@emission_signal],
200 "state2" => [@emission_source]})
204 class ExecScriptProgram < Program
207 def initialize(collection, id, name)
210 @type = TYPE_EXEC_SCRIPT
215 @script = v.to_str.dup
219 class ProgramArgs < Array
220 attr_reader :collection
222 def initialize(collection)
223 @collection = collection
227 if v.collection != @collection
228 raise(ArgumentError, "items not in the same collection")
236 attr_reader :collection
239 @collection = v.collection
244 def to_eet_properties
249 class ProgramAfter < ProgramArg
256 class ProgramTarget < ProgramArg
259 "Edje_Program_Target"