CmsAnnotation

EDrag

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#ifndef Fireworks_Core_CmsAnnotation_h
#define Fireworks_Core_CmsAnnotation_h

#include "TGLOverlay.h"

class TGLViewer;
class TGLViewerBase;
class FWConfiguration;

class CmsAnnotation : public TGLOverlayElement {
private:
  enum EDrag { kMove, kResize, kNone };

public:
  CmsAnnotation(TGLViewerBase* parent, Float_t posx, Float_t posy);
  ~CmsAnnotation() override;

  // ---------- member, functions -------------------------

  //configuration management interface
  virtual void addTo(FWConfiguration&) const;
  virtual void setFrom(const FWConfiguration&);

  void Render(TGLRnrCtx& rnrCtx) override;

  Bool_t MouseEnter(TGLOvlSelectRecord& selRec) override;
  Bool_t Handle(TGLRnrCtx& rnrCtx, TGLOvlSelectRecord& selRec, Event_t* event) override;
  void MouseLeave() override;

  Float_t getSize() const { return fSize; }
  void setSize(Float_t x) { fSize = x; }

  bool getVisible() const;
  void setVisible(bool x);

  bool getAllowDestroy() const { return fAllowDestroy; }
  void setAllowDestroy(bool x) { fAllowDestroy = x; }

  CmsAnnotation(const CmsAnnotation&) = delete;                   // stop default
  const CmsAnnotation& operator=(const CmsAnnotation&) = delete;  // stop default

private:
  Float_t fPosX;  // x position [0, 1]
  Float_t fPosY;  // y position [0, 1]

  Int_t fMouseX, fMouseY;  //! last mouse position
  EDrag fDrag;

  TGLViewer* fParent;

  Float_t fSize;  //! relative size to viewport width
  Float_t fSizeDrag;

  bool fActive;
  bool fAllowDestroy;
};

#endif