~vanvugt/compiz-plugins-main/fix-1084386

« back to all changes in this revision

Viewing changes to animation/include/animation/grid.h

  • Committer: Sam Spilsbury
  • Date: 2011-08-12 06:36:10 UTC
  • Revision ID: sam.spilsbury@canonical.com-20110812063610-8mcxo2xohctyp2ak
Sync - Remove Plugins

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef ANIMATION_GRID_H
2
 
#define ANIMATION_GRID_H
3
 
#include "animation.h"
4
 
class GridAnim :
5
 
    virtual public Animation
6
 
{
7
 
 public:
8
 
     class GridModel
9
 
     {
10
 
         friend class GridAnim;
11
 
         
12
 
     public:
13
 
         GridModel (CompWindow *w,
14
 
                    WindowEvent curWindowEvent,
15
 
                    int height,
16
 
                    int gridWidth,
17
 
                    int gridHeight,
18
 
                    int decorTopHeight,
19
 
                    int decorBottomHeight);
20
 
         ~GridModel ();
21
 
         
22
 
         void move (float tx, float ty);
23
 
         
24
 
         class GridObject
25
 
         {
26
 
             friend class GridAnim;
27
 
             friend class GridZoomAnim;
28
 
             friend class GridTransformAnim;
29
 
             
30
 
         public:
31
 
             GridObject ();
32
 
             void setGridPosition (Point &gridPosition);
33
 
             inline Point3d &position () { return mPosition; }
34
 
             inline Point &gridPosition () { return mGridPosition; }
35
 
             
36
 
             inline Point &offsetTexCoordForQuadBefore ()
37
 
             { return mOffsetTexCoordForQuadBefore; }
38
 
             
39
 
             inline Point &offsetTexCoordForQuadAfter ()
40
 
             { return mOffsetTexCoordForQuadAfter; }
41
 
             
42
 
         private:
43
 
             Point3d mPosition;  ///< Position on screen
44
 
             Point mGridPosition; ///< Position on window in [0,1] range
45
 
             
46
 
             Point mOffsetTexCoordForQuadBefore;
47
 
             Point mOffsetTexCoordForQuadAfter;
48
 
             ///< Texture x, y coordinates will be offset by given amounts
49
 
             ///< for quads that fall after and before this object in x and y directions.
50
 
             ///< Currently only y offset can be used.
51
 
        };
52
 
 
53
 
        inline GridObject *objects () { return mObjects; }
54
 
        inline unsigned int numObjects () { return mNumObjects; }
55
 
        inline Point &scale () { return mScale; }
56
 
 
57
 
    private:
58
 
        GridObject *mObjects; // TODO: convert to vector
59
 
        unsigned int mNumObjects;
60
 
 
61
 
        Point mScale;
62
 
        Point mScaleOrigin;
63
 
 
64
 
        void initObjects (WindowEvent curWindowEvent,
65
 
                          int height,
66
 
                          int gridWidth, int gridHeight,
67
 
                          int decorTopHeight, int decorBottomHeight);
68
 
    };
69
 
 
70
 
protected:
71
 
    GridModel *mModel;
72
 
 
73
 
    int mGridWidth;     ///< Number of cells along grid width
74
 
    int mGridHeight;    ///< Number of cells along grid height
75
 
 
76
 
    /// true if effect needs Q texture coordinates.
77
 
    /// Q texture coordinates are used to avoid jagged-looking quads
78
 
    /// ( http://www.r3.nu/~cass/qcoord/ )
79
 
    bool mUseQTexCoord;
80
 
 
81
 
    GLWindow::Geometry mGeometry; ///< geometry for grid mesh
82
 
 
83
 
    virtual bool using3D () { return false; }
84
 
 
85
 
    virtual void initGrid ();   ///< Initializes grid width/height.
86
 
                                ///< Default grid size is 2x2.
87
 
                                ///< Override for custom grid size.
88
 
 
89
 
public:
90
 
    GridAnim (CompWindow *w,
91
 
              WindowEvent curWindowEvent,
92
 
              float duration,
93
 
              const AnimEffect info,
94
 
              const CompRect &icon);
95
 
    ~GridAnim ();
96
 
    void init ();
97
 
    void updateBB (CompOutput &output);
98
 
    bool updateBBUsed () { return true; }
99
 
    void addGeometry (const GLTexture::MatrixList &matrix,
100
 
                      const CompRegion            &region,
101
 
                      const CompRegion            &clip,
102
 
                      unsigned int                maxGridWidth,
103
 
                      unsigned int                maxGridHeight);
104
 
    void drawGeometry ();
105
 
};
106
 
#endif