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

#ifndef DJ_IMAGE_OP_CORE_WIDGET_H
#define DJ_IMAGE_OP_CORE_WIDGET_H
#include <djImageOpCore.h>
#include <djEnumWidget.h>
#include <djImageOpWidget.h>

namespace dj {

class IntWidget;
class Vec2iWidget;
class PixelWidget;

// Image crop operation widget.
//
class ImageOpCropWidget : public ImageOpWidget {
public:

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

  DJ_CALLBACK(ImageOpCropWidget, positionCallback, const Vec2i &)
  DJ_CALLBACK(ImageOpCropWidget, sizeCallback, const Vec2i &)

  Vec2iWidget * _positionWidget, * _sizeWidget;
  bool _callbacks;
};

// Image convert operation widget.
//
class ImageOpConvertWidget : public ImageOpWidget {
public:

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

  DJ_CALLBACK(ImageOpConvertWidget, widgetCallback, const Pixel &)

  PixelWidget * _widget;
  bool _callbacks;
};

// Image channel operation widgets.
//
class ImageOpChannelWidget : public ImageOpWidget {
public:

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

  DJ_CALLBACK(ImageOpChannelWidget, widgetCallback, int)

  IntWidget * _widget;
  bool _callbacks;
};

// Utility.
//
inline const List<ImageOpWidget *> imageOpCoreWidgetList()
{
  List<ImageOpWidget *> out;
  out += new ImageOpCropWidget;
  out += new ImageOpConvertWidget;
  out += new ImageOpChannelWidget;
  return out;
}

}

#endif
