Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef SELECTOR_H
Toshihiro Shimizu 890ddd
#define SELECTOR_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
 * @author  Fabrizio Morciano <fabrizio.morciano@gmail.com></fabrizio.morciano@gmail.com>
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tstroke.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZEXT_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "ext/Types.h"
Toshihiro Shimizu 890ddd
#include "ext/Designer.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace ToonzExt {
Shinya Kitaoka 120a6e
class DVAPI Selector {
Shinya Kitaoka 120a6e
  enum Selection { NONE = 0, POSITION = 1, LENGTH = 2 };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Selection isSelected_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TStroke *strokeRef_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double w_, height_, stroke_length_, original_stroke_length_, signum_,
Shinya Kitaoka 120a6e
      pixel_size_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Selection getSelection(const TPointD &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD click_, curr_, prev_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD range_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isVisible_;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void init();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  Selector(double stroke_length, double min_val, double max_val);
Shinya Kitaoka 120a6e
  virtual ~Selector();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void draw(Designer *designer);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void mouseDown(const TPointD &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void mouseUp(const TPointD &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void mouseMove(const TPointD &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  virtual void mouseDrag(const TPointD &pos);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setStroke(const TStroke *ref);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TStroke *getStroke() const { return strokeRef_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double getW() const { return w_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  double getLength() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setLength(double);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isSelected() const { return (isVisible_ && (isSelected_ != NONE)); }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setVisibility(bool val) { isVisible_ = val; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isVisible() const { return isVisible_; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD getUp() const;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
#endif /* SELECTOR_H */