From bc4cef92d8efbf97a9215122abc2d7247c287f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 2 Sep 2022 20:16:04 +0200 Subject: Improve Window object. --- c/drag.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 c/drag.h (limited to 'c/drag.h') diff --git a/c/drag.h b/c/drag.h new file mode 100644 index 0000000..ac97090 --- /dev/null +++ b/c/drag.h @@ -0,0 +1,48 @@ +#ifndef DRAG_H +#define DRAG_H + +#include + +/* Dragger objects implement draggable portions of the client area, + * such as the split between two list views. HandleLButtonDown and + * HandleSetCursor are called by relevant window procedures upon + * WM_(NC)LBUTTONDOWN and WM_SETCURSOR. */ + +struct Window; + +struct Dragger +{ + Window& parent; + bool HandleLButtonDown(); + bool HandleSetCursor(); + inline Dragger(Window& parent) : parent(parent) {} +protected: + bool IsDown() const; + bool IsDouble(const long time, const POINT& pt); + virtual bool InDragArea(int x, int y) const = 0; + /* Perform drag, resizing relevant windows. */ + virtual void Drag(int x, int y) const = 0; + /* Reset dragger to automatic position. */ + virtual void Reset() const = 0; + /* Called after drag, when mouse button is released. */ + virtual void Done() const = 0; +private: + bool m_bActive = false; + long m_time0 = 0; + POINT m_pt0 = {0, 0}; +}; + +/* DlvDragger implements the draggable split between the data list + * view and the episode list view. */ + +struct DlvDragger : public Dragger +{ + inline DlvDragger(Window& parent) : Dragger(parent) {} +private: + bool InDragArea(int x, int y) const override; + void Drag(int x, int y) const override; + void Reset() const override; + void Done() const override; +}; + +#endif -- cgit v1.2.3