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

#ifndef DJ_VEC_WIDGET_H
#define DJ_VEC_WIDGET_H
#include <djVec.h>
#include <djWidget.h>

namespace dj {

class IntWidget;
class FloatWidget;

// Two-dimensional integer vector widget.
//
class Vec2iWidget : public Widget {
public:

  Vec2iWidget();
  
  // Value.
  //
  void set(const Vec2i &);
  const Vec2i & get() const { return _value; }
  
  // Signals.
  //
  Signal<const Vec2i &> & sig() { return _sig; }
  
private:

  DJ_CALLBACK(Vec2iWidget, widgetCallback, int)
  DJ_CALLBACK(Vec2iWidget, widget2Callback, int)

  void widgetUpdate();

  Vec2i _value, _tmp;
  
  Signal<const Vec2i &> _sig;
  
  IntWidget * _widget, * _widget2;
  bool _callbacks;
};

// Two-dimensional floating point vector widget.
//
class Vec2fWidget : public Widget {
public:

  Vec2fWidget();
  
  // Value.
  //
  void set(const Vec2f &);
  const Vec2f & get() const { return _value; }
  
  // Signals.
  //
  Signal<const Vec2f &> & sig() { return _sig; }

private:

  DJ_CALLBACK(Vec2fWidget, widgetCallback, double)
  DJ_CALLBACK(Vec2fWidget, widget2Callback, double)

  void widgetUpdate();

  Vec2f _value, _tmp;
  
  Signal<const Vec2f &> _sig;
  
  FloatWidget * _widget, * _widget2;
  bool _callbacks;
};

}

#endif
