blob: 1b78945a324986c38ca87f421306ed6acb036d2e (
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
|
#ifndef LAYOUT_H
#define LAYOUT_H
#include <windows.h>
#include "common.h"
#include "datalistview.h"
#include "pl.h"
void UpdateLayout(int w = 0, int h = 0);
struct Dragger
{
bool HandleDown();
bool HandleMove();
private:
bool InDragArea(int x, int y);
bool IsDown();
bool IsDouble();
void Drag(int x, int y);
bool m_bActive = false;
long m_time = 0;
};
inline bool Dragger::IsDouble()
{
const long time = GetMessageTime();
const bool dbl = time-m_time <= static_cast<long>(GetDoubleClickTime());
m_time = time;
return dbl;
}
inline bool Dragger::IsDown()
{
return GetKeyState(VK_LBUTTON) & 0x8000;
}
inline bool Dragger::HandleDown()
{
extern HWND g_hWnd;
POINT pt;
require(GetRelativeCursorPos(g_hWnd, &pt));
if (!InDragArea(pt.x, pt.y)) return false;
if (IsDouble()) {
extern DataListView* g_dlv;
g_dlv->SetHeight(0);
Pl("cfg","set_dlv_height",0);
UpdateLayout();
return false;
} else
return m_bActive = true;
}
inline bool Dragger::HandleMove()
{
extern HWND g_hWnd;
POINT pt;
require(GetRelativeCursorPos(g_hWnd, &pt));
extern HCURSOR g_hcSizeNs;
bool r = true;
if (InDragArea(pt.x, pt.y))
SetCursor(g_hcSizeNs);
else
r = false;
if (!m_bActive) return r;
Drag(pt.x, pt.y);
if (!IsDown()) {
extern DataListView* g_dlv;
m_bActive = false;
Pl("cfg","set_dlv_height",g_dlv->Height());
}
return r;
}
#endif
|