Shoes/samples/expert-video-player.rb
def tweak(origin_left, args = nil)
        @released = false
        origin_pos = @fraction
        
        self.app.motion do |lf,t|
            pos =(origin_pos - (origin_left - lf))
            if @active and not @released and @range.cover?(pos)
                self.fraction= pos
                if args
                    @driven.call( *args.map { |v| v = @fraction if v == "driver" } )
                else
                    @driven.call @fraction
                end
            end
        end
        self.app.release {|b,l,t| @released = true}
    end
# Calling bound method of the driven element.
# args is an array of the arguments given to the method
# if method has more than one argument, the driven argument is the one, in the array, marqued as "driver",
#       ie: for shape.displace(x,y) --> tweak(left, ["driver", 5]) 
#       displace.x beeing driven by knob, capturing mouse's left coordinates
# other arguments are given default values 
Calling bound method of the driven element.
args is an array of the arguments given to the method
if method has more than one argument, the driven argument is the one, in the array, marqued as "driver",
ie: for shape.displace(x,y) --> tweak(left, ["driver", 5])
displace.x beeing driven by knob, capturing mouse's left coordinates
other arguments are given default values
Calling bound method of the driven element . args is an array of the arguments given to the method if method has more than one argument the driven argument is the one in the array marqued as " driver " ie : for shape . displace ( x y ) -- > tweak ( left [ " driver " 5 ] ) displace . x beeing driven by knob capturing mouse ' s left coordinates other arguments are given default values
def tweak(origin_left, args = nil)
        @released = false
        origin_pos = @fraction
        self.app.motion do |lf,t|
            pos =(origin_pos - (origin_left - lf))
            if @active and not @released and @range.cover?(pos)
                self.fraction= pos
                if args
                    @driven.call( *args.map { |v| v = @fraction if v == "driver" } )
                else
                    @driven.call @fraction
                end
            end
        end
        self.app.release {|b,l,t| @released = true}
    end
def tweak ( origin_left , args = nil ) @released = false origin_pos = @fraction self . app . motion do | lf , t | pos = ( origin_pos - ( origin_left - lf ) ) if @active and not @released and @range . cover? ( pos ) self . fraction = pos if args @driven . call ( * args . map { | v | v = @fraction if v == "driver" } ) else @driven . call @fraction end end end self . app . release { | b , l , t | @released = true } end
Calling bound method of the driven element.
Calling bound method of the driven element .
origin_left
args