/*------------------------------------------------------------------------------
 src/bin/djview/widget.h

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

#ifndef DJVIEW_WIDGET_H
#define DJVIEW_WIDGET_H
#include "base.h"
#include <djTextWidget.h>
#include <djSliderWidget.h>
#include <djImageWidget.h>

namespace djview {

// Frame slider.
//
class FrameSliderWidget : public IntSliderWidget {
public:

  FrameSliderWidget();
  
  // Value.
  //
  void set(int);
  
  // In/out points.
  //
  void inOutPoint(bool, bool);
  void inOutFrame(int, int);
  bool inPoint() const { return _inPoint; }
  bool outPoint() const { return _outPoint; }
  int inFrame() const { return _inFrame; }
  int outFrame() const { return _outFrame; }
  
protected:

  void drawBackground(const Box2i &);
  
private:

  bool _inPoint, _outPoint;
  int _inFrame, _outFrame;
};

// Playback speed display widget.
//
class PlaybackSpeedDisplayWidget : public TextDisplayWidget {
public:

  PlaybackSpeedDisplayWidget();
  
  void set(double);
  void droppedFrames(bool);
  
private:

  bool _droppedFrames;
};

// View widget.
//
class ViewWidget : public ImageViewWidget {
public:

  ViewWidget();
  
  void toolMode(bool);
  
  void hud(bool);
  void fileName(const Str &);
  void pixelDataInfo(const PixelDataInfo &);
  void imageTagList(const ImageTagList &);
  void playbackFrame(int, int start, int end);
  void playbackSpeed(double, double real, bool droppedFrames);
  
  const Vec2i & mouse() const { return _mouse; }
  
  Signal<bool> & toolSig() { return _toolSig; }
  
  void draw();
  int handle(int);
  
private:

  void drawText(
    const Str &, const Vec2i & position, const Fl_Color & = FL_WHITE
  );
  
  bool _toolMode;
  bool _hud;
  Str _fileName;
  PixelDataInfo _pixelDataInfo;
  ImageTagList _imageTagList;
  int _playbackFrame, _playbackFrameStart, _playbackFrameEnd;
  double _playbackSpeed, _playbackSpeedReal;
  bool _playbackDroppedFrames;
  
  Signal<bool> _toolSig;
  
  Vec2i _mouse;
};

}

#endif
