camerauis/cameraxui/cxengine/inc/api/cxeautofocuscontrol.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 17 Sep 2010 08:27:13 +0300
changeset 60 a289dde0a1d6
parent 32 5c1e3c6aa4ef
permissions -rw-r--r--
Revision: 201035 Kit: 201037

/*
* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/

#ifndef CXEAUTOFOCUSCONTROL_H
#define CXEAUTOFOCUSCONTROL_H

#include <QObject>
#include <QMetaType>
#include "cxeerror.h"

class QImage;


/**
 * CxeAutoFocusControl is responsible for handling Autofocus events from the camera adaptation.
 * It also routes the Autofocus successful and failed events to the clients interested in Žknowing the
 * status of Autofocus.
 */
class CxeAutoFocusControl : public QObject
    {
    Q_OBJECT
public:

    /*
     * Autofocus control states.
     */
    enum State
        {
        //! focusing
        InProgress = 0x01,

        //! Autofocus Failed
        Failed     = 0x02,

        //! Focused
        Ready      = 0x04,

        //! State after successfully canceling AF or during startup
        Unknown    = 0x08,

        //! Starting to cancel any pending AF requests
        Canceling  = 0x10     // Starting to Cancel any pending AF requests
        };

    // TODO: Check if we have to get all the supported modes from adaptation.
    enum Mode
        {
        //! AF mode: Auto
        Auto,

        //! AF mode: Hyperfocal
        Hyperfocal,

        //! AF mode: Macro
        Macro,

        //! AF mode: Infinity
        Infinity,

        //! AF mode: Portrait
        Portrait
        };

    /**
     * Starts Autofocus.
     * \param soundEnabled indicates if the auto focus sound should be played
     */
    virtual CxeError::Id start(bool soundEnabled = true) = 0;

    /**
     * Cancels Autofocus.
     */
    virtual void cancel() = 0;                // cancels active start operation


    /**
     * Setting Autofocus Mode.
     */
    virtual void setMode( Mode newMode ) = 0; // sets default value for current view/mode

    /**
     * Get current Autofocus mode.
     */
    virtual Mode mode() const = 0;

    /**
     * Is the mode a fixed focus mode.
     */
    virtual bool isFixedFocusMode(Mode mode) const = 0;

    /**
     * Get current Autofocus state.
     */
    virtual State state() const = 0;                // returns current AF state, one of AutoFocusState

    /**
     * Check if Autofocus is Supported or Not.
     */
    virtual bool supported() const = 0;             // true when AF is supported

    /**
    * Check if auto focus sound is enabled
    */
    virtual bool isSoundEnabled() const = 0;

signals:
    void stateChanged( CxeAutoFocusControl::State newState, CxeError::Id error );

protected:
    CxeAutoFocusControl() {} // protected empty contructor so that derived class construction works

private:
    Q_DISABLE_COPY( CxeAutoFocusControl )
    };

Q_DECLARE_METATYPE(CxeAutoFocusControl::State)

#endif // CXEAUTOFOCUSCONTROL_H