diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-02 20:40:24 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-02 20:40:24 +0200 |
commit | c0174806a7c59cdbac1cd941d66e844e55829444 (patch) | |
tree | 3f4acd3702cb489e47b56c5b1ad7db977d1fd3c2 /c/layout.h | |
parent | ae3225a4e7ef86d159fdf27834c453ffcd4da76c (diff) | |
download | EpisodeBrowser-c0174806a7c59cdbac1cd941d66e844e55829444.tar.gz |
Double-click dragger to reset.
One cannot use WM_LBUTTONDBLCLK here, because it relies on
WM_LBUTTONDOWN being passed to the default message handler.
Diffstat (limited to 'c/layout.h')
-rw-r--r-- | c/layout.h | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -4,6 +4,7 @@ #include <windows.h> #include "common.h" +#include "datalistview.h" void UpdateLayout(int w = 0, int h = 0); @@ -14,22 +15,39 @@ struct Dragger 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; - return m_bActive = true; -} -inline bool Dragger::IsDown() -{ - return GetKeyState(VK_LBUTTON) & 0x8000; + if (IsDouble()) { + extern DataListView* g_dlv; + g_dlv->SetHeight(0); + UpdateLayout(); + return false; + } else + return m_bActive = true; } inline bool Dragger::HandleMove() |