texturewidget.h

Go to the documentation of this file.
00001 //=============================================================================
00016 #ifndef __TEXTUREWIDGET_H_INCLUDED__
00017 #define __TEXTUREWIDGET_H_INCLUDED__
00018 
00019 #include <QtCore/QSignalMapper>
00020 #include <QtGui/QWidget>
00021 #include <QtGui/QSpinBox>
00022 #include <QtGui/QPushButton>
00023 #include <QtGui/QComboBox>
00024 #include <QtGui/QCheckBox>
00025 #include <QtGui/QGridLayout>
00026 #include <QtGui/QGroupBox>
00027 #include <QtGui/QLabel>
00028 
00029 #include "config.h"
00030 
00031 // forward declarations
00032 class ITextureState;
00033 class IUniformState;
00034 
00035 
00036 //=============================================================================
00037 //  CTextureWidget
00038 //=============================================================================
00039 
00051 class CTextureWidget : public QWidget
00052 {
00053     Q_OBJECT
00054 public:
00059     CTextureWidget( ITextureState* ts, IUniformState* us );
00060 
00068     void init( void );
00069 
00073     void shutdown( void );
00074 
00075 public slots:
00081     void updateSamplerList( void );
00082 
00083 private slots:
00084     void setActiveSampler( int active );
00085     void setSamplerTmu( int tmu );
00086     void selectTexture( int tmu ); // bring up 'load image' dialog
00087     void checkBilinearFilter( int checkState );
00088 
00089 private:
00090 
00092     enum { MAX_USED_TMUS = CONFIG_MAX_USED_TMUS };
00093 
00094     // helpers
00095     QGroupBox*  createSamplerWidget( void );
00096     QGroupBox*  createTmuWidget( void );
00097     int         uniformIndex( int comboBoxIndex );
00098 
00099     // texture loading helpers
00100     QString     selectImageFileName( void );
00101     void        uploadTextureImage( int tmu, const QString & fileName );
00102 
00103     // texture button size helpers
00104     QSize textureButtonSize( void ) const;
00105     QSize textureIconSize  ( void ) const;
00106 
00107     // widgets
00108     QComboBox*      m_activeSampler;
00109     QSpinBox*       m_samplerTmu; // TMU of the active sampler
00110     QCheckBox*      m_chkBilinearFilter;
00111 
00112     // mapping from buttons to TMUs
00113     QSignalMapper*  m_mapper;
00114 
00115     // where to look for images when the 'load image' dialog pops up.
00116     QString m_lastImageDirectory;
00117 
00118     // signal processing
00119     int m_skipSetActiveSampler;
00120     int m_skipSetSamplerTmu;
00121 
00122     // helpers struct for texture buttons.
00123     typedef struct buttonInfo_s {
00124         QPushButton*    button;
00125         QGroupBox*      groupBox;
00126         QImage          image; // loaded image
00127         QIcon           icon;  // small version of image
00128     } buttonInfo_t;
00129 
00130     // texture unit widgets
00131     buttonInfo_t    m_tmus[ MAX_USED_TMUS ];
00132     int             m_validTmus; // number of used elements in m_tmus
00133 
00134     ITextureState* m_textureState;
00135     IUniformState* m_uniformState;
00136 };
00137 
00138 
00139 #endif  // __TEXTUREWIDGET_H_INCLUDED__

Generated on Sun Mar 2 17:12:31 2008 for Shader Maker by  doxygen 1.5.4