2 # $Id: program.rb 23 2005-04-02 23:20:32Z 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
77 attr_accessor :state, :value, :mode, :time
79 def initialize(collection, id, name)
82 @type = TYPE_SET_STATE
87 @targets = ProgramArgs.new(collection)
97 raise(RedactError, "invalid mode - #{@mode}")
101 {"state" => [@state],
102 "value" => [@value, :double],
103 "tween.mode" => [mode],
104 "tween.time" => [@time, :double],
105 "targets" => [@targets]})
109 class StopProgramProgram < Program
110 def initialize(collection, id, name)
113 @type = TYPE_STOP_PROGRAM
114 @targets = ProgramArgs.new(collection)
117 def to_eet_properties
118 super.merge!({"targets" => [@targets]})
122 class EmitSignalProgram < Program
123 attr_accessor :emission_signal, :emission_source
125 def initialize(collection, id, name)
128 @type = TYPE_EMIT_SIGNAL
129 @emission_signal = nil
130 @emission_source = nil
133 def to_eet_properties
135 {"state" => [@emission_signal],
136 "state2" => [@emission_source]})
140 class ExecScriptProgram < Program
141 attr_accessor :script
143 def initialize(collection, id, name)
146 @type = TYPE_EXEC_SCRIPT
151 class ProgramArgs < Array
152 attr_reader :collection
154 def initialize(collection)
155 @collection = collection
159 if v.collection != @collection
160 raise(ArgumentError, "items not in the same collection")
168 attr_reader :collection
171 @collection = v.collection
175 def to_eet_properties
180 class ProgramAfter < ProgramArg
186 class ProgramTarget < ProgramArg
188 "Edje_Program_Target"