// SceneC.h: interface for the SceneC class.
//
//////////////////////////////////////////////////////////////////////

#ifndef __SCENEC_H__
#define __SCENEC_H__


#include "DataBlockI.h"
#include "EditableI.h"
#include "UndoC.h"
#include "LayerC.h"
#include "PajaTypes.h"
#include <vector>
#include <string>


namespace Composition {

	//! Composition scene class.
	/*!	The base of the demo in Demopaja is scene. The layers are store inside
		the scene. Scene also contains information about the size of the canvas
		where the demo is shown and the speed of the demo.

		The changes made to the scene is saved to a undo object if present.

		This class is implemented by the system.
	*/
	class SceneC : public Edit::EditableI
	{
	public:
		//! Creates new, empty scene.
		static SceneC*				create_new();
		//! Creates new, empty scene.
		virtual Edit::DataBlockI*	create();
		//! Creates new scene (used internally), see Edit::EditableI::create().
		virtual Edit::DataBlockI*	create( Edit::EditableI* pOriginal );
		//! Deep copy from a data block, see Edit::DataBlockI::copy().
		virtual void				copy( Edit::DataBlockI* pBlock );
		//! Shallow copy from a editable, see Edit::EditableI::restore().
		virtual void				restore( Edit::EditableI* pEditable );

		//! Sets the name of the scene.
		void						set_name( const char* szName );
		//! Returns the name of the scene.
		const char*					get_name() const;

		//! Returns number of layers in the scene.
		PajaTypes::uint32			get_layer_count();
		//! Returns a layer at specified index.
		LayerC*						get_layer( PajaTypes::uint32 ui32Index );
		//! Adds new layer to the scene.
		LayerC*						add_layer();
		//! Deletes a layer at specified index.
		void						del_layer( PajaTypes::uint32 ui32Index );
		//! Moves the order of a layer.
		/*! \param ui32Index the index of the layer to move.
			\param ui32IndexBefore the index of the layer before the layer is moved.
			Moves the layer before another layer.
		*/
		void						move_layer_before( PajaTypes::uint32 ui32Index, PajaTypes::uint32 ui32IndexBefore );

		//! Returns number of beats per minute (BPM) of the demo.
		PajaTypes::int32			get_beats_per_min();
		//! Sets number of beats per minute (BPM) of the demo.
		void						set_beats_per_min( PajaTypes::int32 i32BeatsPerMin );

		//! Returns the edit accuracy of the demo.
		PajaTypes::int32			get_edit_accuracy();
		//! Sets the edit accuracy of the demo.
		void						set_edit_accuracy( PajaTypes::int32 i32Accuracy );

		//! Returns number of beats per measure of the demo.
		PajaTypes::int32			get_beats_per_measure();
		//! Sets number of beats per measure of the demo.
		void						set_beats_per_measure( PajaTypes::int32 i32Beats );

		//! Returns number of quater-notes per beat.
		PajaTypes::int32			get_qnotes_per_beat();
		//! Sets number of quater-notes per beat.
		void						set_qnotes_per_beat( PajaTypes::int32 i32QNotes );

		//! Returns the duration of the demo.
		/*!	The return value is number of quater-notes multiplied by 256.
		*/
		PajaTypes::int32			get_duration();
		//! Sets the duration of the demo.
		void						set_duration( PajaTypes::int32 i32Duration );

		//! Returns the width of the layout in pixels.
		PajaTypes::int32			get_layout_width();
		//! Sets the width of the layout in pixels.
		void						set_layout_width( PajaTypes::int32 i32Width );

		//! Returns the height of the layout in pixels.
		PajaTypes::int32			get_layout_height();
		//! Sets the height of the layout in pixels.
		void						set_layout_height( PajaTypes::int32 i32Height );

		//! Serialize the key to a Demopaja output stream.
		PajaTypes::uint32			save( FileIO::SaveC* pSave );
		//! Serialize the key from a Demopaja input stream.
		PajaTypes::uint32			load( FileIO::LoadC* pLoad );
		//! Serialize the key from a Demopaja input stream with merge to old scnene.
		PajaTypes::uint32			load( FileIO::LoadC* pLoad, bool bMerge );

	protected:
		//! Default constructor.
		SceneC();
		//! Constructor with reference to the original.
		SceneC( Edit::EditableI* pOriginal );
		//! Default destructor.
		virtual ~SceneC();

	private:
		std::string					m_sName;
		std::vector<LayerC*>		m_rLayers;
		PajaTypes::int32			m_i32BeatsPerMin;
		PajaTypes::int32			m_i32EditAccuracy;
		PajaTypes::int32			m_i32BeatsPerMeasure;
		PajaTypes::int32			m_i32QNotesPerBeat;
		PajaTypes::int32			m_i32Duration;
		PajaTypes::int32			m_i32LayoutWidth;
		PajaTypes::int32			m_i32LayoutHeight;
	};

};

#endif // __SCENEC_H__
