#ifndef __SELECTRECTWIDGET_HH
#define __SELECTRECTWIDGET_HH

#include "videoWidget.hh"

class SelectRectWidget: public VideoWidget
{
  Q_OBJECT
public:
  SelectRectWidget( QWidget *parent = 0, Qt::WFlags f = 0 );
  virtual void setImage( const mimas::image< mimas::rgba< unsigned char > > &_img );
  mimas::image< mimas::rgba< unsigned char > > selectedImage();
  bool isRectDefined(void) { return haveRect && !dragging; }
  void clearSelection(void);
signals:
  void rectDefined(bool);
protected:
  void paintGL(void);
  void refresh(void);
  void mousePressEvent( QMouseEvent *e );
  void mouseMoveEvent( QMouseEvent *e );
  void mouseReleaseEvent( QMouseEvent *e );
  int x0;
  int y0;
  int x1;
  int y1;
  bool dragging;
  bool haveRect;
};

#endif