diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-02 20:10:35 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-02 20:10:35 +0200 |
commit | ae3225a4e7ef86d159fdf27834c453ffcd4da76c (patch) | |
tree | f52129b946fdebfee8ffd88bc2b90347786e6e0e /c/layout.h | |
parent | 288f4c294ac1be89b151a3f96eb9d5cb9d91055f (diff) | |
download | EpisodeBrowser-ae3225a4e7ef86d159fdf27834c453ffcd4da76c.tar.gz |
Implement draggable split.
Next step is to allow a double click to reset the split to be
automatically resized.
Diffstat (limited to 'c/layout.h')
-rw-r--r-- | c/layout.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/c/layout.h b/c/layout.h new file mode 100644 index 0000000..82189fb --- /dev/null +++ b/c/layout.h @@ -0,0 +1,54 @@ +#ifndef LAYOUT_H +#define LAYOUT_H + +#include <windows.h> + +#include "common.h" + +void UpdateLayout(int w = 0, int h = 0); + +struct Dragger +{ + bool HandleDown(); + bool HandleMove(); +private: + bool InDragArea(int x, int y); + bool IsDown(); + void Drag(int x, int y); + bool m_bActive = false; +}; + +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; +} + +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) + Drag(pt.x, pt.y); + if (!IsDown()) + m_bActive = false; + return r; +} + +#endif |