~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to Nux/BezierCurveControl2.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-02 03:28:11 UTC
  • Revision ID: neil.patel@canonical.com-20100902032811-i2m18tfb6pkasnvt
Remove Win EOL chars

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
 
22
22
 
23
 
#ifndef BEZIERCURVECONTROL2_H
24
 
#define BEZIERCURVECONTROL2_H
25
 
 
26
 
#include "PaintLayer.h"
27
 
 
28
 
NAMESPACE_BEGIN_GUI
29
 
 
30
 
class Knot2
31
 
{
32
 
public :
33
 
 
34
 
    float  m_X;
35
 
    float  m_Y;
36
 
 
37
 
    bool m_IsSelected;
38
 
 
39
 
public :
40
 
 
41
 
    Knot2() : m_X(0), m_Y(0), m_IsSelected(false) {}    //Constructors  
42
 
    Knot2(float ptX, float ptY) : 
43
 
    m_X(ptX), m_Y(ptY), m_IsSelected(false) {}
44
 
 
45
 
    void setPoint(float x, float y)  {m_X = x; m_Y = y;}        //Setting
46
 
    
47
 
 
48
 
    //Operator overloading
49
 
    void operator = (Knot2 knot)   {m_X = knot.m_X; m_Y = knot.m_Y;}
50
 
    bool operator != (Knot2 knot)
51
 
    {
52
 
        bool b;
53
 
        b = ((m_X != knot.m_X) || (m_Y != knot.m_Y)) ? true : false;
54
 
        return b;
55
 
    }
56
 
};
57
 
 
58
 
 
59
 
typedef float (*FunctionCallback)(float);  
60
 
 
61
 
class BezierCurveControl2 : public ActiveInterfaceObject
62
 
