#pragma once //- // =========================================================================== // Copyright 2021 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== //+ // // **************************************************************************** // // CLASS: MTimeSliderCustomDrawManager // // ***** #include #include #include #include #include #include #include OPENMAYA_MAJOR_NAMESPACE_OPEN OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MTimeSliderDrawPrimitive{ public: OPENMAYA_ENUM (MPrimitiveType, kFilledRect, /*!< Draws a filled rectangle with no border. */ kUpperOutline, /*!< Draws an outline with no bottom side. */ kFullOutline, /*!< Draws an outline on all sides. */ kVerticalLine, /*!< Draws a vertical line at startTime. */ kBracket, /*!< Draws a bracket from start to end time. */ kFrameFlag /*!< Draws a flag at a specific frame. */ ); OPENMAYA_ENUM (MEditPrimitiveType, kNone, // default value kMovePrimitive, // Move primitive start and end time together kMoveStartTime, // Move only start time of primitive while start < end time kMoveEndTime // Move only end time of primitive while end > start time ); MTimeSliderDrawPrimitive(MPrimitiveType, MTime startTime, MTime endTime, MColor color, double bottom=0, double height= -1, unsigned int priority = 0); MTimeSliderDrawPrimitive(const MTimeSliderDrawPrimitive&); MTimeSliderDrawPrimitive& operator=(const MTimeSliderDrawPrimitive&); MTimeSliderDrawPrimitive& operator=(MTimeSliderDrawPrimitive&&)= delete; MTimeSliderDrawPrimitive() = delete; MTimeSliderDrawPrimitive(MTimeSliderDrawPrimitive&&) = delete; ~MTimeSliderDrawPrimitive(); void setPriority (unsigned int p); unsigned int priority () const; // set/get methods void setDrawType (MPrimitiveType type); MPrimitiveType drawType () const; void setStartTime (const MTime& start); MTime startTime () const; void setEndTime (const MTime& end); MTime endTime () const; void setHeight (double height); double height () const; void setBottom (double bottom); double bottom () const; void setColor (const MColor& color); MColor color () const; void setLabel (const MString& label); MString label () const; //tool tip for this particular primitive overrides the DrawObject tooltip void setTooltip (const MString& tooltip); MString tooltip () const; OPENMAYA_PRIVATE: struct Impl; MTimeSliderDrawPrimitive(Impl*); Impl* mImpl; }; OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MTimeSliderDrawPrimitives{ public: MTimeSliderDrawPrimitives(); MTimeSliderDrawPrimitives(const MTimeSliderDrawPrimitives& other) = delete; MTimeSliderDrawPrimitives(MTimeSliderDrawPrimitives&& other); MTimeSliderDrawPrimitives& operator=(const MTimeSliderDrawPrimitives&); MTimeSliderDrawPrimitives& operator=(MTimeSliderDrawPrimitives&&); ~MTimeSliderDrawPrimitives(); void clear(); bool empty() const; size_t length() const; void append (const MTimeSliderDrawPrimitive& value); void append (const MTimeSliderDrawPrimitives& list); void setAt(size_t pos, const MTimeSliderDrawPrimitive& prim); MTimeSliderDrawPrimitive operator[](size_t pos) const; OPENMAYA_PRIVATE: struct Impl; Impl* mImpl; }; OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MStartPrimitiveEditingFct { public: virtual ~MStartPrimitiveEditingFct(); /*! Called at the start of a primitive edit operation. \param[in] time Time of the initial edit frame. This is the frame on the time slider where the mouse was pressed to begin editing. */ virtual void operator()(MTime time) = 0; }; OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MEditPrimitiveFct { public: virtual ~MEditPrimitiveFct(); /*! Called on mouse drag while editing primitives. \param[in] offset Time difference between this call and the last. \param[in] snap Indicates that the edit operation should snap to whole frames. \param[in] currentTime Time at the current frame. \param[in] editType The type of edit operation being performed. */ virtual void operator()(MTime offset, bool snap, MTime currentTime, MTimeSliderDrawPrimitive::MEditPrimitiveType editType) = 0; }; OPENMAYA_AVAILABLE(2024.1) class OPENMAYAUI_EXPORT MSetCopyPrimitivesFct { public: virtual ~MSetCopyPrimitivesFct(); /*! Called during mouse drag to set the primitives to be copied. \param[in] copy Sets whether the current edit is a copy operation or not. */ virtual void operator()(bool copy) = 0; }; OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MStopPrimitiveEditingFct { public: virtual ~MStopPrimitiveEditingFct(); /*! Called on mouse release after a primitive has been edited. */ virtual void operator()() = 0; }; OPENMAYA_AVAILABLE(2023) class OPENMAYAUI_EXPORT MTimeSliderCustomDrawManager { public: using MCustomDrawID = int; static constexpr int kUseDefaultHeight = -1; OPENMAYA_ENUM (MDrawLocation, kAbove, kBelow, kOn ); MTimeSliderCustomDrawManager(); ~MTimeSliderCustomDrawManager(); static MTimeSliderCustomDrawManager& instance(); MCustomDrawID registerCustomDrawOn (const MString& name, int drawLayer); MCustomDrawID registerCustomDrawOutside (MDrawLocation loc, const MString& name, const MString& tooltip, int drawPriority, int height = kUseDefaultHeight); void deregisterCustomDraw (MCustomDrawID id); void clearDrawPrimitives (MCustomDrawID id); void setDrawPrimitives (MCustomDrawID id, const MTimeSliderDrawPrimitives& prims); void setDrawPrimitives (MCustomDrawID id, MTimeSliderDrawPrimitives&& prims); void setDrawVisible (MCustomDrawID id, bool vis); void setDrawLayer (MCustomDrawID id, int drawLayer); void setDrawHeight (MCustomDrawID id, int height); void setDrawLocation (MCustomDrawID id, MDrawLocation loc); void setDrawPriority (MCustomDrawID id, int drawPriority); void setTooltip (MCustomDrawID id, const MString& tooltip); void setStartPrimitiveEditFunction (MCustomDrawID id, MSharedPtr fct); void setEditPrimitiveFunction (MCustomDrawID id, MSharedPtr fct); void setSetCopyPrimitivesFunction (MCustomDrawID id, MSharedPtr fct); void setStopPrimitiveEditFunction (MCustomDrawID id, MSharedPtr fct); void setBackgroundColor (MCustomDrawID id, MColor color); void requestTimeSliderRedraw () const; bool empty () const ; private: //deleted function MTimeSliderCustomDrawManager(const MTimeSliderCustomDrawManager&)=delete; MTimeSliderCustomDrawManager(MTimeSliderCustomDrawManager&&)=delete; MTimeSliderCustomDrawManager& operator=(const MTimeSliderCustomDrawManager&) = delete; MTimeSliderCustomDrawManager& operator=(MTimeSliderCustomDrawManager&&) = delete; struct Impl; Impl* mImpl; }; OPENMAYA_NAMESPACE_CLOSE