forked from mogonen/shady
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ControlPoint.h
45 lines (31 loc) · 1.03 KB
/
ControlPoint.h
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
#ifndef CONTROLPOINT_H
#define CONTROLPOINT_H
#include "base.h"
class ControlPoint;
typedef ControlPoint* ControlPoint_p;
typedef std::list<ControlPoint_p> CPList;
class ControlPoint: public Draggable{
static ControlPoint_p _pTheActive;
protected:
Selectable_p _pControlled;
void onDown(){
if (isChild())
_pTheActive = (ControlPoint_p)parent();
else
_pTheActive = this;
}
virtual void onDrag(const Point& t){ // move the children
if (isParent()){
DraggableList childs = getChilds();
for(DraggableList::iterator it = childs.begin(); it!= childs.end(); it++)
(*it)->pP()->set((*it)->P() + t);
}
if (_pControlled)
_pControlled->update();
}
public:
ControlPoint(Point_p pP, Selectable_p pControlled):Draggable(Renderable::UI, pP), _pControlled(pControlled){}
void render() const;
bool isActive() const {return (_pTheActive == this) || (_pTheActive == this->parent());}
};
#endif // CONTROLPOINT_H