/*------------------------------------------------------------------------------
 src/lib/djWidget/djImageOpXformWidget.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_IMAGE_OP_XFORM_WIDGET_H
#define DJ_IMAGE_OP_XFORM_WIDGET_H
#include <djImageOpXform.h>
#include <djEnumWidget.h>
#include <djImageOpWidget.h>

namespace dj {

class Vec2iWidget;

// Image mirror operation widget.
//
class ImageOpMirrorWidget : public ImageOpWidget {
public:

  ImageOpMirrorWidget();
  
  const Str name() const { return "Mirror"; }
  Plugin * copy() const { return new ImageOpMirrorWidget; }
  void set(ImageOp *);
  void widgetUpdate();
  
private:

  DJ_CALLBACK(ImageOpMirrorWidget, widgetCallback, ImageOpMirror::MIRROR)

  EnumWidget<ImageOpMirror::MIRROR> * _widget;
};

// Image rotate operation widget.
//
class ImageOpRotate90Widget : public ImageOpWidget {
public:

  ImageOpRotate90Widget();
  
  const Str name() const { return "Rotate 90"; }
  Plugin * copy() const { return new ImageOpRotate90Widget; }
  void set(ImageOp *);
  void widgetUpdate();
  
private:

  DJ_CALLBACK(ImageOpRotate90Widget, widgetCallback, ImageOpRotate90::ROTATE)

  EnumWidget<ImageOpRotate90::ROTATE> * _widget;
};

// Image scale operation widget.
//
class ImageOpScaleWidget : public ImageOpWidget {
public:

  ImageOpScaleWidget();
  
  const Str name() const { return "Scale"; }
  Plugin * copy() const { return new ImageOpScaleWidget; }
  void set(ImageOp *);
  void widgetUpdate();
  
private:

  DJ_CALLBACK(ImageOpScaleWidget, sizeCallback, const Vec2i &)
  DJ_CALLBACK(ImageOpScaleWidget, filterCallback, ImageOpScale::FILTER)
  DJ_CALLBACK(ImageOpScaleWidget, filter2Callback, ImageOpScale::FILTER)
  DJ_CALLBACK(ImageOpScaleWidget, edgeCallback, Image::EDGE)
  DJ_CALLBACK(ImageOpScaleWidget, edge2Callback, Image::EDGE)

  Vec2iWidget * _sizeWidget;
  EnumWidget<ImageOpScale::FILTER> * _filterWidget, * _filter2Widget;
  EnumWidget<Image::EDGE> * _edgeWidget, * _edge2Widget;
  bool _callbacks;
};

// Utility.
//
inline const List<ImageOpWidget *> imageOpXformWidgetList()
{
  List<ImageOpWidget *> out;
  out += new ImageOpMirrorWidget;
  out += new ImageOpRotate90Widget;
  out += new ImageOpScaleWidget;
  return out;
}

}

#endif
