2 # $Id: program.rb 1 2005-03-26 01:32:38Z 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
39 attr_accessor :signal, :source, :in_from, :in_range
41 def initialize(collection, id, name)
42 @collection = collection
45 @name = name.to_str.dup.freeze
48 @after = ProgramArgs.new(collection)
67 "signal" => [@signal],
68 "source" => [@source],
69 "in.from" => [@in_from, :double],
70 "in.range" => [@in_range, :double],
75 class SetStateProgram < Program
82 attr_accessor :state, :value, :mode, :time
84 def initialize(collection, id, name)
87 @type = TYPE_SET_STATE
92 @targets = ProgramArgs.new(collection)
98 "value" => [@value, :double],
99 "tween.mode" => [@mode],
100 "tween.time" => [@time, :double],
101 "targets" => [@targets]})
105 class StopProgramProgram < Program
106 def initialize(collection, id, name)
109 @type = TYPE_STOP_PROGRAM
110 @targets = ProgramArgs.new(collection)
113 def to_eet_properties
114 super.merge!({"targets" => [@targets]})
118 class EmitSignalProgram < Program
119 attr_accessor :emission_signal, :emission_source
121 def initialize(collection, id, name)
124 @type = TYPE_EMIT_SIGNAL
125 @emission_signal = nil
126 @emission_source = nil
129 def to_eet_properties
131 {"state" => [@emission_signal],
132 "state2" => [@emission_source]})
136 class ExecScriptProgram < Program
137 attr_accessor :script
139 def initialize(collection, id, name)
142 @type = TYPE_EXEC_SCRIPT
147 class ProgramArgs < Array
148 attr_reader :collection
150 def initialize(collection)
151 @collection = collection
155 if v.collection != @collection
156 raise(ArgumentError, "items not in the same collection")
164 attr_reader :collection
167 @collection = v.collection
171 def to_eet_properties
176 class ProgramAfter < ProgramArg
182 class ProgramTarget < ProgramArg
184 "Edje_Program_Target"