{
63
 
public:
64
 
    BezierCurveControl2();
65
 
    ~BezierCurveControl2();
66
 
    virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
67
 
    virtual void Draw(GraphicsContext& GfxContext, bool force_draw);
68
 
    virtual void DrawContent(GraphicsContext& GfxContext, bool force_draw);
69
 
    virtual void PostDraw(GraphicsContext& GfxContext, bool force_draw);
70
 
 
71
 
    void EnablePanning(bool b)      { m_bPanningEnabled = b; }
72
 
    bool IsPanningEnabled() const   { return  m_bPanningEnabled; }
73
 
    void EnableZooming(bool b)      { m_bZoomingEnabled = b; }
74
 
    bool IsZoomingEnable() const    { return m_bZoomingEnabled; }
75
 
 
76
 
    void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
77
 
    void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
78
 
    void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
79
 
 
80
 
    void RecvKeyEvent
81
 
        (
82
 
        GraphicsContext& GfxContext , /*Graphics Context for text operation*/
83
 
        unsigned long    eventType  , /*event type*/
84
 
        unsigned long    keysym     , /*event keysym*/
85
 
        unsigned long    state      , /*event state*/
86
 
        const char*      character  , /*character*/
87
 
        bool             isRepeated , /*true if the key is repeated more than once*/
88
 
        unsigned short   keyCount     /*key repeat count*/
89
 
        );
90
 
 
91
 
private:
92
 
    void DrawRuler(GraphicsContext& GfxContext);
93
 
    void DrawGrid(GraphicsContext& GfxContext);
94
 
    void DrawCoordinateSystem(GraphicsContext& GfxContext);
95
 
 
96
 
    void SetXAxisBounds(float minX, float maxX);
97
 
    void SetYAxisBounds(float minY, float maxY);
98
 
    void SetFunctionCallback(FunctionCallback f);
99
 
    float EvalFunction(float x);
100
 
    void UpdateGraph();
101
 
 
102
 
    void ManipulateBezier(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
103
 
    void ProcessPanning(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
104
 
    void ProcessZooming(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
105
 
 
106
 
    std::vector<Knot2> m_control_knot;
107
 
 
108
 
    float m_minX, m_minY, m_maxX, m_maxY;
109
 
    FunctionCallback m_FunctionCallback;
110
 
    
111
 
    AbstractPaintLayer* m_Background;
112
 
 
113
 
    bool m_bControlPointSelected;
114
 
    bool m_bPanningEnabled;
115
 
    bool m_bZoomingEnabled;
116
 
 
117
 
    float hit_point_dx;
118
 
    float hit_point_dy;
119
 
 
120
 
 
121
 
};
122
 
 
123
 
 
124
 
NAMESPACE_END_GUI
125
 
 
126
 
#endif // BEZIERCURVECONTROL2_H
 
23
#ifndef BEZIERCURVECONTROL2_H
 
24
#define BEZIERCURVECONTROL2_H
 
25
 
 
26
#include "PaintLayer.h"
 
27
 
 
28
NAMESPACE_BEGIN_GUI
 
29
 
 
30
class Knot2
 
31
{
 
32
public :
 
33
 
 
34
    float  m_X;
 
35
    float  m_Y;
 
36
 
 
37
    bool m_IsSelected;
 
38
 
 
39
public :
 
40
 
 
41
    Knot2() : m_X(0), m_Y(0), m_IsSelected(false) {}    //Constructors  
 
42
    Knot2(float ptX, float ptY) : 
 
43
    m_X(ptX), m_Y(ptY), m_IsSelected(false) {}
 
44
 
 
45
    void setPoint(float x, float y)  {m_X = x; m_Y = y;}        //Setting
 
46
    
 
47
 
 
48
    //Operator overloading
 
49
    void operator = (Knot2 knot)   {m_X = knot.m_X; m_Y = knot.m_Y;}
 
50
    bool operator != (Knot2 knot)
 
51
    {
 
52
        bool b;
 
53
        b = ((m_X != knot.m_X) || (m_Y != knot.m_Y)) ? true : false;
 
54
        return b;
 
55
    }
 
56
};
 
57
 
 
58
 
 
59
typedef float (*FunctionCallback)(float);  
 
60
 
 
61
class BezierCurveControl2 : public ActiveInterfaceObject
 
62
{
 
63
public:
 
64
    BezierCurveControl2();
 
65
    ~BezierCurveControl2();
 
66
    virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
67
    virtual void Draw(GraphicsContext& GfxContext, bool force_draw);
 
68
    virtual void DrawContent(GraphicsContext& GfxContext, bool force_draw);
 
69
    virtual void PostDraw(GraphicsContext& GfxContext, bool force_draw);
 
70
 
 
71
    void EnablePanning(bool b)      { m_bPanningEnabled = b; }
 
72
    bool IsPanningEnabled() const   { return  m_bPanningEnabled; }
 
73
    void EnableZooming(bool b)      { m_bZoomingEnabled = b; }
 
74
    bool IsZoomingEnable() const    { return m_bZoomingEnabled; }
 
75
 
 
76
    void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
 
77
    void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
 
78
    void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
79
 
 
80
    void RecvKeyEvent
 
81
        (
 
82
        GraphicsContext& GfxContext , /*Graphics Context for text operation*/
 
83
        unsigned long    eventType  , /*event type*/
 
84
        unsigned long    keysym     , /*event keysym*/
 
85
        unsigned long    state      , /*event state*/
 
86
        const char*      character  , /*character*/
 
87
        bool             isRepeated , /*true if the key is repeated more than once*/
 
88
        unsigned short   keyCount     /*key repeat count*/
 
89
        );
 
90
 
 
91
private:
 
92
    void DrawRuler(GraphicsContext& GfxContext);
 
93
    void DrawGrid(GraphicsContext& GfxContext);
 
94
    void DrawCoordinateSystem(GraphicsContext& GfxContext);
 
95
 
 
96
    void SetXAxisBounds(float minX, float maxX);
 
97
    void SetYAxisBounds(float minY, float maxY);
 
98
    void SetFunctionCallback(FunctionCallback f);
 
99
    float EvalFunction(float x);
 
100
    void UpdateGraph();
 
101
 
 
102
    void ManipulateBezier(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
103
    void ProcessPanning(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
104
    void ProcessZooming(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
 
105
 
 
106
    std::vector<Knot2> m_control_knot;
 
107
 
 
108
    float m_minX, m_minY, m_maxX, m_maxY;
 
109
    FunctionCallback m_FunctionCallback;
 
110
    
 
111
    AbstractPaintLayer* m_Background;
 
112
 
 
113
    bool m_bControlPointSelected;
 
114
    bool m_bPanningEnabled;
 
115
    bool m_bZoomingEnabled;
 
116
 
 
117
    float hit_point_dx;
 
118
    float hit_point_dy;
 
119
 
 
120
 
 
121
};
 
122
 
 
123
 
 
124
NAMESPACE_END_GUI
 
125
 
 
126
#endif // BEZIERCURVECONTROL2_H