-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRect.h
More file actions
54 lines (35 loc) · 1.46 KB
/
Copy pathRect.h
File metadata and controls
54 lines (35 loc) · 1.46 KB
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
#pragma once
#include "AppObject.h"
#include "Point.h"
enum class RectCorner {
NONE = -1,
LEFT_TOP = 0,
LEFT_BOTTOM = 1,
RIGHT_TOP = 2,
RIGHT_BOTTOM = 3
};
class Rect : public AppObject // i want to call it Rectangle too..
{
public:
using Corner = RectCorner;
Rect() { _type = Type::Rect; }
Point corners[4];
Corner dragPoint = Corner::NONE;
Corner hoverPoint = Corner::NONE;
inline Point& leftTop() { return corners[static_cast<int>(Corner::LEFT_TOP)]; }
inline Point& leftBottom() { return corners[static_cast<int>(Corner::LEFT_BOTTOM)]; }
inline Point& rightTop() { return corners[static_cast<int>(Corner::RIGHT_TOP)]; }
inline Point& rightBottom() { return corners[static_cast<int>(Corner::RIGHT_BOTTOM)]; }
inline const Point& leftTop() const { return corners[static_cast<int>(Corner::LEFT_TOP)]; }
inline const Point& leftBottom() const { return corners[static_cast<int>(Corner::LEFT_BOTTOM)]; }
inline const Point& rightTop() const { return corners[static_cast<int>(Corner::RIGHT_TOP)]; }
inline const Point& rightBottom() const { return corners[static_cast<int>(Corner::RIGHT_BOTTOM)]; }
void onCreate(const MouseEvent& ev);
void updateCorner(Corner c, const POINT* pos = nullptr);
virtual bool onMouseEvent(const MouseEvent& ev) override;
void setDragAndHoverPoint(Corner c);
virtual void draw(HDC hdc) const override;
bool updateHoverPoint(const MouseEvent& ev);
void save(std::ofstream& f);
static void load(std::ifstream& f);
};