~macslow/nux/nux.fix-839476

« back to all changes in this revision

Viewing changes to Nux/Matrix3Editor.h

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-01 22:11:16 UTC
  • Revision ID: neil.patel@canonical.com-20100901221116-4hb351fcg6s5nka0
Initial Nux integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it 
 
5
 * under the terms of the GNU Lesser General Public License version 3, as
 
6
 * published by the  Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but 
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of 
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
 
11
 * PURPOSE.  See the applicable version of the GNU Lesser General Public 
 
12
 * License for more details.
 
13
 * 
 
14
 * You should have received a copy of both the GNU Lesser General Public 
 
15
 * License version 3 along with this program.  If not, see 
 
16
 * <http://www.gnu.org/licenses/>
 
17
 *
 
18
 * Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
 
19
 *
 
20
 */
 
21
 
 
22
 
 
23
#ifndef MATRIX3EDITOR_H
 
24
#define MATRIX3EDITOR_H
 
25
 
 
26
#include "EditTextBox.h"
 
27
#include "StaticTextBox.h"
 
28
#include "Layout.h"
 
29
#include "HLayout.h"
 
30
#include "VLayout.h"
 
31
#include "Button.h"
 
32
#include "TimerProc.h"
 
33
 
 
34
NAMESPACE_BEGIN_GUI
 
35
 
 
36
class Matrix3Editor;
 
37
class Matrix3Preview;
 
38
 
 
39
class Matrix3DialogProxy
 
40
{
 
41
public:
 
42
    Matrix3DialogProxy(bool ModalWindow);
 
43
    ~Matrix3DialogProxy();
 
44
 
 
45
    void RecvDialogOk(const weaksmptr(Matrix3Editor) matrixeditor);
 
46
    void RecvDialogCancel(const weaksmptr(Matrix3Editor) matrixeditor);
 
47
    void RecvDialogChange(const weaksmptr(Matrix3Editor) matrixeditor);
 
48
 
 
49
    void Start();
 
50
    bool IsActive();
 
51
    void StopThreadMonitoring();
 
52
 
 
53
    Matrix3 GetMatrix() {return m_Matrix;}
 
54
    void SetMatrix(Matrix3 matrix) {m_Matrix = matrix;}
 
55
 
 
56
private:
 
57
    bool m_bDialogChange;
 
58
    bool m_bDialogRunning;
 
59
 
 
60
    Matrix3 m_PreviousMatrix;
 
61
    Matrix3 m_Matrix;
 
62
 
 
63
    bool m_ModalWindow;
 
64
    unsigned int m_DialogThreadID;
 
65
    NThread* m_Thread;
 
66
 
 
67
    friend class Matrix3Preview;
 
68
};
 
69
 
 
70
 
 
71
 
 
72
//! A User Interface component hosting a 4x4 Matrix. 
 
73
/*!
 
74
    Matrix3Editor is a UI component representing a 4x4 matrix.
 
75
    All elements of the matrix are writeable through the UI. The Matrix3Editor API provides access to the embeded matrix 
 
76
    through the member functions getMatrix() and setMatrix().
 
77
*/
 
78
class Matrix3Editor : public ActiveInterfaceObject
 
79
{
 
80
public:
 
81
    Matrix3Editor(Matrix3 matrix = Matrix3::IDENTITY());
 
82
    ~Matrix3Editor();
 
83
    virtual long ProcessEvent(IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
 
84
    virtual void Draw(GraphicsContext& GfxContext, bool force_draw);
 
85
    virtual void DrawContent(GraphicsContext& GfxContext, bool force_draw);
 
86
    virtual void PostDraw(GraphicsContext& GfxContext, bool force_draw);
 
87
 
 
88
//    virtual void setCaption(const char* s)
 
89
//    {
 
90
//        m_ParameterName.setCaption(s);
 
91
//    }
 
92
    void SetParameterName(const char* parameter_name);
 
93
 
 
94
    void EmitButtonPress() {};
 
95
 
 
96
    ////////////////
 
97
    //  EMITTERS  //
 
98
    ////////////////
 
99
    void EmitIncrementComponent(int index);
 
100
    void EmitDecrementComponent(int index);
 
101
    void EmitComponentValue(float f, int index);
 
102
 
 
103
    /////////////////
 
104
    //  RECEIVERS  //
 
105
    /////////////////
 
106
 
 
107
    //! Set the UI matrix.
 
108
    /*!
 
109
        Set each component of the 3x3 matrix UI to the ones provided by the input matrix.
 
110
        \param matrix a 3x3 matrix of type Matrix3.
 
111
        \return NULL.
 
112
        \sa getMatrix().
 
113
    */
 
114
    void SetMatrix(Matrix3 matrix);
 
115
 
 
116
    //! Get the UI matrix.
 
117
    /*!
 
118
        Get the matrix hosted by the UI.
 
119
        \param NULL.
 
120
        \return a Matrix3 object.
 
121
        \sa setMatrix().
 
122
    */
 
123
    Matrix3 GetMatrix() const;
 
124
 
 
125
 
 
126
 
 
127
    /////////////////
 
128
    //  SIGNALS    //
 
129
    /////////////////
 
130
    //sigc::signal<void> sigClick;
 
131
//    sigc::signal<void, int> sigIncrementComponent;
 
132
//    sigc::signal<void, int> sigDecrementComponent;
 
133
    sigc::signal<void, int, char*> sigValidateKeyboarEntry;
 
134
 
 
135
    sigc::signal<void, const weaksmptr(Matrix3Editor) > sigMatrixChanged;
 
136
 
 
137
private:
 
138
 
 
139
 
 
140
    void RecvIdentityMatrixCmd();
 
141
    void RecvZeroMatrixCmd();
 
142
    void RecvInverseMatrixCmd();
 
143
    void RecvNegateMatrixCmd();
 
144
 
 
145
    void WriteMatrix();
 
146
 
 
147
    void RecvComponentInput(const weaksmptr(EditTextBox) textbox, const NString& text, int componentIndex);
 
148
 
 
149
private:
 
150
    smptr(VLayout) m_vlayout;
 
151
    smptr(VLayout) mtx_layout;
 
152
    smptr(HLayout) mtx_row_layout[3];
 
153
 
 
154
    //smptr(StaticTextBox) m_ParameterName;
 
155
 
 
156
    smptr(EditTextBox) m_MtxInput[3][3];
 
157
 
 
158
    smptr(Button) m_IdentityMtxBtn;
 
159
    smptr(Button) m_ZeroMtxBtn;
 
160
    smptr(Button) m_InverseMtxBtn;
 
161
    smptr(Button) m_NegateMtxBtn;
 
162
    smptr(HLayout) m_MtxFunctionLayout;
 
163
 
 
164
    Matrix3x3<float> m_Matrix;
 
165
};
 
166
 
 
167
NAMESPACE_END_GUI
 
168
 
 
169
#endif // MATRIX3EDITOR_H