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
|
#include <windows.h>
#include "episodelistview.h"
#include "datalistview.h"
#include "layout.h"
#include "win.h"
extern HWND g_hWnd;
extern HWND g_hWndStatus;
extern EpisodeListView* g_elv;
extern DataListView* g_dlv;
void UpdateLayout(int w, int h)
{
if (!g_hWndStatus) return;
RECT rc, rrStatus;
if (w && h) rc = {0, 0, w, h};
else Require(GetClientRect(g_hWnd, &rc));
Require(GetRelativeRect(g_hWndStatus, &rrStatus));
SendMessage(g_hWnd, WM_SETREDRAW, FALSE, 0);
/* Resize list views. */
const long pad = EBIsThemeActive()? Dpi(6): 0; /* Add padding in modern themes. */
const long cyDlv = rrStatus.top-g_dlv->Height()-pad;
Require(SetWindowRect(g_dlv->hWnd, pad, cyDlv, rc.right-pad, rrStatus.top-pad));
Require(SetWindowRect(g_elv->hWnd, pad, pad, rc.right-pad, cyDlv-pad));
g_dlv->ResizeColumns(rc.right-pad-pad);
g_elv->ResizeColumns(rc.right-pad-pad);
/* Resize status bar parts. */
const int aParts[] = {rc.right-Dpi(55), rc.right};
SendMessage(g_hWndStatus, SB_SETPARTS,
reinterpret_cast<WPARAM>(sizeof(aParts)), reinterpret_cast<LPARAM>(aParts));
SendMessage(g_hWnd, WM_SETREDRAW, TRUE, 0);
RedrawWindow(g_hWnd, nullptr, nullptr,
RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN);
}
bool DlvDragger::InDragArea(const int x, const int y) const
{
RECT rrDlv;
Require(GetRelativeRect(g_dlv->hWnd, &rrDlv));
const int pad = EBIsThemeActive()? Dpi(6): 0;
const int extra = EBIsThemeActive()? 0: Dpi(2);
if (x < rrDlv.left || x > rrDlv.right) return false;
if (y < rrDlv.top-pad*2-extra*3 || y > rrDlv.top+extra) return false;
return true;
}
void DlvDragger::Drag(const int, const int y) const
{
RECT rrDlv;
Require(GetRelativeRect(g_dlv->hWnd, &rrDlv));
if (y < Dpi(50) || y > rrDlv.bottom-Dpi(20)) return;
int h;
h = rrDlv.bottom-y;
g_dlv->SetHeight(h);
UpdateLayout();
RedrawWindow(g_hWnd, nullptr, nullptr,
RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_UPDATENOW);
}
void DlvDragger::Reset() const
{
extern CfgA& g_cfg;
g_dlv->SetHeight(0);
g_cfg.heightDlv = 0;
UpdateLayout();
}
void DlvDragger::Done() const
{
extern CfgA& g_cfg;
g_cfg.heightDlv = g_dlv->Height();
}
|