From dee3a413f072e5779fc5ba80692f895ba43815c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Wed, 3 Aug 2022 19:22:40 +0200 Subject: Clean up Dragger. --- c/layout.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'c/layout.h') diff --git a/c/layout.h b/c/layout.h index 1b78945..47702c4 100644 --- a/c/layout.h +++ b/c/layout.h @@ -9,19 +9,39 @@ void UpdateLayout(int w = 0, int h = 0); +/* Draggable portions of the client area, such as the split between + * two list views, are implemented in Dragger singletons. + * + * HandleDown and HandleMove are called by the relevant window + * procedures for WM_(NC)LBUTTONDOWN and WM_SETCURSOR. */ + struct Dragger { bool HandleDown(); bool HandleMove(); -private: - bool InDragArea(int x, int y); +protected: bool IsDown(); bool IsDouble(); - void Drag(int x, int y); + virtual bool InDragArea(int x, int y); + virtual void Drag(int x, int y); + virtual void Reset(); + virtual void Done(); +private: bool m_bActive = false; long m_time = 0; }; +/* Dragger for data list view (upper border). */ + +struct DlvDragger : public Dragger +{ +private: + bool InDragArea(int x, int y) override; + void Drag(int x, int y) override; + void Reset() override; + void Done() override; +}; + inline bool Dragger::IsDouble() { const long time = GetMessageTime(); @@ -43,13 +63,12 @@ inline bool Dragger::HandleDown() 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; + m_bActive = false; + Reset(); } else - return m_bActive = true; + m_bActive = true; + + return m_bActive; } inline bool Dragger::HandleMove() @@ -64,12 +83,12 @@ inline bool Dragger::HandleMove() SetCursor(g_hcSizeNs); else r = false; - if (!m_bActive) return r; + 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()); + Done(); } return r; } -- cgit v1.2.3