ASPiK SDK
cxypad.h
1 // This file is part of VSTGUI. It is subject to the license terms
2 // in the LICENSE file found in the top-level directory of this
3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE
4 
5 #ifndef __cxypad__
6 #define __cxypad__
7 
8 #include "cparamdisplay.h"
9 #include <cmath>
10 
11 namespace VSTGUI {
12 
13 //------------------------------------------------------------------------
14 class CXYPad : public CParamDisplay
15 {
16 public:
17  explicit CXYPad (const CRect& size = CRect (0, 0, 0, 0));
18 
19  void setStopTrackingOnMouseExit (bool state) { stopTrackingOnMouseExit = state; }
20  bool getStopTrackingOnMouseExit () const { return stopTrackingOnMouseExit; }
21 
22  void draw (CDrawContext* context) override;
23 
24  CMouseEventResult onMouseDown (CPoint& where, const CButtonState& buttons) override;
25  CMouseEventResult onMouseUp (CPoint& where, const CButtonState& buttons) override;
26  CMouseEventResult onMouseMoved (CPoint& where, const CButtonState& buttons) override;
27  CMouseEventResult onMouseCancel () override;
28  bool onWheel (const CPoint& where, const CMouseWheelAxis& axis, const float& distance, const CButtonState& buttons) override;
29 
30  static float calculateValue (float x, float y)
31  {
32  x = std::floor (x * 1000.f + 0.5f) * 0.001f;
33  y = std::floor (y * 1000.f + 0.5f) * 0.0000001f;
34  return x + y;
35  }
36 
37  static void calculateXY (float value, float& x, float& y)
38  {
39  x = std::floor (value * 1000.f + 0.5f) * 0.001f;
40  y = std::floor ((value - x) * 10000000.f + 0.5f) * 0.001f;
41  }
42 
43 protected:
44  void setMin (float val) override { }
45  void setMax (float val) override { }
46 
47  void boundValues (float& x, float& y);
48 
49  float mouseStartValue;
50  CPoint mouseChangeStartPoint;
51  CPoint lastMouseChangePoint;
52  bool stopTrackingOnMouseExit;
53 
54  SharedPointer<CBaseObject> endEditTimer = nullptr;
55 };
56 
57 
58 } // namespace
59 
60 #endif // __cxypad__
bool onWheel(const CPoint &where, const CMouseWheelAxis &axis, const float &distance, const CButtonState &buttons) override
called if a mouse wheel event is happening over this view
Definition: cxypad.cpp:116
Rect structure.
Definition: crect.h:17
Definition: vstguibase.h:299
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
Definition: cxypad.h:14
CMouseEventResult onMouseCancel() override
called when mouse tracking should be canceled
Definition: cxypad.cpp:65
Definition: customcontrols.cpp:8
CMouseEventResult onMouseUp(CPoint &where, const CButtonState &buttons) override
called when a mouse up event occurs
Definition: cxypad.cpp:54
Button and Modifier state.
Definition: cbuttonstate.h:34
CMouseEventResult onMouseDown(CPoint &where, const CButtonState &buttons) override
called when a mouse down event occurs
Definition: cxypad.cpp:39
void draw(CDrawContext *context) override
called if the view should draw itself
Definition: cxypad.cpp:20
CMouseEventResult onMouseMoved(CPoint &where, const CButtonState &buttons) override
called when a mouse move event occurs
Definition: cxypad.cpp:81
Point structure.
Definition: cpoint.h:17
a parameter display
Definition: cparamdisplay.h:24