00001
00002
00003
00004 #ifndef Impala_Visualization_VideoJpgPlayerControl_h
00005 #define Impala_Visualization_VideoJpgPlayerControl_h
00006
00007 #ifndef Impala_Visualization_VideoJpgPlayer_h
00008 #include "Visualization/VideoJpgPlayer.h"
00009 #endif
00010
00011 #ifndef OglGui_RadioGroup_h
00012 #include "OglGui/RadioGroup.h"
00013 #endif
00014
00015 namespace Impala
00016 {
00017 namespace Visualization
00018 {
00019
00020 class VideoJpgPlayerControl : public OglGui::RadioGroup,
00021 OglGui::RadioGroupListener
00022 {
00023 public:
00024 typedef OglGui::Window Window;
00025 typedef OglGui::RadioGroup RadioGroup;
00026 typedef OglGui::Button Button;
00027
00028 VideoJpgPlayerControl(int x, int y, int w, int h,
00029 VideoJpgPlayer* videoJpgPlayer=0) :
00030 RadioGroup(x, y, w, h)
00031 {
00032 Init(w, h, videoJpgPlayer);
00033 }
00034
00035 VideoJpgPlayerControl(Window* parent, int w, int h,
00036 VideoJpgPlayer* videoJpgPlayer=0) :
00037 RadioGroup(parent, w, h)
00038 {
00039 Init(w, h, videoJpgPlayer);
00040 }
00041
00042 VideoJpgPlayerControl(Window* parent, int x, int y, int w, int h,
00043 VideoJpgPlayer* videoJpgPlayer=0) :
00044 RadioGroup(parent, x, y, w, h)
00045 {
00046 Init(w, h, videoJpgPlayer);
00047 }
00048
00049 void SetVideoJpgPlayer(VideoJpgPlayer* videoJpgPlayer)
00050 {
00051 if (mVideoJpgPlayer = videoJpgPlayer)
00052 MapKeysTo(mVideoJpgPlayer);
00053 }
00054
00055 virtual void OnRadioChange(RadioGroup *src, int button, void* data)
00056 {
00057 if (button == 0)
00058 mVideoJpgPlayer->Play();
00059 if (button == 1)
00060 mVideoJpgPlayer->Stop();
00061 if (button == 2)
00062 mVideoJpgPlayer->Reset();
00063 if (button == 3)
00064 mVideoJpgPlayer->NextFrame(1);
00065 if (button == 4)
00066 mVideoJpgPlayer->NextFrame(-1);
00067 if (button == 5)
00068 mVideoJpgPlayer->FFwd();
00069 if (button == 6)
00070 mVideoJpgPlayer->FBwd();
00071 }
00072
00073 Button* GetButton(int id)
00074 {
00075 switch (id)
00076 {
00077 case 1: return mPlayButton;
00078 case 2: return mStopButton;
00079 case 3: return mResetButton;
00080 case 4: return mNextButton;
00081 case 5: return mPrevButton;
00082 case 6: return mFFwdButton;
00083 case 7: return mFBwdButton;
00084 }
00085 return NULL;
00086 }
00087
00088 virtual void InitDisplayFunc()
00089 {
00090 RadioGroup::InitDisplayFunc();
00091
00092 SetDisabled(!mVideoJpgPlayer);
00093 if (mVideoJpgPlayer)
00094 {
00095 if (mVideoJpgPlayer->Playing())
00096 {
00097 if (mVideoJpgPlayer->FFwding())
00098 SetActiveRadio(5);
00099 else if (mVideoJpgPlayer->FBwding())
00100 SetActiveRadio(6);
00101 else
00102 SetActiveRadio(0);
00103 }
00104 else
00105 SetActiveRadio(1);
00106 }
00107 }
00108
00109 private:
00110 void Init(int w, int h, VideoJpgPlayer* videoJpgPlayer)
00111 {
00112 SetDimensions(242, 30);
00113 SetVideoJpgPlayer(videoJpgPlayer);
00114 Add(mPlayButton = new Button(this, 4, 4, 30, 24, ">"));
00115 Add(mStopButton = new Button(this, 38, 4, 30, 24, "[]"));
00116 Add(mResetButton = new Button(this, 72, 4, 30, 24, "<<"));
00117 Add(mNextButton = new Button(this, 106, 4, 30, 24, "+"));
00118 Add(mPrevButton = new Button(this, 140, 4, 30, 24, "-"));
00119 Add(mFFwdButton = new Button(this, 174, 4, 30, 24, "FF"));
00120 Add(mFBwdButton = new Button(this, 208, 4, 30, 24, "FB"));
00121 ScaleChildren();
00122 this->SetAllowChildScaling(false);
00123 SetDimensions(w, h);
00124
00125 mNextButton->SetRepeatMode(true);
00126 mPrevButton->SetRepeatMode(true);
00127
00128
00129
00130 SetRadioListener(this);
00131 }
00132
00133 VideoJpgPlayer* mVideoJpgPlayer;
00134
00135 Button* mPlayButton;
00136 Button* mStopButton;
00137 Button* mResetButton;
00138 Button* mNextButton;
00139 Button* mPrevButton;
00140 Button* mFFwdButton;
00141 Button* mFBwdButton;
00142 };
00143
00144 }
00145 }
00146 #endif