blob: 3b206ea01d6a194d0cbcca7c2d8c8b2f48836506 (
plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
//******************************************************************************
// @file VisObject.cpp
// @author Nicolai Shlapunov
//
// @details DevCore: Visual Object Base Class, implementation
//
// @copyright Copyright (c) 2016, Devtronic & Nicolai Shlapunov
// All rights reserved.
//
// @section SUPPORT
//
// Devtronic invests time and resources providing this open source code,
// please support Devtronic and open-source hardware/software by
// donations and/or purchasing products from Devtronic.
//
//******************************************************************************
// *****************************************************************************
// *** Includes ************************************************************
// *****************************************************************************
#include "VisObject.h"
#include "DisplayDrv.h" // for DelVisObjectFromList()
// *****************************************************************************
// *** Destructor **********************************************************
// *****************************************************************************
VisObject::~VisObject()
{
// Remove object from object list before delete
DisplayDrv::GetInstance().DelVisObjectFromList(this);
}
// *****************************************************************************
// *** Lock Visual Object ***************************************************
// *****************************************************************************
void VisObject::LockVisObject()
{
// Lock line
DisplayDrv::GetInstance().LockDisplayLine();
};
// *****************************************************************************
// *** Unlock Visual Object ************************************************
// *****************************************************************************
void VisObject::UnlockVisObject()
{
// Unlock line
DisplayDrv::GetInstance().UnlockDisplayLine();
};
// *****************************************************************************
// *** Show Visual Object **************************************************
// *****************************************************************************
void VisObject::Show(uint32_t z_pos)
{
// Z position is 0 by default. In this case we can use 0 here as "no pos" flag
if(z_pos != 0)
{
z = z_pos;
}
// Add to VisObject List
DisplayDrv::GetInstance().AddVisObjectToList(this, z);
}
// *****************************************************************************
// *** Hide Visual Object **************************************************
// *****************************************************************************
void VisObject::Hide(void)
{
// Delete from VisObject List
DisplayDrv::GetInstance().DelVisObjectFromList(this);
}
// *****************************************************************************
// *** Check status of Show Visual Object **********************************
// *****************************************************************************
bool VisObject::IsShow(void)
{
// Return false by default
bool ret = false;
// If any pointer is not null - object in list
if( (p_next != nullptr) || (p_prev != nullptr) )
{
ret = true;
}
// Return result
return ret;
}
// *****************************************************************************
// *** Move Visual Object **************************************************
// *****************************************************************************
void VisObject::Move(int32_t x, int32_t y, bool is_delta)
{
// Lock object for changes
LockVisObject();
// Make changes
if(is_delta == true)
{
// Move object in delta coordinates
x_start += x;
y_start += y;
x_end += x;
y_end += y;
}
else
{
// Move object in absolute coordinates
x_start = x;
y_start = y;
x_end = x + width - 1;
y_end = y + height - 1;
}
// Unlock object after changes
UnlockVisObject();
}
// *****************************************************************************
// *** Action **************************************************************
// *****************************************************************************
void VisObject::Action(ActionType action, int32_t tx, int32_t ty)
{
// Empty function. We can do active object without custom Action function
// for cover active object with lower Z.
}
|