aboutsummaryrefslogtreecommitdiff
path: root/c/layout.h
diff options
context:
space:
mode:
Diffstat (limited to 'c/layout.h')
-rw-r--r--c/layout.h37
1 files changed, 20 insertions, 17 deletions
diff --git a/c/layout.h b/c/layout.h
index 3d9cc3b..29647e2 100644
--- a/c/layout.h
+++ b/c/layout.h
@@ -21,18 +21,19 @@ struct Dragger
bool HandleLButtonDown();
bool HandleSetCursor();
protected:
- bool IsDown();
- bool IsDouble();
- virtual bool InDragArea(int x, int y);
+ bool IsDown() const;
+ bool IsDouble(const long time, const POINT& pt);
+ virtual bool InDragArea(int x, int y) const;
/* Perform drag, resizing relevant windows. */
- virtual void Drag(int x, int y);
+ virtual void Drag(int x, int y) const;
/* Reset dragger to automatic position. */
- virtual void Reset();
+ virtual void Reset() const;
/* Called after drag, when mouse button is released. */
- virtual void Done();
+ virtual void Done() const;
private:
bool m_bActive = false;
- long m_time = 0;
+ long m_time0 = 0;
+ POINT m_pt0 = {0, 0};
};
/* DlvDragger implements the draggable split between the data list
@@ -41,24 +42,26 @@ private:
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;
+ bool InDragArea(int x, int y) const override;
+ void Drag(int x, int y) const override;
+ void Reset() const override;
+ void Done() const override;
};
/* Below follows the implementation of the non-virtual member
* functions of Dragger, on which derived objects rely. */
-inline bool Dragger::IsDouble()
+inline bool Dragger::IsDouble(const long time, const POINT& pt)
{
- const long time = GetMessageTime();
- const bool dbl = time-m_time <= static_cast<long>(GetDoubleClickTime());
- m_time = time;
+ const bool dbl = time-m_time0 <= static_cast<long>(GetDoubleClickTime())
+ && abs(pt.x-m_pt0.x) <= Metric<SM_CXDOUBLECLK>
+ && abs(pt.y-m_pt0.y) <= Metric<SM_CYDOUBLECLK>;
+ m_time0 = time;
+ m_pt0 = std::move(pt);
return dbl;
}
-inline bool Dragger::IsDown()
+inline bool Dragger::IsDown() const
{
return GetKeyState(VK_LBUTTON) & 0x8000;
}
@@ -70,7 +73,7 @@ inline bool Dragger::HandleLButtonDown()
Require(GetRelativeCursorPos(g_hWnd, &pt));
if (!InDragArea(pt.x, pt.y)) return false;
- if (IsDouble()) {
+ if (IsDouble(GetMessageTime(), pt)) {
m_bActive = false;
Reset();
} else