Torque3D Documentation / _generateds / guiFilterCtrl.h

guiFilterCtrl.h

Engine/source/gui/editor/guiFilterCtrl.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _GUIFILTERCTRL_H_
 25#define _GUIFILTERCTRL_H_
 26
 27#ifndef _GUICONTROL_H_
 28#include "gui/core/guiControl.h"
 29#endif
 30
 31
 32class Filter: public Vector<F32>
 33{
 34   public:
 35      Filter() : Vector<F32>(__FILE__, __LINE__) { }
 36
 37      void set(S32 argc, const char *argv[]);
 38      F32  getValue(F32 t) const;
 39};
 40
 41
 42class GuiFilterCtrl : public GuiControl
 43{
 44protected:
 45
 46   typedef GuiControl Parent;
 47
 48   S32 mControlPointRequest;
 49
 50   S32 mCurKnot;
 51
 52   Filter mFilter;
 53
 54   bool mShowIdentity;
 55
 56   Point2F mIdentity;
 57
 58public:
 59
 60   //creation methods
 61   DECLARE_CONOBJECT(GuiFilterCtrl);
 62   DECLARE_CATEGORY( "Gui Other" );
 63   DECLARE_DESCRIPTION( "A control that displays a Catmull-Rom spline through a number of control points\n"
 64      "and allows to edit the Y-coordinates of the control points to adjust the curve." );
 65   
 66   GuiFilterCtrl();
 67   static void initPersistFields();
 68
 69   //Parental methods
 70   bool onWake();
 71
 72   void onMouseDown(const GuiEvent &event);
 73   void onMouseDragged(const GuiEvent &event);
 74   void onMouseUp(const GuiEvent &);
 75
 76   F32  getValue(S32 n);
 77   const Filter* get() { return &mFilter; }
 78   void set(const Filter &f);
 79   S32  getNumControlPoints() {return mFilter.size(); }
 80   void identity();
 81
 82   void onPreRender();
 83   void onRender(Point2I offset, const RectI &updateRect );
 84};
 85
 86
 87inline F32 GuiFilterCtrl::getValue(S32 n)
 88{
 89   S32 index = getMin(getMax(n,0), (S32)mFilter.size()-1);
 90   return mFilter[index];
 91}
 92
 93
 94inline void GuiFilterCtrl::set(const Filter &f)
 95{
 96   mControlPointRequest = f.size();
 97   mFilter = f;
 98}
 99
100#endif
101