2 # $Id: program.rb 25 2005-04-14 19:42:06Z 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} " +
95 "signal" => [@signal],
96 "source" => [@source],
97 "in.from" => [@in_from, :double],
98 "in.range" => [@in_range, :double],
103 class SetStateProgram < Program
104 attr_reader :targets, :state, :value, :time
107 def initialize(collection, id, name)
110 @type = TYPE_SET_STATE
115 @targets = ProgramArgs.new(collection)
119 @state = v.to_str.dup
123 unless v.is_a?(Float)
125 "wrong argument type #{v.class.name} " +
133 unless v.is_a?(Float)
135 "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)
169 def to_eet_properties
170 super.merge!({"targets" => [@targets]})
174 class EmitSignalProgram < Program
175 attr_reader :emission_signal, :emission_source
177 def initialize(collection, id, name)
180 @type = TYPE_EMIT_SIGNAL
181 @emission_signal = nil
182 @emission_source = nil
185 def emission_signal=(v)
186 @emission_signal = v.to_str.dup
189 def emission_source=(v)
190 @emission_source = v.to_str.dup
193 def to_eet_properties
195 {"state" => [@emission_signal],
196 "state2" => [@emission_source]})
200 class ExecScriptProgram < Program
203 def initialize(collection, id, name)
206 @type = TYPE_EXEC_SCRIPT
211 @script = v.to_str.dup
215 class ProgramArgs < Array
216 attr_reader :collection
218 def initialize(collection)
219 @collection = collection
223 if v.collection != @collection
224 raise(ArgumentError, "items not in the same collection")
232 attr_reader :collection
235 @collection = v.collection
239 def to_eet_properties
244 class ProgramAfter < ProgramArg
250 class ProgramTarget < ProgramArg
252 "Edje_Program_Target"