My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#include "TopFrame.h"

#ifdef GUI_WINGL

NAMESPACE_UPP

#define LLOG(x) //LOG(x)

static Point glmousepos;

Point GetMousePos() {
return glmousepos;
}

void Ctrl::MouseEventGl(Ptr<Ctrl> t, int event, Point p, int zdelta)
{
if(!t->IsEnabled() && (t != (Ctrl*) &infoPanel && t != (Ctrl*) &console))
return;
Rect rr = t->GetRect();
if((event & Ctrl::ACTION) == DOWN) {
Ptr<Ctrl> q = t;
TopWindowFrame *wf = dynamic_cast<TopWindowFrame *>(~t);
if(wf)
q = wf->window;
if(q) q->ClickActivateWnd();
if(q) q->SetForeground();
if(ignoreclick)
return;
}
if(t)
t->DispatchMouse(event, p - rr.TopLeft(), zdelta);
if(t)
t->PostInput();
}

Ctrl *Ctrl::FindMouseTopCtrl()
{
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
Ctrl *t = topctrl[i];
if(t->GetRect().Contains(glmousepos))
return t->IsEnabled() ? t : NULL;
}
return desktop->IsEnabled() ? desktop : NULL;
}

bool Ctrl::DoMouseGl(Ctrl* q, int event, Point p, int zdelta)
{
Rect rr = q->GetRect();
if(rr.Contains(p)) {
MouseEventGl(q, event, p, zdelta);
return true;
}
return false;
}

void Ctrl::DoMouseGl(int event, Point p, int zdelta)
{
glmousepos = p;
int a = event & Ctrl::ACTION;
if(a == Ctrl::UP && Ctrl::ignoreclick) {
EndIgnore();
return;
}
else
if(a == Ctrl::DOWN && ignoreclick)
return;
LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
if(captureCtrl)
MouseEventGl(captureCtrl->GetTopCtrl(), event, p, zdelta);
else
{
bool processed = consoleActive && DoMouseGl((Ctrl*) &console, event, p, zdelta);

if(!processed && controlPanelActive)
processed = DoMouseGl((Ctrl*) &infoPanel, event, p, zdelta);

if(!processed)
{
for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
Ptr<Ctrl> t = topctrl[i];
if(t != (Ctrl*) &infoPanel && t != (Ctrl*) &console && t->GetRect().Contains(p) &&
DoMouseGl(t, event, p, zdelta))
return;
}
Ctrl *desktop = GetDesktop();
if(desktop) {
desktop->DispatchMouse(event, p, zdelta);
desktop->PostInput();
}
}
}
}

bool Ctrl::DoKeyGl(dword key, int cnt)
{
if(key == K_CTRL_GRAVE)
{
controlPanelActive = !controlPanelActive;
consoleActive = !consoleActive;
return true;
}
else if(key == K_CTRL_F12)
{
consoleActive = !consoleActive;
return true;
}
else if(key == K_CTRL_F11)
{
controlPanelActive = !controlPanelActive;
return true;
}

bool b = DispatchKey(key, cnt);
SyncCaret();
Ctrl *desktop = GetDesktop();
if(desktop)
desktop->PostInput();
return b;
}

void Ctrl::SetCaret(int x, int y, int cx, int cy)
{
GuiLock __;
caretx = x;
carety = y;
caretcx = cx;
caretcy = cy;
glCaretTm = GetTickCount();
SyncCaret();
}

void Ctrl::SyncCaret() {
GuiLock __;
}

void Ctrl::CursorSync(Draw& w)
{
Rect cr = Null;
if(focusCtrl && (((GetTickCount() - glCaretTm) / 500) & 1) == 0)
cr = (RectC(focusCtrl->caretx, focusCtrl->carety, focusCtrl->caretcx, focusCtrl->caretcy)
+ focusCtrl->GetScreenView().TopLeft()) & focusCtrl->GetScreenView();

glCaretRect = cr;
if(!cr.IsEmpty())
w.DrawRect(cr, Black);
}

void Ctrl::MouseSync(Draw& w)
{
glCursorPos = GetMousePos() - glCursorImage.GetHotSpot();
Size sz = glCursorImage.GetSize();
w.DrawImage(glCursorPos.x, glCursorPos.y, sz.cx, sz.cy, glCursorImage);
}

void Ctrl::SetMouseCursor(const Image& image)
{
GuiLock __;
if(image.GetSerialId() != glCursorImage.GetSerialId()) {
glCursorImage = image;
glCursorPos = Null;
}
}

END_UPP_NAMESPACE

#endif

Change log

r4853 by unodgs on Apr 24, 2012   Diff
WinGL: Fixed timers, added support for
perspective view
Go to: 
Project members, sign in to write a code review

Older revisions

r4365 by unodgs on Jan 6, 2012   Diff
WinGL: Added painting through fbo,
added blur shader, fixed children
clipping, optimized painting a bit
r3924 by unodgs on Sep 28, 2011   Diff
Rainbow: WinGL..
r3915 by unodgs on Sep 26, 2011   Diff
Rainbow: WinGL..
All revisions of this file

File info

Size: 3533 bytes, 166 lines

File properties

svn:eol-style
native
Powered by Google Project Hosting